Use docker to build

This commit is contained in:
Ivan Izaguirre 2019-12-26 23:11:32 +01:00
parent 22b15bf89b
commit aa46cc48e5
5 changed files with 56 additions and 12 deletions

View File

@ -80,7 +80,7 @@ Displays super hi-res box art as seen with the VidHD card.
### Terminal mode
To run text mode right on the terminal without the SDL2 dependency, use `apple2console`. It runs on the console using ANSI escape codes. Input is sent to the emulated Apple II one line at a time:
```
casa@servidor:~$ ./apple2console
casa@servidor:~$ ./apple2console -model 2plus
############################################
# #
@ -199,17 +199,12 @@ $ go get github.com/ivanizag/apple2/apple2sdl
$ go build github.com/ivanizag/apple2/apple2sdl
```
### Cross compile apple2sdl.exe for Windows in Ubuntu
### Use docker to cross compile for Linux and Windows
Install the mingw cross compile tools and the [SDL2 Windows libs for mingw](https://www.libsdl.org/download-2.0.php).
To create executables for Linux and Windows without installing Go, SDL2 or the Windows cross compilation toosl, run:
```
$ sudo apt install mingw-w64
$ wget https://www.libsdl.org/release/SDL2-devel-2.0.9-mingw.tar.gz
$ tar -xzf SDL2-devel-2.0.9-mingw.tar.gz
$ sudo cp -r SDL2-2.0.9/x86_64-w64-mingw32/* /usr/x86_64-w64-mingw32
$ cd docker
$ ./build.sh
```
Compile:
```
$ env CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc GOOS=windows CGO_LDFLAGS="-L/usr/x86_64-w64-mingw32/lib -lSDL2 --verbose" CGO_FLAGS="-I/usr/x86_64-w64-mingw32/include -D_REENTRANT" go build -o apple2sdl.exe -x github.com/ivanizag/apple2/apple2sdl
```
To run the executable in Windows, copy the file `SDL2.dll` on the same folder. The latest `SDL2.dll` can be found in the [Runtime binary for Windows 64-bit](https://www.libsdl.org/download-2.0.php).
To run in Windows, copy the file `SDL2.dll` on the same folder as `apple2sdl.exe`. The latest `SDL2.dll` can be found in the [Runtime binary for Windows 64-bit](https://www.libsdl.org/download-2.0.php).

2
dockerbuild/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
build

15
dockerbuild/Dockerfile Normal file
View File

@ -0,0 +1,15 @@
FROM circleci/golang:1.12
LABEL MAINTAINER="Ivan Izaguirre <ivanizag@gmail.com>"
RUN sudo apt-get update
RUN sudo apt-get install -y libsdl2-dev mingw-w64
RUN wget https://www.libsdl.org/release/SDL2-devel-2.0.9-mingw.tar.gz
RUN sudo tar -xzf SDL2-devel-2.0.9-mingw.tar.gz
RUN sudo cp -r SDL2-2.0.9/x86_64-w64-mingw32 /usr
COPY buildindocker.sh .
RUN sudo chmod +x buildindocker.sh
CMD ["./buildindocker.sh"]

5
dockerbuild/build.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
cd "$( dirname $0)"
docker build . -t apple2builder
mkdir -p ${PWD}/build
docker run --rm -it -v ${PWD}/build:/build apple2builder

View File

@ -0,0 +1,27 @@
#!/bin/bash
cd /tmp
git clone https://github.com/ivanizag/apple2
# Build apple2console for Linux
cd /tmp/apple2/apple2console
go build .
sudo chown --reference /build apple2console
sudo cp apple2console /build
# Build apple2console.exe for Windows
cd /tmp/apple2/apple2console
env CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc GOOS=windows CGO_LDFLAGS="-L/usr/x86_64-w64-mingw32/lib" CGO_FLAGS="-I/usr/x86_64-w64-mingw32/include -D_REENTRANT" go build -o apple2console.exe .
sudo chown --reference /build apple2console.exe
sudo cp apple2console.exe /build
# Build apple2sdl for Linux
cd /tmp/apple2/apple2sdl
go build .
sudo chown --reference /build apple2sdl
sudo cp apple2sdl /build
# Build apple2sdl.exe for Windows
cd /tmp/apple2/apple2sdl
env CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc GOOS=windows CGO_LDFLAGS="-L/usr/x86_64-w64-mingw32/lib -lSDL2" CGO_FLAGS="-I/usr/x86_64-w64-mingw32/include -D_REENTRANT" go build -o apple2sdl.exe .
sudo chown --reference /build apple2sdl.exe
sudo cp apple2sdl.exe /build