Skip to content

Commit

Permalink
gpu-dawn: include full target triple in binary releases
Browse files Browse the repository at this point in the history
Fixes hexops/mach#170

Signed-off-by: Stephen Gutekanst <[email protected]>
  • Loading branch information
slimsag committed Feb 27, 2022
1 parent 35efaec commit ab7fa12
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 36 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ jobs:
run: zig build install -Dfrom-source=true -Dtarget=x86_64-linux
- name: upload (debug)
run: |
mv zig-out/lib/libdawn.a zig-out/lib/libdawn_linux-x86_64_debug.a
gzip -9 zig-out/lib/libdawn_linux-x86_64_debug.a
gh release upload "release-$(git rev-parse --short HEAD)" zig-out/lib/libdawn_linux-x86_64_debug.a.gz
mv zig-out/lib/libdawn.a zig-out/lib/libdawn_x86_64-linux-gnu_debug.a
gzip -9 zig-out/lib/libdawn_x86_64-linux-gnu_debug.a
gh release upload "release-$(git rev-parse --short HEAD)" zig-out/lib/libdawn_x86_64-linux-gnu_debug.a.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: install (release-fast)
run: zig build install -Dfrom-source=true -Drelease-fast=true -Dtarget=x86_64-linux
- name: upload (release-fast)
run: |
mv zig-out/lib/libdawn.a zig-out/lib/libdawn_linux-x86_64_release-fast.a
gzip -9 zig-out/lib/libdawn_linux-x86_64_release-fast.a
gh release upload "release-$(git rev-parse --short HEAD)" zig-out/lib/libdawn_linux-x86_64_release-fast.a.gz
mv zig-out/lib/libdawn.a zig-out/lib/libdawn_x86_64-linux-gnu_release-fast.a
gzip -9 zig-out/lib/libdawn_x86_64-linux-gnu_release-fast.a
gh release upload "release-$(git rev-parse --short HEAD)" zig-out/lib/libdawn_x86_64-linux-gnu_release-fast.a.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# TODO(build-system): enable windows CI here once gpu-dawn builds under Windows
Expand Down Expand Up @@ -77,9 +77,9 @@ jobs:
AGREE: true
- name: upload (debug)
run: |
mv zig-out/lib/libdawn.a zig-out/lib/libdawn_macos-x86_64_debug.a
gzip -9 zig-out/lib/libdawn_macos-x86_64_debug.a
gh release upload "release-$(git rev-parse --short HEAD)" zig-out/lib/libdawn_macos-x86_64_debug.a.gz
mv zig-out/lib/libdawn.a zig-out/lib/libdawn_x86_64-macos.12.1...12.1-gnu_debug.a
gzip -9 zig-out/lib/libdawn_x86_64-macos.12.1...12.1-gnu_debug.a
gh release upload "release-$(git rev-parse --short HEAD)" zig-out/lib/libdawn_x86_64-macos.12.1...12.1-gnu_debug.a.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: install (release-fast)
Expand All @@ -88,8 +88,8 @@ jobs:
AGREE: true
- name: upload (release-fast)
run: |
mv zig-out/lib/libdawn.a zig-out/lib/libdawn_macos-x86_64_release-fast.a
gzip -9 zig-out/lib/libdawn_macos-x86_64_release-fast.a
gh release upload "release-$(git rev-parse --short HEAD)" zig-out/lib/libdawn_macos-x86_64_release-fast.a.gz
mv zig-out/lib/libdawn.a zig-out/lib/libdawn_x86_64-macos.12.1...12.1-gnu_release-fast.a
gzip -9 zig-out/lib/libdawn_x86_64-macos.12.1...12.1-gnu_release-fast.a
gh release upload "release-$(git rev-parse --short HEAD)" zig-out/lib/libdawn_x86_64-macos.12.1...12.1-gnu_release-fast.a.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12 changes: 6 additions & 6 deletions .github/workflows/m1_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ jobs:
AGREE: true
- name: upload (debug)
run: |
mv zig-out/lib/libdawn.a zig-out/lib/libdawn_macos-aarch64_debug.a
gzip -9 zig-out/lib/libdawn_macos-aarch64_debug.a
gh release upload "release-$(git rev-parse --short HEAD)" zig-out/lib/libdawn_macos-aarch64_debug.a.gz
mv zig-out/lib/libdawn.a zig-out/lib/libdawn_aarch64-macos.12.1...12.1-gnu_debug.a
gzip -9 zig-out/lib/libdawn_aarch64-macos.12.1...12.1-gnu_debug.a
gh release upload "release-$(git rev-parse --short HEAD)" zig-out/lib/libdawn_aarch64-macos.12.1...12.1-gnu_debug.a.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: install (release-fast)
Expand All @@ -40,8 +40,8 @@ jobs:
AGREE: true
- name: upload (release-fast)
run: |
mv zig-out/lib/libdawn.a zig-out/lib/libdawn_macos-aarch64_release-fast.a
gzip -9 zig-out/lib/libdawn_macos-aarch64_release-fast.a
gh release upload "release-$(git rev-parse --short HEAD)" zig-out/lib/libdawn_macos-aarch64_release-fast.a.gz
mv zig-out/lib/libdawn.a zig-out/lib/libdawn_aarch64-macos.12.1...12.1-gnu_release-fast.a
gzip -9 zig-out/lib/libdawn_aarch64-macos.12.1...12.1-gnu_release-fast.a
gh release upload "release-$(git rev-parse --short HEAD)" zig-out/lib/libdawn_aarch64-macos.12.1...12.1-gnu_release-fast.a.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28 changes: 10 additions & 18 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -191,32 +191,24 @@ fn ensureSubmodules(allocator: std.mem.Allocator) !void {
pub fn linkFromBinary(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void {
const target = (std.zig.system.NativeTargetInfo.detect(b.allocator, step.target) catch unreachable).target;

// If it's not the default ABI, we have no binaries available.
const default_abi = std.Target.Abi.default(target.cpu.arch, target.os);
if (target.abi != default_abi) return linkFromSource(b, step, options);

const triple = blk: {
if (target.cpu.arch.isX86()) switch (target.os.tag) {
.windows => return linkFromSource(b, step, options), // break :blk "windows-x86_64",
.linux => break :blk "linux-x86_64",
.macos => break :blk "macos-x86_64",
else => return linkFromSource(b, step, options),
};
if (target.cpu.arch.isAARCH64()) switch (target.os.tag) {
.macos => break :blk "macos-aarch64",
else => return linkFromSource(b, step, options),
};
return linkFromSource(b, step, options);
const have_binaries = switch (target.os.tag) {
.windows => false, // TODO(build-system): add Windows binaries
.linux => target.cpu.arch.isX86() and target.abi.isGnu(),
.macos => (target.cpu.arch.isX86() or target.cpu.arch.isAARCH64()) and target.abi == .macabi,
else => false,
};
ensureBinaryDownloaded(b.allocator, triple, b.is_release, options.binary_version);
if (!have_binaries) return linkFromSource(b, step, options);

const zig_triple = target.zigTriple(b.allocator) catch unreachable;
ensureBinaryDownloaded(b.allocator, zig_triple, b.is_release, options.binary_version);

const current_git_commit = getCurrentGitCommit(b.allocator) catch unreachable;
const base_cache_dir_rel = std.fs.path.join(b.allocator, &.{ "zig-cache", "mach", "gpu-dawn" }) catch unreachable;
std.fs.cwd().makePath(base_cache_dir_rel) catch unreachable;
const base_cache_dir = std.fs.cwd().realpathAlloc(b.allocator, base_cache_dir_rel) catch unreachable;
const commit_cache_dir = std.fs.path.join(b.allocator, &.{ base_cache_dir, current_git_commit }) catch unreachable;
const release_tag = if (b.is_release) "release-fast" else "debug";
const target_cache_dir = std.fs.path.join(b.allocator, &.{ commit_cache_dir, triple, release_tag }) catch unreachable;
const target_cache_dir = std.fs.path.join(b.allocator, &.{ commit_cache_dir, zig_triple, release_tag }) catch unreachable;

step.addLibraryPath(target_cache_dir);
step.linkSystemLibrary("dawn");
Expand Down

0 comments on commit ab7fa12

Please sign in to comment.