Skip to content

Commit f9fa768

Browse files
committed
zig build system: installFile and installClibrary
See #332
1 parent 0f63316 commit f9fa768

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

std/build.zig

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,10 @@ pub const Builder = struct {
569569
}
570570

571571
fn copyFile(self: &Builder, source_path: []const u8, dest_path: []const u8) {
572+
const dirname = os.path.dirname(dest_path);
573+
os.makePath(self.allocator, dirname) %% |err| {
574+
debug.panic("Unable to create path {}: {}", dirname, @errorName(err));
575+
};
572576
os.copyFile(self.allocator, source_path, dest_path) %% |err| {
573577
debug.panic("Unable to copy {} to {}: {}", source_path, dest_path, @errorName(err));
574578
};
@@ -1725,11 +1729,14 @@ pub const InstallCLibraryStep = struct {
17251729

17261730
fn make(step: &Step) -> %void {
17271731
const self = @fieldParentPtr(InstallCLibraryStep, "step", step);
1732+
const builder = self.builder;
17281733

17291734
self.builder.copyFile(self.lib.out_filename, self.dest_file);
17301735
if (!self.lib.static) {
1731-
%%os.atomicSymLink(self.builder.allocator, self.lib.out_filename, self.lib.major_only_filename);
1732-
%%os.atomicSymLink(self.builder.allocator, self.lib.major_only_filename, self.lib.name_only_filename);
1736+
const dest_major_only = %%os.path.join(builder.allocator, builder.lib_dir, self.lib.major_only_filename);
1737+
const dest_name_only = %%os.path.join(builder.allocator, builder.lib_dir, self.lib.name_only_filename);
1738+
%%os.atomicSymLink(self.builder.allocator, self.lib.out_filename, dest_major_only);
1739+
%%os.atomicSymLink(self.builder.allocator, self.lib.major_only_filename, dest_name_only);
17331740
}
17341741
}
17351742
};
@@ -1751,8 +1758,7 @@ pub const InstallFileStep = struct {
17511758

17521759
fn make(step: &Step) -> %void {
17531760
const self = @fieldParentPtr(InstallFileStep, "step", step);
1754-
1755-
debug.panic("TODO install file");
1761+
self.builder.copyFile(self.src_path, self.dest_path);
17561762
}
17571763
};
17581764

0 commit comments

Comments
 (0)