builder-cross-windows/Dockerfile

229 lines
17 KiB
Docker

# SPDX-FileCopyrightText: 2023 - 2024 Daniel Wolf <nephatrine@gmail.com>
#
# SPDX-License-Identifier: ISC
FROM code.nephatrine.net/nephnet/nxb-debian:llvm-stable AS winebox
ENV WINEDEBUG=fixme-all \
WINE=/usr/bin/wine \
WINEPREFIX=/opt/wine \
WINESERVER=/usr/bin/wineserver
ARG DEBIAN_FRONTEND=noninteractive
RUN echo "====== INSTALL WINE ======" \
&& if [ "$(uname -m)" = "x86_64" ]; then dpkg --add-architecture i386; fi \
&& apt-get update \
&& if [ "$(uname -m)" = "i686" ]; then export WINEARCH=win32; else export WINEARCH=win64; fi \
&& if [ ! "$(uname -m)" = "aarch64" ]; then apt-get -o Dpkg::Options::="--force-confnew" install -y --no-install-recommends wine32; fi \
&& if [ ! "$(uname -m)" = "i686" ]; then apt-get -o Dpkg::Options::="--force-confnew" install -y --no-install-recommends wine64; fi \
&& apt-get -o Dpkg::Options::="--force-confnew" install -y --no-install-recommends wine wine-binfmt \
&& apt-get autoremove -y && apt-get clean \
&& export WINEDLLOVERRIDES="mscoree,mshtml=" \
&& DISPLAY="${WINE}" wineboot --init \
&& while pgrep -f "${WINESERVER}" >/dev/null; do sleep 5; done \
&& rm -rf /tmp/* /var/tmp/*
ENV WINDOWS_SYSROOT=${WINEPREFIX}/drive_c
RUN echo "====== INSTALL PACKAGING TOOLS ======" \
&& apt-get -o Dpkg::Options::="--force-confnew" install -y --no-install-recommends msitools osslsigncode wixl \
&& if [ ! "$(uname -m)" = "aarch64" ]; then apt-get -o Dpkg::Options::="--force-confnew" install -y --no-install-recommends nsis; fi \
&& apt-get autoremove -y && apt-get clean \
&& rm -rf /tmp/* /var/tmp/*
RUN echo "====== BUILD MSIX TOOLS ======" \
&& if [ ! "$(uname -m)" = "i686" ]; then git -C "${HOME}" clone --single-branch --depth=1 https://github.com/microsoft/msix-packaging.git \
&& cd "${HOME}/msix-packaging" && ./makelinux.sh --pack --validation-parser --skip-samples --skip-tests \
&& mkdir "/usr/local/lib/$(uname -m)-linux-gnu" && cp -nv .vs/lib/*.so "/usr/local/lib/$(uname -m)-linux-gnu/" && ldconfig \
&& cp -nv .vs/bin/makemsix /usr/local/bin/ \
&& rm -rf /tmp/* /var/tmp/* "${HOME}/msix-packaging"; fi
FROM winebox AS mingw
LABEL maintainer="Daniel Wolf <nephatrine@gmail.com>"
RUN echo "====== BUILD UASM ======" \
&& git -C "${HOME}" clone --single-branch --depth=1 -b 'v2.56' https://github.com/Terraspace/UASM.git \
&& cd "${HOME}/UASM" \
&& make -j$(( $(getconf _NPROCESSORS_ONLN) / 2 + 1 )) -f gccLinux64.mak \
&& cp GccUnixR/uasm /usr/local/bin/ \
&& cd .. && rm -rf /tmp/* /var/tmp/* "${HOME}/UASM"
ENV WINDOWS_TOOLCHAIN=/opt/llvm-mingw
RUN echo "====== BUILD LLVM-MINGW ======" \
&& git -C "${HOME}" clone --single-branch --depth=1 -b '20240320' https://github.com/mstorsjo/llvm-mingw.git \
&& cd "${HOME}/llvm-mingw" \
&& export LLVM_VERSION="release/${LLVM_MAJOR}.x" \
&& export TOOLCHAIN_ARCHS="$(uname -m)" \
&& if [ "$(uname -m)" = "x86_64" ]; then export TOOLCHAIN_ARCHS="${TOOLCHAIN_ARCHS} i686"; fi \
&& if [ "$(uname -m)" = "aarch64" ]; then sed -i 's~continue~~g' build-compiler-rt.sh; fi \
&& ./build-all.sh "${WINDOWS_TOOLCHAIN}" --host-clang="clang-${LLVM_MAJOR}" --with-default-msvcrt=ucrt --enable-cfguard \
&& export PATH="${WINDOWS_TOOLCHAIN}/bin:$PATH" \
&& cp -nrvs ${WINDOWS_TOOLCHAIN}/$(uname -m)-w64-mingw32/bin/*.dll "${WINDOWS_SYSROOT}/windows/system32/" \
&& ln -s "${WINDOWS_TOOLCHAIN}/$(uname -m)-w64-mingw32" "${WINDOWS_SYSROOT}/$(uname -m)-w64-mingw32" \
&& if [ "$(uname -m)" = "x86_64" ]; then cp -nrvs ${WINDOWS_TOOLCHAIN}/i686-w64-mingw32/bin/*.dll "${WINDOWS_SYSROOT}/windows/syswow64/" \
&& ln -s "${WINDOWS_TOOLCHAIN}/i686-w64-mingw32" "${WINDOWS_SYSROOT}/i686-w64-mingw32"; fi \
&& cd .. && rm -rf /tmp/* /var/tmp/* "${HOME}/llvm-mingw"
ARG DEBIAN_FRONTEND=noninteractive
RUN echo "====== INSTALL MINGW-W64 ======" \
&& if [ "$(uname -m)" = "x86_64" ]; then apt-get -o Dpkg::Options::="--force-confnew" install -y --no-install-recommends mingw-w64 mingw-w64-tools \
&& apt-get autoremove -y && apt-get clean \
&& cp -nrvs /usr/x86_64-w64-mingw32/lib/*.dll /usr/lib/gcc/x86_64-w64-mingw32/12-posix/*.dll "${WINDOWS_SYSROOT}/windows/system32/" \
&& cp -nrvs /usr/i686-w64-mingw32/lib/*.dll /usr/lib/gcc/i686-w64-mingw32/12-posix/*.dll "${WINDOWS_SYSROOT}/windows/syswow64/" \
&& rm -rf /tmp/* /var/tmp/*; fi \
&& if [ "$(uname -m)" = "i686" ]; then apt-get -o Dpkg::Options::="--force-confnew" install -y --no-install-recommends mingw-w64 mingw-w64-tools \
&& apt-get autoremove -y && apt-get clean \
&& cp -nrvs /usr/i686-w64-mingw32/lib/*.dll /usr/lib/gcc/i686-w64-mingw32/12-posix/*.dll "${WINDOWS_SYSROOT}/windows/system32/" \
&& rm -rf /tmp/* /var/tmp/*; fi
COPY override /
RUN echo "====== TEST TOOLCHAINS ======" \
&& . /opt/wine/winearch \
&& git -C "${HOME}" clone --single-branch --depth=1 https://code.nephatrine.net/nephatrine/hello-test.git \
&& if [ ! "$(uname -m)" = "aarch64" ]; then mkdir "/tmp/build-$(uname -m)-gnu" && cd "/tmp/build-$(uname -m)-gnu" \
&& "nxbuild-windows-$(uname -m)-gnu" -GNinja "${HOME}/hello-test" \
&& ninja && "${WINE}" ./HelloTest.exe; fi \
&& if [ "$(uname -m)" = "x86_64" ]; then mkdir /tmp/build-i686-gnu && cd /tmp/build-i686-gnu \
&& nxbuild-windows-i686-gnu -GNinja "${HOME}/hello-test" \
&& ninja && "${WINE}" ./HelloTest.exe; fi \
&& mkdir "/tmp/build-$(uname -m)-llvm" && cd "/tmp/build-$(uname -m)-llvm" \
&& "nxbuild-windows-$(uname -m)-llvm" -GNinja "${HOME}/hello-test" \
&& ninja && "${WINE}" ./HelloTest.exe \
&& if [ "$(uname -m)" = "x86_64" ]; then mkdir /tmp/build-i686-llvm && cd /tmp/build-i686-llvm \
&& nxbuild-windows-i686-llvm -GNinja "${HOME}/hello-test" \
&& ninja && "${WINE}" ./HelloTest.exe; fi \
&& cd .. && rm -rf /tmp/* /var/tmp/* "${HOME}/hello-test"
FROM winebox
LABEL maintainer="Daniel Wolf <nephatrine@gmail.com>"
ENV WindowsSdkDir="${WINEPREFIX}/drive_c/Program Files (x86)/Windows Kits/10" \
VSINSTALLDIR="${WINEPREFIX}/drive_c/Program Files/Microsoft Visual Studio/2022/Community" \
VCINSTALLDIR="${WINEPREFIX}/drive_c/Program Files/Microsoft Visual Studio/2022/Community/VC"
RUN echo "====== INSTALL MSVC-WINE ======" \
&& git -C "${HOME}" clone --single-branch --depth=1 https://github.com/mstorsjo/msvc-wine.git \
&& mkdir /tmp/msvc-staging /tmp/msvc-cache \
&& echo "Microsoft.VisualStudio.Workload.NativeDesktop" >>"${WINEPREFIX}/drive_c/packages-input-pass1.txt" \
&& echo "Microsoft.VisualStudio.Workload.Universal" >>"${WINEPREFIX}/drive_c/packages-input-pass1.txt" \
&& cat "${WINEPREFIX}/drive_c/packages-input-pass1.txt" \
| xargs python3 "${HOME}/msvc-wine/vsdownload.py" --accept-license --major 17 --sdk-version 20348 --include-optional --print-selection >"${WINEPREFIX}/drive_c/packages-output-pass1.txt" \
&& cat "${WINEPREFIX}/drive_c/packages-input-pass1.txt" \
| xargs -I{} sed -i "s~^{} ~FILTERED ~g" "${WINEPREFIX}/drive_c/packages-output-pass1.txt" \
&& if [ "$(uname -m)" = "x86_64" ]; then cat "${WINEPREFIX}/drive_c/packages-output-pass1.txt" \
| egrep '^Microsoft.|^Win..SDK' \
| egrep '^Microsoft\.Windows|\.VC\.|\.VisualC\.|\.VisualCpp\.|\.20348' \
| egrep -v '\.ATL[. ]|\.CA\.|\.CodeAnalysis|\.CoreIDE|\.IFC[. ]|\.MFC[. ]|\.Modules|\.MSBuild|\.Premium|\.Prem[. ]|\.Props[. ]|\.Resources|\.Res[. ]|\.Servicing|\.Shortcuts|\.Templates|\.TestAdapter|\.VisualStudio\.VC.[^L][^l]' \
| egrep -v '14\.[12].\.|[Aa][Rr][Mm][. ]|[Aa][Rr][Mm]64[Ee. ]|Host[Xx]86|\(Ms[iu]\)' >"${WINEPREFIX}/drive_c/packages-selected-pass1.txt"; fi \
&& if [ "$(uname -m)" = "i686" ]; then cat "${WINEPREFIX}/drive_c/packages-output-pass1.txt" \
| egrep '^Microsoft.|^Win..SDK' \
| egrep '^Microsoft\.Windows|\.VC\.|\.VisualC\.|\.VisualCpp\.|\.20348' \
| egrep -v '\.ATL[. ]|\.CA\.|\.CodeAnalysis|\.CoreIDE|\.IFC[. ]|\.MFC[. ]|\.Modules|\.MSBuild|\.Premium|\.Prem[. ]|\.Props[. ]|\.Resources|\.Res[. ]|\.Servicing|\.Shortcuts|\.Templates|\.TestAdapter|\.VisualStudio\.VC.[^L][^l]' \
| egrep -v '14\.[12].\.|[Aa][Rr][Mm][. ]|[Aa][Rr][Mm]64[Ee. ]|[Xx]64[. ]|\(Ms[iu]\)' >"${WINEPREFIX}/drive_c/packages-selected-pass1.txt"; fi \
&& if [ "$(uname -m)" = "aarch64" ]; then cat "${WINEPREFIX}/drive_c/packages-output-pass1.txt" \
| egrep '^Microsoft.|^Win..SDK' \
| egrep '^Microsoft\.Windows|\.VC\.|\.VisualC\.|\.VisualCpp\.|\.20348' \
| egrep -v '\.ATL[. ]|\.CA\.|\.CodeAnalysis|\.CoreIDE|\.IFC[. ]|\.MFC[. ]|\.Modules|\.MSBuild|\.Premium|\.Prem[. ]|\.Props[. ]|\.Resources|\.Res[. ]|\.Servicing|\.Shortcuts|\.Templates|\.TestAdapter|\.VisualStudio\.VC.[^L][^l]' \
| egrep -v '14\.[12].\.|[Aa][Rr][Mm][. ]|[Xx]86[. ]|[Xx]64[. ]|\(Ms[iu]\)' >"${WINEPREFIX}/drive_c/packages-selected-pass1.txt"; fi \
&& cat "${WINEPREFIX}/drive_c/packages-selected-pass1.txt" \
| grep ' 0 bytes' | awk '{print $1}' | sort -u >"${WINEPREFIX}/drive_c/packages-input-pass2.txt" \
&& cat "${WINEPREFIX}/drive_c/packages-input-pass2.txt" \
| xargs python3 "${HOME}/msvc-wine/vsdownload.py" --accept-license --major 17 --include-optional --print-selection >"${WINEPREFIX}/drive_c/packages-output-pass2.txt" \
&& cat "${WINEPREFIX}/drive_c/packages-input-pass2.txt" \
| xargs -I{} sed -i "s~^{} ~FILTERED ~g" "${WINEPREFIX}/drive_c/packages-output-pass2.txt" \
&& if [ "$(uname -m)" = "x86_64" ]; then cat "${WINEPREFIX}/drive_c/packages-output-pass2.txt" \
| egrep '^Microsoft.|^Win..SDK' \
| egrep '^Microsoft\.Windows|\.VC\.|\.VisualC\.|\.VisualCpp\.|\.20348' \
| egrep -v '\.ATL[. ]|\.CA\.|\.CodeAnalysis|\.CoreIDE|\.IFC[. ]|\.MFC[. ]|\.Modules|\.MSBuild|\.Premium|\.Prem[. ]|\.Props[. ]|\.Resources|\.Res[. ]|\.Servicing|\.Shortcuts|\.Templates|\.TestAdapter|\.VisualStudio\.VC.[^L][^l]' \
| egrep -v '14\.[12].\.|[Aa][Rr][Mm][. ]|[Aa][Rr][Mm]64[Ee. ]|Host[Xx]86|\(Ms[iu]\)' >"${WINEPREFIX}/drive_c/packages-selected-pass2.txt"; fi \
&& if [ "$(uname -m)" = "i686" ]; then cat "${WINEPREFIX}/drive_c/packages-output-pass2.txt" \
| egrep '^Microsoft.|^Win..SDK' \
| egrep '^Microsoft\.Windows|\.VC\.|\.VisualC\.|\.VisualCpp\.|\.20348' \
| egrep -v '\.ATL[. ]|\.CA\.|\.CodeAnalysis|\.CoreIDE|\.IFC[. ]|\.MFC[. ]|\.Modules|\.MSBuild|\.Premium|\.Prem[. ]|\.Props[. ]|\.Resources|\.Res[. ]|\.Servicing|\.Shortcuts|\.Templates|\.TestAdapter|\.VisualStudio\.VC.[^L][^l]' \
| egrep -v '14\.[12].\.|[Aa][Rr][Mm][. ]|[Aa][Rr][Mm]64[Ee. ]|[Xx]64[. ]|\(Ms[iu]\)' >"${WINEPREFIX}/drive_c/packages-selected-pass2.txt"; fi \
&& if [ "$(uname -m)" = "aarch64" ]; then cat "${WINEPREFIX}/drive_c/packages-output-pass2.txt" \
| egrep '^Microsoft.|^Win..SDK' \
| egrep '^Microsoft\.Windows|\.VC\.|\.VisualC\.|\.VisualCpp\.|\.20348' \
| egrep -v '\.ATL[. ]|\.CA\.|\.CodeAnalysis|\.CoreIDE|\.IFC[. ]|\.MFC[. ]|\.Modules|\.MSBuild|\.Premium|\.Prem[. ]|\.Props[. ]|\.Resources|\.Res[. ]|\.Servicing|\.Shortcuts|\.Templates|\.TestAdapter|\.VisualStudio\.VC.[^L][^l]' \
| egrep -v '14\.[12].\.|[Aa][Rr][Mm][. ]|[Xx]86[. ]|[Xx]64[. ]|\(Ms[iu]\)' >"${WINEPREFIX}/drive_c/packages-selected-pass2.txt"; fi \
&& cat "${WINEPREFIX}/drive_c/packages-selected-pass2.txt" \
| grep -v ' 0 bytes' | awk '{print $1}' | sort -u >"${WINEPREFIX}/drive_c/packages-finalized.txt" \
&& cat "${WINEPREFIX}/drive_c/packages-finalized.txt" \
| xargs python3 "${HOME}/msvc-wine/vsdownload.py" --accept-license --major 17 --cache /tmp/msvc-cache --dest /tmp/msvc-staging \
&& mkdir -p "${WindowsSdkDir}" \
&& mv /tmp/msvc-staging/kits/10/* "${WindowsSdkDir}/" \
&& rm -rf \
"${WindowsSdkDir}/App Certification Kit" \
"${WindowsSdkDir}/Catalogs" \
"${WindowsSdkDir}/DesignTime" \
"${WindowsSdkDir}/Extension SDKs" \
"${WindowsSdkDir}/Platforms" \
"${WindowsSdkDir}/Shortcuts" \
"${WindowsSdkDir}/References" \
"${WindowsSdkDir}/Testing" \
"${WindowsSdkDir}/UnionMetadata" \
&& rm -rf /tmp/msvc-staging/kits \
&& find "${WindowsSdkDir}" -name 'arm' -type d -exec rm -rf {} + \
&& if [ ! "$(uname -m)" = "x86_64" ]; then find "${WindowsSdkDir}" -name 'x64' -type d -exec rm -rf {} +; fi \
&& if [ ! "$(uname -m)" = "aarch64" ]; then find "${WindowsSdkDir}" -name 'arm64' -type d -exec rm -rf {} +; fi \
&& if [ "$(uname -m)" = "aarch64" ]; then find "${WindowsSdkDir}" -name 'x86' -type d -exec rm -rf {} +; fi \
&& mkdir -p "${VSINSTALLDIR}" \
&& mv /tmp/msvc-staging/* "${VSINSTALLDIR}/" \
&& find "${VSINSTALLDIR}" -name 'Auxiliary' -type d -exec rm -rf {} + \
&& find "${VSINSTALLDIR}" -name 'arm' -type d -exec rm -rf {} + \
&& find "${VSINSTALLDIR}" -name 'bin' -type d -exec rm -rf {} + \
&& find "${VSINSTALLDIR}" -name 'modules' -type d -exec rm -rf {} + \
&& find "${VSINSTALLDIR}" -name 'src' -type d -exec rm -rf {} + \
&& if [ ! "$(uname -m)" = "x86_64" ]; then find "${VSINSTALLDIR}" -name 'x64' -type d -exec rm -rf {} +; fi \
&& if [ ! "$(uname -m)" = "aarch64" ]; then find "${VSINSTALLDIR}" -name 'arm64' -type d -exec rm -rf {} +; fi \
&& if [ "$(uname -m)" = "aarch64" ]; then find "${VSINSTALLDIR}" -name 'x86' -type d -exec rm -rf {} +; fi \
&& mkdir /usr/lib/clang/${LLVM_MAJOR}/lib/windows \
&& if [ "$(uname -m)" = "x86_64" ]; then cp -nrv "${VCINSTALLDIR}/Tools/Llvm/x64/lib/clang/${LLVM_MAJOR}/lib/windows/." "/usr/lib/clang/${LLVM_MAJOR}/lib/windows/"; fi \
&& if [ "$(uname -m)" = "aarch64" ]; then cp -nrv "${VCINSTALLDIR}/Tools/Llvm/ARM64/lib/clang/${LLVM_MAJOR}/lib/windows/." "/usr/lib/clang/${LLVM_MAJOR}/lib/windows/"; fi \
&& if [ ! "$(uname -m)" = "aarch64" ]; then cp -nrv "${VCINSTALLDIR}/Tools/Llvm/lib/clang/${LLVM_MAJOR}/lib/windows/." "/usr/lib/clang/${LLVM_MAJOR}/lib/windows/"; fi \
&& rm -rf /tmp/* /var/tmp/* "${VCINSTALLDIR}/Tools/Llvm" "${HOME}/msvc-wine"
ENV WindowsSDKVersion=10.0.20348.0 \
VCToolsVersion=14.39.33519 \
VCRedistVersion=14.38.33135
ENV VCToolsInstallDir="${VCINSTALLDIR}/Tools/MSVC/${VCToolsVersion}" \
VCToolsRedistDir="${VCINSTALLDIR}/Redist/MSVC/${VCRedistVersion}" \
WindowsSdkBinPath="${WindowsSdkDir}/bin/${WindowsSDKVersion}" \
WindowsSDKRedist="${WindowsSdkDir}/Redist/${WindowsSDKVersion}/ucrt/DLLs"
RUN echo "====== SANITY CHECK ======" \
&& echo "== WinSDK Tree: " && cd "${WindowsSdkDir}/bin" && find . -type d | egrep './[0-9.]+/' \
&& echo "== Redist Tree: " && cd "${VCINSTALLDIR}/Redist/MSVC" && find . -type d | egrep './[0-9.]+/' \
&& echo "== Tools Tree: " && cd "${VCINSTALLDIR}/Tools/MSVC" && find . -type d | egrep './[0-9.]+/' \
&& echo "== WinSDK Contains: " && ls "${WindowsSdkBinPath}" \
&& echo "== Redist Contains: " && ls "${VCToolsRedistDir}" \
&& echo "== Tools Contains: " && ls "${VCToolsInstallDir}" \
&& if [ "$(uname -m)" = "x86_64" ]; then find "${WindowsSDKRedist}/x64" -name '*.dll' -type f | xargs -I{} cp -nvs {} "${WINDOWS_SYSROOT}/windows/system32/" \
&& find "${WindowsSdkBinPath}/x64/ucrt" -name '*.dll' -type f | xargs -I{} cp -nvs {} "${WINDOWS_SYSROOT}/windows/system32/" \
&& find "${VCToolsRedistDir}/x64" -name '*.dll' -type f | xargs -I{} cp -nvs {} "${WINDOWS_SYSROOT}/windows/system32/" \
&& find "${VCToolsRedistDir}/debug_nonredist/x64" -name '*.dll' -type f | xargs -I{} cp -nvs {} "${WINDOWS_SYSROOT}/windows/system32/"; fi \
&& if [ "$(uname -m)" = "x86_64" ]; then find "${WindowsSDKRedist}/x86" -name '*.dll' -type f | xargs -I{} cp -nvs {} "${WINDOWS_SYSROOT}/windows/syswow64/" \
&& find "${WindowsSdkBinPath}/x86/ucrt" -name '*.dll' -type f | xargs -I{} cp -nvs {} "${WINDOWS_SYSROOT}/windows/syswow64/" \
&& find "${VCToolsRedistDir}/x86" -name '*.dll' -type f | xargs -I{} cp -nvs {} "${WINDOWS_SYSROOT}/windows/syswow64/" \
&& find "${VCToolsRedistDir}/debug_nonredist/x86" -name '*.dll' -type f | xargs -I{} cp -nvs {} "${WINDOWS_SYSROOT}/windows/syswow64/"; fi \
&& if [ "$(uname -m)" = "i686" ]; then find "${WindowsSDKRedist}/x86" -name '*.dll' -type f | xargs -I{} cp -nvs {} "${WINDOWS_SYSROOT}/windows/system32/" \
&& find "${WindowsSdkBinPath}/x86/ucrt" -name '*.dll' -type f | xargs -I{} cp -nvs {} "${WINDOWS_SYSROOT}/windows/system32/" \
&& find "${VCToolsRedistDir}/x86" -name '*.dll' -type f | xargs -I{} cp -nvs {} "${WINDOWS_SYSROOT}/windows/system32/" \
&& find "${VCToolsRedistDir}/debug_nonredist/x86" -name '*.dll' -type f | xargs -I{} cp -nvs {} "${WINDOWS_SYSROOT}/windows/system32/"; fi \
&& if [ "$(uname -m)" = "aarch64" ]; then find "${WindowsSDKRedist}/arm64" -name '*.dll' -type f | xargs -I{} cp -nvs {} "${WINDOWS_SYSROOT}/windows/system32/" \
&& find "${WindowsSdkBinPath}/arm64/ucrt" -name '*.dll' -type f | xargs -I{} cp -nvs {} "${WINDOWS_SYSROOT}/windows/system32/" \
&& find "${VCToolsRedistDir}/arm64" -name '*.dll' -type f | xargs -I{} cp -nvs {} "${WINDOWS_SYSROOT}/windows/system32/" \
&& find "${VCToolsRedistDir}/debug_nonredist/arm64" -name '*.dll' -type f | xargs -I{} cp -nvs {} "${WINDOWS_SYSROOT}/windows/system32/"; fi
COPY override /
RUN echo "====== TEST TOOLCHAINS ======" \
&& . /opt/wine/winearch \
&& git -C "${HOME}" clone --single-branch --depth=1 https://code.nephatrine.net/nephatrine/hello-test.git \
&& mkdir "/tmp/build-$(uname -m)" && cd "/tmp/build-$(uname -m)" \
&& if [ "$(uname -m)" = "aarch64" ]; then sed -i 's~PRIVATE HelloWorld)~PRIVATE HelloWorld_Static)~g' "${HOME}/hello-test/CMakeLists.txt"; fi \
&& "nxbuild-windows-$(uname -m)-msvc" -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo "${HOME}/hello-test" \
&& ninja && "${WINE}" ./HelloTest.exe \
&& if [ "$(uname -m)" = "x86_64" ]; then mkdir /tmp/build-i686 && cd /tmp/build-i686 \
&& nxbuild-windows-i686-msvc -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo "${HOME}/hello-test" \
&& ninja && "${WINE}" ./HelloTest.exe; fi \
&& cd .. && rm -rf /tmp/* /var/tmp/* "${HOME}/hello-test"