Repository navigation
Expand file tree
/
Copy pathcpp.Dockerfile
More file actions
153 lines (136 loc) · 7.63 KB
/
Copy pathcpp.Dockerfile
File metadata and controls
153 lines (136 loc) · 7.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
FROM ubuntu:24.04
SHELL ["/bin/bash", "-c"]
ENV DEBIAN_FRONTEND=noninteractive
# ============================================================
# Install build tools: g++, cmake, make, git, curl, unzip,
# plus Clang 19 + Ninja for Windows cross-compile
# ============================================================
RUN apt-get update -qq && \
apt-get install -y -qq --no-install-recommends \
build-essential \
g++ \
cmake \
make \
ninja-build \
git \
curl \
ca-certificates \
unzip \
xz-utils \
pkg-config \
wget \
gnupg \
lsb-release \
software-properties-common \
&& rm -rf /var/lib/apt/lists/*
# Install LLVM/Clang 19 from the official LLVM repository
# (Ubuntu 24.04's default Clang 18 is too old for xwin's CRT headers)
RUN wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc && \
add-apt-repository -y "deb https://apt.llvm.org/$(lsb_release -sc)/ llvm-toolchain-$(lsb_release -sc)-19 main" && \
apt-get update -qq && \
apt-get install -y -qq --no-install-recommends \
clang-19 \
lld-19 \
llvm-19-dev \
libc++-19-dev \
libc++abi-19-dev \
clang-tidy-19 \
&& rm -rf /var/lib/apt/lists/*
# Set up symlinks so that /usr/bin/clang, /usr/bin/clang++, /usr/bin/lld etc. point to version 19
RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-19 100 && \
update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-19 100 && \
update-alternatives --install /usr/bin/lld lld /usr/bin/lld-19 100 && \
update-alternatives --install /usr/bin/ld.lld ld.lld /usr/bin/ld.lld-19 100 && \
update-alternatives --install /usr/bin/llvm-ar llvm-ar /usr/bin/llvm-ar-19 100 && \
update-alternatives --install /usr/bin/llvm-ranlib llvm-ranlib /usr/bin/llvm-ranlib-19 100 && \
update-alternatives --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-19 100 && \
update-alternatives --install /usr/bin/lld-link lld-link /usr/bin/lld-link-19 100 && \
update-alternatives --install /usr/bin/llvm-dlltool llvm-dlltool /usr/bin/llvm-dlltool-19 100 && \
update-alternatives --install /usr/bin/llvm-lib llvm-lib /usr/bin/llvm-lib-19 100
RUN git --version && g++ --version | head -1 && cmake --version | head -1 && clang++-19 --version | head -1
# ============================================================
# Create a clang-cl wrapper so Clang accepts MSVC-style flags (/EHsc etc.)
# This is static — no source dependency — so we do it early for caching.
# ============================================================
RUN mkdir -p /usr/local/bin && \
printf '#!/bin/bash\nexec /usr/bin/clang++ --driver-mode=cl -target x86_64-pc-windows-msvc "$@"\n' > /usr/local/bin/clang-cl && \
printf '#!/bin/bash\nexec /usr/bin/clang --driver-mode=cl -target x86_64-pc-windows-msvc "$@"\n' > /usr/local/bin/clang-cl-c && \
chmod +x /usr/local/bin/clang-cl /usr/local/bin/clang-cl-c
# ============================================================
# Install Rust + xwin – downloads the Windows CRT + SDK headers
# so Clang can target x86_64-pc-windows-msvc on Linux.
# ============================================================
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
| sh -s -- -y --no-modify-path
ENV PATH="/root/.cargo/bin:$PATH"
RUN cargo install xwin --locked
# Accepting the Microsoft license is required to download the SDK
# Also list the structure so we can fix paths
RUN xwin --accept-license splat --output /tmp/xwin && \
echo "=== xwin output structure ===" && \
find /tmp/xwin -type d | head -40 && \
echo "=== xwin lib files ===" && \
find /tmp/xwin -name "*.lib" | head -20
# Plain Bob builds download the shared CPU SDK. GPU builds require the helper's
# staged CUDA SDK; runtime DLLs stay in the user's existing bot-pack installation.
COPY build-support/libtorch/ /tmp/libtorch-win/
COPY cmake/ReadDevice.cmake /tmp/ReadDevice.cmake
COPY rlbot/device.txt /tmp/gglbot-device.txt
ARG LIBTORCH_WINDOWS_CPU_URL=https://github.com/VirxEC/pytorch-archive/releases/download/r-1/botpack_x86_64-windows.tar.xz
ARG LIBTORCH_WINDOWS_CPU_SHA256=ac228f5b25bb0caa4c8c378aeaa7ee5d9073c5d65945ac4c6f2ead6deae2aa05
RUN cmake -DDEVICE_FILE=/tmp/gglbot-device.txt -DOUTPUT_FILE=/tmp/gglbot-device \
-P /tmp/ReadDevice.cmake && \
if [ ! -d /tmp/libtorch-win/local ]; then \
if [ "$(cat /tmp/gglbot-device)" != cpu ]; then \
echo "GPU builds require a staged Windows CUDA LibTorch SDK. Run scripts/build_bob.py --libtorch <SDK>." >&2; \
exit 1; \
fi && \
curl -fSL --retry 3 -o /tmp/botpack-windows.tar.xz "$LIBTORCH_WINDOWS_CPU_URL" && \
echo "$LIBTORCH_WINDOWS_CPU_SHA256 /tmp/botpack-windows.tar.xz" | sha256sum -c - && \
mkdir -p /tmp/libtorch-win/local && \
tar -xJf /tmp/botpack-windows.tar.xz -C /tmp/libtorch-win/local --strip-components=2 \
torch-archive/torch/include \
torch-archive/torch/lib/torch.lib \
torch-archive/torch/lib/torch_cpu.lib \
torch-archive/torch/lib/c10.lib && \
rm -f /tmp/botpack-windows.tar.xz; \
fi && \
test -s /tmp/libtorch-win/local/include/torch/csrc/api/include/torch/version.h && \
test -s /tmp/libtorch-win/local/lib/torch.lib && \
test -s /tmp/libtorch-win/local/lib/torch_cpu.lib && \
test -s /tmp/libtorch-win/local/lib/c10.lib
# Linux CPU needs its platform's bot-pack archive. CUDA builds never fetch CPU archives.
ARG LIBTORCH_LINUX_CPU_URL=https://github.com/VirxEC/pytorch-archive/releases/download/r-1/botpack_x86_64-linux.tar.xz
ARG LIBTORCH_LINUX_CPU_SHA256=151319d9f9c9fa432f29e30677a5eb9585577ab1aa2a3d1dd96894ffa131cb61
RUN if [ "$(cat /tmp/gglbot-device)" = cpu ]; then \
curl -fSL --retry 3 -o /tmp/botpack-linux.tar.xz "$LIBTORCH_LINUX_CPU_URL" && \
echo "$LIBTORCH_LINUX_CPU_SHA256 /tmp/botpack-linux.tar.xz" | sha256sum -c - && \
mkdir -p /tmp/botpack-linux && \
tar -xJf /tmp/botpack-linux.tar.xz -C /tmp/botpack-linux && \
rm -f /tmp/botpack-linux.tar.xz; \
fi
WORKDIR /src
COPY . /src
RUN if [ "$(cat /tmp/gglbot-device)" = cpu ]; then \
cmake -S . -B build-linux -G Ninja \
-DCMAKE_BUILD_TYPE=Release -DGGLBOT_DEVICE=cpu -DBUILD_TESTING=OFF \
-DGGLBOT_DEPLOY_DIR=/out/x86_64-unknown-linux-gnu \
-DLIBTORCH_CPU_ROOT=/tmp/botpack-linux/torch-archive/torch && \
cmake --build build-linux --target GGLBot --parallel "$(nproc)"; \
fi
RUN sed -i '/Zc:preprocessor/d' /src/cpp-interface/library/CMakeLists.txt
RUN device="$(cat /tmp/gglbot-device)" && \
if [ "$device" = gpu ]; then root=LIBTORCH_CUDA_ROOT; core=GGLBotCoreCUDA; \
else root=LIBTORCH_CPU_ROOT; core=GGLBotCoreCPU; fi && \
cmake -S . -B build-win -G Ninja \
-DCMAKE_TOOLCHAIN_FILE=/src/cmake/toolchain-msvc.cmake \
-DCMAKE_BUILD_TYPE=Release -DGGLBOT_DEVICE="$device" -DBUILD_TESTING=OFF \
-DGGLBOT_DEPLOY_DIR=/out/x86_64-pc-windows-msvc \
-D"$root"=/tmp/libtorch-win/local && \
cmake --build build-win --target GGLBot --parallel "$(nproc)"
# Models and configuration belong to the shared root, where bob writes bot.toml.
# Never flatten same-named policies or put a second bot.toml under each platform.
RUN cmake -DSOURCE_PACKAGE=/src/rlbot -DDEST_PACKAGE=/out -P /src/cmake/StagePackage.cmake
# Sorting puts the core before the launcher, which bob uses as the entry point.
# Export only platforms produced by this build.
ENTRYPOINT ["tar", "--sort=name", "-C", "/out", "-cf", "-", "."]