Skip to content

Commit

Permalink
Updates build.zig with to use new APIs (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathannen authored Aug 28, 2024
1 parent fe2fce9 commit 168c4a8
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ const MakePathStep = struct {
};
return new;
}
fn make(step: *std.Build.Step, prog_node: *std.Progress.Node) anyerror!void {
fn make(step: *std.Build.Step, prog_node: std.Progress.Node) anyerror!void {
_ = prog_node;
const self: *Self = @fieldParentPtr("step", step);
const cwd = fs.cwd();
Expand Down Expand Up @@ -466,7 +466,7 @@ const CopyFileStep = struct {
return new;
}

fn make(step: *std.Build.Step, prog_node: *std.Progress.Node) anyerror!void {
fn make(step: *std.Build.Step, prog_node: std.Progress.Node) anyerror!void {
_ = prog_node;
const self: *Self = @fieldParentPtr("step", step);
try std.fs.copyFileAbsolute(self.src_path, self.dst_path, .{});
Expand All @@ -482,7 +482,7 @@ fn linkV8(b: *Builder, step: *std.Build.Step.Compile, mode: std.builtin.Optimize
mode_str,
lib,
}) catch unreachable;
step.addAssemblyFile(.{ .path = lib_path });
step.addAssemblyFile(b.path(lib_path));
if (builtin.os.tag == .linux) {
if (use_zig_tc) {
// TODO: This should be linked already when we built v8.
Expand All @@ -500,20 +500,20 @@ fn linkV8(b: *Builder, step: *std.Build.Step.Compile, mode: std.builtin.Optimize
// We need libcpmt to statically link with c++ stl for exception_ptr references from V8.
// Zig already adds the SDK path to the linker but doesn't sync it to the internal libs array which linkSystemLibrary checks against.
// For now we'll hardcode the MSVC path here.
step.addLibraryPath(.{ .path = "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/lib/x64" });
step.addLibraryPath(b.path("C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/lib/x64"));
step.linkSystemLibrary("libcpmt");
}
}
}

fn createTest(b: *Builder, target: std.Build.ResolvedTarget, mode: std.builtin.OptimizeMode, use_zig_tc: bool) *std.Build.Step.Compile {
const step = b.addTest(.{
.root_source_file = .{ .path = "src/test.zig" },
.root_source_file = b.path("src/test.zig"),
.target = target,
.optimize = mode,
}); //FIXED

step.addIncludePath(.{ .path = "src" });
step.addIncludePath(b.path("src"));
step.linkLibC();

linkV8(b, step, mode, target, use_zig_tc);
Expand Down Expand Up @@ -621,7 +621,7 @@ pub const GetV8SourceStep = struct {
}
}

fn make(step: *Step, prog_node: *std.Progress.Node) !void {
fn make(step: *Step, prog_node: std.Progress.Node) !void {
_ = prog_node;
const self: *Self = @fieldParentPtr("step", step);

Expand Down Expand Up @@ -717,17 +717,15 @@ fn createBuildExeStep(b: *Builder, path: []const u8, target: std.Build.ResolvedT

const step = b.addExecutable(.{
.target = target,
.root_source_file = .{
.path = path,
},
.root_source_file = b.path(path),
.name = name,
.optimize = mode,
}); //FIXED
//step.setBuildMode(mode);
//step.setTarget(target);

step.linkLibC();
step.addIncludePath(.{ .path = "src" });
step.addIncludePath(b.path("src"));

if (mode == .ReleaseSafe) {
step.root_module.strip = true;
Expand Down

0 comments on commit 168c4a8

Please sign in to comment.