Skip to content

[wip] Add Windows support for cppyy #605

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/actions/Build_and_Test_CppInterOp/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ runs:
echo "CLING_BUILD_DIR=$env:CLING_BUILD_DIR"
echo "CLING_BUILD_DIR=$env:CLING_BUILD_DIR" >> $env:GITHUB_ENV

$env:CPLUS_INCLUDE_PATH="$env:CLING_DIR\tools\cling\include;$env:CLING_BUILD_DIR\include;$env:LLVM_DIR\llvm\include;$env:LLVM_DIR\clang\include;$env:LLVM_BUILD_DIR\include;$env:LLVM_BUILD_DIR\tools\clang\include;$env:PWD_DIR\include;"
echo "CPLUS_INCLUDE_PATH=$env:CPLUS_INCLUDE_PATH"
echo "CPLUS_INCLUDE_PATH=$env:CPLUS_INCLUDE_PATH" >> $env:GITHUB_ENV
$env:IncludePath="$env:IncludePath;$env:CLING_DIR\tools\cling\include;$env:CLING_BUILD_DIR\include;$env:LLVM_DIR\llvm\include;$env:LLVM_DIR\clang\include;$env:LLVM_BUILD_DIR\include;$env:LLVM_BUILD_DIR\tools\clang\include;$env:PWD_DIR\include;"
echo "IncludePath=$env:IncludePath"
echo "IncludePath=$env:IncludePath" >> $env:GITHUB_ENV
}
else
{
$env:CPLUS_INCLUDE_PATH="$env:LLVM_DIR\llvm\include;$env:LLVM_DIR\clang\include;$env:LLVM_BUILD_DIR\include;$env:LLVM_BUILD_DIR\tools\clang\include;$env:PWD_DIR\include;"
echo "CPLUS_INCLUDE_PATH=$env:CPLUS_INCLUDE_PATH"
echo "CPLUS_INCLUDE_PATH=$env:CPLUS_INCLUDE_PATH" >> $env:GITHUB_ENV
$env:IncludePath="$env:IncludePath;$env:LLVM_DIR\llvm\include;$env:LLVM_DIR\clang\include;$env:LLVM_BUILD_DIR\include;$env:LLVM_BUILD_DIR\tools\clang\include;$env:PWD_DIR\include;"
echo "IncludePath=$env:IncludePath"
echo "IncludePath=$env:IncludePath" >> $env:GITHUB_ENV
}

$env:CB_PYTHON_DIR="$env:PWD_DIR\cppyy-backend\python"
Expand All @@ -113,7 +113,7 @@ runs:
# Build CppInterOp next to cling and llvm-project.
mkdir build
cd build
$env:CPPINTEROP_BUILD_DIR="$env:PWD_DIR"
$env:CPPINTEROP_BUILD_DIR=$PWD.Path
echo "CPPINTEROP_BUILD_DIR=$env:CPPINTEROP_BUILD_DIR"
echo "CPPINTEROP_BUILD_DIR=$env:CPPINTEROP_BUILD_DIR" >> $env:GITHUB_ENV
if ( "${{ matrix.cling }}" -imatch "On" )
Expand All @@ -123,14 +123,14 @@ runs:
-DCPPINTEROP_USE_REPL=OFF `
-DCling_DIR="$env:LLVM_BUILD_DIR\tools\cling" `
-DLLVM_DIR="$env:LLVM_BUILD_DIR" `
-DLLVM_ENABLE_WERROR=On `
-DLLVM_ENABLE_WERROR=On -DBUILD_SHARED_LIBS=ON `
-DClang_DIR="$env:LLVM_BUILD_DIR" -DCODE_COVERAGE=${{ env.CODE_COVERAGE }} -DCMAKE_INSTALL_PREFIX="$env:CPPINTEROP_DIR" ..\
}
else
{
cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} `
-DLLVM_DIR="$env:LLVM_BUILD_DIR\lib\cmake\llvm" `
-DLLVM_ENABLE_WERROR=On `
-DLLVM_ENABLE_WERROR=On -DBUILD_SHARED_LIBS=ON `
-DClang_DIR="$env:LLVM_BUILD_DIR\lib\cmake\clang" -DCODE_COVERAGE=${{ env.CODE_COVERAGE }} -DCMAKE_INSTALL_PREFIX="$env:CPPINTEROP_DIR" ..\
}
cmake --build . --config ${{ env.BUILD_TYPE }} --target check-cppinterop --parallel ${{ env.ncpus }}
cmake --build . --config ${{ env.BUILD_TYPE }} --parallel ${{ env.ncpus }}
99 changes: 99 additions & 0 deletions .github/actions/Build_and_Test_cppyy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,102 @@ runs:
tail -n1 test_xfailed.log
echo "Return Code: ${RETCODE}"
exit $RETCODE

- name: Build and Install cppyy-backend
if: ${{ matrix.cppyy == 'On' && runner.os == 'Windows' }}
shell: powershell
run: |
# Download cppyy-backend
git clone --depth=1 https://github.com/compiler-research/cppyy-backend.git
cd cppyy-backend
mkdir $env:CPPINTEROP_DIR\lib
mkdir build
cd build
# Install CppInterOp
cd $env:CPPINTEROP_BUILD_DIR
cmake --build . --target install --parallel ${{ env.ncpus }}
find.exe . -name "*.dll"
find.exe . -name "*.lib"
cd ..\cppyy-backend\build\
# Build and Install cppyy-backend
cmake -DCppInterOp_DIR=$env:CPPINTEROP_DIR -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} ..
cmake --build . --config ${{ env.BUILD_TYPE }} --parallel ${{ env.ncpus }}
find.exe . -name "*"
cp Release\libcppyy-backend.dll $env:CPPINTEROP_DIR\lib\
cd ..

- name: Install CPyCppyy
if: ${{ matrix.cppyy == 'On' && runner.os == 'Windows' }}
shell: powershell
run: |
python -m venv .venv
. .\.venv\Scripts\Activate.ps1
# Install CPyCppyy
git clone --depth=1 https://github.com/compiler-research/CPyCppyy.git
mkdir CPyCppyy\build
cd CPyCppyy\build
cmake ..
cmake --build . --parallel ${{ env.ncpus }}
#
env:CPYCPPYY_DIR = $PWD.Path
cd ../..
# We need CPYCPPYY_DIR later
echo "CPYCPPYY_DIR=$env:CPYCPPYY_DIR" >> $env:GITHUB_ENV

- name: Install cppyy
if: ${{ matrix.cppyy == 'On' && runner.os == 'Windows' }}
shell: powershell
run: |
# source virtual environment
. .\.venv\Scripts\Activate.ps1
# Install cppyy
git clone --depth=1 https://github.com/compiler-research/cppyy.git
cd cppyy
python -m pip install --upgrade . --no-deps
cd ..

- name: Run cppyy
if: ${{ matrix.cppyy == 'On' && runner.os == 'Windows' }}
shell: powershell
run: |
# Run cppyy
. .\.venv\Scripts\Activate.ps1
$env:PYTHONPATH=$env:PYTHONPATH:$env:CPYCPPYY_DIR:$env:CB_PYTHON_DIR
python -c "import cppyy"
# We need PYTHONPATH later
echo "PYTHONPATH=$env:PYTHONPATH" >> $GITHUB_ENV

- name: Run the tests
if: ${{ matrix.cppyy == 'On' && runner.os == 'Windows' }}
shell: powershell
run: |
# Run the tests
. .\.venv\Scripts\Activate.ps1
cd cppyy\test
echo ::group::Prepare For Testing
make all
python -m pip install --upgrade pip
python -m pip install pytest
python -m pip install pytest-xdist
python -m pip install numba
echo ::endgroup::
echo ::group::Run complete test suite
$ErrorActionPreference = "Stop"
python -m pytest -sv -ra 2>&1 | Tee-Object -FilePath complete_testrun.log
$ErrorActionPreference = "Continue"
echo ::group::Crashing Test Logs
# See if we don't have a crash that went away
# Comment out all xfails but the ones that have a run=False condition.
find.exe . -name "*.py" -exec sed.exe -i '/run=False/!s/^ *@mark.xfail\(.*\)/#&/' {} \;
python -m pytest -n 1 -m "xfail" --runxfail -sv -ra --max-worker-restart 512 2>&1 | Tee-Object -FilePath test_crashed.log
$LASTEXITCODE = 0
git checkout .
echo ::endgroup::
echo ::group::XFAIL Test Logs
# Rewrite all xfails that have a run clause to skipif. This way we will
# avoid conditionally crashing xfails
find.exe . -name "*.py" -exec sed.exe -i -E 's/(^ *)@mark.xfail\(run=(.*)/\1@mark.skipif(condition=not \2/g' {} \;
# See if we don't have an xfail that went away
python -m pytest --runxfail -sv -ra | tee test_xfailed.log 2>&1 || true
git checkout .
echo ::endgroup::
17 changes: 13 additions & 4 deletions .github/workflows/Windows-arm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,19 +233,19 @@ jobs:
fail-fast: false
matrix:
include:
- name: win11-msvc-clang-repl-20
- name: win11-msvc-clang-repl-20-cppyy
os: windows-11-arm
compiler: msvc
clang-runtime: '20'
cling: Off
cppyy: Off
- name: win11-msvc-clang18-cling
cppyy: On
- name: win11-msvc-clang18-cling-cppyy
os: windows-11-arm
compiler: msvc
clang-runtime: '18'
cling: On
cling-version: '1.2'
cppyy: Off
cppyy: On

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -291,6 +291,13 @@ jobs:
$env:ncpus=$([Environment]::ProcessorCount)
echo "ncpus=$env:ncpus" >> $env:GITHUB_ENV

- name: Install deps on Windows
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: |
choco install findutils
choco install gnuwin32-coreutils.install
$env:PATH="C:\Program Files (x86)\GnuWin32\bin;$env:PATH"

- name: Setup compiler on Windows
run: |
if ( "${{ matrix.compiler }}" -imatch "clang" )
Expand Down Expand Up @@ -324,6 +331,8 @@ jobs:

- uses: ./.github/actions/Build_and_Test_CppInterOp

- uses: ./.github/actions/Build_and_Test_cppyy

- name: Setup tmate session
if: ${{ failure() && runner.debug }}
uses: mxschmitt/action-tmate@v3
Expand Down
17 changes: 13 additions & 4 deletions .github/workflows/Windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,19 +233,19 @@ jobs:
fail-fast: false
matrix:
include:
- name: win2025-msvc-clang-repl-20
- name: win2025-msvc-clang-repl-20-cppyy
os: windows-2025
compiler: msvc
clang-runtime: '20'
cling: Off
cppyy: Off
- name: win2025-msvc-clang18-cling
cppyy: On
- name: win2025-msvc-clang18-cling-cppyy
os: windows-2025
compiler: msvc
clang-runtime: '18'
cling: On
cling-version: '1.2'
cppyy: Off
cppyy: On

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -291,6 +291,13 @@ jobs:
$env:ncpus=$([Environment]::ProcessorCount)
echo "ncpus=$env:ncpus" >> $env:GITHUB_ENV

- name: Install deps on Windows
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: |
choco install findutils
choco install gnuwin32-coreutils.install
$env:PATH="C:\Program Files (x86)\GnuWin32\bin;$env:PATH"

- name: Setup compiler on Windows
run: |
if ( "${{ matrix.compiler }}" -imatch "clang" )
Expand Down Expand Up @@ -324,6 +331,8 @@ jobs:

- uses: ./.github/actions/Build_and_Test_CppInterOp

- uses: ./.github/actions/Build_and_Test_cppyy

- name: Setup tmate session
if: ${{ failure() && runner.debug }}
uses: mxschmitt/action-tmate@v3
Expand Down
5 changes: 5 additions & 0 deletions include/clang/Interpreter/CppInterOp.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
#define CLANG_CPPINTEROP_H

#include "CppInterOp/CppInterOp.h"
#if defined(_MSC_VER)
#pragma message( \
"#include <clang/Interpreter/CppInterOp.h> is deprecated; use #include <CppInterOp/CppInterOp.h")
#else
#warning \
"#include <clang/Interpreter/CppInterOp.h> is deprecated; use #include <CppInterOp/CppInterOp.h"
#endif

#endif // CLANG_CPPINTEROP_H
Loading