authorgravatar for xq@random-projects.netFelix "xq" Queißner <xq@random-projects.net> 2021-02-23 21:14:50+01:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2021-06-11 10:38:57+03:00
log07acb1ccc97329cdcc0df37234325af9b00420a3
tree26e56446411725be53958dfef4331cd6ad598e73
parent56cb0b5ca0ffc4fc2c54b9dfb0f15fb7c50dc840

Changes createExecutable parameter is_dynamic to a enum to make code more readable .


7 files changed, 77 insertions(+), 66 deletions(-)

lib/std/build.zig+61-43
...@@ -174,7 +174,7 @@ pub const Builder = struct {...@@ -174,7 +174,7 @@ pub const Builder = struct {
174 .is_release = false,174 .is_release = false,
175 .override_lib_dir = null,175 .override_lib_dir = null,
176 .install_path = undefined,176 .install_path = undefined,
177 .vcpkg_root = VcpkgRoot{ .Unattempted = {} },177 .vcpkg_root = VcpkgRoot{ .unattempted = {} },
178 .args = null,178 .args = null,
179 };179 };
180 try self.top_level_steps.append(&self.install_tls);180 try self.top_level_steps.append(&self.install_tls);
...@@ -212,7 +212,7 @@ pub const Builder = struct {...@@ -212,7 +212,7 @@ pub const Builder = struct {
212 }212 }
213213
214 pub fn addExecutable(self: *Builder, name: []const u8, root_src: ?[]const u8) *LibExeObjStep {214 pub fn addExecutable(self: *Builder, name: []const u8, root_src: ?[]const u8) *LibExeObjStep {
215 return addExecutableSource(self, name, convertOptionalPathToFileSource(root_src), false);215 return addExecutableSource(self, name, convertOptionalPathToFileSource(root_src), .static);
216 }216 }
217217
218 pub const addExecutableSource = LibExeObjStep.createExecutable;218 pub const addExecutableSource = LibExeObjStep.createExecutable;
...@@ -250,7 +250,7 @@ pub const Builder = struct {...@@ -250,7 +250,7 @@ pub const Builder = struct {
250 }250 }
251251
252 pub fn addAssemble(self: *Builder, name: []const u8, src: []const u8) *LibExeObjStep {252 pub fn addAssemble(self: *Builder, name: []const u8, src: []const u8) *LibExeObjStep {
253 return addAssembleSource(self, name, FileSource.relative(src));253 return addAssembleSource(self, name, .{ .path = src });
254 }254 }
255255
256 pub fn addAssembleSource(self: *Builder, name: []const u8, src: FileSource) *LibExeObjStep {256 pub fn addAssembleSource(self: *Builder, name: []const u8, src: FileSource) *LibExeObjStep {
...@@ -876,7 +876,7 @@ pub const Builder = struct {...@@ -876,7 +876,7 @@ pub const Builder = struct {
876876
877 ///`dest_rel_path` is relative to prefix path877 ///`dest_rel_path` is relative to prefix path
878 pub fn installFile(self: *Builder, src_path: []const u8, dest_rel_path: []const u8) void {878 pub fn installFile(self: *Builder, src_path: []const u8, dest_rel_path: []const u8) void {
879 self.getInstallStep().dependOn(&self.addInstallFileWithDir(FileSource.relative(src_path), .Prefix, dest_rel_path).step);879 self.getInstallStep().dependOn(&self.addInstallFileWithDir(.{ .path = src_path }, .Prefix, dest_rel_path).step);
880 }880 }
881881
882 pub fn installDirectory(self: *Builder, options: InstallDirectoryOptions) void {882 pub fn installDirectory(self: *Builder, options: InstallDirectoryOptions) void {
...@@ -885,12 +885,12 @@ pub const Builder = struct {...@@ -885,12 +885,12 @@ pub const Builder = struct {
885885
886 ///`dest_rel_path` is relative to bin path886 ///`dest_rel_path` is relative to bin path
887 pub fn installBinFile(self: *Builder, src_path: []const u8, dest_rel_path: []const u8) void {887 pub fn installBinFile(self: *Builder, src_path: []const u8, dest_rel_path: []const u8) void {
888 self.getInstallStep().dependOn(&self.addInstallFileWithDir(FileSource.relative(src_path), .Bin, dest_rel_path).step);888 self.getInstallStep().dependOn(&self.addInstallFileWithDir(.{ .path = src_path }, .Bin, dest_rel_path).step);
889 }889 }
890890
891 ///`dest_rel_path` is relative to lib path891 ///`dest_rel_path` is relative to lib path
892 pub fn installLibFile(self: *Builder, src_path: []const u8, dest_rel_path: []const u8) void {892 pub fn installLibFile(self: *Builder, src_path: []const u8, dest_rel_path: []const u8) void {
893 self.getInstallStep().dependOn(&self.addInstallFileWithDir(FileSource.relative(src_path), .Lib, dest_rel_path).step);893 self.getInstallStep().dependOn(&self.addInstallFileWithDir(.{ .path = src_path }, .Lib, dest_rel_path).step);
894 }894 }
895895
896 pub fn installRaw(self: *Builder, artifact: *LibExeObjStep, dest_filename: []const u8) void {896 pub fn installRaw(self: *Builder, artifact: *LibExeObjStep, dest_filename: []const u8) void {
...@@ -1239,7 +1239,7 @@ pub const GeneratedFile = struct {...@@ -1239,7 +1239,7 @@ pub const GeneratedFile = struct {
1239/// A file source is a reference to an existing or future file.1239/// A file source is a reference to an existing or future file.
1240///1240///
1241pub const FileSource = union(enum) {1241pub const FileSource = union(enum) {
1242 /// A plain file path, relative to build root.1242 /// A plain file path, relative to build root or absolute.
1243 path: []const u8,1243 path: []const u8,
12441244
1245 /// A file that is generated by an interface. Those files usually are1245 /// A file that is generated by an interface. Those files usually are
...@@ -1270,13 +1270,12 @@ pub const FileSource = union(enum) {...@@ -1270,13 +1270,12 @@ pub const FileSource = union(enum) {
1270 }1270 }
1271 }1271 }
12721272
1273 /// Should only be called during make(), returns an absolute path to the file.1273 /// Should only be called during make(), returns a path relative to the build root or absolute.
1274 pub fn getPath(self: FileSource, builder: *Builder) []const u8 {1274 pub fn getPath(self: FileSource, builder: *Builder) []const u8 {
1275 const path = switch (self) {1275 const path = switch (self) {
1276 .path => |p| builder.pathFromRoot(p),1276 .path => |p| builder.pathFromRoot(p),
1277 .generated => |gen| gen.getPath(),1277 .generated => |gen| gen.getPath(),
1278 };1278 };
1279 std.debug.assert(std.fs.path.isAbsolute(path));
1280 return path;1279 return path;
1281 }1280 }
12821281
...@@ -1307,7 +1306,7 @@ pub const LibExeObjStep = struct {...@@ -1307,7 +1306,7 @@ pub const LibExeObjStep = struct {
1307 linker_script: ?FileSource = null,1306 linker_script: ?FileSource = null,
1308 version_script: ?[]const u8 = null,1307 version_script: ?[]const u8 = null,
1309 out_filename: []const u8,1308 out_filename: []const u8,
1310 is_dynamic: bool,1309 linkage: Linkage,
1311 version: ?Version,1310 version: ?Version,
1312 build_mode: builtin.Mode,1311 build_mode: builtin.Mode,
1313 kind: Kind,1312 kind: Kind,
...@@ -1442,9 +1441,11 @@ pub const LibExeObjStep = struct {...@@ -1442,9 +1441,11 @@ pub const LibExeObjStep = struct {
1442 unversioned: void,1441 unversioned: void,
1443 };1442 };
14441443
1444 pub const Linkage = enum { dynamic, static };
1445
1445 pub fn createSharedLibrary(builder: *Builder, name: []const u8, root_src: ?FileSource, kind: SharedLibKind) *LibExeObjStep {1446 pub fn createSharedLibrary(builder: *Builder, name: []const u8, root_src: ?FileSource, kind: SharedLibKind) *LibExeObjStep {
1446 const self = builder.allocator.create(LibExeObjStep) catch unreachable;1447 const self = builder.allocator.create(LibExeObjStep) catch unreachable;
1447 self.* = initExtraArgs(builder, name, root_src, Kind.Lib, true, switch (kind) {1448 self.* = initExtraArgs(builder, name, root_src, Kind.Lib, .dynamic, switch (kind) {
1448 .versioned => |ver| ver,1449 .versioned => |ver| ver,
1449 .unversioned => null,1450 .unversioned => null,
1450 });1451 });
...@@ -1453,25 +1454,25 @@ pub const LibExeObjStep = struct {...@@ -1453,25 +1454,25 @@ pub const LibExeObjStep = struct {
14531454
1454 pub fn createStaticLibrary(builder: *Builder, name: []const u8, root_src: ?FileSource) *LibExeObjStep {1455 pub fn createStaticLibrary(builder: *Builder, name: []const u8, root_src: ?FileSource) *LibExeObjStep {
1455 const self = builder.allocator.create(LibExeObjStep) catch unreachable;1456 const self = builder.allocator.create(LibExeObjStep) catch unreachable;
1456 self.* = initExtraArgs(builder, name, root_src, Kind.Lib, false, null);1457 self.* = initExtraArgs(builder, name, root_src, Kind.Lib, .static, null);
1457 return self;1458 return self;
1458 }1459 }
14591460
1460 pub fn createObject(builder: *Builder, name: []const u8, root_src: ?FileSource) *LibExeObjStep {1461 pub fn createObject(builder: *Builder, name: []const u8, root_src: ?FileSource) *LibExeObjStep {
1461 const self = builder.allocator.create(LibExeObjStep) catch unreachable;1462 const self = builder.allocator.create(LibExeObjStep) catch unreachable;
1462 self.* = initExtraArgs(builder, name, root_src, Kind.Obj, false, null);1463 self.* = initExtraArgs(builder, name, root_src, Kind.Obj, .static, null);
1463 return self;1464 return self;
1464 }1465 }
14651466
1466 pub fn createExecutable(builder: *Builder, name: []const u8, root_src: ?FileSource, is_dynamic: bool) *LibExeObjStep {1467 pub fn createExecutable(builder: *Builder, name: []const u8, root_src: ?FileSource, linkage: Linkage) *LibExeObjStep {
1467 const self = builder.allocator.create(LibExeObjStep) catch unreachable;1468 const self = builder.allocator.create(LibExeObjStep) catch unreachable;
1468 self.* = initExtraArgs(builder, name, root_src, Kind.Exe, is_dynamic, null);1469 self.* = initExtraArgs(builder, name, root_src, Kind.Exe, linkage, null);
1469 return self;1470 return self;
1470 }1471 }
14711472
1472 pub fn createTest(builder: *Builder, name: []const u8, root_src: FileSource) *LibExeObjStep {1473 pub fn createTest(builder: *Builder, name: []const u8, root_src: FileSource) *LibExeObjStep {
1473 const self = builder.allocator.create(LibExeObjStep) catch unreachable;1474 const self = builder.allocator.create(LibExeObjStep) catch unreachable;
1474 self.* = initExtraArgs(builder, name, root_src, Kind.Test, false, null);1475 self.* = initExtraArgs(builder, name, root_src, Kind.Test, .static, null);
1475 return self;1476 return self;
1476 }1477 }
14771478
...@@ -1480,7 +1481,7 @@ pub const LibExeObjStep = struct {...@@ -1480,7 +1481,7 @@ pub const LibExeObjStep = struct {
1480 name_raw: []const u8,1481 name_raw: []const u8,
1481 root_src_raw: ?FileSource,1482 root_src_raw: ?FileSource,
1482 kind: Kind,1483 kind: Kind,
1483 is_dynamic: bool,1484 linkage: Linkage,
1484 ver: ?Version,1485 ver: ?Version,
1485 ) LibExeObjStep {1486 ) LibExeObjStep {
1486 const name = builder.dupe(name_raw);1487 const name = builder.dupe(name_raw);
...@@ -1494,7 +1495,7 @@ pub const LibExeObjStep = struct {...@@ -1494,7 +1495,7 @@ pub const LibExeObjStep = struct {
1494 .verbose_link = false,1495 .verbose_link = false,
1495 .verbose_cc = false,1496 .verbose_cc = false,
1496 .build_mode = builtin.Mode.Debug,1497 .build_mode = builtin.Mode.Debug,
1497 .is_dynamic = is_dynamic,1498 .linkage = linkage,
1498 .kind = kind,1499 .kind = kind,
1499 .root_src = root_src,1500 .root_src = root_src,
1500 .name = name,1501 .name = name,
...@@ -1553,12 +1554,15 @@ pub const LibExeObjStep = struct {...@@ -1553,12 +1554,15 @@ pub const LibExeObjStep = struct {
1553 .Obj => .Obj,1554 .Obj => .Obj,
1554 .Exe, .Test => .Exe,1555 .Exe, .Test => .Exe,
1555 },1556 },
1556 .link_mode = if (self.is_dynamic) .Dynamic else .Static,1557 .link_mode = switch (self.linkage) {
1558 .dynamic => std.builtin.LinkMode.Dynamic,
1559 .static => std.builtin.LinkMode.Static,
1560 },
1557 .version = self.version,1561 .version = self.version,
1558 }) catch unreachable;1562 }) catch unreachable;
15591563
1560 if (self.kind == .Lib) {1564 if (self.kind == .Lib) {
1561 if (!self.is_dynamic) {1565 if (self.linkage == .static) {
1562 self.out_lib_filename = self.out_filename;1566 self.out_lib_filename = self.out_filename;
1563 } else if (self.version) |version| {1567 } else if (self.version) |version| {
1564 if (target.isDarwin()) {1568 if (target.isDarwin()) {
...@@ -1655,7 +1659,7 @@ pub const LibExeObjStep = struct {...@@ -1655,7 +1659,7 @@ pub const LibExeObjStep = struct {
1655 }1659 }
16561660
1657 pub fn isDynamicLibrary(self: *LibExeObjStep) bool {1661 pub fn isDynamicLibrary(self: *LibExeObjStep) bool {
1658 return self.kind == Kind.Lib and self.is_dynamic;1662 return self.kind == Kind.Lib and self.linkage == .dynamic;
1659 }1663 }
16601664
1661 pub fn producesPdbFile(self: *LibExeObjStep) bool {1665 pub fn producesPdbFile(self: *LibExeObjStep) bool {
...@@ -1920,8 +1924,13 @@ pub const LibExeObjStep = struct {...@@ -1920,8 +1924,13 @@ pub const LibExeObjStep = struct {
1920 source_duped.addStepDependencies(&self.step);1924 source_duped.addStepDependencies(&self.step);
1921 }1925 }
19221926
1923 pub fn addObjectFile(self: *LibExeObjStep, source: FileSource) void {1927 pub fn addObjectFile(self: *LibExeObjStep, source_file: []const u8) void {
1928 self.addObjectFileSource(.{ .path = source_file });
1929 }
1930
1931 pub fn addObjectFileSource(self: *LibExeObjStep, source: FileSource) void {
1924 self.link_objects.append(LinkObject{ .static_path = source.dupe(self.builder) }) catch unreachable;1932 self.link_objects.append(LinkObject{ .static_path = source.dupe(self.builder) }) catch unreachable;
1933 source.addStepDependencies(&self.step);
1925 }1934 }
19261935
1927 pub fn addObject(self: *LibExeObjStep, obj: *LibExeObjStep) void {1936 pub fn addObject(self: *LibExeObjStep, obj: *LibExeObjStep) void {
...@@ -2063,15 +2072,24 @@ pub const LibExeObjStep = struct {...@@ -2063,15 +2072,24 @@ pub const LibExeObjStep = struct {
2063 }2072 }
20642073
2065 pub fn addPackage(self: *LibExeObjStep, package: Pkg) void {2074 pub fn addPackage(self: *LibExeObjStep, package: Pkg) void {
2066 package.path.addStepDependencies(&self.step);
2067 self.packages.append(self.builder.dupePkg(package)) catch unreachable;2075 self.packages.append(self.builder.dupePkg(package)) catch unreachable;
2076 self.addRecursiveBuildDeps(package);
2077 }
2078
2079 fn addRecursiveBuildDeps(self: *LibExeObjStep, package: Pkg) void {
2080 package.path.addStepDependencies(&self.step);
2081 if (package.dependencies) |deps| {
2082 for (deps) |dep| {
2083 self.addRecursiveBuildDeps(dep);
2084 }
2085 }
2068 }2086 }
20692087
2070 pub fn addPackagePath(self: *LibExeObjStep, name: []const u8, pkg_index_path: []const u8) void {2088 pub fn addPackagePath(self: *LibExeObjStep, name: []const u8, pkg_index_path: []const u8) void {
2071 self.packages.append(Pkg{2089 self.addPackage(Pkg{
2072 .name = self.builder.dupe(name),2090 .name = self.builder.dupe(name),
2073 .path = .{ .path = self.builder.dupe(pkg_index_path) },2091 .path = .{ .path = self.builder.dupe(pkg_index_path) },
2074 }) catch unreachable;2092 });
2075 }2093 }
20762094
2077 /// If Vcpkg was found on the system, it will be added to include and lib2095 /// If Vcpkg was found on the system, it will be added to include and lib
...@@ -2081,20 +2099,20 @@ pub const LibExeObjStep = struct {...@@ -2081,20 +2099,20 @@ pub const LibExeObjStep = struct {
2081 // after findVcpkgRoot and have only one switch statement, but the compiler2099 // after findVcpkgRoot and have only one switch statement, but the compiler
2082 // cannot resolve the error set.2100 // cannot resolve the error set.
2083 switch (self.builder.vcpkg_root) {2101 switch (self.builder.vcpkg_root) {
2084 .Unattempted => {2102 .unattempted => {
2085 self.builder.vcpkg_root = if (try findVcpkgRoot(self.builder.allocator)) |root|2103 self.builder.vcpkg_root = if (try findVcpkgRoot(self.builder.allocator)) |root|
2086 VcpkgRoot{ .Found = root }2104 VcpkgRoot{ .found = root }
2087 else2105 else
2088 .NotFound;2106 .not_found;
2089 },2107 },
2090 .NotFound => return error.VcpkgNotFound,2108 .not_found => return error.VcpkgNotFound,
2091 .Found => {},2109 .found => {},
2092 }2110 }
20932111
2094 switch (self.builder.vcpkg_root) {2112 switch (self.builder.vcpkg_root) {
2095 .Unattempted => unreachable,2113 .unattempted => unreachable,
2096 .NotFound => return error.VcpkgNotFound,2114 .not_found => return error.VcpkgNotFound,
2097 .Found => |root| {2115 .found => |root| {
2098 const allocator = self.builder.allocator;2116 const allocator = self.builder.allocator;
2099 const triplet = try self.target.vcpkgTriplet(allocator, linkage);2117 const triplet = try self.target.vcpkgTriplet(allocator, linkage);
2100 defer self.builder.allocator.free(triplet);2118 defer self.builder.allocator.free(triplet);
...@@ -2207,7 +2225,7 @@ pub const LibExeObjStep = struct {...@@ -2207,7 +2225,7 @@ pub const LibExeObjStep = struct {
2207 const full_path_lib = other.getOutputLibPath();2225 const full_path_lib = other.getOutputLibPath();
2208 try zig_args.append(full_path_lib);2226 try zig_args.append(full_path_lib);
22092227
2210 if (other.is_dynamic and !self.target.isWindows()) {2228 if (other.linkage == .dynamic and !self.target.isWindows()) {
2211 if (fs.path.dirname(full_path_lib)) |dirname| {2229 if (fs.path.dirname(full_path_lib)) |dirname| {
2212 try zig_args.append("-rpath");2230 try zig_args.append("-rpath");
2213 try zig_args.append(dirname);2231 try zig_args.append(dirname);
...@@ -2373,13 +2391,13 @@ pub const LibExeObjStep = struct {...@@ -2373,13 +2391,13 @@ pub const LibExeObjStep = struct {
2373 zig_args.append("--name") catch unreachable;2391 zig_args.append("--name") catch unreachable;
2374 zig_args.append(self.name) catch unreachable;2392 zig_args.append(self.name) catch unreachable;
23752393
2376 if (self.kind == Kind.Lib and self.is_dynamic) {2394 if (self.kind == Kind.Lib and self.linkage == .dynamic) {
2377 if (self.version) |version| {2395 if (self.version) |version| {
2378 zig_args.append("--version") catch unreachable;2396 zig_args.append("--version") catch unreachable;
2379 zig_args.append(builder.fmt("{}", .{version})) catch unreachable;2397 zig_args.append(builder.fmt("{}", .{version})) catch unreachable;
2380 }2398 }
2381 }2399 }
2382 if (self.is_dynamic) {2400 if (self.linkage == .dynamic) {
2383 try zig_args.append("-dynamic");2401 try zig_args.append("-dynamic");
2384 }2402 }
2385 if (self.bundle_compiler_rt) |x| {2403 if (self.bundle_compiler_rt) |x| {
...@@ -2682,7 +2700,7 @@ pub const LibExeObjStep = struct {...@@ -2682,7 +2700,7 @@ pub const LibExeObjStep = struct {
2682 }2700 }
2683 }2701 }
26842702
2685 if (self.kind == Kind.Lib and self.is_dynamic and self.version != null and self.target.wantSharedLibSymLinks()) {2703 if (self.kind == .Lib and self.linkage == .dynamic and self.version != null and self.target.wantSharedLibSymLinks()) {
2686 try doAtomicSymLinks(builder.allocator, self.getOutputPath(), self.major_only_filename.?, self.name_only_filename.?);2704 try doAtomicSymLinks(builder.allocator, self.getOutputPath(), self.major_only_filename.?, self.name_only_filename.?);
2687 }2705 }
2688 }2706 }
...@@ -3033,15 +3051,15 @@ fn findVcpkgRoot(allocator: *Allocator) !?[]const u8 {...@@ -3033,15 +3051,15 @@ fn findVcpkgRoot(allocator: *Allocator) !?[]const u8 {
3033}3051}
30343052
3035const VcpkgRoot = union(VcpkgRootStatus) {3053const VcpkgRoot = union(VcpkgRootStatus) {
3036 Unattempted: void,3054 unattempted: void,
3037 NotFound: void,3055 not_found: void,
3038 Found: []const u8,3056 found: []const u8,
3039};3057};
30403058
3041const VcpkgRootStatus = enum {3059const VcpkgRootStatus = enum {
3042 Unattempted,3060 unattempted,
3043 NotFound,3061 not_found,
3044 Found,3062 found,
3045};3063};
30463064
3047pub const VcpkgLinkage = std.builtin.LinkMode;3065pub const VcpkgLinkage = std.builtin.LinkMode;
lib/std/build/TranslateCStep.zig+1-1
...@@ -63,7 +63,7 @@ pub fn setTarget(self: *TranslateCStep, target: CrossTarget) void {...@@ -63,7 +63,7 @@ pub fn setTarget(self: *TranslateCStep, target: CrossTarget) void {
6363
64/// Creates a step to build an executable from the translated source.64/// Creates a step to build an executable from the translated source.
65pub fn addExecutable(self: *TranslateCStep) *LibExeObjStep {65pub fn addExecutable(self: *TranslateCStep) *LibExeObjStep {
66 return self.builder.addExecutableSource("translated_c", build.FileSource{ .generated = &self.output_file }, false);66 return self.builder.addExecutableSource("translated_c", build.FileSource{ .generated = &self.output_file }, .static);
67}67}
6868
69pub fn addIncludeDir(self: *TranslateCStep, include_dir: []const u8) void {69pub fn addIncludeDir(self: *TranslateCStep, include_dir: []const u8) void {
lib/std/build/WriteFileStep.zig+1-4
...@@ -48,10 +48,7 @@ pub fn add(self: *WriteFileStep, basename: []const u8, bytes: []const u8) void {...@@ -48,10 +48,7 @@ pub fn add(self: *WriteFileStep, basename: []const u8, bytes: []const u8) void {
4848
49 self.files.append(node);49 self.files.append(node);
50}50}
51/// Unless setOutputDir was called, this function must be called only in51
52/// the make step, from a step that has declared a dependency on this one.
53/// To run an executable built with zig build, use `run`, or create an install step and invoke it.
54//pub const getOutputPath = @compileError("WriteFileStep.getOutputPath is deprecated! Use getFileSource to retrieve a ");
55/// Gets a file source for the given basename. If the file does not exist, returns `null`.52/// Gets a file source for the given basename. If the file does not exist, returns `null`.
56pub fn getFileSource(step: *WriteFileStep, basename: []const u8) ?build.FileSource {53pub fn getFileSource(step: *WriteFileStep, basename: []const u8) ?build.FileSource {
57 var it = step.files.first;54 var it = step.files.first;
test/src/compare_output.zig+3-3
...@@ -105,7 +105,7 @@ pub const CompareOutputContext = struct {...@@ -105,7 +105,7 @@ pub const CompareOutputContext = struct {
105 }105 }
106106
107 const exe = b.addExecutable("test", null);107 const exe = b.addExecutable("test", null);
108 exe.addAssemblyFileFromWriteFileStep(write_src, case.sources.items[0].filename);108 exe.addAssemblyFileSource(write_src.getFileSource(case.sources.items[0].filename).?);
109109
110 const run = exe.run();110 const run = exe.run();
111 run.addArgs(case.cli_args);111 run.addArgs(case.cli_args);
...@@ -126,7 +126,7 @@ pub const CompareOutputContext = struct {...@@ -126,7 +126,7 @@ pub const CompareOutputContext = struct {
126 }126 }
127127
128 const basename = case.sources.items[0].filename;128 const basename = case.sources.items[0].filename;
129 const exe = b.addExecutableFromWriteFileStep("test", write_src, basename);129 const exe = b.addExecutableSource("test", write_src.getFileSource(basename).?, false);
130 exe.setBuildMode(mode);130 exe.setBuildMode(mode);
131 if (case.link_libc) {131 if (case.link_libc) {
132 exe.linkSystemLibrary("c");132 exe.linkSystemLibrary("c");
...@@ -147,7 +147,7 @@ pub const CompareOutputContext = struct {...@@ -147,7 +147,7 @@ pub const CompareOutputContext = struct {
147 }147 }
148148
149 const basename = case.sources.items[0].filename;149 const basename = case.sources.items[0].filename;
150 const exe = b.addExecutableFromWriteFileStep("test", write_src, basename);150 const exe = b.addExecutableSource("test", write_src.getFileSource(basename).?, false);
151 if (case.link_libc) {151 if (case.link_libc) {
152 exe.linkSystemLibrary("c");152 exe.linkSystemLibrary("c");
153 }153 }
test/src/run_translated_c.zig+2-6
...@@ -86,12 +86,8 @@ pub const RunTranslatedCContext = struct {...@@ -86,12 +86,8 @@ pub const RunTranslatedCContext = struct {
86 for (case.sources.items) |src_file| {86 for (case.sources.items) |src_file| {
87 write_src.add(src_file.filename, src_file.source);87 write_src.add(src_file.filename, src_file.source);
88 }88 }
89 const translate_c = b.addTranslateC(.{89 const translate_c = b.addTranslateC(write_src.getFileSource(case.sources.items[0].filename).?);
90 .write_file = .{90
91 .step = write_src,
92 .basename = case.sources.items[0].filename,
93 },
94 });
95 translate_c.step.name = b.fmt("{s} translate-c", .{annotated_case_name});91 translate_c.step.name = b.fmt("{s} translate-c", .{annotated_case_name});
96 const exe = translate_c.addExecutable();92 const exe = translate_c.addExecutable();
97 exe.setTarget(self.target);93 exe.setTarget(self.target);
test/src/translate_c.zig+2-6
...@@ -109,12 +109,8 @@ pub const TranslateCContext = struct {...@@ -109,12 +109,8 @@ pub const TranslateCContext = struct {
109 write_src.add(src_file.filename, src_file.source);109 write_src.add(src_file.filename, src_file.source);
110 }110 }
111111
112 const translate_c = b.addTranslateC(.{112 const translate_c = b.addTranslateC(write_src.getFileSource(case.sources.items[0].filename).?);
113 .write_file = .{113
114 .step = write_src,
115 .basename = case.sources.items[0].filename,
116 },
117 });
118 translate_c.step.name = annotated_case_name;114 translate_c.step.name = annotated_case_name;
119 translate_c.setTarget(case.target);115 translate_c.setTarget(case.target);
120116
test/tests.zig+7-3
...@@ -107,6 +107,7 @@ const test_targets = blk: {...@@ -107,6 +107,7 @@ const test_targets = blk: {
107 .link_libc = true,107 .link_libc = true,
108 },108 },
109109
110
110 TestTarget{111 TestTarget{
111 .target = .{112 .target = .{
112 .cpu_arch = .aarch64,113 .cpu_arch = .aarch64,
...@@ -227,6 +228,7 @@ const test_targets = blk: {...@@ -227,6 +228,7 @@ const test_targets = blk: {
227 .link_libc = true,228 .link_libc = true,
228 },229 },
229230
231
230 TestTarget{232 TestTarget{
231 .target = .{233 .target = .{
232 .cpu_arch = .riscv64,234 .cpu_arch = .riscv64,
...@@ -654,7 +656,7 @@ pub const StackTracesContext = struct {...@@ -654,7 +656,7 @@ pub const StackTracesContext = struct {
654 const b = self.b;656 const b = self.b;
655 const src_basename = "source.zig";657 const src_basename = "source.zig";
656 const write_src = b.addWriteFile(src_basename, source);658 const write_src = b.addWriteFile(src_basename, source);
657 const exe = b.addExecutableFromWriteFileStep("test", write_src, src_basename);659 const exe = b.addExecutableSource("test", write_src.getFileSource(src_basename).?, false);
658 exe.setBuildMode(mode);660 exe.setBuildMode(mode);
659661
660 const run_and_compare = RunAndCompareStep.create(662 const run_and_compare = RunAndCompareStep.create(
...@@ -668,6 +670,7 @@ pub const StackTracesContext = struct {...@@ -668,6 +670,7 @@ pub const StackTracesContext = struct {
668 self.step.dependOn(&run_and_compare.step);670 self.step.dependOn(&run_and_compare.step);
669 }671 }
670672
673
671 const RunAndCompareStep = struct {674 const RunAndCompareStep = struct {
672 step: build.Step,675 step: build.Step,
673 context: *StackTracesContext,676 context: *StackTracesContext,
...@@ -776,6 +779,7 @@ pub const StackTracesContext = struct {...@@ -776,6 +779,7 @@ pub const StackTracesContext = struct {
776 var it = mem.split(stderr, "\n");779 var it = mem.split(stderr, "\n");
777 process_lines: while (it.next()) |line| {780 process_lines: while (it.next()) |line| {
778 if (line.len == 0) continue;781 if (line.len == 0) continue;
782
779 // offset search past `[drive]:` on windows783 // offset search past `[drive]:` on windows
780 var pos: usize = if (std.Target.current.os.tag == .windows) 2 else 0;784 var pos: usize = if (std.Target.current.os.tag == .windows) 2 else 0;
781 // locate delims/anchor785 // locate delims/anchor
...@@ -935,7 +939,7 @@ pub const CompileErrorContext = struct {...@@ -935,7 +939,7 @@ pub const CompileErrorContext = struct {
935 try zig_args.append("build-obj");939 try zig_args.append("build-obj");
936 }940 }
937 const root_src_basename = self.case.sources.items[0].filename;941 const root_src_basename = self.case.sources.items[0].filename;
938 try zig_args.append(self.write_src.getOutputPath(root_src_basename));942 try zig_args.append(self.write_src.getFileSource(root_src_basename).?.getPath(b));
939943
940 zig_args.append("--name") catch unreachable;944 zig_args.append("--name") catch unreachable;
941 zig_args.append("test") catch unreachable;945 zig_args.append("test") catch unreachable;
...@@ -1368,4 +1372,4 @@ fn printInvocation(args: []const []const u8) void {...@@ -1368,4 +1372,4 @@ fn printInvocation(args: []const []const u8) void {
1368 warn("{s} ", .{arg});1372 warn("{s} ", .{arg});
1369 }1373 }
1370 warn("\n", .{});1374 warn("\n", .{});
1371}1375}
\ No newline at end of file