ci: build and cache vendored libghostty-vt in release workflow
This commit is contained in:
parent
b2e6929aa8
commit
8fd1bc56ce
|
|
@ -48,18 +48,35 @@ jobs:
|
|||
with:
|
||||
targets: ${{ matrix.target }}
|
||||
|
||||
- name: Install musl tools (Linux x86_64)
|
||||
if: matrix.target == 'x86_64-unknown-linux-musl'
|
||||
run: sudo apt-get update && sudo apt-get install -y musl-tools
|
||||
- name: Install Zig
|
||||
uses: mlugg/setup-zig@v2
|
||||
with:
|
||||
version: 0.15.2
|
||||
|
||||
- name: Install cross-compilation tools (Linux aarch64)
|
||||
- name: Install Linux build tools
|
||||
if: runner.os == 'Linux'
|
||||
run: sudo apt-get update && sudo apt-get install -y cmake ninja-build musl-tools gcc-aarch64-linux-gnu crossbuild-essential-arm64
|
||||
|
||||
- name: Install macOS build tools
|
||||
if: runner.os == 'macOS'
|
||||
run: brew install cmake ninja
|
||||
|
||||
- name: Set Linux aarch64 linker
|
||||
if: matrix.target == 'aarch64-unknown-linux-musl'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y gcc-aarch64-linux-gnu musl-tools
|
||||
# Install aarch64 musl cross-compiler
|
||||
sudo apt-get install -y crossbuild-essential-arm64
|
||||
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
|
||||
run: echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
|
||||
|
||||
- name: Cache Rust artifacts
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
key: release-${{ matrix.target }}
|
||||
|
||||
- name: Cache vendored libghostty-vt build outputs
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
vendor/libghostty-vt/.zig-cache
|
||||
vendor/libghostty-vt/zig-out
|
||||
key: ${{ runner.os }}-${{ matrix.target }}-libghostty-${{ hashFiles('vendor/libghostty-vt.vendor.json', 'vendor/libghostty-vt/build.zig', 'vendor/libghostty-vt/build.zig.zon', 'vendor/libghostty-vt/VERSION', 'build.rs') }}
|
||||
|
||||
- name: Build
|
||||
run: cargo build --release --locked --target ${{ matrix.target }}
|
||||
|
|
|
|||
23
build.rs
23
build.rs
|
|
@ -2,6 +2,18 @@ use std::env;
|
|||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
|
||||
fn zig_target(target: &str) -> &str {
|
||||
match target {
|
||||
"x86_64-unknown-linux-gnu" => "x86_64-linux-gnu",
|
||||
"aarch64-unknown-linux-gnu" => "aarch64-linux-gnu",
|
||||
"x86_64-unknown-linux-musl" => "x86_64-linux-musl",
|
||||
"aarch64-unknown-linux-musl" => "aarch64-linux-musl",
|
||||
"x86_64-apple-darwin" => "x86_64-macos",
|
||||
"aarch64-apple-darwin" => "aarch64-macos",
|
||||
other => panic!("unsupported target for libghostty-vt build: {other}"),
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
println!("cargo:rerun-if-changed=vendor/libghostty-vt.vendor.json");
|
||||
|
|
@ -13,11 +25,14 @@ fn main() {
|
|||
let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR"));
|
||||
let vendored_dir = manifest_dir.join("vendor/libghostty-vt");
|
||||
let optimize = env::var("LIBGHOSTTY_VT_OPTIMIZE").unwrap_or_else(|_| "ReleaseFast".into());
|
||||
let target = env::var("TARGET").expect("TARGET");
|
||||
let zig_target = zig_target(&target);
|
||||
|
||||
let status = Command::new("zig")
|
||||
.arg("build")
|
||||
.arg("-Demit-lib-vt")
|
||||
.arg(format!("-Doptimize={optimize}"))
|
||||
.arg(format!("-Dtarget={zig_target}"))
|
||||
.current_dir(&vendored_dir)
|
||||
.status()
|
||||
.expect("failed to execute zig build for vendored libghostty-vt");
|
||||
|
|
@ -28,12 +43,10 @@ fn main() {
|
|||
|
||||
let lib_dir = vendored_dir.join("zig-out/lib");
|
||||
println!("cargo:rustc-link-search=native={}", lib_dir.display());
|
||||
println!("cargo:rustc-link-lib=dylib=ghostty-vt");
|
||||
|
||||
let target = env::var("TARGET").expect("TARGET");
|
||||
println!("cargo:rustc-link-lib=static=ghostty-vt");
|
||||
if target.contains("linux") {
|
||||
println!("cargo:rustc-link-arg=-Wl,-rpath,{}", lib_dir.display());
|
||||
println!("cargo:rustc-link-lib=dylib=stdc++");
|
||||
} else if target.contains("apple-darwin") {
|
||||
println!("cargo:rustc-link-arg=-Wl,-rpath,{}", lib_dir.display());
|
||||
println!("cargo:rustc-link-lib=dylib=c++");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue