From b74831cdff0b205de00a4b4ef90902ec379c30fb Mon Sep 17 00:00:00 2001 From: darkstack <1835601+darkstack@users.noreply.github.com> Date: Fri, 4 Apr 2025 17:42:19 +0200 Subject: [PATCH] Add AArch64 crossbuild via Podman Limit FPS Config screen W/H --- .gitea/workflows/build.yaml | 14 ++------------ Dockerfile | 14 ++++++++++++++ buildaarch64.sh | 12 ++++++++++++ config.toml | 9 +++++++++ src/main.rs | 8 +++++--- 5 files changed, 42 insertions(+), 15 deletions(-) create mode 100644 Dockerfile create mode 100755 buildaarch64.sh create mode 100644 config.toml diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 29aa02b..d5c6731 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -8,22 +8,15 @@ jobs: steps: - name: Update run: | - sudo dpkg --add-architecture arm64 - sed -i 's/deb /deb [arch=amd64] /g' /etc/apt/sources.list cat /etc/apt/sources.list # TODO : Add from previous file - echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy main multiverse restricted universe" >> /etc/apt/sources.list - echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main multiverse restricted universe" >> /etc/apt/sources.list - sudo apt-get update -y -qq || true sudo apt-get install -y build-essential git make zip libsdl2-dev libsdl2-2.0-0 libsdl2-net-dev libsdl2-mixer-dev libsdl2-image-dev libsdl2-gfx-dev libsdl2-ttf-dev gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu #ARM64 - sudo apt-get install -y libsdl2-dev:arm64 libsdl2-2.0-0:arm64 libsdl2-net-dev:arm64 libsdl2-mixer-dev:arm64 libsdl2-image-dev:arm64 libsdl2-gfx-dev:arm64 libsdl2-ttf-dev:arm64 #sudo apt install -y libssl-dev:arm64 libasound2-dev:arm64 sudo sh -c "echo '192.168.1.253 descartes.local' >> /etc/hosts" sudo sh -c "echo '192.168.1.253 build.ladose.net' >> /etc/hosts" sudo curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y - sudo -E $HOME/.cargo/bin/rustup target add aarch64-unknown-linux-gnu - name: GetDNS run: | @@ -37,15 +30,13 @@ jobs: run: | . "$HOME/.cargo/env" cargo build --release - cargo build --release --target=aarch64-unknown-linux-gnu - name: Zip file run: | - zip -rj build.zip ./target/release/ - zip -rj build-Aarch64.zip ./target/release/ + zip -rj build.zip ./target/release/ladose-caller ./font/ - name: Upload Artifact uses: actions/upload-artifact@v3 with: - path: build-linux64.zip + path: build.zip name: build-linux64.zip retention-days: 30 overwrite: true @@ -56,6 +47,5 @@ jobs: with: tag_name: release-${{ steps.date.outputs.date }} files: |- - build-winx64.zip build-linux64.zip diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d47563d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM rust:latest + +RUN dpkg --add-architecture arm64 +RUN apt update && apt upgrade -y +RUN apt install -y g++-aarch64-linux-gnu libc6-dev-arm64-cross +RUN apt-get install -y libsdl2-dev:arm64 libsdl2-2.0-0:arm64 libsdl2-net-dev:arm64 libsdl2-mixer-dev:arm64 libsdl2-image-dev:arm64 libsdl2-gfx-dev:arm64 libsdl2-ttf-dev:arm64 +RUN rustup target add aarch64-unknown-linux-gnu +RUN rustup toolchain add stable-aarch64-unknown-linux-gnu --force-non-host + +WORKDIR /app + +ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++ + +CMD ["cargo", "build", "--target", "aarch64-unknown-linux-gnu","-r"] diff --git a/buildaarch64.sh b/buildaarch64.sh new file mode 100755 index 0000000..26e64ae --- /dev/null +++ b/buildaarch64.sh @@ -0,0 +1,12 @@ +#!/bin/sh +echo "build podman image" +podman build . -t cross_compile/rust_aarch64 +echo "run build" +podman run --rm -v .:/app cross_compile/rust_aarch64 + + +ssh tom@raspberrypi.local -f 'sudo systemctl stop lightdm' +ssh tom@raspberrypi.local -f 'killall ladose-caller' +scp ./target/aarch64-unknown-linux-gnu/release/ladose-caller tom@raspberrypi.local: + +ssh tom@raspberrypi.local -f 'sudo systemctl start lightdm' diff --git a/config.toml b/config.toml new file mode 100644 index 0000000..3933416 --- /dev/null +++ b/config.toml @@ -0,0 +1,9 @@ +tournament = 'tournoi-kiouze-test' +update = 2 +fullscreen = true +font_size = 40 +font_size_departure = 60 +smash_key = 'Bearer API_KEY' +margin = 10 +w = 1920 +h = 1080 diff --git a/src/main.rs b/src/main.rs index 01bc0d9..2ba7b33 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,6 +19,8 @@ use serde::Deserialize; #[derive(Deserialize,Clone)] pub struct Config { tournament: String, + w : u32, + h : u32, update: Option, fullscreen: Option, smash_key: String, @@ -40,7 +42,7 @@ struct Line<'a> { impl Config { fn new() -> Self { - Self { tournament: String::new(), update: Some(1),fullscreen:Some(false), smash_key: String::new(), font_size: 30 , font_size_departure : 45, margin: 10,tournament_image: None } + Self { tournament: String::new(), update: Some(1),fullscreen:Some(false), smash_key: String::new(), font_size: 30 , font_size_departure : 45, margin: 10,tournament_image: None , w : 1920, h: 1080} } } @@ -159,7 +161,7 @@ pub fn main() -> Result<(), Box> { let sdl_context = sdl2::init().unwrap(); let video_subsystem = sdl_context.video().unwrap(); - let mut build = video_subsystem.window("LaDOSE-SNCF", 1280, 720); + let mut build = video_subsystem.window("LaDOSE-SNCF", box_config.w, box_config.h); if fullscreen { build.fullscreen(); } @@ -217,6 +219,6 @@ pub fn main() -> Result<(), Box> { } canvas.present(); - ::std::thread::sleep(Duration::new(0, 1_000_000_000u32 / 60)); + ::std::thread::sleep(Duration::new(0, 1_000_000_000u32 / 30)); } }