| ... | ... | @@ -206,7 +206,7 @@ pub const Builder = struct { |
| 206 | 206 | |
| 207 | 207 | fn convertOptionalPathToFileSource(path: ?[]const u8) ?FileSource { |
| 208 | 208 | return if (path) |p| |
| 209 | | FileSource.relative(p) |
| 209 | FileSource{ .path = p } |
| 210 | 210 | else |
| 211 | 211 | null; |
| 212 | 212 | } |
| ... | ... | @@ -246,7 +246,7 @@ pub const Builder = struct { |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | pub fn addTestSource(self: *Builder, root_src: FileSource) *LibExeObjStep { |
| 249 | | return LibExeObjStep.createTest(self, "test", root_src); |
| 249 | return LibExeObjStep.createTest(self, "test", root_src.dupe(self)); |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | pub fn addAssemble(self: *Builder, name: []const u8, src: []const u8) *LibExeObjStep { |
| ... | ... | @@ -255,7 +255,7 @@ pub const Builder = struct { |
| 255 | 255 | |
| 256 | 256 | pub fn addAssembleSource(self: *Builder, name: []const u8, src: FileSource) *LibExeObjStep { |
| 257 | 257 | const obj_step = LibExeObjStep.createObject(self, name, null); |
| 258 | | obj_step.addAssemblyFileSource(src); |
| 258 | obj_step.addAssemblyFileSource(src.dupe(self)); |
| 259 | 259 | return obj_step; |
| 260 | 260 | } |
| 261 | 261 | |
| ... | ... | @@ -341,7 +341,7 @@ pub const Builder = struct { |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | pub fn addTranslateC(self: *Builder, source: FileSource) *TranslateCStep { |
| 344 | | return TranslateCStep.create(self, source); |
| 344 | return TranslateCStep.create(self, source.dupe(self)); |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | pub fn version(self: *const Builder, major: u32, minor: u32, patch: u32) LibExeObjStep.SharedLibKind { |
| ... | ... | @@ -898,18 +898,18 @@ pub const Builder = struct { |
| 898 | 898 | } |
| 899 | 899 | |
| 900 | 900 | ///`dest_rel_path` is relative to install prefix path |
| 901 | | pub fn addInstallFile(self: *Builder, src_path: []const u8, dest_rel_path: []const u8) *InstallFileStep { |
| 902 | | return self.addInstallFileWithDir(FileSource.relative(src_path), .Prefix, dest_rel_path); |
| 901 | pub fn addInstallFile(self: *Builder, source: FileSource, dest_rel_path: []const u8) *InstallFileStep { |
| 902 | return self.addInstallFileWithDir(source.dupe(self), .Prefix, dest_rel_path); |
| 903 | 903 | } |
| 904 | 904 | |
| 905 | 905 | ///`dest_rel_path` is relative to bin path |
| 906 | | pub fn addInstallBinFile(self: *Builder, src_path: []const u8, dest_rel_path: []const u8) *InstallFileStep { |
| 907 | | return self.addInstallFileWithDir(FileSource.relative(src_path), .Bin, dest_rel_path); |
| 906 | pub fn addInstallBinFile(self: *Builder, source: FileSource, dest_rel_path: []const u8) *InstallFileStep { |
| 907 | return self.addInstallFileWithDir(source.dupe(self), .Bin, dest_rel_path); |
| 908 | 908 | } |
| 909 | 909 | |
| 910 | 910 | ///`dest_rel_path` is relative to lib path |
| 911 | | pub fn addInstallLibFile(self: *Builder, src_path: []const u8, dest_rel_path: []const u8) *InstallFileStep { |
| 912 | | return self.addInstallFileWithDir(FileSource.relative(src_path), .Lib, dest_rel_path); |
| 911 | pub fn addInstallLibFile(self: *Builder, source: FileSource, dest_rel_path: []const u8) *InstallFileStep { |
| 912 | return self.addInstallFileWithDir(source.dupe(self), .Lib, dest_rel_path); |
| 913 | 913 | } |
| 914 | 914 | |
| 915 | 915 | pub fn addInstallRaw(self: *Builder, artifact: *LibExeObjStep, dest_filename: []const u8) *InstallRawStep { |
| ... | ... | @@ -926,7 +926,7 @@ pub const Builder = struct { |
| 926 | 926 | panic("dest_rel_path must be non-empty", .{}); |
| 927 | 927 | } |
| 928 | 928 | const install_step = self.allocator.create(InstallFileStep) catch unreachable; |
| 929 | | install_step.* = InstallFileStep.init(self, source, install_dir, dest_rel_path); |
| 929 | install_step.* = InstallFileStep.init(self, source.dupe(self), install_dir, dest_rel_path); |
| 930 | 930 | return install_step; |
| 931 | 931 | } |
| 932 | 932 | |
| ... | ... | @@ -1236,12 +1236,20 @@ pub const GeneratedFile = struct { |
| 1236 | 1236 | } |
| 1237 | 1237 | }; |
| 1238 | 1238 | |
| 1239 | /// A file source is a reference to an existing or future file. |
| 1240 | /// |
| 1239 | 1241 | pub const FileSource = union(enum) { |
| 1240 | | /// Relative to build root |
| 1242 | /// A plain file path, relative to build root. |
| 1241 | 1243 | path: []const u8, |
| 1244 | |
| 1245 | /// A file that is generated by an interface. Those files usually are |
| 1246 | /// not available until built by a build step. |
| 1242 | 1247 | generated: *const GeneratedFile, |
| 1243 | 1248 | |
| 1249 | /// Returns a new file source that will have a relative path to the build root guaranteed. |
| 1250 | /// This should be preferred over setting `.path` directly as it documents that the files are in the project directory. |
| 1244 | 1251 | pub fn relative(path: []const u8) FileSource { |
| 1252 | std.debug.assert(!std.fs.path.isAbsolute(path)); |
| 1245 | 1253 | return FileSource{ .path = path }; |
| 1246 | 1254 | } |
| 1247 | 1255 | |
| ... | ... | @@ -1254,6 +1262,7 @@ pub const FileSource = union(enum) { |
| 1254 | 1262 | }; |
| 1255 | 1263 | } |
| 1256 | 1264 | |
| 1265 | /// Adds dependencies this file source implies to the given step. |
| 1257 | 1266 | pub fn addStepDependencies(self: FileSource, step: *Step) void { |
| 1258 | 1267 | switch (self) { |
| 1259 | 1268 | .path => {}, |
| ... | ... | @@ -1271,6 +1280,7 @@ pub const FileSource = union(enum) { |
| 1271 | 1280 | return path; |
| 1272 | 1281 | } |
| 1273 | 1282 | |
| 1283 | /// Duplicates the file source for a given builder. |
| 1274 | 1284 | pub fn dupe(self: FileSource, b: *Builder) FileSource { |
| 1275 | 1285 | return switch (self) { |
| 1276 | 1286 | .path => |p| .{ .path = b.dupePath(p) }, |
| ... | ... | @@ -1284,10 +1294,9 @@ const BuildOptionArtifactArg = struct { |
| 1284 | 1294 | artifact: *LibExeObjStep, |
| 1285 | 1295 | }; |
| 1286 | 1296 | |
| 1287 | | const BuildOptionWriteFileArg = struct { |
| 1297 | const BuildOptionFileSourceArg = struct { |
| 1288 | 1298 | name: []const u8, |
| 1289 | | write_file: *WriteFileStep, |
| 1290 | | basename: []const u8, |
| 1299 | source: FileSource, |
| 1291 | 1300 | }; |
| 1292 | 1301 | |
| 1293 | 1302 | pub const LibExeObjStep = struct { |
| ... | ... | @@ -1295,7 +1304,7 @@ pub const LibExeObjStep = struct { |
| 1295 | 1304 | builder: *Builder, |
| 1296 | 1305 | name: []const u8, |
| 1297 | 1306 | target: CrossTarget = CrossTarget{}, |
| 1298 | | linker_script: ?[]const u8 = null, |
| 1307 | linker_script: ?FileSource = null, |
| 1299 | 1308 | version_script: ?[]const u8 = null, |
| 1300 | 1309 | out_filename: []const u8, |
| 1301 | 1310 | is_dynamic: bool, |
| ... | ... | @@ -1338,7 +1347,7 @@ pub const LibExeObjStep = struct { |
| 1338 | 1347 | packages: ArrayList(Pkg), |
| 1339 | 1348 | build_options_contents: std.ArrayList(u8), |
| 1340 | 1349 | build_options_artifact_args: std.ArrayList(BuildOptionArtifactArg), |
| 1341 | | build_options_write_file_args: std.ArrayList(BuildOptionWriteFileArg), |
| 1350 | build_options_file_source_args: std.ArrayList(BuildOptionFileSourceArg), |
| 1342 | 1351 | |
| 1343 | 1352 | object_src: []const u8, |
| 1344 | 1353 | |
| ... | ... | @@ -1358,7 +1367,7 @@ pub const LibExeObjStep = struct { |
| 1358 | 1367 | /// Base address for an executable image. |
| 1359 | 1368 | image_base: ?u64 = null, |
| 1360 | 1369 | |
| 1361 | | libc_file: ?[]const u8 = null, |
| 1370 | libc_file: ?FileSource = null, |
| 1362 | 1371 | |
| 1363 | 1372 | valgrind_support: ?bool = null, |
| 1364 | 1373 | |
| ... | ... | @@ -1407,18 +1416,18 @@ pub const LibExeObjStep = struct { |
| 1407 | 1416 | want_lto: ?bool = null, |
| 1408 | 1417 | |
| 1409 | 1418 | const LinkObject = union(enum) { |
| 1410 | | StaticPath: []const u8, |
| 1411 | | OtherStep: *LibExeObjStep, |
| 1412 | | SystemLib: []const u8, |
| 1413 | | AssemblyFile: FileSource, |
| 1414 | | CSourceFile: *CSourceFile, |
| 1415 | | CSourceFiles: *CSourceFiles, |
| 1419 | static_path: FileSource, |
| 1420 | other_step: *LibExeObjStep, |
| 1421 | system_lib: []const u8, |
| 1422 | assembly_file: FileSource, |
| 1423 | c_source_file: *CSourceFile, |
| 1424 | c_source_files: *CSourceFiles, |
| 1416 | 1425 | }; |
| 1417 | 1426 | |
| 1418 | 1427 | const IncludeDir = union(enum) { |
| 1419 | | RawPath: []const u8, |
| 1420 | | RawPathSystem: []const u8, |
| 1421 | | OtherStep: *LibExeObjStep, |
| 1428 | raw_path: []const u8, |
| 1429 | raw_path_system: []const u8, |
| 1430 | other_step: *LibExeObjStep, |
| 1422 | 1431 | }; |
| 1423 | 1432 | |
| 1424 | 1433 | const Kind = enum { |
| ... | ... | @@ -1508,7 +1517,7 @@ pub const LibExeObjStep = struct { |
| 1508 | 1517 | .object_src = undefined, |
| 1509 | 1518 | .build_options_contents = std.ArrayList(u8).init(builder.allocator), |
| 1510 | 1519 | .build_options_artifact_args = std.ArrayList(BuildOptionArtifactArg).init(builder.allocator), |
| 1511 | | .build_options_write_file_args = std.ArrayList(BuildOptionWriteFileArg).init(builder.allocator), |
| 1520 | .build_options_file_source_args = std.ArrayList(BuildOptionFileSourceArg).init(builder.allocator), |
| 1512 | 1521 | .c_std = Builder.CStd.C99, |
| 1513 | 1522 | .override_lib_dir = null, |
| 1514 | 1523 | .main_pkg_path = null, |
| ... | ... | @@ -1613,8 +1622,8 @@ pub const LibExeObjStep = struct { |
| 1613 | 1622 | return run_step; |
| 1614 | 1623 | } |
| 1615 | 1624 | |
| 1616 | | pub fn setLinkerScriptPath(self: *LibExeObjStep, path: []const u8) void { |
| 1617 | | self.linker_script = self.builder.dupePath(path); |
| 1625 | pub fn setLinkerScriptPath(self: *LibExeObjStep, source: FileSource) void { |
| 1626 | self.linker_script = source.dupe(self.builder); |
| 1618 | 1627 | } |
| 1619 | 1628 | |
| 1620 | 1629 | pub fn linkFramework(self: *LibExeObjStep, framework_name: []const u8) void { |
| ... | ... | @@ -1633,7 +1642,7 @@ pub const LibExeObjStep = struct { |
| 1633 | 1642 | } |
| 1634 | 1643 | for (self.link_objects.items) |link_object| { |
| 1635 | 1644 | switch (link_object) { |
| 1636 | | LinkObject.SystemLib => |n| if (mem.eql(u8, n, name)) return true, |
| 1645 | .system_lib => |n| if (mem.eql(u8, n, name)) return true, |
| 1637 | 1646 | else => continue, |
| 1638 | 1647 | } |
| 1639 | 1648 | } |
| ... | ... | @@ -1658,7 +1667,7 @@ pub const LibExeObjStep = struct { |
| 1658 | 1667 | pub fn linkLibC(self: *LibExeObjStep) void { |
| 1659 | 1668 | if (!self.is_linking_libc) { |
| 1660 | 1669 | self.is_linking_libc = true; |
| 1661 | | self.link_objects.append(LinkObject{ .SystemLib = "c" }) catch unreachable; |
| 1670 | self.link_objects.append(LinkObject{ .system_lib = "c" }) catch unreachable; |
| 1662 | 1671 | } |
| 1663 | 1672 | } |
| 1664 | 1673 | |
| ... | ... | @@ -1677,7 +1686,7 @@ pub const LibExeObjStep = struct { |
| 1677 | 1686 | /// This one has no integration with anything, it just puts -lname on the command line. |
| 1678 | 1687 | /// Prefer to use `linkSystemLibrary` instead. |
| 1679 | 1688 | pub fn linkSystemLibraryName(self: *LibExeObjStep, name: []const u8) void { |
| 1680 | | self.link_objects.append(LinkObject{ .SystemLib = self.builder.dupe(name) }) catch unreachable; |
| 1689 | self.link_objects.append(LinkObject{ .system_lib = self.builder.dupe(name) }) catch unreachable; |
| 1681 | 1690 | } |
| 1682 | 1691 | |
| 1683 | 1692 | /// This links against a system library, exclusively using pkg-config to find the library. |
| ... | ... | @@ -1817,7 +1826,7 @@ pub const LibExeObjStep = struct { |
| 1817 | 1826 | .files = files_copy, |
| 1818 | 1827 | .flags = flags_copy, |
| 1819 | 1828 | }; |
| 1820 | | self.link_objects.append(LinkObject{ .CSourceFiles = c_source_files }) catch unreachable; |
| 1829 | self.link_objects.append(LinkObject{ .c_source_files = c_source_files }) catch unreachable; |
| 1821 | 1830 | } |
| 1822 | 1831 | |
| 1823 | 1832 | pub fn addCSourceFile(self: *LibExeObjStep, file: []const u8, flags: []const []const u8) void { |
| ... | ... | @@ -1830,7 +1839,8 @@ pub const LibExeObjStep = struct { |
| 1830 | 1839 | pub fn addCSourceFileSource(self: *LibExeObjStep, source: CSourceFile) void { |
| 1831 | 1840 | const c_source_file = self.builder.allocator.create(CSourceFile) catch unreachable; |
| 1832 | 1841 | c_source_file.* = source.dupe(self.builder); |
| 1833 | | self.link_objects.append(LinkObject{ .CSourceFile = c_source_file }) catch unreachable; |
| 1842 | self.link_objects.append(LinkObject{ .c_source_file = c_source_file }) catch unreachable; |
| 1843 | source.source.addStepDependencies(&self.step); |
| 1834 | 1844 | } |
| 1835 | 1845 | |
| 1836 | 1846 | pub fn setVerboseLink(self: *LibExeObjStep, value: bool) void { |
| ... | ... | @@ -1853,8 +1863,8 @@ pub const LibExeObjStep = struct { |
| 1853 | 1863 | self.main_pkg_path = self.builder.dupePath(dir_path); |
| 1854 | 1864 | } |
| 1855 | 1865 | |
| 1856 | | pub fn setLibCFile(self: *LibExeObjStep, libc_file: ?[]const u8) void { |
| 1857 | | self.libc_file = if (libc_file) |f| self.builder.dupe(f) else null; |
| 1866 | pub fn setLibCFile(self: *LibExeObjStep, libc_file: ?FileSource) void { |
| 1867 | self.libc_file = if (libc_file) |f| f.dupe(self.builder) else null; |
| 1858 | 1868 | } |
| 1859 | 1869 | |
| 1860 | 1870 | /// Unless setOutputDir was called, this function must be called only in |
| ... | ... | @@ -1900,18 +1910,18 @@ pub const LibExeObjStep = struct { |
| 1900 | 1910 | |
| 1901 | 1911 | pub fn addAssemblyFile(self: *LibExeObjStep, path: []const u8) void { |
| 1902 | 1912 | self.link_objects.append(LinkObject{ |
| 1903 | | .AssemblyFile = .{ .path = self.builder.dupe(path) }, |
| 1913 | .assembly_file = .{ .path = self.builder.dupe(path) }, |
| 1904 | 1914 | }) catch unreachable; |
| 1905 | 1915 | } |
| 1906 | 1916 | |
| 1907 | 1917 | pub fn addAssemblyFileSource(self: *LibExeObjStep, source: FileSource) void { |
| 1908 | 1918 | const source_duped = source.dupe(self.builder); |
| 1909 | | self.link_objects.append(LinkObject{ .AssemblyFile = source_duped }) catch unreachable; |
| 1919 | self.link_objects.append(LinkObject{ .assembly_file = source_duped }) catch unreachable; |
| 1910 | 1920 | source_duped.addStepDependencies(&self.step); |
| 1911 | 1921 | } |
| 1912 | 1922 | |
| 1913 | | pub fn addObjectFile(self: *LibExeObjStep, path: []const u8) void { |
| 1914 | | self.link_objects.append(LinkObject{ .StaticPath = self.builder.dupe(path) }) catch unreachable; |
| 1923 | pub fn addObjectFile(self: *LibExeObjStep, source: FileSource) void { |
| 1924 | self.link_objects.append(LinkObject{ .static_path = source.dupe(self.builder) }) catch unreachable; |
| 1915 | 1925 | } |
| 1916 | 1926 | |
| 1917 | 1927 | pub fn addObject(self: *LibExeObjStep, obj: *LibExeObjStep) void { |
| ... | ... | @@ -2020,26 +2030,24 @@ pub const LibExeObjStep = struct { |
| 2020 | 2030 | /// The value is the path in the cache dir. |
| 2021 | 2031 | /// Adds a dependency automatically. |
| 2022 | 2032 | /// basename refers to the basename of the WriteFileStep |
| 2023 | | pub fn addBuildOptionWriteFile( |
| 2033 | pub fn addBuildOptionFileSource( |
| 2024 | 2034 | self: *LibExeObjStep, |
| 2025 | 2035 | name: []const u8, |
| 2026 | | write_file: *WriteFileStep, |
| 2027 | | basename: []const u8, |
| 2036 | source: FileSource, |
| 2028 | 2037 | ) void { |
| 2029 | | self.build_options_write_file_args.append(.{ |
| 2038 | self.build_options_file_source_args.append(.{ |
| 2030 | 2039 | .name = name, |
| 2031 | | .write_file = write_file, |
| 2032 | | .basename = basename, |
| 2040 | .source = source.dupe(self.builder), |
| 2033 | 2041 | }) catch unreachable; |
| 2034 | | self.step.dependOn(&write_file.step); |
| 2042 | source.addStepDependencies(&self.step); |
| 2035 | 2043 | } |
| 2036 | 2044 | |
| 2037 | 2045 | pub fn addSystemIncludeDir(self: *LibExeObjStep, path: []const u8) void { |
| 2038 | | self.include_dirs.append(IncludeDir{ .RawPathSystem = self.builder.dupe(path) }) catch unreachable; |
| 2046 | self.include_dirs.append(IncludeDir{ .raw_path_system = self.builder.dupe(path) }) catch unreachable; |
| 2039 | 2047 | } |
| 2040 | 2048 | |
| 2041 | 2049 | pub fn addIncludeDir(self: *LibExeObjStep, path: []const u8) void { |
| 2042 | | self.include_dirs.append(IncludeDir{ .RawPath = self.builder.dupe(path) }) catch unreachable; |
| 2050 | self.include_dirs.append(IncludeDir{ .raw_path = self.builder.dupe(path) }) catch unreachable; |
| 2043 | 2051 | } |
| 2044 | 2052 | |
| 2045 | 2053 | pub fn addLibPath(self: *LibExeObjStep, path: []const u8) void { |
| ... | ... | @@ -2093,7 +2101,7 @@ pub const LibExeObjStep = struct { |
| 2093 | 2101 | |
| 2094 | 2102 | const include_path = try fs.path.join(allocator, &[_][]const u8{ root, "installed", triplet, "include" }); |
| 2095 | 2103 | errdefer allocator.free(include_path); |
| 2096 | | try self.include_dirs.append(IncludeDir{ .RawPath = include_path }); |
| 2104 | try self.include_dirs.append(IncludeDir{ .raw_path = include_path }); |
| 2097 | 2105 | |
| 2098 | 2106 | const lib_path = try fs.path.join(allocator, &[_][]const u8{ root, "installed", triplet, "lib" }); |
| 2099 | 2107 | try self.lib_paths.append(lib_path); |
| ... | ... | @@ -2114,13 +2122,13 @@ pub const LibExeObjStep = struct { |
| 2114 | 2122 | |
| 2115 | 2123 | fn linkLibraryOrObject(self: *LibExeObjStep, other: *LibExeObjStep) void { |
| 2116 | 2124 | self.step.dependOn(&other.step); |
| 2117 | | self.link_objects.append(LinkObject{ .OtherStep = other }) catch unreachable; |
| 2118 | | self.include_dirs.append(IncludeDir{ .OtherStep = other }) catch unreachable; |
| 2125 | self.link_objects.append(LinkObject{ .other_step = other }) catch unreachable; |
| 2126 | self.include_dirs.append(IncludeDir{ .other_step = other }) catch unreachable; |
| 2119 | 2127 | |
| 2120 | 2128 | // Inherit dependency on system libraries |
| 2121 | 2129 | for (other.link_objects.items) |link_object| { |
| 2122 | 2130 | switch (link_object) { |
| 2123 | | .SystemLib => |name| self.linkSystemLibrary(name), |
| 2131 | .system_lib => |name| self.linkSystemLibrary(name), |
| 2124 | 2132 | else => continue, |
| 2125 | 2133 | } |
| 2126 | 2134 | } |
| ... | ... | @@ -2187,11 +2195,9 @@ pub const LibExeObjStep = struct { |
| 2187 | 2195 | var prev_has_extra_flags = false; |
| 2188 | 2196 | for (self.link_objects.items) |link_object| { |
| 2189 | 2197 | switch (link_object) { |
| 2190 | | .StaticPath => |static_path| { |
| 2191 | | try zig_args.append(builder.pathFromRoot(static_path)); |
| 2192 | | }, |
| 2198 | .static_path => |static_path| try zig_args.append(static_path.getPath(builder)), |
| 2193 | 2199 | |
| 2194 | | .OtherStep => |other| switch (other.kind) { |
| 2200 | .other_step => |other| switch (other.kind) { |
| 2195 | 2201 | .Exe => unreachable, |
| 2196 | 2202 | .Test => unreachable, |
| 2197 | 2203 | .Obj => { |
| ... | ... | @@ -2209,10 +2215,11 @@ pub const LibExeObjStep = struct { |
| 2209 | 2215 | } |
| 2210 | 2216 | }, |
| 2211 | 2217 | }, |
| 2212 | | .SystemLib => |name| { |
| 2218 | .system_lib => |name| { |
| 2213 | 2219 | try zig_args.append(builder.fmt("-l{s}", .{name})); |
| 2214 | 2220 | }, |
| 2215 | | .AssemblyFile => |asm_file| { |
| 2221 | |
| 2222 | .assembly_file => |asm_file| { |
| 2216 | 2223 | if (prev_has_extra_flags) { |
| 2217 | 2224 | try zig_args.append("-extra-cflags"); |
| 2218 | 2225 | try zig_args.append("--"); |
| ... | ... | @@ -2221,7 +2228,7 @@ pub const LibExeObjStep = struct { |
| 2221 | 2228 | try zig_args.append(asm_file.getPath(builder)); |
| 2222 | 2229 | }, |
| 2223 | 2230 | |
| 2224 | | .CSourceFile => |c_source_file| { |
| 2231 | .c_source_file => |c_source_file| { |
| 2225 | 2232 | if (c_source_file.args.len == 0) { |
| 2226 | 2233 | if (prev_has_extra_flags) { |
| 2227 | 2234 | try zig_args.append("-cflags"); |
| ... | ... | @@ -2238,7 +2245,7 @@ pub const LibExeObjStep = struct { |
| 2238 | 2245 | try zig_args.append(c_source_file.source.getPath(builder)); |
| 2239 | 2246 | }, |
| 2240 | 2247 | |
| 2241 | | .CSourceFiles => |c_source_files| { |
| 2248 | .c_source_files => |c_source_files| { |
| 2242 | 2249 | if (c_source_files.flags.len == 0) { |
| 2243 | 2250 | if (prev_has_extra_flags) { |
| 2244 | 2251 | try zig_args.append("-cflags"); |
| ... | ... | @@ -2261,7 +2268,7 @@ pub const LibExeObjStep = struct { |
| 2261 | 2268 | |
| 2262 | 2269 | if (self.build_options_contents.items.len > 0 or |
| 2263 | 2270 | self.build_options_artifact_args.items.len > 0 or |
| 2264 | | self.build_options_write_file_args.items.len > 0) |
| 2271 | self.build_options_file_source_args.items.len > 0) |
| 2265 | 2272 | { |
| 2266 | 2273 | // Render build artifact and write file options at the last minute, now that the path is known. |
| 2267 | 2274 | // |
| ... | ... | @@ -2274,11 +2281,11 @@ pub const LibExeObjStep = struct { |
| 2274 | 2281 | self.builder.pathFromRoot(item.artifact.getOutputPath()), |
| 2275 | 2282 | ); |
| 2276 | 2283 | } |
| 2277 | | for (self.build_options_write_file_args.items) |item| { |
| 2284 | for (self.build_options_file_source_args.items) |item| { |
| 2278 | 2285 | self.addBuildOption( |
| 2279 | 2286 | []const u8, |
| 2280 | 2287 | item.name, |
| 2281 | | self.builder.pathFromRoot(item.write_file.getOutputPath(item.basename)), |
| 2288 | item.source.getPath(self.builder), |
| 2282 | 2289 | ); |
| 2283 | 2290 | } |
| 2284 | 2291 | |
| ... | ... | @@ -2349,7 +2356,7 @@ pub const LibExeObjStep = struct { |
| 2349 | 2356 | |
| 2350 | 2357 | if (self.libc_file) |libc_file| { |
| 2351 | 2358 | try zig_args.append("--libc"); |
| 2352 | | try zig_args.append(builder.pathFromRoot(libc_file)); |
| 2359 | try zig_args.append(libc_file.getPath(self.builder)); |
| 2353 | 2360 | } |
| 2354 | 2361 | |
| 2355 | 2362 | switch (self.build_mode) { |
| ... | ... | @@ -2451,7 +2458,7 @@ pub const LibExeObjStep = struct { |
| 2451 | 2458 | |
| 2452 | 2459 | if (self.linker_script) |linker_script| { |
| 2453 | 2460 | try zig_args.append("--script"); |
| 2454 | | try zig_args.append(builder.pathFromRoot(linker_script)); |
| 2461 | try zig_args.append(linker_script.getPath(builder)); |
| 2455 | 2462 | } |
| 2456 | 2463 | |
| 2457 | 2464 | if (self.version_script) |version_script| { |
| ... | ... | @@ -2526,15 +2533,15 @@ pub const LibExeObjStep = struct { |
| 2526 | 2533 | |
| 2527 | 2534 | for (self.include_dirs.items) |include_dir| { |
| 2528 | 2535 | switch (include_dir) { |
| 2529 | | .RawPath => |include_path| { |
| 2536 | .raw_path => |include_path| { |
| 2530 | 2537 | try zig_args.append("-I"); |
| 2531 | 2538 | try zig_args.append(self.builder.pathFromRoot(include_path)); |
| 2532 | 2539 | }, |
| 2533 | | .RawPathSystem => |include_path| { |
| 2540 | .raw_path_system => |include_path| { |
| 2534 | 2541 | try zig_args.append("-isystem"); |
| 2535 | 2542 | try zig_args.append(self.builder.pathFromRoot(include_path)); |
| 2536 | 2543 | }, |
| 2537 | | .OtherStep => |other| if (other.emit_h) { |
| 2544 | .other_step => |other| if (other.emit_h) { |
| 2538 | 2545 | const h_path = other.getOutputHPath(); |
| 2539 | 2546 | try zig_args.append("-isystem"); |
| 2540 | 2547 | try zig_args.append(fs.path.dirname(h_path).?); |
| ... | ... | @@ -3086,11 +3093,11 @@ test "Builder.dupePkg()" { |
| 3086 | 3093 | |
| 3087 | 3094 | var pkg_dep = Pkg{ |
| 3088 | 3095 | .name = "pkg_dep", |
| 3089 | | .path = FileSource.relative("/not/a/pkg_dep.zig"), |
| 3096 | .path = .{ .path = "/not/a/pkg_dep.zig" }, |
| 3090 | 3097 | }; |
| 3091 | 3098 | var pkg_top = Pkg{ |
| 3092 | 3099 | .name = "pkg_top", |
| 3093 | | .path = FileSource.relative("/not/a/pkg_top.zig"), |
| 3100 | .path = .{ .path = "/not/a/pkg_top.zig" }, |
| 3094 | 3101 | .dependencies = &[_]Pkg{pkg_dep}, |
| 3095 | 3102 | }; |
| 3096 | 3103 | const dupe = builder.dupePkg(pkg_top); |
| ... | ... | @@ -3168,11 +3175,11 @@ test "LibExeObjStep.addPackage" { |
| 3168 | 3175 | |
| 3169 | 3176 | const pkg_dep = Pkg{ |
| 3170 | 3177 | .name = "pkg_dep", |
| 3171 | | .path = FileSource.relative("/not/a/pkg_dep.zig"), |
| 3178 | .path = .{ .path = "/not/a/pkg_dep.zig" }, |
| 3172 | 3179 | }; |
| 3173 | 3180 | const pkg_top = Pkg{ |
| 3174 | 3181 | .name = "pkg_dep", |
| 3175 | | .path = FileSource.relative("/not/a/pkg_top.zig"), |
| 3182 | .path = .{ .path = "/not/a/pkg_top.zig" }, |
| 3176 | 3183 | .dependencies = &[_]Pkg{pkg_dep}, |
| 3177 | 3184 | }; |
| 3178 | 3185 | |