forked from electronicarts/CnC_Generals_Zero_Hour
-
Notifications
You must be signed in to change notification settings - Fork 118
Integrated docker based build #1774
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sherif181
wants to merge
3
commits into
TheSuperHackers:main
Choose a base branch
from
sherif181:feature/docker-build
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+195
−0
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| *.user | ||
| *.ncb | ||
| /build* | ||
| !/build.sh | ||
| nbproject/ | ||
| project/ | ||
| doxygen/ | ||
|
|
||
xezon marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| #!/bin/bash | ||
|
|
||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| usage() { | ||
| cat <<EOF | ||
| Usage: | ||
| $(basename "$0") [OPTIONS] [TARGET] | ||
|
|
||
| TARGET is passed to ninja.exe | ||
|
|
||
| Options: | ||
| -h, --help Show this help and exit | ||
| --cmake Force run cmake. | ||
| --bash Run the container interactively with bash entrypoint. | ||
|
|
||
| Examples: | ||
| $(basename "$0") | ||
| $(basename "$0") my_target | ||
| $(basename "$0") --cmake | ||
| $(basename "$0") --cmake my_target | ||
| $(basename "$0") --bash | ||
| EOF | ||
| } | ||
|
|
||
|
|
||
| FORCE_CMAKE="false" | ||
| MAKE_TARGET="" | ||
| INTERACTIVE="false" | ||
| while [[ $# -gt 0 ]]; do | ||
| case "$1" in | ||
| -h|--help) | ||
| usage | ||
| exit 0 | ||
| ;; | ||
| --cmake) | ||
| FORCE_CMAKE="true" | ||
| shift | ||
| ;; | ||
| --bash) | ||
| INTERACTIVE="true" | ||
| shift | ||
| ;; | ||
| --) # end of options | ||
| shift | ||
| break | ||
| ;; | ||
| -*) | ||
| echo "Unknown option: $1" >&2 | ||
| usage | ||
| exit 1 | ||
| ;; | ||
| *) | ||
| # Positional TARGET (accept only one) | ||
| MAKE_TARGET="$MAKE_TARGET $1" | ||
| shift | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| docker build --build-arg UID=$(id -u) --build-arg GID=$(id -g) dockerbuild -t zerohour-build | ||
| if [[ "$INTERACTIVE" == "true" ]]; then | ||
| FLAGS=" -it --entrypoint bash" | ||
| else | ||
| FLAGS="" | ||
| fi | ||
| docker run -u $(id -u):$(id -g) -e MAKE_TARGET="$MAKE_TARGET" -e FORCE_CMAKE=$FORCE_CMAKE -v "`pwd`":/build/cnc --rm $FLAGS zerohour-build | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| FROM debian:12.10-slim | ||
|
|
||
| # Build arguments | ||
| ARG CMAKE_VERSION="3.31.6" | ||
| ARG GIT_VERSION="2.49.0" | ||
| ARG UID | ||
| ARG GID | ||
|
|
||
| # Install utils | ||
| RUN apt update \ | ||
| && apt install wget gpg unzip git -y \ | ||
| && dpkg --add-architecture i386 \ | ||
| && apt clean \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Install wine | ||
| RUN mkdir -pm755 /etc/apt/keyrings \ | ||
| && (wget -O - https://dl.winehq.org/wine-builds/winehq.key | gpg --dearmor -o /etc/apt/keyrings/winehq-archive.key -) \ | ||
| && wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/debian/dists/bookworm/winehq-bookworm.sources \ | ||
| && apt update \ | ||
| && apt install --no-install-recommends winehq-stable -y \ | ||
| && apt clean \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
| # Setup build folder | ||
| RUN mkdir /build | ||
| RUN chown ${UID}:${GID} /build | ||
|
|
||
| USER ${UID}:${GID} | ||
| WORKDIR /build/tools | ||
|
|
||
| # Install cmake windows | ||
| RUN wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-windows-x86_64.zip \ | ||
| && unzip cmake-${CMAKE_VERSION}-windows-x86_64.zip -d /build/tools/ \ | ||
| && mv /build/tools/cmake-${CMAKE_VERSION}-windows-x86_64 /build/tools/cmake \ | ||
| && find /build/tools/ -name "*.zip" -exec rm -f {} + | ||
|
|
||
| # Install git windows | ||
| RUN wget https://github.com/git-for-windows/git/releases/download/v${GIT_VERSION}.windows.1/MinGit-${GIT_VERSION}-64-bit.zip \ | ||
| && unzip MinGit-${GIT_VERSION}-64-bit.zip -d /build/tools/ \ | ||
| && mv /build/tools/cmd /build/tools/git \ | ||
| && find /build/tools/ -name "*.zip" -exec rm -f {} + | ||
|
|
||
| # Install Visual Studio 6 Portable | ||
| RUN wget https://github.com/itsmattkc/MSVC600/archive/refs/heads/master.zip \ | ||
| && unzip master.zip -d /build/tools \ | ||
| && mv /build/tools/MSVC600-master/ /build/tools/vs6 \ | ||
| && find /build/tools/ -name "*.zip" -exec rm -f {} + | ||
|
|
||
|
|
||
| #Install ninja | ||
| RUN wget https://github.com/ninja-build/ninja/releases/download/v1.13.1/ninja-win.zip \ | ||
| && unzip ninja-win.zip -d /build/tools/ \ | ||
| && find /build/tools/ -name "*.zip" -exec rm -f {} + | ||
|
|
||
| # Setup wine prefix | ||
| ENV WINEDEBUG=-all | ||
| ENV WINEARCH=win64 | ||
| ENV WINEPREFIX=/build/prefix64 | ||
|
|
||
| # Create empty TEMP folder for linking | ||
| RUN mkdir /build/tmp | ||
| ENV TMP="Z:\\build\\tmp" | ||
| ENV TEMP="Z:\\build\\tmp" | ||
| ENV TEMPDIR="Z:\\build\\tmp" | ||
|
|
||
| # Setup Visual Studio 6 Environment variables | ||
| ENV VS="Z:\\build\\tools\\vs6" | ||
| ENV MSVCDir="$VS\\vc98" | ||
| ENV WINEPATH="C:\\windows\\system32;\ | ||
| $VS\\vc98\\bin;\ | ||
| $VS\\vc98\\lib;\ | ||
| $VS\\vc98\\include;\ | ||
| $VS\\common\\Tools;\ | ||
| $VS\\common\\MSDev98\\bin" | ||
| ENV LIB="$VS\\vc98\\Lib;$VS\\vc98\\MFC\\Lib;Z:\\build\\cnc\\build\\vc6" | ||
| ENV INCLUDE="$VS\\vc98\\ATL\\INCLUDE;\ | ||
| $VS\\vc98\\INCLUDE;\ | ||
| $VS\\vc98\\MFC\\INCLUDE;\ | ||
| $VS\\vc98\\Include" | ||
| ENV CC="$VS\\vc98\\bin\\CL.exe" | ||
| ENV CXX="$VS\\vc98\\bin\\CL.exe" | ||
| ENV PRESET=vc6 | ||
|
|
||
| #prevent cache warning | ||
| ENV HOME=/build/tmp/home | ||
| RUN mkdir /build/tmp/home | ||
|
|
||
| WORKDIR /build/cnc | ||
|
|
||
| USER root | ||
| COPY entrypoint.sh /entrypoint.sh | ||
| RUN chmod +x /entrypoint.sh | ||
| CMD /entrypoint.sh |
xezon marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
| cd /build/cnc | ||
| wineboot | ||
| if [ "${FORCE_CMAKE:-}" = "true" ] || [ ! -f build/docker/build.ninja ]; then | ||
| wine /build/tools/cmake/bin/cmake.exe \ | ||
| --preset ${PRESET} \ | ||
| -DCMAKE_SYSTEM="Windows" \ | ||
| -DCMAKE_SYSTEM_NAME="Windows" \ | ||
| -DCMAKE_SIZEOF_VOID_P=4 \ | ||
| -DCMAKE_MAKE_PROGRAM="Z:/build/tools/ninja.exe" \ | ||
| -DCMAKE_C_COMPILER="Z:/build/tools/vs6/vc98/bin/cl.exe" \ | ||
| -DCMAKE_CXX_COMPILER="Z:/build/tools/vs6/vc98/bin/cl.exe" \ | ||
| -DGIT_EXECUTABLE="Z:/build/tools/git/git.exe" \ | ||
| -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \ | ||
| -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \ | ||
| -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \ | ||
| -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY \ | ||
| -DCMAKE_DISABLE_PRECOMPILE_HEADERS=1 \ | ||
| -DCMAKE_C_COMPILER_WORKS=1 \ | ||
| -DCMAKE_CXX_COMPILER_WORKS=1 \ | ||
| -B /build/cnc/build/docker | ||
| fi | ||
|
|
||
| cd /build/cnc/build/docker | ||
| wine cmd /c "set TMP=Z:\build\tmp& set TEMP=Z:\build\tmp& Z:\build\tools\ninja.exe $MAKE_TARGET" | ||
|
|
||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change to .gitignore is no longer required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the docker files should not be too far from the build script but I will split it
But moving it like this causes a problem with the working dir
I can either :
scripts/dockerbuild.sh
having both will need some folder search magic
This will end up to be confusing
having it at least the build script in root makes easier to implement more usable and consistent -> there are 5 build related files and folders in the root (build,cmake....)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script shouldn't care what path its run from, it should detect its path and work out where other stuff is relative to itself. Relying on the current working dir is normally a bad idea and will just generate support requests when people run it wrong.
You already make use of basename to get the script name, using dirname will get you the containing folder (lets say scripts) and running direname on that folder would get you the top level project folder. You can then use that to construct the other paths you need.