cppwinrt should not call LoadLibrary anywhere unless new WINRT_REG_FREE define is defined, re-activating regfree behavior #424
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI Tests | |
on: | |
pull_request: | |
push: | |
branches: | |
- master | |
jobs: | |
test-msvc-cppwinrt-build: | |
name: '${{ matrix.compiler }}: Build (${{ matrix.arch }}, ${{ matrix.config }})' | |
strategy: | |
matrix: | |
compiler: [MSVC, clang-cl] | |
arch: [x86, x64, arm64] | |
config: [Debug, Release] | |
exclude: | |
- arch: arm64 | |
config: Debug | |
- compiler: clang-cl | |
arch: arm64 | |
- compiler: clang-cl | |
config: Release | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- id: setup-llvm | |
name: Set up LLVM (MSVC) | |
uses: ./.github/actions/setup-llvm-msvc | |
if: matrix.compiler == 'clang-cl' | |
- name: Download nuget | |
run: | | |
mkdir ".\.nuget" | |
Invoke-WebRequest "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -OutFile ".\.nuget\nuget.exe" | |
- name: Find VsDevCmd.bat | |
run: | | |
$VSDevCmd = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere" -latest -find Common7\tools\VSDevCmd.bat | |
if (!$VSDevCmd) { exit 1 } | |
echo "Using VSDevCmd: ${VSDevCmd}" | |
Add-Content $env:GITHUB_ENV "VSDevCmd=$VSDevCmd" | |
- name: Prepare build flags | |
run: | | |
$target_configuration = "${{ matrix.config }}" | |
$target_platform = "${{ matrix.arch }}" | |
$target_version = "1.2.3.4" | |
$props = "Configuration=$target_configuration,Platform=$target_platform,CppWinRTBuildVersion=$target_version" | |
if ("${{ matrix.compiler }}" -eq "clang-cl") { | |
$props += ",Clang=1,PlatformToolset=LLVM_v143,LLVMInstallDir=${{ steps.setup-llvm.outputs.llvm-path }}" | |
} | |
Add-Content $env:GITHUB_ENV "msbuild_config_props=/p:$props" | |
- name: Restore nuget packages | |
run: | | |
cmd /c "$env:VSDevCmd" "&" nuget restore cppwinrt.sln | |
- name: Build fast_fwd | |
run: | | |
cmd /c "$env:VSDevCmd" "&" msbuild /m /clp:ForceConsoleColor "$env:msbuild_config_props" cppwinrt.sln /t:fast_fwd | |
- name: Build x86 prebuild tool | |
if: matrix.arch == 'arm64' | |
run: | | |
cmd /c "$env:VSDevCmd" "&" msbuild /m /clp:ForceConsoleColor "$env:msbuild_config_props" /p:Platform=x86 cppwinrt.sln /t:cppwinrt | |
- name: Build cppwinrt | |
run: | | |
cmd /c "$env:VSDevCmd" "&" msbuild /m /clp:ForceConsoleColor "$env:msbuild_config_props" cppwinrt.sln /t:cppwinrt | |
- name: Upload built executables | |
uses: actions/upload-artifact@v4 | |
with: | |
name: msvc-build-${{ matrix.compiler}}-${{ matrix.arch }}-${{ matrix.config }}-bin | |
path: | | |
_build/${{ matrix.arch }}/${{ matrix.config }}/*.exe | |
_build/${{ matrix.arch }}/${{ matrix.config }}/*.dll | |
_build/${{ matrix.arch }}/${{ matrix.config }}/*.winmd | |
_build/${{ matrix.arch }}/${{ matrix.config }}/*.lib | |
_build/${{ matrix.arch }}/${{ matrix.config }}/*.pdb | |
- name: Run cppwinrt to build projection | |
if: matrix.arch != 'arm64' | |
run: | | |
$target_configuration = "${{ matrix.config }}" | |
$target_platform = "${{ matrix.arch }}" | |
& "_build\$target_platform\$target_configuration\cppwinrt.exe" -in local -out _build\$target_platform\$target_configuration -verbose | |
test-msvc-cppwinrt-test: | |
name: '${{ matrix.compiler }}: Test [${{ matrix.test_exe }}] (${{ matrix.arch }}, ${{ matrix.config }})' | |
needs: test-msvc-cppwinrt-build | |
strategy: | |
fail-fast: false | |
matrix: | |
compiler: [MSVC, clang-cl] | |
arch: [x86, x64, arm64] | |
config: [Debug, Release] | |
test_exe: [test, test_cpp20, test_cpp20_no_sourcelocation, test_fast, test_slow, test_old, test_module_lock_custom, test_module_lock_none] | |
exclude: | |
- arch: arm64 | |
config: Debug | |
- compiler: clang-cl | |
arch: arm64 | |
- compiler: clang-cl | |
config: Release | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- id: setup-llvm | |
name: Set up LLVM (MSVC) | |
uses: ./.github/actions/setup-llvm-msvc | |
if: matrix.compiler == 'clang-cl' | |
- name: Fetch cppwinrt executables | |
if: matrix.arch != 'arm64' | |
uses: actions/download-artifact@v4 | |
with: | |
name: msvc-build-${{ matrix.compiler}}-${{ matrix.arch }}-${{ matrix.config }}-bin | |
path: _build/${{ matrix.arch }}/${{ matrix.config }}/ | |
- name: Fetch x86 cppwinrt executables (arm64 only) | |
if: matrix.arch == 'arm64' | |
uses: actions/download-artifact@v4 | |
with: | |
name: msvc-build-${{ matrix.compiler}}-x86-Release-bin | |
path: _build/x86/Release/ | |
- name: Download nuget | |
run: | | |
mkdir ".\.nuget" | |
Invoke-WebRequest "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -OutFile ".\.nuget\nuget.exe" | |
- name: Find VsDevCmd.bat | |
run: | | |
$VSDevCmd = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere" -latest -find Common7\tools\VSDevCmd.bat | |
if (!$VSDevCmd) { exit 1 } | |
echo "Using VSDevCmd: ${VSDevCmd}" | |
Add-Content $env:GITHUB_ENV "VSDevCmd=$VSDevCmd" | |
- name: Prepare build flags | |
run: | | |
$target_configuration = "${{ matrix.config }}" | |
$target_platform = "${{ matrix.arch }}" | |
$target_version = "1.2.3.4" | |
$props = "Configuration=$target_configuration,Platform=$target_platform,CppWinRTBuildVersion=$target_version" | |
if ("${{ matrix.compiler }}" -eq "clang-cl") { | |
$props += ",Clang=1,PlatformToolset=LLVM_v143,LLVMInstallDir=${{ steps.setup-llvm.outputs.llvm-path }}" | |
} | |
Add-Content $env:GITHUB_ENV "msbuild_config_props=/p:$props" | |
- name: Restore nuget packages | |
run: | | |
cmd /c "$env:VSDevCmd" "&" nuget restore cppwinrt.sln | |
- name: Remove cppwinrt dependency from all test projects | |
run: | | |
# HACK: We already have a built exe, so we want to avoid rebuilding cppwinrt | |
mv cppwinrt.sln cppwinrt.sln.orig | |
Get-Content cppwinrt.sln.orig | | |
Where-Object { -not $_.Contains("{D613FB39-5035-4043-91E2-BAB323908AF4} = {D613FB39-5035-4043-91E2-BAB323908AF4}") } | | |
Set-Content cppwinrt.sln | |
- name: Patch catch.hpp to make it build with ANSI colour | |
run: | | |
# HACK: Remove <unistd.h> include and the isatty call in catch.hpp to make ANSI colour build work | |
mv test/catch.hpp test/catch.hpp.orig | |
Get-Content test/catch.hpp.orig | | |
Where-Object { -not $_.Contains("#include <unistd.h>") } | | |
ForEach-Object { | |
$_.Replace("isatty(STDOUT_FILENO)", "false") | |
} | | |
Set-Content test/catch.hpp | |
- name: Run cppwinrt to build projection | |
run: | | |
$target_configuration = "${{ matrix.config }}" | |
$target_platform = "${{ matrix.arch }}" | |
$cppwinrt_path = "_build\$target_platform\$target_configuration\cppwinrt.exe" | |
if ($target_platform -eq "arm64") { | |
$cppwinrt_path = "_build\x86\Release\cppwinrt.exe" | |
} | |
& $cppwinrt_path -in local -out _build\$target_platform\$target_configuration -verbose | |
- name: Build test '${{ matrix.test_exe }}' | |
run: | | |
$test_proj = "${{ matrix.test_exe }}" | |
if ($test_proj -eq "test_old") { | |
$test_proj = "old_tests\test_old" | |
} | |
cmd /c "$env:VSDevCmd" "&" msbuild /m /clp:ForceConsoleColor /p:TestsUseAnsiColor=1 "$env:msbuild_config_props" cppwinrt.sln /t:test\$test_proj | |
- name: Run tests in '${{ matrix.test_exe }}' one by one | |
if: matrix.compiler == 'clang-cl' | |
run: | | |
$target_configuration = "${{ matrix.config }}" | |
$target_platform = "${{ matrix.arch }}" | |
$test_exe = "${{ matrix.test_exe }}" | |
$test_path = "_build\$target_platform\$target_configuration\$test_exe.exe" | |
if (!(Test-Path $test_path)) { | |
echo "::error::Test $test_exe is missing." | |
exit 1 | |
} | |
$test_names = @( & $test_path --list-test-names-only ) | |
$failed_tests = 0 | |
foreach ($test_name in $test_names) { | |
echo "::group::Running test $test_name" | |
$escaped = $test_name.Replace("\", "\\").Replace(",", "\,").Replace("[", "\[") | |
& $test_path --use-colour yes --warn NoTests "$escaped" | |
echo "::endgroup::" | |
if ($LastExitCode -ne 0) { | |
$failed_tests += 1 | |
# Add a newline in case test exited abnormally without newline | |
echo "" | |
echo "::error::Test $test_exe/'$test_name' failed with exit code $LastExitCode!" | |
} | |
} | |
if ($failed_tests -eq 0) { | |
echo "All tests in $test_exe passed." | |
} else { | |
echo "$failed_tests failed in $test_exe." | |
exit 1 | |
} | |
- name: Run test '${{ matrix.test_exe }}' | |
if: matrix.arch != 'arm64' | |
run: | | |
$target_configuration = "${{ matrix.config }}" | |
$target_platform = "${{ matrix.arch }}" | |
$test_exe = "${{ matrix.test_exe }}" | |
$test_path = "_build\$target_platform\$target_configuration\$test_exe.exe" | |
if (!(Test-Path $test_path)) { | |
echo "::error::Test $test_exe is missing." | |
exit 1 | |
} | |
& $test_path --use-colour yes | |
- name: Upload arm64 test executables | |
if: matrix.arch == 'arm64' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: msvc-tests-${{ matrix.test_exe }}-${{ matrix.compiler }}-${{ matrix.arch }}-${{ matrix.config }}-bin | |
path: | | |
_build/${{ matrix.arch }}/${{ matrix.config }}/*.exe | |
_build/${{ matrix.arch }}/${{ matrix.config }}/*.dll | |
_build/${{ matrix.arch }}/${{ matrix.config }}/*.winmd | |
_build/${{ matrix.arch }}/${{ matrix.config }}/*.lib | |
_build/${{ matrix.arch }}/${{ matrix.config }}/*.pdb | |
build-linux-cross-cppwinrt: | |
name: 'cross: Cross-build from Linux' | |
strategy: | |
matrix: | |
arch: [i686, x86_64] | |
runs-on: ubuntu-22.04 | |
env: | |
CMAKE_COLOR_DIAGNOSTICS: 1 | |
CLICOLOR_FORCE: 1 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install cross compiler | |
run: | | |
arch=${{ matrix.arch }} | |
sudo apt-get install g++-mingw-w64-${arch/_/-} | |
sudo update-alternatives --set "${{ matrix.arch }}-w64-mingw32-gcc" "/usr/bin/${{ matrix.arch }}-w64-mingw32-gcc-posix" | |
sudo update-alternatives --set "${{ matrix.arch }}-w64-mingw32-g++" "/usr/bin/${{ matrix.arch }}-w64-mingw32-g++-posix" | |
- name: Cross-build cppwinrt | |
run: | | |
cmake -S . -B build/cross_x64/ --toolchain cross-mingw-toolchain.cmake \ | |
-DCMAKE_SYSTEM_PROCESSOR=${{ matrix.arch }} \ | |
-DCMAKE_BUILD_TYPE=RelWithDebInfo \ | |
-DCMAKE_CXX_FLAGS="-static" \ | |
-DCMAKE_INSTALL_PREFIX=$PWD/install/ | |
cmake --build build/cross_x64/ --target install -j2 | |
- name: Upload cppwinrt.exe | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cross-build-${{ matrix.arch }}-bin | |
path: install/bin/cppwinrt.exe | |
build-msvc-natvis: | |
name: 'Build natvis' | |
strategy: | |
matrix: | |
arch: [x86, x64, arm64] | |
config: [Release] | |
Deployment: [Component, Standalone] | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download nuget | |
run: | | |
mkdir ".\.nuget" | |
Invoke-WebRequest "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -OutFile ".\.nuget\nuget.exe" | |
- name: Find VsDevCmd.bat | |
run: | | |
$VSDevCmd = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere" -latest -find Common7\tools\VSDevCmd.bat | |
if (!$VSDevCmd) { exit 1 } | |
echo "Using VSDevCmd: ${VSDevCmd}" | |
Add-Content $env:GITHUB_ENV "VSDevCmd=$VSDevCmd" | |
- name: Prepare build flags | |
run: | | |
$target_configuration = "${{ matrix.config }}" | |
$target_platform = "${{ matrix.arch }}" | |
$target_version = "1.2.3.4" | |
Add-Content $env:GITHUB_ENV "msbuild_config_props=/p:Configuration=$target_configuration,Platform=$target_platform,CppWinRTBuildVersion=$target_version" | |
- name: Restore nuget packages | |
run: | | |
cmd /c "$env:VSDevCmd" "&" nuget restore natvis\cppwinrtvisualizer.sln | |
- name: Build natvis | |
run: | | |
cmd /c "$env:VSDevCmd" "&" msbuild /m /clp:ForceConsoleColor "$env:msbuild_config_props" /p:Deployment=${{ matrix.Deployment }} natvis\cppwinrtvisualizer.sln | |
build-msvc-nuget-test: | |
name: 'Build nuget test (${{ matrix.arch }})' | |
needs: test-msvc-cppwinrt-build | |
strategy: | |
matrix: | |
compiler: | |
- MSVC | |
arch: [x86, x64] | |
config: [Release] | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Fetch cppwinrt executables | |
uses: actions/download-artifact@v4 | |
with: | |
name: msvc-build-${{ matrix.compiler}}-${{ matrix.arch }}-${{ matrix.config }}-bin | |
path: _build/${{ matrix.arch }}/${{ matrix.config }}/ | |
- name: Download nuget | |
run: | | |
mkdir ".\.nuget" | |
Invoke-WebRequest "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -OutFile ".\.nuget\nuget.exe" | |
- name: Find VsDevCmd.bat | |
run: | | |
$VSDevCmd = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere" -latest -find Common7\tools\VSDevCmd.bat | |
if (!$VSDevCmd) { exit 1 } | |
echo "Using VSDevCmd: ${VSDevCmd}" | |
Add-Content $env:GITHUB_ENV "VSDevCmd=$VSDevCmd" | |
- name: Prepare build flags | |
run: | | |
$target_configuration = "${{ matrix.config }}" | |
$target_platform = "${{ matrix.arch }}" | |
$target_version = "1.2.3.4" | |
Add-Content $env:GITHUB_ENV "msbuild_config_props=/p:Configuration=$target_configuration,Platform=$target_platform,CppWinRTBuildVersion=$target_version" | |
- name: Restore nuget packages | |
run: | | |
cmd /c "$env:VSDevCmd" "&" nuget restore test\nuget\NugetTest.sln | |
- name: Run cppwinrt to build projection | |
run: | | |
$target_configuration = "${{ matrix.config }}" | |
$target_platform = "${{ matrix.arch }}" | |
& "_build\$target_platform\$target_configuration\cppwinrt.exe" -in local -out _build\$target_platform\$target_configuration -verbose | |
- name: Run nuget test | |
run: | | |
cmd /c "$env:VSDevCmd" "&" msbuild /m /clp:ForceConsoleColor "$env:msbuild_config_props" test\nuget\NugetTest.sln | |
if ($LastExitCode -ne 0) { | |
echo "::warning::nuget test failed" | |
} | |
# FIXME: This build was failing from the start | |
exit 0 | |
build-nuget: | |
name: Build nuget package with MSVC | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Package | |
run: | | |
$VSDevCmd = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere" -latest -find Common7\tools\VSDevCmd.bat | |
if (!$VSDevCmd) { exit 1 } | |
echo "Using VSDevCmd: ${VSDevCmd}" | |
cmd /c "${VSDevCmd}" "&" nuget.exe restore cppwinrt.sln | |
cmd /c "${VSDevCmd}" "&" build_nuget.cmd | |
if (!(Test-Path "*.nupkg")) { | |
echo "::error::Output nuget package not found!" | |
exit 1 | |
} | |
- name: Upload nuget package artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: package | |
path: "*.nupkg" |