Skip to content

Commit

Permalink
Encapsulate win/lin building in dockerfiles, must run mac on a mac.
Browse files Browse the repository at this point in the history
  • Loading branch information
erichelgeson committed Sep 22, 2023
1 parent 1a60398 commit ba4dbe4
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 111 deletions.
22 changes: 22 additions & 0 deletions Dockerfile.lin
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM ubuntu:22.04 as setup

RUN apt update
RUN apt install mingw-w64 build-essential libx11-dev -y

FROM setup AS build
ARG MACHINE_TYPE="II"
ARG MAINTAINER="none"
ARG HOMEPAGE="https://example.com"

COPY . /
RUN gcc -o setup_t setup/tool.c

RUN ./setup_t -maintainer "$MAINTAINER" \
-homepage "$HOMEPAGE" \
-n "minivmac-3.7-bluescsi" \
-t lx64 \
-m II \
> setup.sh
RUN sed -i '/.*SDL\.h/i printf \"%s\\n\" \"#define SDL_MAIN_HANDLED\" \>\> \"\$\{DestFile\}\"' setup.sh
RUN bash -x ./setup.sh
RUN export PATH=.:$PATH; make -j $(nproc)
31 changes: 31 additions & 0 deletions Dockerfile.win
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM ubuntu:22.04 AS setup
# TODO: Requires SDL2.dll from github.com/libsdl-org/SDL/releases

RUN apt update
RUN apt install mingw-w64 build-essential wget -y
RUN wget https://www.libsdl.org/release/SDL2-devel-2.0.22-mingw.tar.gz
RUN gzip -dc SDL2-devel-2.0.22-mingw.tar.gz | tar -xvf -
RUN cd SDL2-2.0.22 && make install-package arch=x86_64-w64-mingw32 prefix=/usr/x86_64-w64-mingw32
RUN ln -s /usr/bin/x86_64-w64-mingw32-gcc gcc.exe
RUN ln -s /usr/bin/x86_64-w64-mingw32-windres windres.exe
RUN ln -s /usr/bin/x86_64-w64-mingw32-strip strip.exe
RUN ln -s src SRC

FROM setup AS build
ARG MACHINE_TYPE="II"
ARG MAINTAINER="none"
ARG HOMEPAGE="https://example.com"

COPY . /
RUN gcc -o setup_t setup/tool.c

RUN ./setup_t -maintainer "$MAINTAINER" \
-homepage "$HOMEPAGE" \
-m "$MACHINE_TYPE" \
-n "minivmac-3.7-bluescsi" \
-e mgw \
-t wx64 \
> setup.sh
RUN sed -i '/.*SDL\.h/i printf \"%s\\n\" \"#define SDL_MAIN_HANDLED\" \>\> \"\$\{DestFile\}\"' setup.sh
RUN bash -x ./setup.sh
RUN export PATH=.:$PATH; make -j $(nproc)
17 changes: 17 additions & 0 deletions build_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh -e -x

rm -rf ./dist
mkdir -p ./dist

./build_mac.sh
./build_lin.sh
./build_win.sh

cd dist
for file in ./*;
do
zip -vr $file.zip $file
done
mkdir -p zips
mv *.zip zips/
cd ..
34 changes: 0 additions & 34 deletions build_example.sh

This file was deleted.

22 changes: 22 additions & 0 deletions build_lin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh -e -x

mkdir -p dist/

#Vars
declare -a types=("II" "Plus" "SE")
MAINTAINER="[email protected]"
HOMEPAGE="https://bluescsi.com"

for type in "${types[@]}";
do
docker build -f Dockerfile.lin \
--target=build \
--tag=minivmaclin \
--build-arg="MACHINE_TYPE=$type" \
--build-arg="MAINTAINER=$MAINTAINER" \
--build-arg="HOMEPAGE=$HOMEPAGE" \
.
docker create --name minivmaclin minivmaclin # need to create a container to copy file from
docker cp minivmaclin:/minivmac dist/minivmac-lx64-$type
docker rm minivmaclin
done
102 changes: 25 additions & 77 deletions build_mac.sh
Original file line number Diff line number Diff line change
@@ -1,82 +1,30 @@
#!/bin/sh -e -x
#
# Example on how to build Mini vMac on Macintosh
#
EMAIL="[email protected]"
WEB="https://github.com/egrath"
rm -rf dist/
mkdir -p dist/

# Build tool each time incase of change, it's quick.
gcc -o setup_t setup/tool.c
#mc64 == intel mac
# -t mcar \ arm mac
# run setup tool to generate makefile generator
./setup_t -maintainer $EMAIL \
-homepage $WEB \
-n "minivmac-3.7-test" \
-t mcar \
-m II \
> setup.sh

# generate makefile and build
. ./setup.sh
xcodebuild

mv minivmac.app dist/minivmac-mcar-MacII.app

./setup_t -maintainer $EMAIL \
-homepage $WEB \
-n "minivmac-3.7-test" \
-t mcar \
> setup.sh

# generate makefile and build
. ./setup.sh
xcodebuild

mv minivmac.app dist/minivmac-mcar-MacPlus.app

# will error/stop if we dont have xcode
which xcodebuild
which gcc

# run setup tool to generate makefile generator
./setup_t -maintainer $EMAIL \
-homepage $WEB \
-n "minivmac-3.7-test" \
-t mc64 \
-m II \
-ev 13000 \
> setup.sh

# generate makefile and build
. ./setup.sh
xcodebuild

mv minivmac.app dist/minivmac-mc64-MacII.app


# run setup tool to generate makefile generator
./setup_t -maintainer $EMAIL \
-homepage $WEB \
-n "minivmac-3.7-test" \
-t mc64 \
-ev 13000 \
> setup.sh

# generate makefile and build
. ./setup.sh
xcodebuild
declare -a types=("II" "Plus" "SE")
declare -a platforms=("mc64" "mcar")
MAINTAINER="[email protected]"
HOMEPAGE="https://bluescsi.com"
mkdir -p dist/

mv minivmac.app dist/minivmac-mc64-MacPlus.app
gcc -o setup_t setup/tool.c

# -e xcd \

# -hres 640 -vres 480 -depth 3 \
# -magnify 1 \
# -mf 2 \
# -sound 1 \
# -sony-sum 1 -sony-tag 1 \
# -speed 4 -ta 2 -em-cpu 2 -mem 8M \
# -chr 0 -drc 1 -sss 4 \
# -fullscreen 0 \
# -var-fullscreen 1 \
# -api cco \
for platform in "${platforms[@]}";
do
for type in "${types[@]}";
do
./setup_t -maintainer $MAINTAINER \
-homepage $HOMEPAGE \
-n "minivmac-3.7-bluescsi" \
-t $platform \
-m $type \
-ev 13000 \
> setup.sh
. ./setup.sh
xcodebuild
mv minivmac.app dist/minivmac-$platform-$type.app
done
done
22 changes: 22 additions & 0 deletions build_win.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh -e -x

mkdir -p dist/

#Vars
declare -a types=("II" "Plus" "SE")
MAINTAINER="[email protected]"
HOMEPAGE="https://bluescsi.com"

for type in "${types[@]}";
do
docker build -f Dockerfile.win \
--target=build \
--tag=minivmacwin \
--build-arg="MACHINE_TYPE=$type" \
--build-arg="MAINTAINER=$MAINTAINER" \
--build-arg="HOMEPAGE=$HOMEPAGE" \
.
docker create --name minivmacwin minivmacwin # need to create a container to copy file from
docker cp minivmacwin:/minivmac.exe dist/minivmac-x64-$type.exe
docker rm minivmacwin
done

0 comments on commit ba4dbe4

Please sign in to comment.