From ae22b69026915274fa8a50c5c7d150f914e450f0 Mon Sep 17 00:00:00 2001 From: Mike Desaro Date: Fri, 27 Nov 2020 20:02:50 -0800 Subject: [PATCH] arm64 support --- zig-ecs/.gitignore | 1 + zig-ecs/.vscode/tasks.json | 17 +++++++++++++++++ zig-ecs/build.zig | 8 ++++++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/zig-ecs/.gitignore b/zig-ecs/.gitignore index 2040c29..b72f969 100644 --- a/zig-ecs/.gitignore +++ b/zig-ecs/.gitignore @@ -1 +1,2 @@ zig-cache +zig-arm-cache diff --git a/zig-ecs/.vscode/tasks.json b/zig-ecs/.vscode/tasks.json index dce0dbc..2af359a 100644 --- a/zig-ecs/.vscode/tasks.json +++ b/zig-ecs/.vscode/tasks.json @@ -2,6 +2,11 @@ // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "2.0.0", + "options": { + "env": { + "ZIG_SYSTEM_LINKER_HACK": "1", + } + }, "tasks": [ { "label": "Build Project", @@ -26,6 +31,18 @@ "clear": true } }, + { + "label": "Build and Run Project (x64 on arm)", + "type": "shell", + "command": "~/zig/zig-x64/zig build run", + "problemMatcher": [ + "$gcc" + ], + "group": "build", + "presentation": { + "clear": true + } + }, { "label": "Build and Run Project (release-fast)", "type": "shell", diff --git a/zig-ecs/build.zig b/zig-ecs/build.zig index 8af56bf..7a099dd 100644 --- a/zig-ecs/build.zig +++ b/zig-ecs/build.zig @@ -1,9 +1,13 @@ -const Builder = @import("std").build.Builder; +const std = @import("std"); +const Builder = std.build.Builder; const builtin = @import("builtin"); pub fn build(b: *Builder) void { const buildMode = b.standardReleaseOptions(); + // use a different cache folder for macos arm builds + b.cache_root = if (std.builtin.os.tag == .macos and std.builtin.arch == std.builtin.Arch.aarch64) "zig-arm-cache/bin" else "zig-cache/bin"; + const examples = [_][2][]const u8{ [_][]const u8{ "view_vs_group", "examples/view_vs_group.zig" }, [_][]const u8{ "group_sort", "examples/group_sort.zig" }, @@ -25,7 +29,7 @@ pub fn build(b: *Builder) void { // first element in the list is added as "run" so "zig build run" works if (i == 0) { - exe.setOutputDir("zig-cache/bin"); + exe.setOutputDir(std.fs.path.joinPosix(b.allocator, &[_][]const u8{ b.cache_root, "bin" }) catch unreachable); const run_exe_step = b.step("run", b.fmt("run {}.zig", .{name})); run_exe_step.dependOn(&run_cmd.step); }