103 lines
2.6 KiB
Zig
103 lines
2.6 KiB
Zig
const std = @import("std");
|
|
|
|
pub fn build(b: *std.Build) !void {
|
|
const target = b.standardTargetOptions(.{});
|
|
const optimize = b.standardOptimizeOption(.{});
|
|
|
|
const zig_args_dep = b.dependency("args", .{
|
|
.target = target,
|
|
.optimize = optimize,
|
|
});
|
|
const ansi_term_dep = b.dependency("ansi_term", .{
|
|
.target = target,
|
|
.optimize = optimize,
|
|
});
|
|
const globlin_dep = b.dependency("globlin", .{
|
|
.target = target,
|
|
.optimize = optimize,
|
|
});
|
|
|
|
const server_exe = b.addExecutable(.{
|
|
.name = "vidzig",
|
|
.root_source_file = .{ .path = "server/main.zig" },
|
|
.target = target,
|
|
.optimize = optimize,
|
|
});
|
|
|
|
const build_frontend_step = b.addSystemCommand(&.{
|
|
"haxe",
|
|
|
|
"-cp",
|
|
"frontend",
|
|
|
|
"-main",
|
|
"Index",
|
|
|
|
"-D",
|
|
"dce=full",
|
|
|
|
"-D",
|
|
"js_es=6",
|
|
|
|
"-D",
|
|
"js_classic",
|
|
|
|
"--js",
|
|
"zig-cache/index.js",
|
|
});
|
|
|
|
server_exe.step.dependOn(&build_frontend_step.step);
|
|
|
|
const assets_mod = b.createModule(.{
|
|
.root_source_file = .{ .path = "assets.zig" },
|
|
});
|
|
|
|
server_exe.root_module.addImport("assets", assets_mod);
|
|
|
|
b.installArtifact(server_exe);
|
|
|
|
const run_server_cmd = b.addRunArtifact(server_exe);
|
|
run_server_cmd.step.dependOn(b.getInstallStep());
|
|
if (b.args) |args| {
|
|
run_server_cmd.addArgs(args);
|
|
}
|
|
|
|
const run_server_step = b.step("run-server", "Run the vidzig server");
|
|
run_server_step.dependOn(&run_server_cmd.step);
|
|
|
|
const test_exe = b.addTest(.{
|
|
.root_source_file = .{ .path = "server/main.zig" },
|
|
.target = target,
|
|
.optimize = optimize,
|
|
});
|
|
|
|
test_exe.step.dependOn(&build_frontend_step.step);
|
|
|
|
test_exe.root_module.addImport("assets", assets_mod);
|
|
|
|
const test_step = b.step("test-server", "Run tests");
|
|
test_step.dependOn(&b.addRunArtifact(test_exe).step);
|
|
|
|
const cli_exe = b.addExecutable(.{
|
|
.name = "vzctl",
|
|
.root_source_file = .{ .path = "cli/main.zig" },
|
|
.target = target,
|
|
.optimize = optimize,
|
|
});
|
|
|
|
cli_exe.root_module.addImport("zig-args", zig_args_dep.module("args"));
|
|
cli_exe.root_module.addImport("ansi-term", ansi_term_dep.module("ansi-term"));
|
|
cli_exe.root_module.addImport("globlin", globlin_dep.module("globlin"));
|
|
|
|
b.installArtifact(cli_exe);
|
|
|
|
const run_cli_cmd = b.addRunArtifact(cli_exe);
|
|
run_cli_cmd.step.dependOn(b.getInstallStep());
|
|
if (b.args) |args| {
|
|
run_cli_cmd.addArgs(args);
|
|
}
|
|
|
|
const run_cli_step = b.step("run-cli", "Run the vzctl client");
|
|
run_cli_step.dependOn(&run_cli_cmd.step);
|
|
}
|