gpu-dawn: include full target triple in binary releases

Fixes hexops/mach#170

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-02-27 00:02:26 -07:00
parent 51f14596db
commit b749e23fe2
3 changed files with 28 additions and 36 deletions

View file

@ -23,18 +23,18 @@ jobs:
run: zig build install -Dfrom-source=true -Dtarget=x86_64-linux run: zig build install -Dfrom-source=true -Dtarget=x86_64-linux
- name: upload (debug) - name: upload (debug)
run: | run: |
mv zig-out/lib/libdawn.a zig-out/lib/libdawn_linux-x86_64_debug.a mv zig-out/lib/libdawn.a zig-out/lib/libdawn_x86_64-linux-gnu_debug.a
gzip -9 zig-out/lib/libdawn_linux-x86_64_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_linux-x86_64_debug.a.gz gh release upload "release-$(git rev-parse --short HEAD)" zig-out/lib/libdawn_x86_64-linux-gnu_debug.a.gz
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: install (release-fast) - name: install (release-fast)
run: zig build install -Dfrom-source=true -Drelease-fast=true -Dtarget=x86_64-linux run: zig build install -Dfrom-source=true -Drelease-fast=true -Dtarget=x86_64-linux
- name: upload (release-fast) - name: upload (release-fast)
run: | run: |
mv zig-out/lib/libdawn.a zig-out/lib/libdawn_linux-x86_64_release-fast.a mv zig-out/lib/libdawn.a zig-out/lib/libdawn_x86_64-linux-gnu_release-fast.a
gzip -9 zig-out/lib/libdawn_linux-x86_64_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_linux-x86_64_release-fast.a.gz gh release upload "release-$(git rev-parse --short HEAD)" zig-out/lib/libdawn_x86_64-linux-gnu_release-fast.a.gz
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# TODO(build-system): enable windows CI here once gpu-dawn builds under Windows # TODO(build-system): enable windows CI here once gpu-dawn builds under Windows
@ -77,9 +77,9 @@ jobs:
AGREE: true AGREE: true
- name: upload (debug) - name: upload (debug)
run: | run: |
mv zig-out/lib/libdawn.a zig-out/lib/libdawn_macos-x86_64_debug.a 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_macos-x86_64_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_macos-x86_64_debug.a.gz 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: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: install (release-fast) - name: install (release-fast)
@ -88,8 +88,8 @@ jobs:
AGREE: true AGREE: true
- name: upload (release-fast) - name: upload (release-fast)
run: | run: |
mv zig-out/lib/libdawn.a zig-out/lib/libdawn_macos-x86_64_release-fast.a 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_macos-x86_64_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_macos-x86_64_release-fast.a.gz 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: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View file

@ -29,9 +29,9 @@ jobs:
AGREE: true AGREE: true
- name: upload (debug) - name: upload (debug)
run: | run: |
mv zig-out/lib/libdawn.a zig-out/lib/libdawn_macos-aarch64_debug.a 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_macos-aarch64_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_macos-aarch64_debug.a.gz gh release upload "release-$(git rev-parse --short HEAD)" zig-out/lib/libdawn_aarch64-macos.12.1...12.1-gnu_debug.a.gz
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: install (release-fast) - name: install (release-fast)
@ -40,8 +40,8 @@ jobs:
AGREE: true AGREE: true
- name: upload (release-fast) - name: upload (release-fast)
run: | run: |
mv zig-out/lib/libdawn.a zig-out/lib/libdawn_macos-aarch64_release-fast.a 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_macos-aarch64_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_macos-aarch64_release-fast.a.gz 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: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View file

@ -191,24 +191,16 @@ fn ensureSubmodules(allocator: std.mem.Allocator) !void {
pub fn linkFromBinary(b: *Builder, step: *std.build.LibExeObjStep, options: Options) 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; 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 have_binaries = switch (target.os.tag) {
const default_abi = std.Target.Abi.default(target.cpu.arch, target.os); .windows => false, // TODO(build-system): add Windows binaries
if (target.abi != default_abi) return linkFromSource(b, step, options); .linux => target.cpu.arch.isX86() and target.abi.isGnu(),
.macos => (target.cpu.arch.isX86() or target.cpu.arch.isAARCH64()) and target.abi == .macabi,
const triple = blk: { else => false,
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);
}; };
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 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; const base_cache_dir_rel = std.fs.path.join(b.allocator, &.{ "zig-cache", "mach", "gpu-dawn" }) catch unreachable;
@ -216,7 +208,7 @@ pub fn linkFromBinary(b: *Builder, step: *std.build.LibExeObjStep, options: Opti
const base_cache_dir = std.fs.cwd().realpathAlloc(b.allocator, 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 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 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.addLibraryPath(target_cache_dir);
step.linkSystemLibrary("dawn"); step.linkSystemLibrary("dawn");