Skip to content

Commit

Permalink
Add building for AMR linux
Browse files Browse the repository at this point in the history
  • Loading branch information
jerzywilczek committed Mar 21, 2024
1 parent 6ec9f91 commit a1fd81b
Show file tree
Hide file tree
Showing 2 changed files with 149 additions and 93 deletions.
194 changes: 122 additions & 72 deletions .github/workflows/package_for_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,79 +3,129 @@ on:
workflow_dispatch: {}

jobs:
linux:
# linux:
# runs-on: ubuntu-latest
# steps:
# - name: 🛠 Install system dependencies
# run: |
# sudo add-apt-repository ppa:ubuntuhandbook1/ffmpeg6
# sudo apt-get update -y -qq
# sudo apt-get install -y libegl1-mesa-dev libgl1-mesa-dri libxcb-xfixes0-dev ffmpeg libavcodec-dev libavformat-dev libavfilter-dev libavdevice-dev libopus-dev
# - name: 🔧 Install the rust toolchain
# uses: dtolnay/rust-toolchain@stable
#
# - name: 📥 Checkout repo
# uses: actions/checkout@v3
#
# - name: 📦 Package
# run: cargo run --bin package_for_release
#
# - uses: actions/upload-artifact@v3
# with:
# name: video_compositor_linux_x86_64.tar.gz
# path: video_compositor_linux_x86_64.tar.gz
#
# - uses: actions/upload-artifact@v3
# with:
# name: video_compositor_with_web_renderer_linux_x86_64.tar.gz
# path: video_compositor_with_web_renderer_linux_x86_64.tar.gz

linux-aarch64:
runs-on: ubuntu-latest
steps:
- name: 🛠 Install system dependencies
run: |
sudo add-apt-repository ppa:ubuntuhandbook1/ffmpeg6
sudo apt-get update -y -qq
sudo apt-get install -y libegl1-mesa-dev libgl1-mesa-dri libxcb-xfixes0-dev ffmpeg libavcodec-dev libavformat-dev libavfilter-dev libavdevice-dev libopus-dev
- name: 🔧 Install the rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: 📥 Checkout repo
uses: actions/checkout@v3

- name: 📦 Package
run: cargo run --bin package_for_release

- uses: actions/upload-artifact@v3
- uses: actions/checkout@v4
with:
name: video_compositor_linux_x86_64.tar.gz
path: video_compositor_linux_x86_64.tar.gz

- uses: actions/upload-artifact@v3
with:
name: video_compositor_with_web_renderer_linux_x86_64.tar.gz
path: video_compositor_with_web_renderer_linux_x86_64.tar.gz

macos_x86_64:
runs-on: macos-latest
steps:
- name: 🛠 Install system dependencies
run: brew install ffmpeg

- name: 🔧 Install the rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: 📥 Checkout repo
uses: actions/checkout@v3

- name: 📦 Package
run: cargo run --bin package_for_release

- uses: actions/upload-artifact@v3
with:
name: video_compositor_darwin_x86_64.tar.gz
path: video_compositor_darwin_x86_64.tar.gz

- uses: actions/upload-artifact@v3
with:
name: video_compositor_with_web_renderer_darwin_x86_64.tar.gz
path: video_compositor_with_web_renderer_darwin_x86_64.tar.gz

macos-aarch64:
runs-on: macos-14
steps:
- name: 🛠 Install system dependencies
run: brew install ffmpeg

- name: 🔧 Install the rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: 📥 Checkout repo
uses: actions/checkout@v3

- name: 📦 Package
run: cargo run --bin package_for_release

- uses: actions/upload-artifact@v3
with:
name: video_compositor_darwin_aarch64.tar.gz
path: video_compositor_darwin_aarch64.tar.gz

- uses: actions/upload-artifact@v3
path: "repo"
- uses: uraimo/run-on-arch-action@v2
name: Build artifact
id: build
with:
name: video_compositor_with_web_renderer_darwin_aarch64.tar.gz
path: video_compositor_with_web_renderer_darwin_aarch64.tar.gz
arch: aarch64
distro: ubuntu_latest

# Not required, but speeds up builds
githubToken: ${{ github.token }}

# Create an artifacts directory
setup: |
mkdir -p "${PWD}/artifacts"
# Mount the artifacts directory as /artifacts in the container
dockerRunArgs: |
--volume "${PWD}/artifacts:/artifacts"
--volume "${PWD}/repo:/repo"
# The shell to run commands with in the container
shell: /bin/sh

# Install some dependencies in the container. This speeds up builds if
# you are also using githubToken. Any dependencies installed here will
# be part of the container image that gets cached, so subsequent
# builds don't have to re-install them. The image layer is cached
# publicly in your project's package repository, so it is vital that
# no secrets are present in the container state or logs.
install: |
apt update -y -qq
apt install software-properties-common -y
add-apt-repository ppa:ubuntuhandbook1/ffmpeg6
apt-get update -y -qq
apt-get install -y libegl1-mesa-dev libgl1-mesa-dri libxcb-xfixes0-dev ffmpeg libavcodec-dev libavformat-dev libavfilter-dev libavdevice-dev libopus-dev curl git
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
rm -rf /var/lib/apt/lists/*
# Produce a binary artifact and place it in the mounted volume
run: |
. "$HOME/.cargo/env"
cd "/repo"
cargo run --bin package_for_release
cp *.tar.gz /artifacts
# macos_x86_64:
# runs-on: macos-latest
# steps:
# - name: 🛠 Install system dependencies
# run: brew install ffmpeg
#
# - name: 🔧 Install the rust toolchain
# uses: dtolnay/rust-toolchain@stable
#
# - name: 📥 Checkout repo
# uses: actions/checkout@v3
#
# - name: 📦 Package
# run: cargo run --bin package_for_release
#
# - uses: actions/upload-artifact@v3
# with:
# name: video_compositor_darwin_x86_64.tar.gz
# path: video_compositor_darwin_x86_64.tar.gz
#
# - uses: actions/upload-artifact@v3
# with:
# name: video_compositor_with_web_renderer_darwin_x86_64.tar.gz
# path: video_compositor_with_web_renderer_darwin_x86_64.tar.gz

# macos-aarch64:
# runs-on: macos-14
# steps:
# - name: 🛠 Install system dependencies
# run: brew install ffmpeg
#
# - name: 🔧 Install the rust toolchain
# uses: dtolnay/rust-toolchain@stable
#
# - name: 📥 Checkout repo
# uses: actions/checkout@v3
#
# - name: 📦 Package
# run: cargo run --bin package_for_release
#
# - uses: actions/upload-artifact@v3
# with:
# name: video_compositor_darwin_aarch64.tar.gz
# path: video_compositor_darwin_aarch64.tar.gz
#
# - uses: actions/upload-artifact@v3
# with:
# name: video_compositor_with_web_renderer_darwin_aarch64.tar.gz
# path: video_compositor_with_web_renderer_darwin_aarch64.tar.gz
48 changes: 27 additions & 21 deletions src/bin/package_for_release/bundle_linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,47 @@ const X86_OUTPUT_FILE: &str = "video_compositor_linux_x86_64.tar.gz";
const X86_WITH_WEB_RENDERER_OUTPUT_FILE: &str =
"video_compositor_with_web_renderer_linux_x86_64.tar.gz";

const ARM_TARGET: &str = "aarch64-unknown-linux-gnu";
const ARM_OUTPUT_FILE: &str = "video_compositor_linux_aarch64.tar.gz";
const ARM_WITH_WEB_RENDERER_OUTPUT_FILE: &str =
"video_compositor_with_web_renderer_linux_aarch64.tar.gz";

pub fn bundle_linux_app() -> Result<()> {
tracing_subscriber::fmt().init();

info!("Bundling compositor without web rendering");
bundle_app(false)?;

info!("Bundling compositor with web rendering");
bundle_app(true)?;

if cfg!(target_arch = "x86_64") {
bundle_app(X86_TARGET, X86_OUTPUT_FILE, false)?;
bundle_app(X86_TARGET, X86_WITH_WEB_RENDERER_OUTPUT_FILE, true)?;
} else if cfg!(target_arch = "aarch64") {
bundle_app(ARM_TARGET, ARM_OUTPUT_FILE, false)?;
bundle_app(ARM_TARGET, ARM_WITH_WEB_RENDERER_OUTPUT_FILE, true)?;
}
Ok(())
}

fn bundle_app(enable_web_rendering: bool) -> Result<()> {
fn bundle_app(
target_name: &'static str,
output_name: &str,
enable_web_rendering: bool,
) -> Result<()> {
if enable_web_rendering {
info!("Bundling compositor with web rendering");
} else {
info!("Bundling compositor without web rendering");
}

let root_dir_str = env!("CARGO_MANIFEST_DIR");
let root_dir: PathBuf = root_dir_str.into();
let release_dir = root_dir.join("target/x86_64-unknown-linux-gnu/release");
let release_dir = root_dir.join(format!("target/{target_name}/release"));
let tmp_dir = root_dir.join("video_compositor");
utils::setup_bundle_dir(&tmp_dir)?;

info!("Build main_process binary.");
utils::cargo_build("main_process", X86_TARGET, !enable_web_rendering)?;
utils::cargo_build("main_process", target_name, !enable_web_rendering)?;

if enable_web_rendering {
info!("Build process_helper binary.");
utils::cargo_build("process_helper", X86_TARGET, false)?;
utils::cargo_build("process_helper", target_name, false)?;

info!("Create {} directory", tmp_dir.display());
fs::create_dir_all(tmp_dir.clone())?;
Expand Down Expand Up @@ -75,18 +91,8 @@ fn bundle_app(enable_web_rendering: bool) -> Result<()> {
}

info!("Create tar.gz archive.");
let archive_name = match enable_web_rendering {
true => X86_WITH_WEB_RENDERER_OUTPUT_FILE,
false => X86_OUTPUT_FILE,
};
let exit_code = Command::new("tar")
.args([
"-C",
root_dir_str,
"-czvf",
archive_name,
"video_compositor",
])
.args(["-C", root_dir_str, "-czvf", output_name, "video_compositor"])
.spawn()?
.wait()?
.code();
Expand Down

0 comments on commit a1fd81b

Please sign in to comment.