mirror of
https://github.com/ziglang/zig.git
synced 2025-01-23 10:21:38 +00:00
build system: addAssembly and addObject functions
for building executables
This commit is contained in:
parent
afa80da857
commit
09bc4d6ba3
@ -1130,6 +1130,32 @@ pub const LinkStep = struct {
|
||||
%%self.object_files.append(file);
|
||||
}
|
||||
|
||||
pub fn addObject(self: &LinkStep, obj: &ObjectStep) {
|
||||
self.step.dependOn(&obj.step);
|
||||
|
||||
const path_to_obj = test (obj.output_path) |explicit_out_path| {
|
||||
explicit_out_path
|
||||
} else {
|
||||
// TODO make it so we always know where this will be
|
||||
%%os.path.join(self.builder.allocator, self.builder.out_dir,
|
||||
self.builder.fmt("{}{}", obj.name, obj.target.oFileExt()))
|
||||
};
|
||||
%%self.object_files.append(path_to_obj);
|
||||
}
|
||||
|
||||
pub fn addAssembly(self: &LinkStep, assembly: &AsmStep) {
|
||||
self.step.dependOn(&assembly.step);
|
||||
|
||||
const path_to_obj = test (assembly.output_path) |explicit_out_path| {
|
||||
explicit_out_path
|
||||
} else {
|
||||
// TODO make it so we always know where this will be
|
||||
%%os.path.join(self.builder.allocator, self.builder.out_dir,
|
||||
self.builder.fmt("{}{}", assembly.name, assembly.target.oFileExt()))
|
||||
};
|
||||
%%self.object_files.append(path_to_obj);
|
||||
}
|
||||
|
||||
pub fn setTarget(self: &LinkStep, target_arch: Arch, target_os: Os, target_environ: Environ) {
|
||||
self.target = Target.Cross {
|
||||
CrossTarget {
|
||||
|
@ -349,25 +349,22 @@ pub const CompareOutputContext = struct {
|
||||
|
||||
switch (case.special) {
|
||||
Special.Asm => {
|
||||
const obj_path = %%os.path.join(b.allocator, "test_artifacts", "test.o");
|
||||
const annotated_case_name = %%fmt.allocPrint(self.b.allocator, "assemble-and-link {}", case.name);
|
||||
test (self.test_filter) |filter| {
|
||||
if (mem.indexOf(u8, annotated_case_name, filter) == null)
|
||||
return;
|
||||
}
|
||||
|
||||
const obj = b.addAssemble("test", root_src);
|
||||
obj.setOutputPath(obj_path);
|
||||
const assembly = b.addAssemble("test", root_src);
|
||||
|
||||
for (case.sources.toSliceConst()) |src_file| {
|
||||
const expanded_src_path = %%os.path.join(b.allocator, "test_artifacts", src_file.filename);
|
||||
const write_src = b.addWriteFile(expanded_src_path, src_file.source);
|
||||
obj.step.dependOn(&write_src.step);
|
||||
assembly.step.dependOn(&write_src.step);
|
||||
}
|
||||
|
||||
const exe = b.addLinkExecutable("test");
|
||||
exe.step.dependOn(&obj.step);
|
||||
exe.addObjectFile(obj_path);
|
||||
exe.addAssembly(assembly);
|
||||
exe.setOutputPath(exe_path);
|
||||
|
||||
const run_and_cmp_output = RunCompareOutputStep.create(self, exe_path, annotated_case_name,
|
||||
|
Loading…
Reference in New Issue
Block a user