authorgravatar for johnnymarler@gmail.comJonathan Marler <johnnymarler@gmail.com> 2022-01-24 11:15:32-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2022-01-24 20:15:32+02:00
log3f341bdc26fdfb552809405a188d269244c1e9d3
tree2d8bb53898dceed897332a52dd65316212221cfc
parent5ba4385971108761ec26830b4afa9aae3eab37f8
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

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.

11 files changed, 50 insertions(+), 30 deletions(-)

build.zig+12-12
......@@ -155,11 +155,11 @@ pub fn build(b: *Builder) !void {
155155 const cmake_cfg = if (static_llvm) null else findAndParseConfigH(b, config_h_path_option);
156156
157157 if (is_stage1) {
158 exe.addIncludeDir("src");
159 exe.addIncludeDir("deps/SoftFloat-3e/source/include");
158 exe.addIncludePath("src");
159 exe.addIncludePath("deps/SoftFloat-3e/source/include");
160160
161 test_stage2.addIncludeDir("src");
162 test_stage2.addIncludeDir("deps/SoftFloat-3e/source/include");
161 test_stage2.addIncludePath("src");
162 test_stage2.addIncludePath("deps/SoftFloat-3e/source/include");
163163 // This is intentionally a dummy path. stage1.zig tries to @import("compiler_rt") in case
164164 // of being built by cmake. But when built by zig it's gonna get a compiler_rt so that
165165 // is pointless.
......@@ -170,9 +170,9 @@ pub fn build(b: *Builder) !void {
170170 const softfloat = b.addStaticLibrary("softfloat", null);
171171 softfloat.setBuildMode(.ReleaseFast);
172172 softfloat.setTarget(target);
173 softfloat.addIncludeDir("deps/SoftFloat-3e-prebuilt");
174 softfloat.addIncludeDir("deps/SoftFloat-3e/source/8086");
175 softfloat.addIncludeDir("deps/SoftFloat-3e/source/include");
173 softfloat.addIncludePath("deps/SoftFloat-3e-prebuilt");
174 softfloat.addIncludePath("deps/SoftFloat-3e/source/8086");
175 softfloat.addIncludePath("deps/SoftFloat-3e/source/include");
176176 softfloat.addCSourceFiles(&softfloat_sources, &[_][]const u8{ "-std=c99", "-O3" });
177177 softfloat.single_threaded = single_threaded;
178178
......@@ -282,7 +282,7 @@ pub fn build(b: *Builder) !void {
282282 else
283283 &[_][]const u8{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined" };
284284
285 exe.addIncludeDir(tracy_path);
285 exe.addIncludePath(tracy_path);
286286 exe.addCSourceFile(client_cpp, tracy_c_flags);
287287 if (!enable_llvm) {
288288 exe.linkSystemLibraryName("c++");
......@@ -445,7 +445,7 @@ fn addCmakeCfgOptionsToExe(
445445 b.fmt("{s}{s}{s}", .{ exe.target.libPrefix(), "zigcpp", exe.target.staticLibSuffix() }),
446446 }) catch unreachable);
447447 assert(cfg.lld_include_dir.len != 0);
448 exe.addIncludeDir(cfg.lld_include_dir);
448 exe.addIncludePath(cfg.lld_include_dir);
449449 addCMakeLibraryList(exe, cfg.clang_libraries);
450450 addCMakeLibraryList(exe, cfg.lld_libraries);
451451 addCMakeLibraryList(exe, cfg.llvm_libraries);
......@@ -546,9 +546,9 @@ fn addCxxKnownPath(
546546 if (need_cpp_includes) {
547547 // I used these temporarily for testing something but we obviously need a
548548 // more general purpose solution here.
549 //exe.addIncludeDir("/nix/store/fvf3qjqa5qpcjjkq37pb6ypnk1mzhf5h-gcc-9.3.0/lib/gcc/x86_64-unknown-linux-gnu/9.3.0/../../../../include/c++/9.3.0");
550 //exe.addIncludeDir("/nix/store/fvf3qjqa5qpcjjkq37pb6ypnk1mzhf5h-gcc-9.3.0/lib/gcc/x86_64-unknown-linux-gnu/9.3.0/../../../../include/c++/9.3.0/x86_64-unknown-linux-gnu");
551 //exe.addIncludeDir("/nix/store/fvf3qjqa5qpcjjkq37pb6ypnk1mzhf5h-gcc-9.3.0/lib/gcc/x86_64-unknown-linux-gnu/9.3.0/../../../../include/c++/9.3.0/backward");
549 //exe.addIncludePath("/nix/store/fvf3qjqa5qpcjjkq37pb6ypnk1mzhf5h-gcc-9.3.0/lib/gcc/x86_64-unknown-linux-gnu/9.3.0/../../../../include/c++/9.3.0");
550 //exe.addIncludePath("/nix/store/fvf3qjqa5qpcjjkq37pb6ypnk1mzhf5h-gcc-9.3.0/lib/gcc/x86_64-unknown-linux-gnu/9.3.0/../../../../include/c++/9.3.0/x86_64-unknown-linux-gnu");
551 //exe.addIncludePath("/nix/store/fvf3qjqa5qpcjjkq37pb6ypnk1mzhf5h-gcc-9.3.0/lib/gcc/x86_64-unknown-linux-gnu/9.3.0/../../../../include/c++/9.3.0/backward");
552552 }
553553}
554554
lib/std/build.zig+24-4
......@@ -1949,14 +1949,14 @@ pub const LibExeObjStep = struct {
19491949 while (it.next()) |tok| {
19501950 if (mem.eql(u8, tok, "-I")) {
19511951 const dir = it.next() orelse return error.PkgConfigInvalidOutput;
1952 self.addIncludeDir(dir);
1952 self.addIncludePath(dir);
19531953 } else if (mem.startsWith(u8, tok, "-I")) {
1954 self.addIncludeDir(tok["-I".len..]);
1954 self.addIncludePath(tok["-I".len..]);
19551955 } else if (mem.eql(u8, tok, "-L")) {
19561956 const dir = it.next() orelse return error.PkgConfigInvalidOutput;
1957 self.addLibPath(dir);
1957 self.addLibraryPath(dir);
19581958 } else if (mem.startsWith(u8, tok, "-L")) {
1959 self.addLibPath(tok["-L".len..]);
1959 self.addLibraryPath(tok["-L".len..]);
19601960 } else if (mem.eql(u8, tok, "-l")) {
19611961 const lib = it.next() orelse return error.PkgConfigInvalidOutput;
19621962 self.linkSystemLibraryName(lib);
......@@ -2116,15 +2116,30 @@ pub const LibExeObjStep = struct {
21162116 self.linkLibraryOrObject(obj);
21172117 }
21182118
2119 /// TODO deprecated, use `addSystemIncludePath`.
21192120 pub fn addSystemIncludeDir(self: *LibExeObjStep, path: []const u8) void {
2121 self.addSystemIncludePath(path);
2122 }
2123
2124 pub fn addSystemIncludePath(self: *LibExeObjStep, path: []const u8) void {
21202125 self.include_dirs.append(IncludeDir{ .raw_path_system = self.builder.dupe(path) }) catch unreachable;
21212126 }
21222127
2128 /// TODO deprecated, use `addIncludePath`.
21232129 pub fn addIncludeDir(self: *LibExeObjStep, path: []const u8) void {
2130 self.addIncludePath(path);
2131 }
2132
2133 pub fn addIncludePath(self: *LibExeObjStep, path: []const u8) void {
21242134 self.include_dirs.append(IncludeDir{ .raw_path = self.builder.dupe(path) }) catch unreachable;
21252135 }
21262136
2137 /// TODO deprecated, use `addLibraryPath`.
21272138 pub fn addLibPath(self: *LibExeObjStep, path: []const u8) void {
2139 self.addLibraryPath(path);
2140 }
2141
2142 pub fn addLibraryPath(self: *LibExeObjStep, path: []const u8) void {
21282143 self.lib_paths.append(self.builder.dupe(path)) catch unreachable;
21292144 }
21302145
......@@ -2132,7 +2147,12 @@ pub const LibExeObjStep = struct {
21322147 self.rpaths.append(self.builder.dupe(path)) catch unreachable;
21332148 }
21342149
2150 /// TODO deprecated, use `addFrameworkPath`.
21352151 pub fn addFrameworkDir(self: *LibExeObjStep, dir_path: []const u8) void {
2152 self.addFrameworkPath(dir_path);
2153 }
2154
2155 pub fn addFrameworkPath(self: *LibExeObjStep, dir_path: []const u8) void {
21362156 self.framework_dirs.append(self.builder.dupe(dir_path)) catch unreachable;
21372157 }
21382158
test/standalone/issue_794/build.zig+1-1
......@@ -2,7 +2,7 @@ const Builder = @import("std").build.Builder;
22
33pub fn build(b: *Builder) void {
44 const test_artifact = b.addTest("main.zig");
5 test_artifact.addIncludeDir("a_directory");
5 test_artifact.addIncludePath("a_directory");
66
77 b.default_step.dependOn(&test_artifact.step);
88
test/standalone/issue_9812/build.zig+1-1
......@@ -8,7 +8,7 @@ pub fn build(b: *std.build.Builder) !void {
88 "-std=c99",
99 "-fno-sanitize=undefined",
1010 });
11 zip_add.addIncludeDir("vendor/kuba-zip");
11 zip_add.addIncludePath("vendor/kuba-zip");
1212 zip_add.linkLibC();
1313
1414 const test_step = b.step("test", "Test it");
test/standalone/link_interdependent_static_c_libs/build.zig+3-3
......@@ -6,18 +6,18 @@ pub fn build(b: *Builder) void {
66 const lib_a = b.addStaticLibrary("a", null);
77 lib_a.addCSourceFile("a.c", &[_][]const u8{});
88 lib_a.setBuildMode(mode);
9 lib_a.addIncludeDir(".");
9 lib_a.addIncludePath(".");
1010
1111 const lib_b = b.addStaticLibrary("b", null);
1212 lib_b.addCSourceFile("b.c", &[_][]const u8{});
1313 lib_b.setBuildMode(mode);
14 lib_b.addIncludeDir(".");
14 lib_b.addIncludePath(".");
1515
1616 const test_exe = b.addTest("main.zig");
1717 test_exe.setBuildMode(mode);
1818 test_exe.linkLibrary(lib_a);
1919 test_exe.linkLibrary(lib_b);
20 test_exe.addIncludeDir(".");
20 test_exe.addIncludePath(".");
2121
2222 const test_step = b.step("test", "Test it");
2323 test_step.dependOn(&test_exe.step);
test/standalone/link_static_lib_as_system_lib/build.zig+3-3
......@@ -7,15 +7,15 @@ pub fn build(b: *Builder) void {
77 const lib_a = b.addStaticLibrary("a", null);
88 lib_a.addCSourceFile("a.c", &[_][]const u8{});
99 lib_a.setBuildMode(mode);
10 lib_a.addIncludeDir(".");
10 lib_a.addIncludePath(".");
1111 lib_a.install();
1212
1313 const test_exe = b.addTest("main.zig");
1414 test_exe.setBuildMode(mode);
1515 test_exe.linkSystemLibrary("a"); // force linking liba.a as -la
16 test_exe.addSystemIncludeDir(".");
16 test_exe.addSystemIncludePath(".");
1717 const search_path = std.fs.path.join(b.allocator, &[_][]const u8{ b.install_path, "lib" }) catch unreachable;
18 test_exe.addLibPath(search_path);
18 test_exe.addLibraryPath(search_path);
1919
2020 const test_step = b.step("test", "Test it");
2121 test_step.dependOn(b.getInstallStep());
test/standalone/objc/build.zig+1-1
......@@ -19,7 +19,7 @@ pub fn build(b: *Builder) void {
1919
2020 const exe = b.addExecutable("test", null);
2121 b.default_step.dependOn(&exe.step);
22 exe.addIncludeDir(".");
22 exe.addIncludePath(".");
2323 exe.addCSourceFile("Foo.m", &[0][]const u8{});
2424 exe.addCSourceFile("test.m", &[0][]const u8{});
2525 exe.setBuildMode(mode);
test/standalone/objcpp/build.zig+1-1
......@@ -19,7 +19,7 @@ pub fn build(b: *Builder) void {
1919
2020 const exe = b.addExecutable("test", null);
2121 b.default_step.dependOn(&exe.step);
22 exe.addIncludeDir(".");
22 exe.addIncludePath(".");
2323 exe.addCSourceFile("Foo.mm", &[0][]const u8{});
2424 exe.addCSourceFile("test.mm", &[0][]const u8{});
2525 exe.setBuildMode(mode);
test/standalone/static_c_lib/build.zig+2-2
......@@ -6,12 +6,12 @@ pub fn build(b: *Builder) void {
66 const foo = b.addStaticLibrary("foo", null);
77 foo.addCSourceFile("foo.c", &[_][]const u8{});
88 foo.setBuildMode(mode);
9 foo.addIncludeDir(".");
9 foo.addIncludePath(".");
1010
1111 const test_exe = b.addTest("foo.zig");
1212 test_exe.setBuildMode(mode);
1313 test_exe.linkLibrary(foo);
14 test_exe.addIncludeDir(".");
14 test_exe.addIncludePath(".");
1515
1616 const test_step = b.step("test", "Test it");
1717 test_step.dependOn(&test_exe.step);
test/standalone/use_alias/build.zig+1-1
......@@ -3,7 +3,7 @@ const Builder = @import("std").build.Builder;
33pub fn build(b: *Builder) void {
44 const main = b.addTest("main.zig");
55 main.setBuildMode(b.standardReleaseOptions());
6 main.addIncludeDir(".");
6 main.addIncludePath(".");
77
88 const test_step = b.step("test", "Test it");
99 test_step.dependOn(&main.step);
test/tests.zig+1-1
......@@ -578,7 +578,7 @@ pub fn addPkgTests(
578578 these_tests.linkSystemLibrary("c");
579579 }
580580 these_tests.overrideZigLibDir("lib");
581 these_tests.addIncludeDir("test");
581 these_tests.addIncludePath("test");
582582
583583 step.dependOn(&these_tests.step);
584584 }