aboutsummaryrefslogtreecommitdiff
path: root/lib/init-lib
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-05-06 19:22:40 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-05-06 22:41:00 -0700
commitec95e00e28cb23f37dc097f71afd7090e947a1cd (patch)
treea7393f13c3d2c7895eb3687d0ebd7f3205699289 /lib/init-lib
parent3b60ab4872355f0b9a9c7d0794ca8b548ab99412 (diff)
downloadzig-ec95e00e28cb23f37dc097f71afd7090e947a1cd.tar.gz
zig-ec95e00e28cb23f37dc097f71afd7090e947a1cd.zip
flatten lib/std/special and improve "pkg inside another" logic
stage2: change logic for detecting whether the main package is inside the std package. Previously it relied on realpath() which is not portable. This uses resolve() which is how imports already work. * stage2: fix cleanup bug when creating Module * flatten lib/std/special/* to lib/* - this was motivated by making main_pkg_is_inside_std false for compiler_rt & friends. * rename "mini libc" to "universal libc"
Diffstat (limited to 'lib/init-lib')
-rw-r--r--lib/init-lib/build.zig17
-rw-r--r--lib/init-lib/src/main.zig10
2 files changed, 27 insertions, 0 deletions
diff --git a/lib/init-lib/build.zig b/lib/init-lib/build.zig
new file mode 100644
index 0000000000..b3876691a2
--- /dev/null
+++ b/lib/init-lib/build.zig
@@ -0,0 +1,17 @@
+const std = @import("std");
+
+pub fn build(b: *std.build.Builder) void {
+ // Standard release options allow the person running `zig build` to select
+ // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
+ const mode = b.standardReleaseOptions();
+
+ const lib = b.addStaticLibrary("$", "src/main.zig");
+ lib.setBuildMode(mode);
+ lib.install();
+
+ const main_tests = b.addTest("src/main.zig");
+ main_tests.setBuildMode(mode);
+
+ const test_step = b.step("test", "Run library tests");
+ test_step.dependOn(&main_tests.step);
+}
diff --git a/lib/init-lib/src/main.zig b/lib/init-lib/src/main.zig
new file mode 100644
index 0000000000..ecfeade1a3
--- /dev/null
+++ b/lib/init-lib/src/main.zig
@@ -0,0 +1,10 @@
+const std = @import("std");
+const testing = std.testing;
+
+export fn add(a: i32, b: i32) i32 {
+ return a + b;
+}
+
+test "basic add functionality" {
+ try testing.expect(add(3, 7) == 10);
+}