From 50c00eafeb35edb0c302453577ad560390d8399d Mon Sep 17 00:00:00 2001 From: Christian Wimmer Date: Sun, 16 Apr 2023 18:05:25 +0200 Subject: [PATCH 1/3] Added CICD --- .cicd/.dockerignore | 24 ++++++++++++++++++++++++ .cicd/.gitattributes | 1 + .cicd/docker-compose.yml | 8 ++++++++ .cicd/dockerfile | 30 ++++++++++++++++++++++++++++++ .cicd/package.json | 12 ++++++++++++ .cicd/runenv.sh | 12 ++++++++++++ 6 files changed, 87 insertions(+) create mode 100644 .cicd/.dockerignore create mode 100644 .cicd/.gitattributes create mode 100644 .cicd/docker-compose.yml create mode 100644 .cicd/dockerfile create mode 100644 .cicd/package.json create mode 100644 .cicd/runenv.sh diff --git a/.cicd/.dockerignore b/.cicd/.dockerignore new file mode 100644 index 0000000..95520b4 --- /dev/null +++ b/.cicd/.dockerignore @@ -0,0 +1,24 @@ +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/bin +**/charts +**/docker-compose* +**/compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +README.md diff --git a/.cicd/.gitattributes b/.cicd/.gitattributes new file mode 100644 index 0000000..7418f43 --- /dev/null +++ b/.cicd/.gitattributes @@ -0,0 +1 @@ +runenv.sh text eol=lf \ No newline at end of file diff --git a/.cicd/docker-compose.yml b/.cicd/docker-compose.yml new file mode 100644 index 0000000..f87fcb9 --- /dev/null +++ b/.cicd/docker-compose.yml @@ -0,0 +1,8 @@ +version: '3.4' + +services: + build: + image: build + build: + context: . + dockerfile: ./Dockerfile diff --git a/.cicd/dockerfile b/.cicd/dockerfile new file mode 100644 index 0000000..53d23d8 --- /dev/null +++ b/.cicd/dockerfile @@ -0,0 +1,30 @@ +FROM wimmercg/lazarus-docker:1.1.0 +#FROM lazarus-base + +LABEL Name="FCP Source and Lazarus Git main, Linux64 and Win32, Win64 crosscompile with lazbuild" + +RUN apt update && apt install subversion -y +RUN mkdir /build && mkdir source && mkdir -p /temp + +RUN git clone https://github.com/PascalCorpsman/fpc_atomic.git /source/fpc_atomic +RUN wget https://www.un4seen.com/files/bass24.zip && unzip -j bass24.zip x64/bass.dll -d /temp && unzip -j bass24.zip delphi/bass.pas -d /source/fpc_atomic +RUN mkdir -p /source/fpc_atomic/lib/x86_64-linux && wget https://www.un4seen.com/files/bass24-linux.zip && unzip -j bass24-linux.zip libs/x86_64/libbass.so -d /source/fpc_atomic/ + +RUN wget https://raw.githubusercontent.com/SaschaWillems/dglOpenGL/master/dglOpenGL.pas -O /source/fpc_atomic/dglOpenGL.pas + +RUN mkdir -p /source/synapse && cd /source/synapse && svn checkout https://svn.code.sf.net/p/synalist/code/trunk . && mv /source/synapse/* /source/fpc_atomic/ + +# build linux 64 +RUN echo "cd /source/fpc_atomic/ && lazbuildl64 fpc_atomic.lpi && mv fpc_atomic /build" > /bl.sh && chmod 777 /bl.sh + +#RUN cd $LAZARUSDIR && ./lazbuild --add-package /source/synapse/laz_synapse.lpk --primary-config-path=$LAZARUSDIR --lazarusdir=$LAZARUSDIR +RUN echo "URL_CheckForUpdate = '';" > /source/fpc_atomic/updater_link.inc + +RUN /install_corpsman_lnet.sh + + + +COPY runenv.sh /runenv.sh +RUN chmod 777 /runenv.sh + +CMD /runenv.sh \ No newline at end of file diff --git a/.cicd/package.json b/.cicd/package.json new file mode 100644 index 0000000..3846af5 --- /dev/null +++ b/.cicd/package.json @@ -0,0 +1,12 @@ +{ + "name": "build", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "make": "docker build . -t atomic", + "run": "(docker container rm atomic || true) && docker run --name atomic atomic ", + "it": "docker run -it atomic /bin/bash" + }, + "author": "" +} diff --git a/.cicd/runenv.sh b/.cicd/runenv.sh new file mode 100644 index 0000000..800b099 --- /dev/null +++ b/.cicd/runenv.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +cd /fpc_atomic +git pull + +cp /temp/bass.dll /build/ + +cd /source/fpc_atomic/ && lazbuildl64 fpc_atomic.lpi && mv fpc_atomic /build +cd /source/fpc_atomic/ && lazbuildw64 fpc_atomic.lpi && mv fpc_atomic.exe /build +cd /source/fpc_atomic/ && lazbuildw32 fpc_atomic.lpi && mv fpc_atomic.exe /build/fpc_atomic32.exe + +cd /source/cd_data_extractor && lazbuildl64 cd_data_extractor.lpi && mv cd_data_extractor /build \ No newline at end of file From 0c7e9e8c4eedba87b777f7cfb36a4dfd33e8fbab Mon Sep 17 00:00:00 2001 From: Christian Wimmer Date: Sun, 16 Apr 2023 19:26:39 +0200 Subject: [PATCH 2/3] Simple CI/CD for building the game --- .cicd/.gitignore | 3 +++ .cicd/AtomicGameRoot/.empty | 0 .cicd/build/.empty | 0 .cicd/docker-compose.yml | 17 ++++++++++----- .cicd/dockerfile | 16 ++++----------- .cicd/mountAtomicRoot.sh | 4 ++++ .cicd/runenv.sh | 41 ++++++++++++++++++++++++++++++++----- 7 files changed, 59 insertions(+), 22 deletions(-) create mode 100644 .cicd/.gitignore create mode 100644 .cicd/AtomicGameRoot/.empty create mode 100644 .cicd/build/.empty create mode 100644 .cicd/mountAtomicRoot.sh diff --git a/.cicd/.gitignore b/.cicd/.gitignore new file mode 100644 index 0000000..e39a2b6 --- /dev/null +++ b/.cicd/.gitignore @@ -0,0 +1,3 @@ +build/* +AtomicGameRoot/* +*.zip diff --git a/.cicd/AtomicGameRoot/.empty b/.cicd/AtomicGameRoot/.empty new file mode 100644 index 0000000..e69de29 diff --git a/.cicd/build/.empty b/.cicd/build/.empty new file mode 100644 index 0000000..e69de29 diff --git a/.cicd/docker-compose.yml b/.cicd/docker-compose.yml index f87fcb9..5ee678f 100644 --- a/.cicd/docker-compose.yml +++ b/.cicd/docker-compose.yml @@ -1,8 +1,15 @@ version: '3.4' services: - build: - image: build - build: - context: . - dockerfile: ./Dockerfile + atomic: + image: atomic + volumes: + - /d/Projekte/fpc_atomic/bomber/:/AtomicGameRoot + - ${PWD}/build:/build + tty: true + stdin_open: true + environment: + - ATOMIC_BUILD_WIN64=true + - ATOMIC_BUILD_WIN32=true + - ATOMIC_BUILD_LINUX=true + - ATOMIC_EXTRA_ANI=true diff --git a/.cicd/dockerfile b/.cicd/dockerfile index 53d23d8..92fccf0 100644 --- a/.cicd/dockerfile +++ b/.cicd/dockerfile @@ -4,25 +4,17 @@ FROM wimmercg/lazarus-docker:1.1.0 LABEL Name="FCP Source and Lazarus Git main, Linux64 and Win32, Win64 crosscompile with lazbuild" RUN apt update && apt install subversion -y -RUN mkdir /build && mkdir source && mkdir -p /temp +RUN mkdir /build && mkdir -p /source && mkdir -p /temp +# FPC-Atomic GIT clone RUN git clone https://github.com/PascalCorpsman/fpc_atomic.git /source/fpc_atomic +# Pre-Requisites for FPC-Atomic RUN wget https://www.un4seen.com/files/bass24.zip && unzip -j bass24.zip x64/bass.dll -d /temp && unzip -j bass24.zip delphi/bass.pas -d /source/fpc_atomic RUN mkdir -p /source/fpc_atomic/lib/x86_64-linux && wget https://www.un4seen.com/files/bass24-linux.zip && unzip -j bass24-linux.zip libs/x86_64/libbass.so -d /source/fpc_atomic/ - RUN wget https://raw.githubusercontent.com/SaschaWillems/dglOpenGL/master/dglOpenGL.pas -O /source/fpc_atomic/dglOpenGL.pas - RUN mkdir -p /source/synapse && cd /source/synapse && svn checkout https://svn.code.sf.net/p/synalist/code/trunk . && mv /source/synapse/* /source/fpc_atomic/ - -# build linux 64 -RUN echo "cd /source/fpc_atomic/ && lazbuildl64 fpc_atomic.lpi && mv fpc_atomic /build" > /bl.sh && chmod 777 /bl.sh - -#RUN cd $LAZARUSDIR && ./lazbuild --add-package /source/synapse/laz_synapse.lpk --primary-config-path=$LAZARUSDIR --lazarusdir=$LAZARUSDIR -RUN echo "URL_CheckForUpdate = '';" > /source/fpc_atomic/updater_link.inc - RUN /install_corpsman_lnet.sh - - +RUN echo "URL_CheckForUpdate = '';" > /source/fpc_atomic/updater_link.inc COPY runenv.sh /runenv.sh RUN chmod 777 /runenv.sh diff --git a/.cicd/mountAtomicRoot.sh b/.cicd/mountAtomicRoot.sh new file mode 100644 index 0000000..739faf2 --- /dev/null +++ b/.cicd/mountAtomicRoot.sh @@ -0,0 +1,4 @@ +#!/bin/bash +#docker run -it -v /${PWD}/AtomicGameRoot:/AtomicGameRoot -v /${PWD}/build:/build atomic bash +#docker run -it -v //d/Projekte/fpc_atomic/bomber/:/AtomicGameRoot -v /${PWD}/build:/build atomic bash +docker-compose -f docker-compose.yml up \ No newline at end of file diff --git a/.cicd/runenv.sh b/.cicd/runenv.sh index 800b099..e462216 100644 --- a/.cicd/runenv.sh +++ b/.cicd/runenv.sh @@ -1,12 +1,43 @@ #!/bin/bash +set -x -cd /fpc_atomic +cd /source/fpc_atomic git pull +rm -r /build/* +mkdir -p /build/DATA cp /temp/bass.dll /build/ -cd /source/fpc_atomic/ && lazbuildl64 fpc_atomic.lpi && mv fpc_atomic /build -cd /source/fpc_atomic/ && lazbuildw64 fpc_atomic.lpi && mv fpc_atomic.exe /build -cd /source/fpc_atomic/ && lazbuildw32 fpc_atomic.lpi && mv fpc_atomic.exe /build/fpc_atomic32.exe +if [ "$ATOMIC_BUILD_LINUX" == "true" ] +then + cd /source/fpc_atomic/ && lazbuildl64 fpc_atomic.lpi && mv fpc_atomic /build +fi -cd /source/cd_data_extractor && lazbuildl64 cd_data_extractor.lpi && mv cd_data_extractor /build \ No newline at end of file +if [ "$ATOMIC_BUILD_WIN64" == "true" ] +then + cd /source/fpc_atomic/ && lazbuildw64 fpc_atomic.lpi && mv fpc_atomic.exe /build +fi + +if [ "$ATOMIC_BUILD_WIN32" == "true" ] +then + cd /source/fpc_atomic/ && lazbuildw32 fpc_atomic.lpi && mv fpc_atomic.exe /build/fpc_atomic32.exe +fi + +if [ -z "$(ls -A /AtomicGameRoot)" ] +then + echo "/AtomicGameRoot is empty" +else + echo Found AtomicGameRoot DATA. Copying to build/DATA folder + + cd /source/fpc_atomic/cd_data_extractor && lazbuildl64 cd_data_extractor.lpi && mv cd_data_extractor /build + # TODO: executing a CLI version of cd_data_extractor to convert data from /AtomicGameRoot/DATA/ to /build/DATA/ + + # cp -r /AtomicGameRoot/DATA/* /build/DATA/ + + if [ "$ATOMIC_EXTRA_ANI" == "true" ] + then + echo Download extra content + wget https://www.oocities.org/timessquare/tower/4056/download/ani.zip --no-check-certificate -O /temp/ani.zip && unzip -jo /temp/ani.zip -d /build/DATA/ANI + fi +fi + From 6682342b7cf7ea789424b5d1d9c25f5e931ca270 Mon Sep 17 00:00:00 2001 From: Christian Wimmer Date: Sun, 23 Apr 2023 20:39:27 +0200 Subject: [PATCH 3/3] Build script finished. --- .cicd/docker-compose.yml | 12 +++++++----- .cicd/dockerfile | 4 ++-- .cicd/package.json | 3 ++- .cicd/runenv.sh | 7 ++++++- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/.cicd/docker-compose.yml b/.cicd/docker-compose.yml index 5ee678f..55dea77 100644 --- a/.cicd/docker-compose.yml +++ b/.cicd/docker-compose.yml @@ -3,13 +3,15 @@ version: '3.4' services: atomic: image: atomic + container_name: atomic volumes: - - /d/Projekte/fpc_atomic/bomber/:/AtomicGameRoot + - /d/Projekte/fpc_atomic/bomber/:/AtomicGameRoot:ro - ${PWD}/build:/build - tty: true - stdin_open: true environment: - - ATOMIC_BUILD_WIN64=true - - ATOMIC_BUILD_WIN32=true + - ATOMIC_BUILD_WIN64=false + - ATOMIC_BUILD_WIN32=false - ATOMIC_BUILD_LINUX=true - ATOMIC_EXTRA_ANI=true + #tty: true + #stdin_open: true + #command: bash diff --git a/.cicd/dockerfile b/.cicd/dockerfile index 92fccf0..b7e756c 100644 --- a/.cicd/dockerfile +++ b/.cicd/dockerfile @@ -11,10 +11,10 @@ RUN git clone https://github.com/PascalCorpsman/fpc_atomic.git /source/fpc_atomi # Pre-Requisites for FPC-Atomic RUN wget https://www.un4seen.com/files/bass24.zip && unzip -j bass24.zip x64/bass.dll -d /temp && unzip -j bass24.zip delphi/bass.pas -d /source/fpc_atomic RUN mkdir -p /source/fpc_atomic/lib/x86_64-linux && wget https://www.un4seen.com/files/bass24-linux.zip && unzip -j bass24-linux.zip libs/x86_64/libbass.so -d /source/fpc_atomic/ -RUN wget https://raw.githubusercontent.com/SaschaWillems/dglOpenGL/master/dglOpenGL.pas -O /source/fpc_atomic/dglOpenGL.pas +RUN wget https://raw.githubusercontent.com/SaschaWillems/dglOpenGL/master/dglOpenGL.pas -O /source/fpc_atomic/dglOpenGL.pas && cp /source/fpc_atomic/dglOpenGL.pas /source/fpc_atomic/cd_data_extractor/ + RUN mkdir -p /source/synapse && cd /source/synapse && svn checkout https://svn.code.sf.net/p/synalist/code/trunk . && mv /source/synapse/* /source/fpc_atomic/ RUN /install_corpsman_lnet.sh -RUN echo "URL_CheckForUpdate = '';" > /source/fpc_atomic/updater_link.inc COPY runenv.sh /runenv.sh RUN chmod 777 /runenv.sh diff --git a/.cicd/package.json b/.cicd/package.json index 3846af5..f6eda58 100644 --- a/.cicd/package.json +++ b/.cicd/package.json @@ -6,7 +6,8 @@ "scripts": { "make": "docker build . -t atomic", "run": "(docker container rm atomic || true) && docker run --name atomic atomic ", - "it": "docker run -it atomic /bin/bash" + "it": "docker run -it atomic /bin/bash", + "up": "docker compose up -d && docker exec -it cicd_atomic_1 bash ; docker compose down" }, "author": "" } diff --git a/.cicd/runenv.sh b/.cicd/runenv.sh index e462216..efafc07 100644 --- a/.cicd/runenv.sh +++ b/.cicd/runenv.sh @@ -29,9 +29,14 @@ then else echo Found AtomicGameRoot DATA. Copying to build/DATA folder - cd /source/fpc_atomic/cd_data_extractor && lazbuildl64 cd_data_extractor.lpi && mv cd_data_extractor /build + cd /source/fpc_atomic/cd_data_extractor && lazbuildl64 cd_data_extractor_nogui.lpi && lazbuildw64 cd_data_extractor_nogui.lpi # TODO: executing a CLI version of cd_data_extractor to convert data from /AtomicGameRoot/DATA/ to /build/DATA/ + cp cd_data_extractor_nogui /build + cp cd_data_extractor_nogui.exe /build + + # not working due to gtk error on linux + #./cd_data_extractor_nogui -cd /AtomicGameRoot -atomic /build # cp -r /AtomicGameRoot/DATA/* /build/DATA/ if [ "$ATOMIC_EXTRA_ANI" == "true" ]