aboutsummaryrefslogtreecommitdiff
path: root/test/link/static_lib_as_system_lib/build.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2022-05-28 11:44:53 +0200
committerJakub Konka <kubkon@jakubkonka.com>2022-06-20 17:59:17 +0200
commit38edef35bfcba5789ea50adc7c76dec504079812 (patch)
tree66d7f7279a005a36c201cadd474b66035f5c1a44 /test/link/static_lib_as_system_lib/build.zig
parent74ed7c1f0998e9dd89aa3f3480fff845afd6b422 (diff)
downloadzig-38edef35bfcba5789ea50adc7c76dec504079812.tar.gz
zig-38edef35bfcba5789ea50adc7c76dec504079812.zip
test: introduce link(er) tests - builds on standalone tests
Diffstat (limited to 'test/link/static_lib_as_system_lib/build.zig')
-rw-r--r--test/link/static_lib_as_system_lib/build.zig23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/link/static_lib_as_system_lib/build.zig b/test/link/static_lib_as_system_lib/build.zig
new file mode 100644
index 0000000000..f39f3fac2a
--- /dev/null
+++ b/test/link/static_lib_as_system_lib/build.zig
@@ -0,0 +1,23 @@
+const std = @import("std");
+const Builder = std.build.Builder;
+
+pub fn build(b: *Builder) void {
+ const mode = b.standardReleaseOptions();
+
+ const lib_a = b.addStaticLibrary("a", null);
+ lib_a.addCSourceFile("a.c", &[_][]const u8{});
+ lib_a.setBuildMode(mode);
+ lib_a.addIncludePath(".");
+ lib_a.install();
+
+ const test_exe = b.addTest("main.zig");
+ test_exe.setBuildMode(mode);
+ test_exe.linkSystemLibrary("a"); // force linking liba.a as -la
+ test_exe.addSystemIncludePath(".");
+ const search_path = std.fs.path.join(b.allocator, &[_][]const u8{ b.install_path, "lib" }) catch unreachable;
+ test_exe.addLibraryPath(search_path);
+
+ const test_step = b.step("test", "Test it");
+ test_step.dependOn(b.getInstallStep());
+ test_step.dependOn(&test_exe.step);
+}