Skip to content

Commit

Permalink
build: allow aarch64-linux-unknown-gnu build of librashader-capi
Browse files Browse the repository at this point in the history
  • Loading branch information
chyyran committed Nov 29, 2023
1 parent f4bdf16 commit 2be2178
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 5 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/build-linux-arm64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: build librashader-capi for ARM64 Linux

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
schedule:
- cron: "0 0 * * 6"
env:
CARGO_TERM_COLOR: always

jobs:
build:
strategy:
matrix:
profile: ['debug', 'release', 'optimized']
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install nightly Rust
uses: actions-rs/[email protected]
with:
toolchain: nightly
override: true
target: aarch64-unknown-linux-gnu
- uses: actions/setup-python@v1
name: Setup Python 3.11
with:
python-version: '3.11.6'
- name: Install ARM64 cross-compilation dependencies
continue-on-error: true
run: |
sudo dpkg --add-architecture arm64
echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports jammy main restricted" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates main restricted" | sudo tee -a /etc/apt/sources.list
sudo apt-get update || true
sudo apt-get -y install libvulkan-dev:arm64 g++-aarch64-linux-gnu gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu
- name: Build dynamic library
run: CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=/usr/bin/aarch64-linux-gnu-gcc cargo run -p librashader-build-script -- --profile ${{ matrix.profile }} --target aarch64-unknown-linux-gnu
- name: Upload build artifacts
uses: actions/[email protected]
with:
name: ${{ format('build-outputs-aarch64-unknown-linux-gnu-{0}', matrix.profile) }}
path: ${{ format('target/aarch64-unknown-linux-gnu/{0}/librashader.*', matrix.profile) }}
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: build librashader-capi
name: build librashader-capi for x86_64

on:
push:
Expand All @@ -16,7 +16,6 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest]
profile: ['debug', 'release', 'optimized']
arch: ['x86_64']
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,15 @@ static GL_DEFAULT_MVP: &[f32; 16] = &[
librashader requires the following build time dependencies

* The [Vulkan SDK](https://www.lunarg.com/vulkan-sdk/)
* [Meson](https://mesonbuild.com/)
* [CMake 3.8 or later](https://cmake.org/)

For DXIL support on Windows, the following is also needed
* [Meson](https://mesonbuild.com/)
* [Python 3.6 or later](https://www.python.org/)

---

For Rust projects, simply add the crate to your `Cargo.toml`.
For Rust projects, simply add the crate tofil your `Cargo.toml`.

```
cargo add librashader
Expand Down
18 changes: 17 additions & 1 deletion librashader-build-script/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ use std::{env, fs};
struct Args {
#[arg(long, default_value = "debug", global = true)]
profile: String,
#[arg(long, global = true)]
target: Option<String>,
}

pub fn main() {
Expand All @@ -32,12 +34,26 @@ pub fn main() {
"--profile={}",
if profile == "debug" { "dev" } else { &profile }
));

if let Some(target) = &args.target {
cmd.arg(format!(
"--target={}",
&target
));
}

Some(cmd.status().expect("Failed to build librashader-capi"));

let output_dir = PathBuf::from(format!("target/{}", profile))
let mut output_dir = PathBuf::from(format!("target/{}", profile));
if let Some(target) = &args.target {
output_dir = PathBuf::from(format!("target/{}/{}", target, profile));
}

let output_dir = output_dir
.canonicalize()
.expect("Could not find output directory.");


println!("Generating C headers...");

// Create headers.
Expand Down

0 comments on commit 2be2178

Please sign in to comment.