Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions resources/dockerbuild/Dockerfile
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
28 changes: 28 additions & 0 deletions resources/dockerbuild/entrypoint.sh
Comment thread
xezon marked this conversation as resolved.
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"


78 changes: 78 additions & 0 deletions scripts/dockerbuild.sh
Comment thread
xezon marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/bin/bash
#!/usr/bin/env bash

set -euo pipefail

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
RESOURCES_DIR=$SCRIPT_DIR/../resources


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) $RESOURCES_DIR/dockerbuild -t zerohour-build

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mentions "zerohour-build". Does this mean it only builds zero hour, never generals?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested and it builds both targets, I believe its just the name the built container is assigned?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can name it to clarify that both games are in there?

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





Loading