|
| 1 | +FROM ubuntu:24.04 AS cross-base |
| 2 | +ENV DEBIAN_FRONTEND=noninteractive |
| 3 | + |
| 4 | +RUN apt-get update && apt-get install --assume-yes --no-install-recommends git ca-certificates |
| 5 | + |
| 6 | +RUN git clone https://github.com/cross-rs/cross |
| 7 | +WORKDIR cross/docker |
| 8 | +RUN git checkout 9e2298e17170655342d3248a9c8ac37ef92ba38f |
| 9 | + |
| 10 | +RUN cp common.sh lib.sh / && /common.sh |
| 11 | +RUN cp cmake.sh / && /cmake.sh |
| 12 | +RUN cp xargo.sh / && /xargo.sh |
| 13 | + |
| 14 | +FROM cross-base AS build |
| 15 | + |
| 16 | +RUN dpkg --add-architecture i386 && apt-get install --assume-yes --no-install-recommends libz-mingw-w64-dev |
| 17 | + |
| 18 | +RUN cp wine.sh / && /wine.sh |
| 19 | + |
| 20 | +RUN apt-get install --assume-yes --no-install-recommends g++-mingw-w64-x86-64 gfortran-mingw-w64-x86-64 llvm-dev libclang-10-dev clang-10 |
| 21 | + |
| 22 | +# run-detectors are responsible for calling the correct interpreter for exe |
| 23 | +# files. For some reason it does not work inside a docker container (it works |
| 24 | +# fine in the host). So we replace the usual paths of run-detectors to run wine |
| 25 | +# directly. This only affects the guest, we are not messing up with the host. |
| 26 | +# |
| 27 | +# See /usr/share/doc/binfmt-support/detectors |
| 28 | +RUN mkdir -p /usr/lib/binfmt-support/ && \ |
| 29 | + rm -f /usr/lib/binfmt-support/run-detectors /usr/bin/run-detectors && \ |
| 30 | + ln -s /usr/bin/wine /usr/lib/binfmt-support/run-detectors && \ |
| 31 | + ln -s /usr/bin/wine /usr/bin/run-detectors |
| 32 | + |
| 33 | +RUN cp windows-entry.sh / |
| 34 | +ENTRYPOINT ["/windows-entry.sh"] |
| 35 | + |
| 36 | +RUN cp cross/docker/toolchain.cmake /opt/toolchain.cmake |
| 37 | + |
| 38 | +# for why we always link with pthread support, see: |
| 39 | +# https://github.com/cross-rs/cross/pull/1123#issuecomment-1312287148 |
| 40 | +ENV CROSS_TOOLCHAIN_PREFIX=x86_64-w64-mingw32- |
| 41 | +ENV CROSS_TOOLCHAIN_SUFFIX=-posix |
| 42 | +ENV CROSS_SYSROOT=/usr/x86_64-w64-mingw32 |
| 43 | +ENV CROSS_TARGET_RUNNER="env -u CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUNNER wine" |
| 44 | +ENV CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc"$CROSS_TOOLCHAIN_SUFFIX" \ |
| 45 | + CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUNNER="$CROSS_TARGET_RUNNER" \ |
| 46 | + AR_x86_64_pc_windows_gnu="$CROSS_TOOLCHAIN_PREFIX"ar \ |
| 47 | + CC_x86_64_pc_windows_gnu="$CROSS_TOOLCHAIN_PREFIX"gcc"$CROSS_TOOLCHAIN_SUFFIX" \ |
| 48 | + CXX_x86_64_pc_windows_gnu="$CROSS_TOOLCHAIN_PREFIX"g++"$CROSS_TOOLCHAIN_SUFFIX" \ |
| 49 | + CMAKE_TOOLCHAIN_FILE_x86_64_pc_windows_gnu=/opt/toolchain.cmake \ |
| 50 | + BINDGEN_EXTRA_CLANG_ARGS_x86_64_pc_windows_gnu="--sysroot=$CROSS_SYSROOT -idirafter/usr/include" \ |
| 51 | + CROSS_CMAKE_SYSTEM_NAME=Windows \ |
| 52 | + CROSS_CMAKE_SYSTEM_PROCESSOR=AMD64 \ |
| 53 | + CROSS_CMAKE_CRT=gnu \ |
| 54 | + CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -m64" |
0 commit comments