authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-02-01 18:20:55-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-02-02 20:43:01-07:00
log2637b573761bd14c089f01d8310fc26bc9ec1d47
tree3b4f2a499f78a5244c89bd7e4e191cafb4643ddc
parent370438943e47d9206870e592d4e0fb0f83365b27

std.Build: make system library integrations more general

Before it was named "library" inconsistently. Now the CLI args are -fsys=[name] and -fno-sys=[name] and it is a more general-purpose "system integration" which could be a library name or perhaps a project name such as "ffmpeg" or a binary such as "nasm".

2 files changed, 8 insertions(+), 8 deletions(-)

lib/build_runner.zig+7-7
...@@ -125,11 +125,11 @@ pub fn main() !void {...@@ -125,11 +125,11 @@ pub fn main() !void {
125 install_prefix = nextArgOrFatal(args, &arg_idx);125 install_prefix = nextArgOrFatal(args, &arg_idx);
126 } else if (mem.eql(u8, arg, "-l") or mem.eql(u8, arg, "--list-steps")) {126 } else if (mem.eql(u8, arg, "-l") or mem.eql(u8, arg, "--list-steps")) {
127 steps_menu = true;127 steps_menu = true;
128 } else if (mem.eql(u8, arg, "--system-lib")) {128 } else if (mem.startsWith(u8, arg, "-fsys=")) {
129 const name = nextArgOrFatal(args, &arg_idx);129 const name = arg["-fsys=".len..];
130 graph.system_library_options.put(arena, name, .user_enabled) catch @panic("OOM");130 graph.system_library_options.put(arena, name, .user_enabled) catch @panic("OOM");
131 } else if (mem.eql(u8, arg, "--no-system-lib")) {131 } else if (mem.startsWith(u8, arg, "-fno-sys=")) {
132 const name = nextArgOrFatal(args, &arg_idx);132 const name = arg["-fno-sys=".len..];
133 graph.system_library_options.put(arena, name, .user_disabled) catch @panic("OOM");133 graph.system_library_options.put(arena, name, .user_disabled) catch @panic("OOM");
134 } else if (mem.eql(u8, arg, "--host-target")) {134 } else if (mem.eql(u8, arg, "--host-target")) {
135 graph.host_query_options.arch_os_abi = nextArgOrFatal(args, &arg_idx);135 graph.host_query_options.arch_os_abi = nextArgOrFatal(args, &arg_idx);
...@@ -1111,13 +1111,13 @@ fn usage(b: *std.Build, out_stream: anytype) !void {...@@ -1111,13 +1111,13 @@ fn usage(b: *std.Build, out_stream: anytype) !void {
1111 \\1111 \\
1112 \\System Integration Options:1112 \\System Integration Options:
1113 \\ --system [dir] System Package Mode. Disable fetching; prefer system libs1113 \\ --system [dir] System Package Mode. Disable fetching; prefer system libs
1114 \\ -fsys=[name] Enable a system integration
1115 \\ -fno-sys=[name] Disable a system integration
1114 \\ --host-target [triple] Use the provided target as the host1116 \\ --host-target [triple] Use the provided target as the host
1115 \\ --host-cpu [cpu] Use the provided CPU as the host1117 \\ --host-cpu [cpu] Use the provided CPU as the host
1116 \\ --host-dynamic-linker [path] Use the provided dynamic linker as the host1118 \\ --host-dynamic-linker [path] Use the provided dynamic linker as the host
1117 \\ --system-lib [name] Use the system-provided library
1118 \\ --no-system-lib [name] Do not use the system-provided library
1119 \\1119 \\
1120 \\ Available System Library Integrations: Enabled:1120 \\ Available System Integrations: Enabled:
1121 \\1121 \\
1122 );1122 );
1123 if (b.graph.system_library_options.entries.len == 0) {1123 if (b.graph.system_library_options.entries.len == 0) {
lib/std/Build.zig+1-1
...@@ -2324,7 +2324,7 @@ pub fn wantSharedLibSymLinks(target: Target) bool {...@@ -2324,7 +2324,7 @@ pub fn wantSharedLibSymLinks(target: Target) bool {
2324 return target.os.tag != .windows;2324 return target.os.tag != .windows;
2325}2325}
23262326
2327pub fn systemLibraryOption(b: *Build, name: []const u8) bool {2327pub fn systemIntegrationOption(b: *Build, name: []const u8) bool {
2328 const gop = b.graph.system_library_options.getOrPut(b.allocator, name) catch @panic("OOM");2328 const gop = b.graph.system_library_options.getOrPut(b.allocator, name) catch @panic("OOM");
2329 if (gop.found_existing) switch (gop.value_ptr.*) {2329 if (gop.found_existing) switch (gop.value_ptr.*) {
2330 .user_disabled => {2330 .user_disabled => {