summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRadioactivity <85001747+voidwyrm-2@users.noreply.github.com>2025-07-27 18:32:50 -1000
committerRadioactivity <85001747+voidwyrm-2@users.noreply.github.com>2025-07-27 18:33:02 -1000
commit89d330975b9f26194f385b17cfbae3d91f1958eb (patch)
tree4bff3da0ad40bb71f187b0ae6adab8456c5cc75b
parent61b28643aea598d66bcb9fff79392ede10a02209 (diff)
Changes
- Added link to Zig downloads - Simplified build script
-rw-r--r--README.md6
-rw-r--r--build.zig97
2 files changed, 28 insertions, 75 deletions
diff --git a/README.md b/README.md
index 7a2aaee..876b0e5 100644
--- a/README.md
+++ b/README.md
@@ -12,14 +12,16 @@ TODO: insert video link here
TODO: add wasm build?
-Clone the repository
+Clone the repository:
```
git clone https://github.com/The-Memory-Managers/cpu-vs-ai
cd hackathon
```
-Install zig release version 0.14 and run:
+Install zig release version 0.14 from https://ziglang.org/download/
+
+Then run:
```
zig build run
diff --git a/build.zig b/build.zig
index 4302bcb..10ea9b1 100644
--- a/build.zig
+++ b/build.zig
@@ -3,25 +3,8 @@ const rlz = @import("raylib_zig");
const exe_name = "hackathon";
-const all_targets: []const std.Target.Query = &.{
- .{ .cpu_arch = .aarch64, .os_tag = .macos },
- // .{ .cpu_arch = .aarch64, .os_tag = .linux },
- .{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .gnu },
- // .{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .musl },
- .{ .cpu_arch = .x86_64, .os_tag = .windows },
- //
- // TODO: add WASM support
- //.{ .cpu_arch = .wasm32, .os_tag = .emscripten },
-};
-
-const wasm_targets: []const std.Target.Query = &.{
- // TODO: add WASM support
- .{ .cpu_arch = .wasm32, .os_tag = .emscripten },
-};
-
pub fn build(b: *std.Build) !void {
- const build_all = b.option(bool, "ball", "Build and package");
- const build_wasm = b.option(bool, "wasm", "Build and package WASM");
+ const build_wasm = b.option(bool, "bwasm", "Build and package WASM");
const emcc = rlz.emcc;
_ = emcc;
@@ -29,18 +12,15 @@ pub fn build(b: *std.Build) !void {
const optimize = b.standardOptimizeOption(.{});
const run_step = b.step("run", "Run the app");
- const pack_step = b.step("pack", "Build and package for each supported OS/arch");
-
- try buildRun(b, run_step, optimize);
- if (build_all orelse false) {
- try buildPack(b, pack_step, optimize, all_targets);
- } else if (build_wasm orelse false) {
- try buildPack(b, pack_step, optimize, wasm_targets);
+ if (build_wasm orelse false) {
+ try buildWasm(b, run_step, optimize);
+ } else {
+ try buildNative(b, run_step, optimize);
}
}
-fn buildRun(b: *std.Build, parent: *std.Build.Step, optimize: std.builtin.OptimizeMode) !void {
+fn buildNative(b: *std.Build, parent: *std.Build.Step, optimize: std.builtin.OptimizeMode) !void {
const target = b.standardTargetOptions(.{});
const exe_mod = b.createModule(.{
@@ -65,61 +45,32 @@ fn buildRun(b: *std.Build, parent: *std.Build.Step, optimize: std.builtin.Optimi
parent.dependOn(&run_cmd.step);
}
-const pkg_folder = "pkg";
-
-// TODO: fix this function
-fn buildPack(b: *std.Build, parent: *std.Build.Step, optimize: std.builtin.OptimizeMode, targets: []const std.Target.Query) !void {
- const rm_pkg = b.addSystemCommand(&.{ "rm", "-rf", pkg_folder });
-
- const mkdir_pkg = b.addSystemCommand(&.{ "mkdir", pkg_folder });
- mkdir_pkg.step.dependOn(&rm_pkg.step);
-
- for (targets) |t| {
- const target = b.resolveTargetQuery(t);
- const target_triple = try t.zigTriple(b.allocator);
+fn buildWasm(b: *std.Build, parent: *std.Build.Step, optimize: std.builtin.OptimizeMode) !void {
+ if (true)
+ @panic("WASM builds are not supported at this time");
- const exe = b.addExecutable(.{
- .name = exe_name,
- .root_source_file = b.path("src/main.zig"),
- .target = target,
- .optimize = optimize,
- });
-
- try addRaylibDep(b, exe, target, optimize);
-
- const target_output = b.addInstallArtifact(exe, .{
- .dest_dir = .{
- .override = .{
- .custom = target_triple,
- },
- },
- });
+ const target = b.standardTargetOptions(.{});
- b.getInstallStep().dependOn(&target_output.step);
+ const exe_mod = b.createModule(.{
+ .root_source_file = b.path("src/main.zig"),
+ .target = target,
+ .optimize = optimize,
+ });
- const move_output = b.addSystemCommand(&.{
- "mv",
- try std.fmt.allocPrint(b.allocator, "zig-out/{s}", .{target_triple}),
- ".",
- });
+ const exe = b.addExecutable(.{
+ .name = exe_name,
+ .root_module = exe_mod,
+ });
- move_output.step.dependOn(b.getInstallStep());
+ try addRaylibDep(b, exe, target, optimize);
- const zip = b.addSystemCommand(&.{
- "zip",
- "-r",
- try std.fmt.allocPrint(b.allocator, "{s}/{s}.zip", .{ pkg_folder, target_triple }),
- target_triple,
- });
+ b.installArtifact(exe);
- zip.step.dependOn(&mkdir_pkg.step);
- zip.step.dependOn(&move_output.step);
+ const run_cmd = b.addRunArtifact(exe);
- const rm_exe = b.addSystemCommand(&.{ "rm", "-rf", target_triple });
- rm_exe.step.dependOn(&zip.step);
+ run_cmd.step.dependOn(b.getInstallStep());
- parent.dependOn(&rm_exe.step);
- }
+ parent.dependOn(&run_cmd.step);
}
fn addRaylibDep(b: *std.Build, exe: *std.Build.Step.Compile, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) !void {