| author | |
| committer | |
| log | 3f341bdc26fdfb552809405a188d269244c1e9d3 |
| tree | 2d8bb53898dceed897332a52dd65316212221cfc |
| parent | 5ba4385971108761ec26830b4afa9aae3eab37f8 |
| signature |
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 { | ... | @@ -155,11 +155,11 @@ pub fn build(b: *Builder) !void { |
| 155 | const cmake_cfg = if (static_llvm) null else findAndParseConfigH(b, config_h_path_option); | 155 | const cmake_cfg = if (static_llvm) null else findAndParseConfigH(b, config_h_path_option); |
| 156 | 156 | ||
| 157 | if (is_stage1) { | 157 | if (is_stage1) { |
| 158 | exe.addIncludeDir("src"); | 158 | exe.addIncludePath("src"); |
| 159 | exe.addIncludeDir("deps/SoftFloat-3e/source/include"); | 159 | exe.addIncludePath("deps/SoftFloat-3e/source/include"); |
| 160 | 160 | ||
| 161 | test_stage2.addIncludeDir("src"); | 161 | test_stage2.addIncludePath("src"); |
| 162 | test_stage2.addIncludeDir("deps/SoftFloat-3e/source/include"); | 162 | test_stage2.addIncludePath("deps/SoftFloat-3e/source/include"); |
| 163 | // This is intentionally a dummy path. stage1.zig tries to @import("compiler_rt") in case | 163 | // This is intentionally a dummy path. stage1.zig tries to @import("compiler_rt") in case |
| 164 | // of being built by cmake. But when built by zig it's gonna get a compiler_rt so that | 164 | // of being built by cmake. But when built by zig it's gonna get a compiler_rt so that |
| 165 | // is pointless. | 165 | // is pointless. |
| ... | @@ -170,9 +170,9 @@ pub fn build(b: *Builder) !void { | ... | @@ -170,9 +170,9 @@ pub fn build(b: *Builder) !void { |
| 170 | const softfloat = b.addStaticLibrary("softfloat", null); | 170 | const softfloat = b.addStaticLibrary("softfloat", null); |
| 171 | softfloat.setBuildMode(.ReleaseFast); | 171 | softfloat.setBuildMode(.ReleaseFast); |
| 172 | softfloat.setTarget(target); | 172 | softfloat.setTarget(target); |
| 173 | softfloat.addIncludeDir("deps/SoftFloat-3e-prebuilt"); | 173 | softfloat.addIncludePath("deps/SoftFloat-3e-prebuilt"); |
| 174 | softfloat.addIncludeDir("deps/SoftFloat-3e/source/8086"); | 174 | softfloat.addIncludePath("deps/SoftFloat-3e/source/8086"); |
| 175 | softfloat.addIncludeDir("deps/SoftFloat-3e/source/include"); | 175 | softfloat.addIncludePath("deps/SoftFloat-3e/source/include"); |
| 176 | softfloat.addCSourceFiles(&softfloat_sources, &[_][]const u8{ "-std=c99", "-O3" }); | 176 | softfloat.addCSourceFiles(&softfloat_sources, &[_][]const u8{ "-std=c99", "-O3" }); |
| 177 | softfloat.single_threaded = single_threaded; | 177 | softfloat.single_threaded = single_threaded; |
| 178 | 178 | ||
| ... | @@ -282,7 +282,7 @@ pub fn build(b: *Builder) !void { | ... | @@ -282,7 +282,7 @@ pub fn build(b: *Builder) !void { |
| 282 | else | 282 | else |
| 283 | &[_][]const u8{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined" }; | 283 | &[_][]const u8{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined" }; |
| 284 | 284 | ||
| 285 | exe.addIncludeDir(tracy_path); | 285 | exe.addIncludePath(tracy_path); |
| 286 | exe.addCSourceFile(client_cpp, tracy_c_flags); | 286 | exe.addCSourceFile(client_cpp, tracy_c_flags); |
| 287 | if (!enable_llvm) { | 287 | if (!enable_llvm) { |
| 288 | exe.linkSystemLibraryName("c++"); | 288 | exe.linkSystemLibraryName("c++"); |
| ... | @@ -445,7 +445,7 @@ fn addCmakeCfgOptionsToExe( | ... | @@ -445,7 +445,7 @@ fn addCmakeCfgOptionsToExe( |
| 445 | b.fmt("{s}{s}{s}", .{ exe.target.libPrefix(), "zigcpp", exe.target.staticLibSuffix() }), | 445 | b.fmt("{s}{s}{s}", .{ exe.target.libPrefix(), "zigcpp", exe.target.staticLibSuffix() }), |
| 446 | }) catch unreachable); | 446 | }) catch unreachable); |
| 447 | assert(cfg.lld_include_dir.len != 0); | 447 | assert(cfg.lld_include_dir.len != 0); |
| 448 | exe.addIncludeDir(cfg.lld_include_dir); | 448 | exe.addIncludePath(cfg.lld_include_dir); |
| 449 | addCMakeLibraryList(exe, cfg.clang_libraries); | 449 | addCMakeLibraryList(exe, cfg.clang_libraries); |
| 450 | addCMakeLibraryList(exe, cfg.lld_libraries); | 450 | addCMakeLibraryList(exe, cfg.lld_libraries); |
| 451 | addCMakeLibraryList(exe, cfg.llvm_libraries); | 451 | addCMakeLibraryList(exe, cfg.llvm_libraries); |
| ... | @@ -546,9 +546,9 @@ fn addCxxKnownPath( | ... | @@ -546,9 +546,9 @@ fn addCxxKnownPath( |
| 546 | if (need_cpp_includes) { | 546 | if (need_cpp_includes) { |
| 547 | // I used these temporarily for testing something but we obviously need a | 547 | // I used these temporarily for testing something but we obviously need a |
| 548 | // more general purpose solution here. | 548 | // 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"); | 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.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"); | 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.addIncludeDir("/nix/store/fvf3qjqa5qpcjjkq37pb6ypnk1mzhf5h-gcc-9.3.0/lib/gcc/x86_64-unknown-linux-gnu/9.3.0/../../../../include/c++/9.3.0/backward"); | 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"); |
| 552 | } | 552 | } |
| 553 | } | 553 | } |
| 554 | 554 |
lib/std/build.zig+24-4| ... | @@ -1949,14 +1949,14 @@ pub const LibExeObjStep = struct { | ... | @@ -1949,14 +1949,14 @@ pub const LibExeObjStep = struct { |
| 1949 | while (it.next()) |tok| { | 1949 | while (it.next()) |tok| { |
| 1950 | if (mem.eql(u8, tok, "-I")) { | 1950 | if (mem.eql(u8, tok, "-I")) { |
| 1951 | const dir = it.next() orelse return error.PkgConfigInvalidOutput; | 1951 | const dir = it.next() orelse return error.PkgConfigInvalidOutput; |
| 1952 | self.addIncludeDir(dir); | 1952 | self.addIncludePath(dir); |
| 1953 | } else if (mem.startsWith(u8, tok, "-I")) { | 1953 | } else if (mem.startsWith(u8, tok, "-I")) { |
| 1954 | self.addIncludeDir(tok["-I".len..]); | 1954 | self.addIncludePath(tok["-I".len..]); |
| 1955 | } else if (mem.eql(u8, tok, "-L")) { | 1955 | } else if (mem.eql(u8, tok, "-L")) { |
| 1956 | const dir = it.next() orelse return error.PkgConfigInvalidOutput; | 1956 | const dir = it.next() orelse return error.PkgConfigInvalidOutput; |
| 1957 | self.addLibPath(dir); | 1957 | self.addLibraryPath(dir); |
| 1958 | } else if (mem.startsWith(u8, tok, "-L")) { | 1958 | } else if (mem.startsWith(u8, tok, "-L")) { |
| 1959 | self.addLibPath(tok["-L".len..]); | 1959 | self.addLibraryPath(tok["-L".len..]); |
| 1960 | } else if (mem.eql(u8, tok, "-l")) { | 1960 | } else if (mem.eql(u8, tok, "-l")) { |
| 1961 | const lib = it.next() orelse return error.PkgConfigInvalidOutput; | 1961 | const lib = it.next() orelse return error.PkgConfigInvalidOutput; |
| 1962 | self.linkSystemLibraryName(lib); | 1962 | self.linkSystemLibraryName(lib); |
| ... | @@ -2116,15 +2116,30 @@ pub const LibExeObjStep = struct { | ... | @@ -2116,15 +2116,30 @@ pub const LibExeObjStep = struct { |
| 2116 | self.linkLibraryOrObject(obj); | 2116 | self.linkLibraryOrObject(obj); |
| 2117 | } | 2117 | } |
| 2118 | 2118 | ||
| 2119 | /// TODO deprecated, use `addSystemIncludePath`. | ||
| 2119 | pub fn addSystemIncludeDir(self: *LibExeObjStep, path: []const u8) void { | 2120 | 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 { | ||
| 2120 | self.include_dirs.append(IncludeDir{ .raw_path_system = self.builder.dupe(path) }) catch unreachable; | 2125 | self.include_dirs.append(IncludeDir{ .raw_path_system = self.builder.dupe(path) }) catch unreachable; |
| 2121 | } | 2126 | } |
| 2122 | 2127 | ||
| 2128 | /// TODO deprecated, use `addIncludePath`. | ||
| 2123 | pub fn addIncludeDir(self: *LibExeObjStep, path: []const u8) void { | 2129 | 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 { | ||
| 2124 | self.include_dirs.append(IncludeDir{ .raw_path = self.builder.dupe(path) }) catch unreachable; | 2134 | self.include_dirs.append(IncludeDir{ .raw_path = self.builder.dupe(path) }) catch unreachable; |
| 2125 | } | 2135 | } |
| 2126 | 2136 | ||
| 2137 | /// TODO deprecated, use `addLibraryPath`. | ||
| 2127 | pub fn addLibPath(self: *LibExeObjStep, path: []const u8) void { | 2138 | 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 { | ||
| 2128 | self.lib_paths.append(self.builder.dupe(path)) catch unreachable; | 2143 | self.lib_paths.append(self.builder.dupe(path)) catch unreachable; |
| 2129 | } | 2144 | } |
| 2130 | 2145 | ||
| ... | @@ -2132,7 +2147,12 @@ pub const LibExeObjStep = struct { | ... | @@ -2132,7 +2147,12 @@ pub const LibExeObjStep = struct { |
| 2132 | self.rpaths.append(self.builder.dupe(path)) catch unreachable; | 2147 | self.rpaths.append(self.builder.dupe(path)) catch unreachable; |
| 2133 | } | 2148 | } |
| 2134 | 2149 | ||
| 2150 | /// TODO deprecated, use `addFrameworkPath`. | ||
| 2135 | pub fn addFrameworkDir(self: *LibExeObjStep, dir_path: []const u8) void { | 2151 | 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 { | ||
| 2136 | self.framework_dirs.append(self.builder.dupe(dir_path)) catch unreachable; | 2156 | self.framework_dirs.append(self.builder.dupe(dir_path)) catch unreachable; |
| 2137 | } | 2157 | } |
| 2138 | 2158 |
test/standalone/issue_794/build.zig+1-1| ... | @@ -2,7 +2,7 @@ const Builder = @import("std").build.Builder; | ... | @@ -2,7 +2,7 @@ const Builder = @import("std").build.Builder; |
| 2 | 2 | ||
| 3 | pub fn build(b: *Builder) void { | 3 | pub fn build(b: *Builder) void { |
| 4 | const test_artifact = b.addTest("main.zig"); | 4 | const test_artifact = b.addTest("main.zig"); |
| 5 | test_artifact.addIncludeDir("a_directory"); | 5 | test_artifact.addIncludePath("a_directory"); |
| 6 | 6 | ||
| 7 | b.default_step.dependOn(&test_artifact.step); | 7 | b.default_step.dependOn(&test_artifact.step); |
| 8 | 8 |
test/standalone/issue_9812/build.zig+1-1| ... | @@ -8,7 +8,7 @@ pub fn build(b: *std.build.Builder) !void { | ... | @@ -8,7 +8,7 @@ pub fn build(b: *std.build.Builder) !void { |
| 8 | "-std=c99", | 8 | "-std=c99", |
| 9 | "-fno-sanitize=undefined", | 9 | "-fno-sanitize=undefined", |
| 10 | }); | 10 | }); |
| 11 | zip_add.addIncludeDir("vendor/kuba-zip"); | 11 | zip_add.addIncludePath("vendor/kuba-zip"); |
| 12 | zip_add.linkLibC(); | 12 | zip_add.linkLibC(); |
| 13 | 13 | ||
| 14 | const test_step = b.step("test", "Test it"); | 14 | 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 { | ... | @@ -6,18 +6,18 @@ pub fn build(b: *Builder) void { |
| 6 | const lib_a = b.addStaticLibrary("a", null); | 6 | const lib_a = b.addStaticLibrary("a", null); |
| 7 | lib_a.addCSourceFile("a.c", &[_][]const u8{}); | 7 | lib_a.addCSourceFile("a.c", &[_][]const u8{}); |
| 8 | lib_a.setBuildMode(mode); | 8 | lib_a.setBuildMode(mode); |
| 9 | lib_a.addIncludeDir("."); | 9 | lib_a.addIncludePath("."); |
| 10 | 10 | ||
| 11 | const lib_b = b.addStaticLibrary("b", null); | 11 | const lib_b = b.addStaticLibrary("b", null); |
| 12 | lib_b.addCSourceFile("b.c", &[_][]const u8{}); | 12 | lib_b.addCSourceFile("b.c", &[_][]const u8{}); |
| 13 | lib_b.setBuildMode(mode); | 13 | lib_b.setBuildMode(mode); |
| 14 | lib_b.addIncludeDir("."); | 14 | lib_b.addIncludePath("."); |
| 15 | 15 | ||
| 16 | const test_exe = b.addTest("main.zig"); | 16 | const test_exe = b.addTest("main.zig"); |
| 17 | test_exe.setBuildMode(mode); | 17 | test_exe.setBuildMode(mode); |
| 18 | test_exe.linkLibrary(lib_a); | 18 | test_exe.linkLibrary(lib_a); |
| 19 | test_exe.linkLibrary(lib_b); | 19 | test_exe.linkLibrary(lib_b); |
| 20 | test_exe.addIncludeDir("."); | 20 | test_exe.addIncludePath("."); |
| 21 | 21 | ||
| 22 | const test_step = b.step("test", "Test it"); | 22 | const test_step = b.step("test", "Test it"); |
| 23 | test_step.dependOn(&test_exe.step); | 23 | 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 { | ... | @@ -7,15 +7,15 @@ pub fn build(b: *Builder) void { |
| 7 | const lib_a = b.addStaticLibrary("a", null); | 7 | const lib_a = b.addStaticLibrary("a", null); |
| 8 | lib_a.addCSourceFile("a.c", &[_][]const u8{}); | 8 | lib_a.addCSourceFile("a.c", &[_][]const u8{}); |
| 9 | lib_a.setBuildMode(mode); | 9 | lib_a.setBuildMode(mode); |
| 10 | lib_a.addIncludeDir("."); | 10 | lib_a.addIncludePath("."); |
| 11 | lib_a.install(); | 11 | lib_a.install(); |
| 12 | 12 | ||
| 13 | const test_exe = b.addTest("main.zig"); | 13 | const test_exe = b.addTest("main.zig"); |
| 14 | test_exe.setBuildMode(mode); | 14 | test_exe.setBuildMode(mode); |
| 15 | test_exe.linkSystemLibrary("a"); // force linking liba.a as -la | 15 | test_exe.linkSystemLibrary("a"); // force linking liba.a as -la |
| 16 | test_exe.addSystemIncludeDir("."); | 16 | test_exe.addSystemIncludePath("."); |
| 17 | const search_path = std.fs.path.join(b.allocator, &[_][]const u8{ b.install_path, "lib" }) catch unreachable; | 17 | 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); |
| 19 | 19 | ||
| 20 | const test_step = b.step("test", "Test it"); | 20 | const test_step = b.step("test", "Test it"); |
| 21 | test_step.dependOn(b.getInstallStep()); | 21 | test_step.dependOn(b.getInstallStep()); |
test/standalone/objc/build.zig+1-1| ... | @@ -19,7 +19,7 @@ pub fn build(b: *Builder) void { | ... | @@ -19,7 +19,7 @@ pub fn build(b: *Builder) void { |
| 19 | 19 | ||
| 20 | const exe = b.addExecutable("test", null); | 20 | const exe = b.addExecutable("test", null); |
| 21 | b.default_step.dependOn(&exe.step); | 21 | b.default_step.dependOn(&exe.step); |
| 22 | exe.addIncludeDir("."); | 22 | exe.addIncludePath("."); |
| 23 | exe.addCSourceFile("Foo.m", &[0][]const u8{}); | 23 | exe.addCSourceFile("Foo.m", &[0][]const u8{}); |
| 24 | exe.addCSourceFile("test.m", &[0][]const u8{}); | 24 | exe.addCSourceFile("test.m", &[0][]const u8{}); |
| 25 | exe.setBuildMode(mode); | 25 | exe.setBuildMode(mode); |
test/standalone/objcpp/build.zig+1-1| ... | @@ -19,7 +19,7 @@ pub fn build(b: *Builder) void { | ... | @@ -19,7 +19,7 @@ pub fn build(b: *Builder) void { |
| 19 | 19 | ||
| 20 | const exe = b.addExecutable("test", null); | 20 | const exe = b.addExecutable("test", null); |
| 21 | b.default_step.dependOn(&exe.step); | 21 | b.default_step.dependOn(&exe.step); |
| 22 | exe.addIncludeDir("."); | 22 | exe.addIncludePath("."); |
| 23 | exe.addCSourceFile("Foo.mm", &[0][]const u8{}); | 23 | exe.addCSourceFile("Foo.mm", &[0][]const u8{}); |
| 24 | exe.addCSourceFile("test.mm", &[0][]const u8{}); | 24 | exe.addCSourceFile("test.mm", &[0][]const u8{}); |
| 25 | exe.setBuildMode(mode); | 25 | exe.setBuildMode(mode); |
test/standalone/static_c_lib/build.zig+2-2| ... | @@ -6,12 +6,12 @@ pub fn build(b: *Builder) void { | ... | @@ -6,12 +6,12 @@ pub fn build(b: *Builder) void { |
| 6 | const foo = b.addStaticLibrary("foo", null); | 6 | const foo = b.addStaticLibrary("foo", null); |
| 7 | foo.addCSourceFile("foo.c", &[_][]const u8{}); | 7 | foo.addCSourceFile("foo.c", &[_][]const u8{}); |
| 8 | foo.setBuildMode(mode); | 8 | foo.setBuildMode(mode); |
| 9 | foo.addIncludeDir("."); | 9 | foo.addIncludePath("."); |
| 10 | 10 | ||
| 11 | const test_exe = b.addTest("foo.zig"); | 11 | const test_exe = b.addTest("foo.zig"); |
| 12 | test_exe.setBuildMode(mode); | 12 | test_exe.setBuildMode(mode); |
| 13 | test_exe.linkLibrary(foo); | 13 | test_exe.linkLibrary(foo); |
| 14 | test_exe.addIncludeDir("."); | 14 | test_exe.addIncludePath("."); |
| 15 | 15 | ||
| 16 | const test_step = b.step("test", "Test it"); | 16 | const test_step = b.step("test", "Test it"); |
| 17 | test_step.dependOn(&test_exe.step); | 17 | test_step.dependOn(&test_exe.step); |
test/standalone/use_alias/build.zig+1-1| ... | @@ -3,7 +3,7 @@ const Builder = @import("std").build.Builder; | ... | @@ -3,7 +3,7 @@ const Builder = @import("std").build.Builder; |
| 3 | pub fn build(b: *Builder) void { | 3 | pub fn build(b: *Builder) void { |
| 4 | const main = b.addTest("main.zig"); | 4 | const main = b.addTest("main.zig"); |
| 5 | main.setBuildMode(b.standardReleaseOptions()); | 5 | main.setBuildMode(b.standardReleaseOptions()); |
| 6 | main.addIncludeDir("."); | 6 | main.addIncludePath("."); |
| 7 | 7 | ||
| 8 | const test_step = b.step("test", "Test it"); | 8 | const test_step = b.step("test", "Test it"); |
| 9 | test_step.dependOn(&main.step); | 9 | test_step.dependOn(&main.step); |
test/tests.zig+1-1| ... | @@ -578,7 +578,7 @@ pub fn addPkgTests( | ... | @@ -578,7 +578,7 @@ pub fn addPkgTests( |
| 578 | these_tests.linkSystemLibrary("c"); | 578 | these_tests.linkSystemLibrary("c"); |
| 579 | } | 579 | } |
| 580 | these_tests.overrideZigLibDir("lib"); | 580 | these_tests.overrideZigLibDir("lib"); |
| 581 | these_tests.addIncludeDir("test"); | 581 | these_tests.addIncludePath("test"); |
| 582 | 582 | ||
| 583 | step.dependOn(&these_tests.step); | 583 | step.dependOn(&these_tests.step); |
| 584 | } | 584 | } |