| author | |
| committer | |
| log | 09bc4d6ba366c1a642b3c92c7ec554e95a369053 |
| tree | cbac0e31042478f82bcf0a48e14a0d875e270d91 |
| parent | afa80da85745913123caebdfa6bb1aad76f2a1c0 |
for building executables2 files changed, 29 insertions(+), 6 deletions(-)
std/build.zig+26| ... | ... | @@ -1130,6 +1130,32 @@ pub const LinkStep = struct { |
| 1130 | 1130 | %%self.object_files.append(file); |
| 1131 | 1131 | } |
| 1132 | 1132 | |
| 1133 | pub fn addObject(self: &LinkStep, obj: &ObjectStep) { | |
| 1134 | self.step.dependOn(&obj.step); | |
| 1135 | ||
| 1136 | const path_to_obj = test (obj.output_path) |explicit_out_path| { | |
| 1137 | explicit_out_path | |
| 1138 | } else { | |
| 1139 | // TODO make it so we always know where this will be | |
| 1140 | %%os.path.join(self.builder.allocator, self.builder.out_dir, | |
| 1141 | self.builder.fmt("{}{}", obj.name, obj.target.oFileExt())) | |
| 1142 | }; | |
| 1143 | %%self.object_files.append(path_to_obj); | |
| 1144 | } | |
| 1145 | ||
| 1146 | pub fn addAssembly(self: &LinkStep, assembly: &AsmStep) { | |
| 1147 | self.step.dependOn(&assembly.step); | |
| 1148 | ||
| 1149 | const path_to_obj = test (assembly.output_path) |explicit_out_path| { | |
| 1150 | explicit_out_path | |
| 1151 | } else { | |
| 1152 | // TODO make it so we always know where this will be | |
| 1153 | %%os.path.join(self.builder.allocator, self.builder.out_dir, | |
| 1154 | self.builder.fmt("{}{}", assembly.name, assembly.target.oFileExt())) | |
| 1155 | }; | |
| 1156 | %%self.object_files.append(path_to_obj); | |
| 1157 | } | |
| 1158 | ||
| 1133 | 1159 | pub fn setTarget(self: &LinkStep, target_arch: Arch, target_os: Os, target_environ: Environ) { |
| 1134 | 1160 | self.target = Target.Cross { |
| 1135 | 1161 | CrossTarget { |
test/tests.zig+3-6| ... | ... | @@ -349,25 +349,22 @@ pub const CompareOutputContext = struct { |
| 349 | 349 | |
| 350 | 350 | switch (case.special) { |
| 351 | 351 | Special.Asm => { |
| 352 | const obj_path = %%os.path.join(b.allocator, "test_artifacts", "test.o"); | |
| 353 | 352 | const annotated_case_name = %%fmt.allocPrint(self.b.allocator, "assemble-and-link {}", case.name); |
| 354 | 353 | test (self.test_filter) |filter| { |
| 355 | 354 | if (mem.indexOf(u8, annotated_case_name, filter) == null) |
| 356 | 355 | return; |
| 357 | 356 | } |
| 358 | 357 | |
| 359 | const obj = b.addAssemble("test", root_src); | |
| 360 | obj.setOutputPath(obj_path); | |
| 358 | const assembly = b.addAssemble("test", root_src); | |
| 361 | 359 | |
| 362 | 360 | for (case.sources.toSliceConst()) |src_file| { |
| 363 | 361 | const expanded_src_path = %%os.path.join(b.allocator, "test_artifacts", src_file.filename); |
| 364 | 362 | const write_src = b.addWriteFile(expanded_src_path, src_file.source); |
| 365 | obj.step.dependOn(&write_src.step); | |
| 363 | assembly.step.dependOn(&write_src.step); | |
| 366 | 364 | } |
| 367 | 365 | |
| 368 | 366 | const exe = b.addLinkExecutable("test"); |
| 369 | exe.step.dependOn(&obj.step); | |
| 370 | exe.addObjectFile(obj_path); | |
| 367 | exe.addAssembly(assembly); | |
| 371 | 368 | exe.setOutputPath(exe_path); |
| 372 | 369 | |
| 373 | 370 | const run_and_cmp_output = RunCompareOutputStep.create(self, exe_path, annotated_case_name, |