build: allow aarch64-linux-unknown-gnu build of librashader-capi

This commit is contained in:
chyyran 2023-11-29 03:02:14 -05:00 committed by Ronny Chan
parent f4bdf160ab
commit 2be2178502
4 changed files with 69 additions and 5 deletions

47
.github/workflows/build-linux-arm64.yml vendored Normal file
View file

@ -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/toolchain@v1.0.6
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/upload-artifact@v3.1.2
with:
name: ${{ format('build-outputs-aarch64-unknown-linux-gnu-{0}', matrix.profile) }}
path: ${{ format('target/aarch64-unknown-linux-gnu/{0}/librashader.*', matrix.profile) }}

View file

@ -1,4 +1,4 @@
name: build librashader-capi
name: build librashader-capi for x86_64
on:
push:
@ -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:

View file

@ -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

View file

@ -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() {
@ -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.