blob: 56dc7c2b1a1a5f8d3f924234e47b7f9a6086e2d5 [file]
#!/bin/bash
# Cross-compiles the Windows unit tests on a Linux runner using MSVC via Wine.
# SPDX-FileCopyrightText: The Eigen Authors
# SPDX-License-Identifier: MPL-2.0
set -x
rootdir=$(pwd)
# Puts the MSVC wrappers (cl, link, ...) on PATH.
. "${rootdir}/ci/scripts/setup.msvc-wine.sh"
# Without set -e a failed download or install would surface only as CMake's
# missing compiler.
if [ ! -x "${msvc_dir}/bin/x64/cl" ]; then
echo "MSVC toolchain setup failed; see the installer output above." >&2
exit 1
fi
# Record the toolset these binaries were built with, so the Windows test job can
# report it next to the runtime it actually has.
mkdir -p "${EIGEN_CI_BUILDDIR}"
printf '%s\n' "${EIGEN_CI_MSVC_TOOLSET}" > "${EIGEN_CI_BUILDDIR}/.eigen_ci_msvc_toolset"
# ccache and sccache identify a compiler by its executable, here the cl wrapper
# script, which every job installs afresh and which stays the same when the
# toolset changes. Key both on the toolset and SDK instead; the pinned manifest
# fixes the two.
sdk_version=$(sed -n 's/^SDKVER=//p' "${msvc_dir}/bin/x64/msvcenv.sh")
compiler_id="msvc-${EIGEN_CI_MSVC_TOOLSET}-sdk-${sdk_version}"
export CCACHE_COMPILERCHECK="string:${compiler_id}"
export SCCACHE_C_CUSTOM_CACHE_BUSTER="${compiler_id}"
# The rest is the Linux build: the compiler cache, the affected-tests selection,
# and the serial retry of targets that failed under parallel load.
# This job has no common.linux.before_script.sh, which would set NPROC.
export NPROC=${NPROC:-$(nproc)}
export EIGEN_CI_C_COMPILER=cl
export EIGEN_CI_CXX_COMPILER=cl
export EIGEN_CI_ADDITIONAL_ARGS="-DCMAKE_SYSTEM_NAME=Windows -DCMAKE_BUILD_TYPE=MinSizeRel \
-DEIGEN_TEST_CUSTOM_CXX_FLAGS=${EIGEN_CI_TEST_CUSTOM_CXX_FLAGS} ${EIGEN_CI_ADDITIONAL_ARGS}"
. "${rootdir}/ci/scripts/build.linux.script.sh"