Commit 9c8c9b7cc8

Carl Åstholm <carl@astholm.se>
2024-01-08 18:57:37
Build: Use `LazyPath` for version scripts
1 parent 4cbf74b
Changed files (1)
lib
std
Build
lib/std/Build/Step/Compile.zig
@@ -25,7 +25,7 @@ root_module: Module,
 
 name: []const u8,
 linker_script: ?LazyPath = null,
-version_script: ?[]const u8 = null,
+version_script: ?LazyPath = null,
 out_filename: []const u8,
 out_lib_filename: []const u8,
 linkage: ?Linkage = null,
@@ -481,6 +481,12 @@ pub fn setLinkerScript(self: *Compile, source: LazyPath) void {
     source.addStepDependencies(&self.step);
 }
 
+pub fn setVersionScript(self: *Compile, source: LazyPath) void {
+    const b = self.step.owner;
+    self.version_script = source.dupe(b);
+    source.addStepDependencies(&self.step);
+}
+
 pub fn forceUndefinedSymbol(self: *Compile, symbol_name: []const u8) void {
     const b = self.step.owner;
     self.force_undefined_symbols.put(b.dupe(symbol_name), {}) catch @panic("OOM");
@@ -1443,7 +1449,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
 
     if (self.version_script) |version_script| {
         try zig_args.append("--version-script");
-        try zig_args.append(b.pathFromRoot(version_script));
+        try zig_args.append(version_script.getPath(b));
     }
 
     if (self.kind == .@"test") {