diff --git a/Cargo.lock b/Cargo.lock index f5032b2..53ac7df 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "agon-ez80-emulator" -version = "0.9.67" +version = "0.9.68" dependencies = [ "chrono", "ez80", @@ -14,7 +14,7 @@ dependencies = [ [[package]] name = "agon-light-emulator-debugger" -version = "0.9.67" +version = "0.9.68" dependencies = [ "agon-ez80-emulator", "ctrlc", @@ -195,7 +195,7 @@ source = "git+https://github.com/tomm/ez80.git?rev=64558c2acda1464248193f2f10804 [[package]] name = "fab-agon-emulator" -version = "0.9.67" +version = "0.9.68" dependencies = [ "agon-ez80-emulator", "agon-light-emulator-debugger", diff --git a/Cargo.toml b/Cargo.toml index 00ab0b8..bed06d5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ members = ["agon-light-emulator-debugger"] [workspace.package] -version = "0.9.67" +version = "0.9.68" edition = "2021" authors = ["Tom Morton "] license = "GPL-3.0" diff --git a/Makefile b/Makefile index cb99989..ac0408c 100644 --- a/Makefile +++ b/Makefile @@ -41,8 +41,8 @@ else endif cargo-clean: - cargo clean rm -f fab-agon-emulator + cargo clean clean: vdp-clean cargo-clean diff --git a/build-release.sh b/build-release.sh new file mode 100755 index 0000000..379b8d5 --- /dev/null +++ b/build-release.sh @@ -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 diff --git a/build.rs b/build.rs index 000d568..67ebce5 100644 --- a/build.rs +++ b/build.rs @@ -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(); } diff --git a/dist_scripts/Dockerfile b/dist_scripts/Dockerfile new file mode 100644 index 0000000..91393af --- /dev/null +++ b/dist_scripts/Dockerfile @@ -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"] diff --git a/dist_scripts/make-dist-linux.sh b/dist_scripts/make-dist-linux.sh index ed9852f..924f74b 100755 --- a/dist_scripts/make-dist-linux.sh +++ b/dist_scripts/make-dist-linux.sh @@ -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 diff --git a/dist_scripts/crosscompile_for_w64_on_linux.sh b/dist_scripts/make-dist-windows.sh similarity index 84% rename from dist_scripts/crosscompile_for_w64_on_linux.sh rename to dist_scripts/make-dist-windows.sh index 5240414..e5d779b 100755 --- a/dist_scripts/crosscompile_for_w64_on_linux.sh +++ b/dist_scripts/make-dist-windows.sh @@ -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 . @@ -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