|
@@ -39,14 +39,17 @@ pub fn build(b: *Builder) !void {
|
|
|
else
|
|
|
b.standardTargetOptions(.{});
|
|
|
|
|
|
- const mode = b.standardReleaseOptions();
|
|
|
+ const optimize = b.standardOptimizeOption(.{});
|
|
|
|
|
|
const zigup_build_options = b.addOptions();
|
|
|
const win32exelink: ?*std.build.LibExeObjStep = blk: {
|
|
|
if (target.getOs().tag == .windows) {
|
|
|
- const exe = b.addExecutable("win32exelink", "win32exelink.zig");
|
|
|
- exe.setTarget(target);
|
|
|
- exe.setBuildMode(mode);
|
|
|
+ const exe = b.addExecutable(.{
|
|
|
+ .name = "win32exelink",
|
|
|
+ .root_source_file = .{ .path = "win32exelink.zig" },
|
|
|
+ .target = target,
|
|
|
+ .optimize = optimize,
|
|
|
+ });
|
|
|
// workaround @embedFile not working with absolute paths, see https://github.com/ziglang/zig/issues/14551
|
|
|
//zigup_build_options.addOptionFileSource("win32exelink_filename", .{ .generated = &exe.output_path_source });
|
|
|
const update_step = RelativeOutputPathSourceStep.create(exe);
|
|
@@ -57,10 +60,10 @@ pub fn build(b: *Builder) !void {
|
|
|
};
|
|
|
|
|
|
// TODO: Maybe add more executables with different ssl backends
|
|
|
- const exe = try addZigupExe(b, ziget_repo, target, mode, zigup_build_options, win32exelink, .std);
|
|
|
- exe.install();
|
|
|
+ const exe = try addZigupExe(b, ziget_repo, target, optimize, zigup_build_options, win32exelink, .iguana);
|
|
|
+ b.installArtifact(exe);
|
|
|
|
|
|
- const run_cmd = exe.run();
|
|
|
+ const run_cmd = b.addRunArtifact(exe);
|
|
|
run_cmd.step.dependOn(b.getInstallStep());
|
|
|
|
|
|
const run_step = b.step("run", "Run the app");
|
|
@@ -69,7 +72,7 @@ pub fn build(b: *Builder) !void {
|
|
|
run_cmd.addArgs(args);
|
|
|
}
|
|
|
|
|
|
- addTest(b, exe, target, mode);
|
|
|
+ addTest(b, exe, target, optimize);
|
|
|
}
|
|
|
|
|
|
// This whole step is a workaround to @embedFile not working with absolute paths, see https://github.com/ziglang/zig/issues/14551
|
|
@@ -78,31 +81,42 @@ const RelativeOutputPathSourceStep = struct {
|
|
|
exe: *std.build.LibExeObjStep,
|
|
|
output_path_source: std.build.GeneratedFile,
|
|
|
pub fn create(exe: *std.build.LibExeObjStep) *RelativeOutputPathSourceStep {
|
|
|
- const s = exe.builder.allocator.create(RelativeOutputPathSourceStep) catch unreachable;
|
|
|
+ const s = exe.step.owner.allocator.create(RelativeOutputPathSourceStep) catch unreachable;
|
|
|
s.* = .{
|
|
|
- .step = std.build.Step.init(.custom, "relative output path", exe.builder.allocator, make),
|
|
|
+ .step = std.build.Step.init(.{
|
|
|
+ .id = .custom,
|
|
|
+ .name = "relative output path",
|
|
|
+ .owner = exe.step.owner,
|
|
|
+ .makeFn = make,
|
|
|
+ }),
|
|
|
.exe = exe,
|
|
|
.output_path_source = .{
|
|
|
.step = &s.step,
|
|
|
},
|
|
|
};
|
|
|
+ s.step.dependOn(&exe.step);
|
|
|
return s;
|
|
|
}
|
|
|
- fn make(step: *std.build.Step) !void {
|
|
|
+ fn make(step: *std.build.Step, prog_node: *std.Progress.Node) !void {
|
|
|
+ _ = prog_node;
|
|
|
const self = @fieldParentPtr(RelativeOutputPathSourceStep, "step", step);
|
|
|
- const b = self.exe.builder;
|
|
|
+ const b = self.exe.step.owner;
|
|
|
//std.log.info("output path is '{s}'", .{self.exe.output_path_source.path.?});
|
|
|
const abs_path = self.exe.output_path_source.path.?;
|
|
|
- std.debug.assert(std.mem.startsWith(u8, abs_path, b.build_root));
|
|
|
- self.output_path_source.path = std.mem.trimLeft(u8, abs_path[b.build_root.len..], "\\/");
|
|
|
+ const build_root_path = b.build_root.path orelse @panic("todo");
|
|
|
+ std.debug.assert(std.mem.startsWith(u8, abs_path, build_root_path));
|
|
|
+ self.output_path_source.path = std.mem.trimLeft(u8, abs_path[build_root_path.len..], "\\/");
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-fn addTest(b: *Builder, exe: *std.build.LibExeObjStep, target: std.zig.CrossTarget, mode: std.builtin.Mode) void {
|
|
|
- const test_exe = b.addExecutable("test", "test.zig");
|
|
|
- test_exe.setTarget(target);
|
|
|
- test_exe.setBuildMode(mode);
|
|
|
- const run_cmd = test_exe.run();
|
|
|
+fn addTest(b: *Builder, exe: *std.build.LibExeObjStep, target: std.zig.CrossTarget, optimize: std.builtin.Mode) void {
|
|
|
+ const test_exe = b.addExecutable(.{
|
|
|
+ .name = "test",
|
|
|
+ .root_source_file = .{ .path = "test.zig" },
|
|
|
+ .target = target,
|
|
|
+ .optimize = optimize,
|
|
|
+ });
|
|
|
+ const run_cmd = b.addRunArtifact(test_exe);
|
|
|
|
|
|
// TODO: make this work, add exe install path as argument to test
|
|
|
//run_cmd.addArg(exe.getInstallPath());
|
|
@@ -117,7 +131,7 @@ fn addZigupExe(
|
|
|
b: *Builder,
|
|
|
ziget_repo: *GitRepoStep,
|
|
|
target: std.zig.CrossTarget,
|
|
|
- mode: std.builtin.Mode,
|
|
|
+ optimize: std.builtin.Mode,
|
|
|
zigup_build_options: *std.build.OptionsStep,
|
|
|
optional_win32exelink: ?*std.build.LibExeObjStep,
|
|
|
ssl_backend: ?SslBackend
|
|
@@ -125,9 +139,12 @@ fn addZigupExe(
|
|
|
const require_ssl_backend = b.allocator.create(RequireSslBackendStep) catch unreachable;
|
|
|
require_ssl_backend.* = RequireSslBackendStep.init(b, "the zigup exe", ssl_backend);
|
|
|
|
|
|
- const exe = b.addExecutable("zigup", "zigup.zig");
|
|
|
- exe.setTarget(target);
|
|
|
- exe.setBuildMode(mode);
|
|
|
+ const exe = b.addExecutable(.{
|
|
|
+ .name = "zigup",
|
|
|
+ .root_source_file = .{ .path = "zigup.zig" },
|
|
|
+ .target = target,
|
|
|
+ .optimize = optimize,
|
|
|
+ });
|
|
|
|
|
|
if (optional_win32exelink) |win32exelink| {
|
|
|
exe.step.dependOn(&win32exelink.step);
|
|
@@ -135,20 +152,20 @@ fn addZigupExe(
|
|
|
exe.addOptions("build_options", zigup_build_options);
|
|
|
|
|
|
exe.step.dependOn(&ziget_repo.step);
|
|
|
- zigetbuild.addZigetPkg(exe, ssl_backend, ziget_repo.getPath(&exe.step));
|
|
|
+ zigetbuild.addZigetModule(exe, ssl_backend, ziget_repo.getPath(&exe.step));
|
|
|
|
|
|
if (targetIsWindows(target)) {
|
|
|
const zarc_repo = GitRepoStep.create(b, .{
|
|
|
.url = "https://github.com/marler8997/zarc",
|
|
|
.branch = "protected",
|
|
|
- .sha = "ca9554ffbfceedec6aae5f39fc71a52dbdec2a15",
|
|
|
+ .sha = "2e5256624d7871180badc9784b96dd66d927d604",
|
|
|
});
|
|
|
exe.step.dependOn(&zarc_repo.step);
|
|
|
const zarc_repo_path = zarc_repo.getPath(&exe.step);
|
|
|
- exe.addPackage(Pkg {
|
|
|
- .name = "zarc",
|
|
|
- .source = .{ .path = try join(b, &[_][]const u8 { zarc_repo_path, "src", "main.zig" }) },
|
|
|
+ const zarc_mod = b.addModule("zarc", .{
|
|
|
+ .source_file = .{ .path = b.pathJoin(&.{ zarc_repo_path, "src", "main.zig" }) },
|
|
|
});
|
|
|
+ exe.addModule("zarc", zarc_mod);
|
|
|
}
|
|
|
|
|
|
exe.step.dependOn(&require_ssl_backend.step);
|
|
@@ -185,12 +202,18 @@ const RequireSslBackendStep = struct {
|
|
|
backend: ?SslBackend,
|
|
|
pub fn init(b: *Builder, context: []const u8, backend: ?SslBackend) RequireSslBackendStep {
|
|
|
return .{
|
|
|
- .step = std.build.Step.init(.custom, "RequireSslBackend", b.allocator, make),
|
|
|
+ .step = std.build.Step.init(.{
|
|
|
+ .id = .custom,
|
|
|
+ .name = "RequireSslBackend",
|
|
|
+ .owner = b,
|
|
|
+ .makeFn = make,
|
|
|
+ }),
|
|
|
.context = context,
|
|
|
.backend = backend,
|
|
|
};
|
|
|
}
|
|
|
- fn make(step: *std.build.Step) !void {
|
|
|
+ fn make(step: *std.build.Step, prog_node: *std.Progress.Node) !void {
|
|
|
+ _ = prog_node;
|
|
|
const self = @fieldParentPtr(RequireSslBackendStep, "step", step);
|
|
|
if (self.backend) |_| { } else {
|
|
|
std.debug.print("error: {s} requires an SSL backend:\n", .{self.context});
|
|
@@ -216,10 +239,6 @@ fn addGithubReleaseExe(b: *Builder, github_release_step: *std.build.Step, ziget_
|
|
|
github_release_step.dependOn(&exe.step);
|
|
|
}
|
|
|
|
|
|
-fn join(b: *Builder, parts: []const []const u8) ![]const u8 {
|
|
|
- return try std.fs.path.join(b.allocator, parts);
|
|
|
-}
|
|
|
-
|
|
|
const ci_target_map = std.ComptimeStringMap([]const u8, .{
|
|
|
.{ "ubuntu-latest-x86_64", "x86_64-linux" },
|
|
|
.{ "macos-latest-x86_64", "x86_64-macos" },
|