Skip to content

Commit

Permalink
Docker-based build-release.sh script
Browse files Browse the repository at this point in the history
  • Loading branch information
tomm committed Nov 14, 2024
1 parent 7dbac17 commit 889d3b6
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 13 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
members = ["agon-light-emulator-debugger"]

[workspace.package]
version = "0.9.67"
version = "0.9.68"
edition = "2021"
authors = ["Tom Morton <[email protected]>"]
license = "GPL-3.0"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ else
endif

cargo-clean:
cargo clean
rm -f fab-agon-emulator
cargo clean

clean: vdp-clean cargo-clean

Expand Down
16 changes: 16 additions & 0 deletions build-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# zipped up binaries will be written to ./artifacts
mkdir -p artifacts

docker build -t fab-agon-emulator-buildenv -f ./dist_scripts/Dockerfile .

if [ $? -ne 0 ]; then
echo "Failed to build docker image!"
exit -1
fi

echo Building binaries...

docker run -i -v ./artifacts:/build/artifacts fab-agon-emulator-buildenv ./dist_scripts/make-dist-linux.sh
docker run -i -v ./artifacts:/build/artifacts fab-agon-emulator-buildenv ./dist_scripts/make-dist-windows.sh
12 changes: 10 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
fn main() {
if std::env::var("CARGO_CFG_TARGET_OS").unwrap() != "windows"
&& std::env::var("CARGO_CFG_TARGET_OS").unwrap() != "macos"
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();

if target_os == "windows" {
// Download https://github.com/libsdl-org/SDL/releases/download/release-2.28.3/SDL2-devel-2.28.3-mingw.tar.gz,
// extract, rename directory from SDL2-2.28.3 to SDL2, and you are ready
println!("cargo:rustc-link-search=./SDL2/x86_64-w64-mingw32/lib");
}

if target_os != "windows"
&& target_os != "macos"
{
system_deps::Config::new().probe().unwrap();
}
Expand Down
20 changes: 20 additions & 0 deletions dist_scripts/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM rust:1.75.0-slim-bookworm

RUN apt update && apt install -y wget mingw-w64 zip bzip2 git gcc g++ libsdl2-dev make && rm -rf /var/lib/apt/lists/*

WORKDIR /build

COPY . .
RUN cd /build && make clean
RUN mkdir /build/artifacts

# Windows dependencies
RUN rustup target add x86_64-pc-windows-gnu
RUN cd /build && wget --quiet https://github.com/libsdl-org/SDL/releases/download/release-2.28.3/SDL2-devel-2.28.3-mingw.tar.gz && tar xvzf SDL2-devel-2.28.3-mingw.tar.gz
RUN mv /build/SDL2-2.28.3 /build/SDL2
RUN cp /build/SDL2/x86_64-w64-mingw32/bin/SDL2.dll /build
RUN cp /usr/lib/gcc/x86_64-w64-mingw32/12-posix/libgcc_s_seh-1.dll /build
RUN cp /usr/lib/gcc/x86_64-w64-mingw32/12-posix/libstdc++-6.dll /build
RUN cp /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll /build

CMD ["bash"]
3 changes: 2 additions & 1 deletion dist_scripts/make-dist-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ cp -r ./firmware $DIST_DIR
cp LICENSE README.md $DIST_DIR
mkdir $DIST_DIR/sdcard
cp -r sdcard/* $DIST_DIR/sdcard/
tar cvjf $DIST_DIR.tar.bz2 $DIST_DIR
strip $DIST_DIR/firmware/*.so $DIST_DIR/fab-agon-emulator
tar cvjf ./artifacts/$DIST_DIR.tar.bz2 $DIST_DIR
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@
# download SDL2 libs for mingw:
# https://github.com/libsdl-org/SDL/releases/download/release-2.28.3/SDL2-devel-2.28.3-mingw.tar.gz
#
# extract, copy contents of x86_64-w64-mingw32/lib to
# $HOME/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib
#
# copy bin/SDL2.dll to .
# extract into fab-agon-emulator project root, rename directory from SDL2-2.28.3 to SDL2
# copy SDL2/x86_64-w64-mingw32/bin/SDL2.dll to .
#
# locate libgcc_s_seh-1.dll, libstdc++-6.dll, libwinpthread-1.dll (posix threads version) somewhere
# in /usr/..... , and copy to .
Expand Down Expand Up @@ -42,5 +40,5 @@ cp LICENSE README.md $DIST_DIR
mkdir $DIST_DIR/sdcard
cp -r sdcard/* $DIST_DIR/sdcard/
x86_64-w64-mingw32-strip $DIST_DIR/firmware/*.so $DIST_DIR/*.exe $DIST_DIR/*.dll
zip -r $DIST_DIR.zip $DIST_DIR
zip -r ./artifacts/$DIST_DIR.zip $DIST_DIR

0 comments on commit 889d3b6

Please sign in to comment.