diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-04-06 00:50:41 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-04-06 00:50:41 +0300 |
| commit | dbbe1f66ba02ecbceac8cad8d79a3ae664a8159a (patch) | |
| tree | dc8c19b41f0ea4386d840c35ae23da9f7e34d5f5 | |
| parent | c113f5713fc759c128a4dc07149140956362cece (diff) | |
build: add libghostty simd toggle for ci
| -rw-r--r-- | .github/workflows/build-artifacts-manual.yml | 16 | ||||
| -rw-r--r-- | build.rs | 21 |
2 files changed, 33 insertions, 4 deletions
diff --git a/.github/workflows/build-artifacts-manual.yml b/.github/workflows/build-artifacts-manual.yml index c880a852..458c8209 100644 --- a/.github/workflows/build-artifacts-manual.yml +++ b/.github/workflows/build-artifacts-manual.yml @@ -22,6 +22,14 @@ on: - ReleaseFast - ReleaseSmall - Debug + libghostty_simd: + description: build libghostty-vt with SIMD-accelerated code paths + required: true + default: 'false' + type: choice + options: + - 'false' + - 'true' permissions: contents: read @@ -45,6 +53,7 @@ jobs: name: herdr-linux-aarch64 env: LIBGHOSTTY_VT_OPTIMIZE: ${{ inputs.libghostty_optimize }} + LIBGHOSTTY_VT_SIMD: ${{ inputs.libghostty_simd }} steps: - uses: actions/checkout@v4 @@ -81,13 +90,14 @@ jobs: echo "commit=$GITHUB_SHA" echo "target=${{ matrix.target }}" echo "libghostty_vt_optimize=$LIBGHOSTTY_VT_OPTIMIZE" + echo "libghostty_vt_simd=$LIBGHOSTTY_VT_SIMD" } >> BUILD_INFO.txt python3 -c "import hashlib, pathlib; artifact = pathlib.Path('${{ matrix.name }}'); print(f'sha256={hashlib.sha256(artifact.read_bytes()).hexdigest()} {artifact.name}')" >> BUILD_INFO.txt - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: ${{ matrix.name }}-${{ inputs.libghostty_optimize }} + name: ${{ matrix.name }}-${{ inputs.libghostty_optimize }}-simd-${{ inputs.libghostty_simd }} path: | ${{ matrix.name }} BUILD_INFO.txt @@ -108,6 +118,7 @@ jobs: name: herdr-macos-aarch64 env: LIBGHOSTTY_VT_OPTIMIZE: ${{ inputs.libghostty_optimize }} + LIBGHOSTTY_VT_SIMD: ${{ inputs.libghostty_simd }} steps: - uses: actions/checkout@v4 @@ -140,13 +151,14 @@ jobs: echo "commit=$GITHUB_SHA" echo "target=${{ matrix.target }}" echo "libghostty_vt_optimize=$LIBGHOSTTY_VT_OPTIMIZE" + echo "libghostty_vt_simd=$LIBGHOSTTY_VT_SIMD" } >> BUILD_INFO.txt python3 -c "import hashlib, pathlib; artifact = pathlib.Path('${{ matrix.name }}'); print(f'sha256={hashlib.sha256(artifact.read_bytes()).hexdigest()} {artifact.name}')" >> BUILD_INFO.txt - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: ${{ matrix.name }}-${{ inputs.libghostty_optimize }} + name: ${{ matrix.name }}-${{ inputs.libghostty_optimize }}-simd-${{ inputs.libghostty_simd }} path: | ${{ matrix.name }} BUILD_INFO.txt @@ -15,6 +15,18 @@ fn zig_target(target: &str) -> &str { } } +fn env_bool(name: &str) -> Option<bool> { + match env::var(name) { + Ok(value) => match value.to_ascii_lowercase().as_str() { + "1" | "true" | "yes" | "on" => Some(true), + "0" | "false" | "no" | "off" => Some(false), + other => panic!("invalid boolean value for {name}: {other}"), + }, + Err(env::VarError::NotPresent) => None, + Err(err) => panic!("failed to read {name}: {err}"), + } +} + fn main() { println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=vendor/libghostty-vt.vendor.json"); @@ -22,10 +34,12 @@ fn main() { println!("cargo:rerun-if-changed=vendor/libghostty-vt/build.zig.zon"); println!("cargo:rerun-if-changed=vendor/libghostty-vt/VERSION"); println!("cargo:rerun-if-env-changed=LIBGHOSTTY_VT_OPTIMIZE"); + println!("cargo:rerun-if-env-changed=LIBGHOSTTY_VT_SIMD"); 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 simd = env_bool("LIBGHOSTTY_VT_SIMD").unwrap_or(true); let target = env::var("TARGET").expect("TARGET"); let zig_target = zig_target(&target); let version_string = fs::read_to_string(vendored_dir.join("VERSION")) @@ -37,6 +51,7 @@ fn main() { .arg("build") .arg("-Demit-lib-vt") .arg(format!("-Doptimize={optimize}")) + .arg(format!("-Dsimd={simd}")) .arg(format!("-Dtarget={zig_target}")) .arg(format!("-Dversion-string={version_string}")) .current_dir(&vendored_dir) @@ -52,10 +67,12 @@ fn main() { if target.contains("apple-darwin") { let static_lib = lib_dir.join("libghostty-vt.a"); println!("cargo:rustc-link-arg={}", static_lib.display()); - println!("cargo:rustc-link-lib=dylib=c++"); + if simd { + println!("cargo:rustc-link-lib=dylib=c++"); + } } else { println!("cargo:rustc-link-lib=static=ghostty-vt"); - if target.contains("linux") { + if target.contains("linux") && simd { println!("cargo:rustc-link-lib=dylib=stdc++"); } } |
