Files
zig/test/standalone/link_static_lib_as_system_lib/build.zig
Jonathan Marler 3f341bdc26 Normalize some build function names
An attempt to normalize some of the function names in build.zig.  Normalize add*Dir to add*Path.  Also use "Library" instead of the "Lib" abbreviation.

The PR does not remove the old names, only adds the new normalized ones to faciliate a transition period.
2022-01-24 20:15:32 +02:00

24 lines
803 B
Zig

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);
}