Skip to content

Commit

Permalink
update to latest Zig
Browse files Browse the repository at this point in the history
Helps hexops/mach#902

Signed-off-by: Stephen Gutekanst <[email protected]>
  • Loading branch information
slimsag committed Sep 17, 2023
1 parent 4c30585 commit 4a89c19
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1,662 deletions.
24 changes: 0 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ jobs:
run: |
sudo apt install xz-utils
sudo sh -c 'wget -c https://pkg.machengine.org/zig/zig-linux-x86_64-0.12.0-dev.389+61b70778b.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
- name: update build.zig
run: mv build.zig.local build.zig
- name: install (debug)
run: zig build install -Dcpu=x86_64_v2 -Dtarget=x86_64-linux-gnu
- name: upload (debug)
Expand All @@ -38,8 +36,6 @@ jobs:
run: |
sudo apt install xz-utils
sudo sh -c 'wget -c https://pkg.machengine.org/zig/zig-linux-x86_64-0.12.0-dev.389+61b70778b.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
- name: update build.zig
run: mv build.zig.local build.zig
- name: install (release-fast)
run: zig build install -Dcpu=x86_64_v2 -Doptimize=ReleaseFast -Dtarget=x86_64-linux-gnu
- name: upload (release-fast)
Expand All @@ -59,8 +55,6 @@ jobs:
run: |
sudo apt install xz-utils
sudo sh -c 'wget -c https://pkg.machengine.org/zig/zig-linux-x86_64-0.12.0-dev.389+61b70778b.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
- name: update build.zig
run: mv build.zig.local build.zig
- name: install (debug)
run: zig build install -Dtarget=x86_64-linux-musl -Dcpu=x86_64_v2
- name: upload (debug)
Expand All @@ -80,8 +74,6 @@ jobs:
run: |
sudo apt install xz-utils
sudo sh -c 'wget -c https://pkg.machengine.org/zig/zig-linux-x86_64-0.12.0-dev.389+61b70778b.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
- name: update build.zig
run: mv build.zig.local build.zig
- name: install (release-fast)
run: zig build install -Doptimize=ReleaseFast -Dtarget=x86_64-linux-musl -Dcpu=x86_64_v2
- name: upload (release-fast)
Expand All @@ -101,8 +93,6 @@ jobs:
run: |
sudo apt install xz-utils
sudo sh -c 'wget -c https://pkg.machengine.org/zig/zig-linux-x86_64-0.12.0-dev.389+61b70778b.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
- name: update build.zig
run: mv build.zig.local build.zig
- name: install (debug)
run: zig build install -Dtarget=aarch64-linux-gnu
- name: upload (debug)
Expand All @@ -122,8 +112,6 @@ jobs:
run: |
sudo apt install xz-utils
sudo sh -c 'wget -c https://pkg.machengine.org/zig/zig-linux-x86_64-0.12.0-dev.389+61b70778b.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
- name: update build.zig
run: mv build.zig.local build.zig
- name: install (release-fast)
run: zig build install -Doptimize=ReleaseFast -Dtarget=aarch64-linux-gnu
- name: upload (release-fast)
Expand All @@ -143,8 +131,6 @@ jobs:
run: |
sudo apt install xz-utils
sudo sh -c 'wget -c https://pkg.machengine.org/zig/zig-linux-x86_64-0.12.0-dev.389+61b70778b.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
- name: update build.zig
run: mv build.zig.local build.zig
- name: install (debug)
run: zig build install -Dtarget=aarch64-linux-musl
- name: upload (debug)
Expand All @@ -164,8 +150,6 @@ jobs:
run: |
sudo apt install xz-utils
sudo sh -c 'wget -c https://pkg.machengine.org/zig/zig-linux-x86_64-0.12.0-dev.389+61b70778b.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
- name: update build.zig
run: mv build.zig.local build.zig
- name: install (release-fast)
run: zig build install -Doptimize=ReleaseFast -Dtarget=aarch64-linux-musl
- name: upload (release-fast)
Expand All @@ -188,8 +172,6 @@ jobs:
cd C:\
7z x zig.zip
Add-Content $env:GITHUB_PATH "C:\zig-windows-x86_64-0.12.0-dev.389+61b70778b\"
- name: update build.zig
run: mv -force build.zig.local build.zig
- name: install (debug)
run: zig build install -Dtarget=x86_64-windows-gnu -Dcpu=x86_64_v2
- name: upload (debug)
Expand All @@ -214,8 +196,6 @@ jobs:
cd C:\
7z x zig.zip
Add-Content $env:GITHUB_PATH "C:\zig-windows-x86_64-0.12.0-dev.389+61b70778b\"
- name: update build.zig
run: mv -force build.zig.local build.zig
- name: install (release-fast)
run: zig build install -Dtarget=x86_64-windows-gnu -Doptimize=ReleaseFast -Dcpu=x86_64_v2
- name: upload (release-fast)
Expand All @@ -238,8 +218,6 @@ jobs:
brew uninstall --ignore-dependencies libx11 # https://github.com/ziglang/zig/issues/11066
brew install xz
sudo sh -c 'wget -c https://pkg.machengine.org/zig/zig-macos-x86_64-0.12.0-dev.389+61b70778b.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
- name: update build.zig
run: mv build.zig.local build.zig
- name: install (debug)
run: zig build install -Dtarget=x86_64-macos
- name: upload (debug)
Expand All @@ -260,8 +238,6 @@ jobs:
brew uninstall --ignore-dependencies libx11 # https://github.com/ziglang/zig/issues/11066
brew install xz
sudo sh -c 'wget -c https://pkg.machengine.org/zig/zig-macos-x86_64-0.12.0-dev.389+61b70778b.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
- name: update build.zig
run: mv build.zig.local build.zig
- name: install (release-fast)
run: zig build install -Doptimize=ReleaseFast -Dtarget=x86_64-macos
- name: upload (release-fast)
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/m1_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: update build.zig
run: mv build.zig.local build.zig
- name: install (debug)
run: zig build install -Dtarget=aarch64-macos
- name: upload (debug)
Expand Down
35 changes: 15 additions & 20 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,20 @@ pub fn build(b: *Build) !void {
const optimize = b.standardOptimizeOption(.{});
const target = b.standardTargetOptions(.{});

// TODO: uncomment all this code once hexops/mach#902 is fixed, b.dependency("...") cannot
// be called inside `pub fn build` if we want this package to be usable via the package manager.
_ = optimize;
_ = target;

// const options = Options{
// .install_libs = true,
// .from_source = true,
// };
// // Just to demonstrate/test linking. This is not a functional example, see the mach/gpu examples
// // or Dawn C++ examples for functional example code.
// const example = b.addExecutable(.{
// .name = "dawn-example",
// .root_source_file = .{ .path = "src/main.zig" },
// .target = target,
// .optimize = optimize,
// });
// try link(b, example, options);
// b.installArtifact(example);
const options = Options{
.install_libs = true,
.from_source = true,
};
// Just to demonstrate/test linking. This is not a functional example, see the mach/gpu examples
// or Dawn C++ examples for functional example code.
const example = b.addExecutable(.{
.name = "dawn-example",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
try link(b, example, options);
b.installArtifact(example);
}

pub const Options = struct {
Expand Down Expand Up @@ -63,7 +58,7 @@ pub const Options = struct {
install_libs: bool = false,

/// The binary release version to use from https://github.com/hexops/mach-gpu-dawn/releases
binary_version: []const u8 = "release-d7b308b",
binary_version: []const u8 = "release-d7b308b",

/// Detects the default options to use for the given target.
pub fn detectDefaults(self: Options, target: std.Target) Options {
Expand Down
Loading

0 comments on commit 4a89c19

Please sign in to comment.