From 5c5947fe0f2ca08ea91f8747902ebe877caf3131 Mon Sep 17 00:00:00 2001 From: mcbarton <150042563+mcbarton@users.noreply.github.com> Date: Thu, 19 Dec 2024 13:30:19 +0000 Subject: [PATCH] Separate out emscripten and non emscripten builds into separate workflows --- .github/workflows/emscripten.yml | 616 ++++++++++++++++++ .../workflows/{ci.yml => non-emscripten.yml} | 456 +------------ README.md | 8 + 3 files changed, 638 insertions(+), 442 deletions(-) create mode 100644 .github/workflows/emscripten.yml rename .github/workflows/{ci.yml => non-emscripten.yml} (70%) diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml new file mode 100644 index 000000000..fdf8350a2 --- /dev/null +++ b/.github/workflows/emscripten.yml @@ -0,0 +1,616 @@ +name: Emscripten CppInterOp Builds +on: + pull_request: + branches: [main] + push: + branches: [main] + release: + types: [published] + schedule: + - cron: '30 20 * * *' # Warning: Timezone dep - 20:00 is 1:00 + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + build_cache: + name: ${{ matrix.name }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - name: ubu22-x86-gcc12-clang-repl-19-emscripten + os: ubuntu-22.04 + compiler: gcc-12 + clang-runtime: '19' + cling: Off + cppyy: On + llvm_enable_projects: "clang;lld" + llvm_targets_to_build: "WebAssembly" + emsdk_ver: "3.1.45" + - name: osx15-arm-clang-clang-repl-19-emscripten + os: macos-15 + compiler: clang + clang-runtime: '19' + cling: Off + cppyy: On + llvm_enable_projects: "clang;lld" + llvm_targets_to_build: "WebAssembly" + emsdk_ver: "3.1.45" + - name: osx13-x86-clang-clang-repl-19-emscripten + os: macos-13 + compiler: clang + clang-runtime: '19' + cling: Off + cppyy: On + llvm_enable_projects: "clang;lld" + llvm_targets_to_build: "WebAssembly" + emsdk_ver: "3.1.45" + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Save PR Info on Unix systems + if: ${{ runner.os != 'windows' }} + run: | + mkdir -p ./pr + echo ${{ github.event.number }} > ./pr/NR + echo ${{ github.repository }} > ./pr/REPO + + cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]') + if [[ "$cling_on" == "ON" ]]; then + export CLING_HASH=$(git ls-remote https://github.com/root-project/cling.git refs/tags/v${{ matrix.cling-version }} | tr '\t' '-') + export LLVM_HASH=$(git ls-remote https://github.com/root-project/llvm-project.git cling-llvm${{ matrix.clang-runtime}} | tr '\t' '-') + else + export CLING_HASH="Repl" + # May need to revert back to both having same llvm_hash, as below cause llvm to be rebuilt everytime commit is made to llvm/llvm-project for release a.x + # which could be quite often for new releases + export LLVM_HASH=$(git ls-remote https://github.com/llvm/llvm-project.git refs/heads/release/${{ matrix.clang-runtime}}.x | tr '\t' '-') + fi + + echo "CLING_HASH=$CLING_HASH" >> $GITHUB_ENV + echo "LLVM_HASH=$LLVM_HASH" >> $GITHUB_ENV + + - name: Save PR Info on Windows systems + if: ${{ runner.os == 'windows' }} + run: | + #can be found + mkdir ./pr + echo "${{ github.event.number }}" > ./pr/NR + echo ${{ github.repository }} > ./pr/REPO + + if ( "${{ matrix.cling }}" -imatch "On" ) + { + $env:CLING_HASH_TEMP = ( git ls-remote https://github.com/root-project/cling.git refs/tags/v${{ matrix.cling-version }} ) + $env:CLING_HASH = $env:CLING_HASH_TEMP -replace "\t","-" + } + else + { + $env:CLING_HASH="Repl" + # May need to revert back to both having same llvm_hash, as below cause llvm to be rebuilt everytime commit is made to llvm/llvm-project for release a.x + # which could be quite often for new releases + $env:LLVM_HASH_TEMP = (git ls-remote https://github.com/llvm/llvm-project.git refs/heads/release/${{ matrix.clang-runtime}}.x ) + $env:LLVM_HASH = $env:LLVM_HASH_TEMP -replace "\t","-" + } + + echo "CLING_HASH=$env:CLING_HASH" + echo "LLVM_HASH=$env:LLVM_HASH" + + echo "CLING_HASH=$env:CLING_HASH" >> $GITHUB_ENV + echo "LLVM_HASH=$env:LLVM_HASH" >> $GITHUB_ENV + + - name: Restore Cache LLVM/Clang runtime build directory (Unix like systems emscripten) + uses: actions/cache/restore@v4 + id: cache + with: + path: | + llvm-project + ${{ matrix.cling=='On' && 'cling' || '' }} + key: ${{ env.CLING_HASH }}-${{ runner.os }}-${{ matrix.os }}-${{ matrix.compiler }}-clang-${{ matrix.clang-runtime }}.x-emscripten + lookup-only: true + + - name: Setup emsdk + if: ${{ runner.os != 'windows' && steps.cache.outputs.cache-hit != 'true' }} + run: | + git clone https://github.com/emscripten-core/emsdk.git + cd emsdk + ./emsdk install ${{ matrix.emsdk_ver }} + + - name: Setup default Build Type on *nux + if: ${{ runner.os != 'windows' && steps.cache.outputs.cache-hit != 'true' }} + run: | + echo "BUILD_TYPE=Release" >> $GITHUB_ENV + echo "CODE_COVERAGE=0" >> $GITHUB_ENV + os="${{ matrix.os }}" + if [[ "${os}" == "macos"* ]]; then + echo "ncpus=$(sysctl -n hw.ncpu)" >> $GITHUB_ENV + else + echo "ncpus=$(nproc --all)" >> $GITHUB_ENV + fi + + - name: Setup default Build Type on Windows + if: ${{ runner.os == 'windows' && steps.cache.outputs.cache-hit != 'true' }} + run: | + echo "BUILD_TYPE=Release" >> $env:GITHUB_ENV + echo "CODE_COVERAGE=0" >> $env:GITHUB_ENV + $env:ncpus=$([Environment]::ProcessorCount) + echo "ncpus=$env:ncpus" >> $env:GITHUB_ENV + + - name: Setup compiler on Linux + if: ${{ runner.os == 'Linux' && steps.cache.outputs.cache-hit != 'true' }} + run: | + # https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html + vers="${compiler#*-}" + os_codename="`cat /etc/os-release | grep UBUNTU_CODENAME | cut -d = -f 2`" + ##sudo apt update + if [[ "${{ matrix.compiler }}" == *"gcc"* ]]; then + sudo apt install -y gcc-${vers} g++-${vers} lld + echo "CC=gcc-${vers}" >> $GITHUB_ENV + echo "CXX=g++-${vers}" >> $GITHUB_ENV + else + if ! sudo apt install -y clang-${vers}; then + curl https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - + echo "deb https://apt.llvm.org/${os_codename}/ llvm-toolchain-${os_codename}-${vers} main" | sudo tee -a /etc/apt/sources.list + sudo apt-get update + sudo apt-get install -y clang-${vers} + fi + echo "CC=clang-${vers}" >> $GITHUB_ENV + echo "CXX=clang++-${vers}" >> $GITHUB_ENV + fi + env: + compiler: ${{ matrix.compiler }} + + - name: Setup compiler on macOS + if: ${{ runner.os == 'macOS' && steps.cache.outputs.cache-hit != 'true' }} + run: | + vers="${compiler#*-}" + if [[ "${{ matrix.compiler }}" == *"gcc"* ]]; then + brew install "gcc@$vers" + echo "CC=gcc-${vers}" >> $GITHUB_ENV + echo "CXX=g++-${vers}" >> $GITHUB_ENV + else + export ARCHITECHURE=$(uname -m) + if [[ "$ARCHITECHURE" == "arm64" ]]; then + cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]') + if [[ "${cling_on}" == "ON" ]]; then + brew install llvm@15 + brew remove llvm@18 + brew cleanup + #FIXME: Do not believe setting all these environment variables are necessary + # They were set to avoid using Xcodes libc++ and to stop CppInterOp using llvm@18 in tests + echo 'LDFLAGS="-L/opt/homebrew/opt/llvm@15/lib/ -L/opt/homebrew/opt/llvm@15/c++/"' >> $GITHUB_ENV + echo 'CPPFLAGS="-I/opt/homebrew/opt/llvm@15/include"' >> $GITHUB_ENV + echo 'CPATH="/opt/homebrew/include/"' >> $GITHUB_ENV + echo 'LIBRARY_PATH="/opt/homebrew/lib/"' >> $GITHUB_ENV + echo "CC=$(brew --prefix llvm@15)/bin/clang" >> $GITHUB_ENV + echo "CXX=$(brew --prefix llvm@15)/bin/clang++" >> $GITHUB_ENV + else + echo "CC=$(brew --prefix llvm@18)/bin/clang" >> $GITHUB_ENV + echo "CXX=$(brew --prefix llvm@18)/bin/clang++" >> $GITHUB_ENV + fi + else + echo "CC=$(brew --prefix llvm@15)/bin/clang" >> $GITHUB_ENV + echo "CXX=$(brew --prefix llvm@15)/bin/clang++" >> $GITHUB_ENV + fi + fi + echo "SDKROOT=$(xcrun --sdk macosx --show-sdk-path)" >> $GITHUB_ENV + env: + compiler: ${{ matrix.compiler }} + + #Section slightly modified version of + #https://github.com/vgvassilev/clad/blob/40d8bec11bde47b14a281078183a4f6147abeac5/.github/workflows/ci.yml#L510C1-L534C10 + - name: Setup compiler on Windows + if: ${{ runner.os == 'windows' && steps.cache.outputs.cache-hit != 'true' }} + run: | + if ( "${{ matrix.compiler }}" -imatch "clang" ) + { + $ver="${{ matrix.compiler }}".split("-")[1] + choco install llvm --version=$ver --no-progress -my + clang --version + # + $env:CC="clang" + $env:CXX="clang++" + echo "CC=clang" >> $env:GITHUB_ENV + echo "CXX=clang++" >> $env:GITHUB_ENV + } + elseif ( "${{ matrix.compiler }}" -imatch "msvc" ) + { + # MSVC is builtin in container image + } + else + { + echo "Unsupported compiler - fix YAML file" + } + + - name: Install deps on Windows + if: ${{ runner.os == 'windows' && steps.cache.outputs.cache-hit != 'true' }} + run: | + choco install findutils + $env:PATH="C:\Program Files (x86)\GnuWin32\bin;$env:PATH" + + - name: Install deps on MacOS + if: ${{ runner.os == 'macOS' && steps.cache.outputs.cache-hit != 'true' }} + run: | + brew update + export ARCHITECHURE=$(uname -m) + if [[ "$ARCHITECHURE" != "x86_64" ]]; then + brew remove unxip + else + brew remove ruby@3.0 + fi + # workaround for https://github.com/actions/setup-python/issues/577 + for pkg in $(brew list | grep '^python@'); do + brew unlink "$pkg" + brew link --overwrite "$pkg" + done + brew upgrade openssl >/dev/null 2>&1 + brew upgrade + + - name: Install deps on Linux + if: ${{ runner.os == 'Linux' && steps.cache.outputs.cache-hit != 'true' }} + run: | + # Install deps + sudo apt-get update + sudo apt-get install valgrind + sudo apt-get autoremove + sudo apt-get clean + + - name: Build LLVM/Cling on Unix systems if the cache is invalid (emscripten) + if: ${{ runner.os != 'windows' && steps.cache.outputs.cache-hit != 'true' }} + run: | + ./emsdk/emsdk activate ${{matrix.emsdk_ver}} + source ./emsdk/emsdk_env.sh + cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]') + if [[ "${cling_on}" == "ON" ]]; then + git clone https://github.com/root-project/cling.git + cd ./cling + git checkout tags/v${{ matrix.cling-version }} + cd .. + git clone --depth=1 -b cling-llvm${{ matrix.clang-runtime }} https://github.com/root-project/llvm-project.git + else # repl + git clone --depth=1 -b release/${{ matrix.clang-runtime }}.x https://github.com/llvm/llvm-project.git + fi + cd llvm-project + # Build + mkdir build + if [[ "${cling_on}" == "ON" ]]; then + cd build + emcmake cmake -DLLVM_EXTERNAL_PROJECTS=cling \ + -DLLVM_EXTERNAL_CLING_SOURCE_DIR=../../cling \ + -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_HOST_TRIPLE=wasm32-unknown-emscripten \ + -DLLVM_ENABLE_ASSERTIONS=ON \ + -DLLVM_TARGETS_TO_BUILD="${{ matrix.llvm_targets_to_build }}" \ + -DLLVM_ENABLE_LIBEDIT=OFF \ + -DLLVM_ENABLE_PROJECTS="${{ matrix.llvm_enable_projects }}" \ + -DLLVM_ENABLE_ZSTD=OFF \ + -DLLVM_ENABLE_LIBXML2=OFF \ + -DCLANG_ENABLE_STATIC_ANALYZER=OFF \ + -DCLANG_ENABLE_ARCMT=OFF \ + -DCLANG_ENABLE_BOOTSTRAP=OFF \ + -DCMAKE_CXX_FLAGS="-Dwait4=__syscall_wait4" \ + ../llvm + emmake make clang -j ${{ env.ncpus }} + emmake make cling -j ${{ env.ncpus }} + # Now build gtest.a and gtest_main for CppInterOp to run its tests. + emmake make gtest_main -j ${{ env.ncpus }} + else + # Apply patches + llvm_vers=$(echo "${{ matrix.clang-runtime }}" | tr '[:lower:]' '[:upper:]') + if [[ "${llvm_vers}" == "19" ]]; then + git apply -v ../patches/llvm/emscripten-clang${{ matrix.clang-runtime }}-*.patch + echo "Apply emscripten-clang${{ matrix.clang-runtime }}-*.patch patches:" + fi + cd build + emcmake cmake -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_HOST_TRIPLE=wasm32-unknown-emscripten \ + -DLLVM_ENABLE_ASSERTIONS=ON \ + -DLLVM_TARGETS_TO_BUILD="${{ matrix.llvm_targets_to_build }}" \ + -DLLVM_ENABLE_LIBEDIT=OFF \ + -DLLVM_ENABLE_PROJECTS="${{ matrix.llvm_enable_projects }}" \ + -DLLVM_ENABLE_ZSTD=OFF \ + -DLLVM_ENABLE_LIBXML2=OFF \ + -DCLANG_ENABLE_STATIC_ANALYZER=OFF \ + -DCLANG_ENABLE_ARCMT=OFF \ + -DCLANG_ENABLE_BOOTSTRAP=OFF \ + -DCMAKE_CXX_FLAGS="-Dwait4=__syscall_wait4" \ + ../llvm + emmake make clang -j ${{ env.ncpus }} + emmake make clang-repl -j ${{ env.ncpus }} + emmake make lld -j ${{ env.ncpus }} + fi + cd ../.. + + - name: Build LLVM/Cling on Windows systems if the cache is invalid + if: ${{ runner.os == 'windows' && steps.cache.outputs.cache-hit != 'true' }} + run: | + + if ( "${{ matrix.cling }}" -imatch "On" ) + { + git clone https://github.com/root-project/cling.git + cd ./cling + git checkout tags/v${{ matrix.cling-version }} + cd .. + git clone --depth=1 -b cling-llvm${{ matrix.clang-runtime }} https://github.com/root-project/llvm-project.git + $env:PWD_DIR= $PWD.Path + $env:CLING_DIR="$env:PWD_DIR\cling" + echo "CLING_DIR=$env:CLING_DIR" + } + else + { + git clone --depth=1 -b release/${{ matrix.clang-runtime }}.x https://github.com/llvm/llvm-project.git + } + + cd llvm-project + # Build + mkdir build + if ( "${{ matrix.cling }}" -imatch "On" ) + { + cd build + cmake -DLLVM_ENABLE_PROJECTS="${{ matrix.llvm_enable_projects}}" ` + -DLLVM_EXTERNAL_PROJECTS=cling ` + -DLLVM_EXTERNAL_CLING_SOURCE_DIR="$env:CLING_DIR" ` + -DLLVM_TARGETS_TO_BUILD="${{ matrix.llvm_targets_to_build }}" ` + -DCMAKE_BUILD_TYPE=Release ` + -DLLVM_ENABLE_ASSERTIONS=ON ` + -DCLANG_ENABLE_STATIC_ANALYZER=OFF ` + -DCLANG_ENABLE_ARCMT=OFF ` + -DCLANG_ENABLE_FORMAT=OFF ` + -DCLANG_ENABLE_BOOTSTRAP=OFF ` + -DLLVM_ENABLE_ZSTD=OFF ` + -DLLVM_ENABLE_TERMINFO=OFF ` + -DLLVM_ENABLE_LIBXML2=OFF ` + ..\llvm + cmake --build . --config Release --target clang --parallel ${{ env.ncpus }} + cmake --build . --config Release --target cling --parallel ${{ env.ncpus }} + # Now build gtest.a and gtest_main for CppInterOp to run its tests. + cmake --build . --config Release --target gtest_main --parallel ${{ env.ncpus }} + } + else + { + cp -r ..\patches\llvm\clang${{ matrix.clang-runtime }}* + #FIXME: Apply patches without hardcoding + if ( "${{ matrix.clang-runtime }}" -imatch "16" ) + { + git apply -v clang16-1-Value.patch + git apply -v clang16-2-CUDA.patch + git apply -v clang16-3-WeakRef.patch + } + elseif ( "${{ matrix.clang-runtime }}" -imatch "17" ) + { + git apply -v clang17-1-NewOperator.patch + } + cd build + echo "Apply clang${{ matrix.clang-runtime }}-*.patch patches:" + cmake -DLLVM_ENABLE_PROJECTS="${{ matrix.llvm_enable_projects}}" ` + -DLLVM_TARGETS_TO_BUILD="${{ matrix.llvm_targets_to_build }}" ` + -DCMAKE_BUILD_TYPE=Release ` + -DLLVM_ENABLE_ASSERTIONS=ON ` + -DCLANG_ENABLE_STATIC_ANALYZER=OFF ` + -DCLANG_ENABLE_ARCMT=OFF ` + -DCLANG_ENABLE_FORMAT=OFF ` + -DCLANG_ENABLE_BOOTSTRAP=OFF ` + -DLLVM_ENABLE_ZSTD=OFF ` + -DLLVM_ENABLE_TERMINFO=OFF ` + -DLLVM_ENABLE_LIBXML2=OFF ` + ..\llvm + cmake --build . --config Release --target clang clang-repl --parallel ${{ env.ncpus }} + } + cd ..\ + rm -r -force $(find.exe . -maxdepth 1 ! -name "build" ! -name "llvm" ! -name "clang" ! -name ".") + if ( "${{ matrix.cling }}" -imatch "On" ) + { + cd .\llvm\ + rm -r -force $(find.exe . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name "utils" ! -name ".") + cd ..\clang\ + rm -r -force $(find.exe . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name "utils" ! -name ".") + cd ..\.. + } + else + { + cd .\llvm\ + rm -r -force $(find.exe . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name ".") + cd ..\clang\ + rm -r -force $(find.exe . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name ".") + cd ..\.. + } + + - name: Save Cache LLVM/Clang runtime build directory (Unix Systems Emscripten) + uses: actions/cache/save@v4 + if: ${{ runner.os != 'windows' && steps.cache.outputs.cache-hit != 'true' }} + with: + path: | + llvm-project + ${{ matrix.cling=='On' && 'cling' || '' }} + key: ${{ steps.cache.outputs.cache-primary-key }} + + emscripten_wasm_CppInterOp_and_xeus_cpp: + needs: [build_cache] + name: ${{ matrix.name }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - name: ubu22-x86-gcc12-clang-repl-19-emscripten_wasm + os: ubuntu-22.04 + compiler: gcc-12 + clang-runtime: '19' + cling: Off + micromamba_shell_init: bash + emsdk_ver: "3.1.45" + - name: osx15-arm-clang-clang-repl-19-emscripten_wasm + os: macos-15 + compiler: clang + clang-runtime: '19' + cling: Off + micromamba_shell_init: bash + emsdk_ver: "3.1.45" + - name: osx13-x86-clang-clang-repl-19-emscripten_wasm + os: macos-13 + compiler: clang + clang-runtime: '19' + cling: Off + micromamba_shell_init: bash + emsdk_ver: "3.1.45" + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Save PR Info on Unix systems + if: ${{ runner.os != 'windows' }} + run: | + mkdir -p ./pr + echo ${{ github.event.number }} > ./pr/NR + echo ${{ github.repository }} > ./pr/REPO + + cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]') + if [[ "$cling_on" == "ON" ]]; then + export CLING_HASH=$(git ls-remote https://github.com/root-project/cling.git refs/tags/v${{ matrix.cling-version }} | tr '\t' '-') + export LLVM_HASH=$(git ls-remote https://github.com/root-project/llvm-project.git cling-llvm${{ matrix.clang-runtime}} | tr '\t' '-') + else + export CLING_HASH="Repl" + # May need to revert back to both having same llvm_hash, as below cause llvm to be rebuilt everytime commit is made to llvm/llvm-project for release a.x + # which could be quite often for new releases + export LLVM_HASH=$(git ls-remote https://github.com/llvm/llvm-project.git refs/heads/release/${{ matrix.clang-runtime}}.x | tr '\t' '-') + fi + + echo "CLING_HASH=$CLING_HASH" >> $GITHUB_ENV + echo "LLVM_HASH=$LLVM_HASH" >> $GITHUB_ENV + + - name: Setup default Build Type on *nux + if: runner.os != 'windows' + run: | + echo "BUILD_TYPE=Release" >> $GITHUB_ENV + echo "CODE_COVERAGE=0" >> $GITHUB_ENV + os="${{ matrix.os }}" + if [[ "${os}" == "macos"* ]]; then + echo "ncpus=$(sysctl -n hw.ncpu)" >> $GITHUB_ENV + else + echo "ncpus=$(nproc --all)" >> $GITHUB_ENV + fi + + - name: install mamba + uses: mamba-org/setup-micromamba@main + with: + init-shell: >- + ${{ matrix.micromamba_shell_init }} + + - name: Setup emsdk + shell: bash -l {0} + run: | + git clone https://github.com/emscripten-core/emsdk.git + cd emsdk + ./emsdk install ${{ matrix.emsdk_ver }} + + - name: Restore Cache LLVM/Clang runtime build directory + uses: actions/cache/restore@v4 + id: cache + with: + path: | + llvm-project + ${{ matrix.cling=='On' && 'cling' || '' }} + key: ${{ env.CLING_HASH }}-${{ runner.os }}-${{ matrix.os }}-${{ matrix.compiler }}-clang-${{ matrix.clang-runtime }}.x-emscripten + + - name: Emscripten build of CppInterOp on Unix systems + if: ${{ runner.os != 'windows' }} + shell: bash -l {0} + run: | + ./emsdk/emsdk activate ${{matrix.emsdk_ver}} + source ./emsdk/emsdk_env.sh + micromamba create -f environment-wasm.yml --platform=emscripten-wasm32 + + export PREFIX=$MAMBA_ROOT_PREFIX/envs/CppInterOp-wasm + export CMAKE_PREFIX_PATH=$PREFIX + export CMAKE_SYSTEM_PREFIX_PATH=$PREFIX + + LLVM_DIR="$(pwd)/llvm-project" + LLVM_BUILD_DIR="$(pwd)/llvm-project/build" + cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]') + if [[ "${cling_on}" == "ON" ]]; then + CLING_DIR="$(pwd)/cling" + CLING_BUILD_DIR="$(pwd)/cling/build" + CPLUS_INCLUDE_PATH="${CLING_DIR}/tools/cling/include:${CLING_BUILD_DIR}/include:${LLVM_DIR}/llvm/include:${LLVM_DIR}/clang/include:${LLVM_BUILD_DIR}/include:${LLVM_BUILD_DIR}/tools/clang/include:$PWD/include" + else + CPLUS_INCLUDE_PATH="${LLVM_DIR}/llvm/include:${LLVM_DIR}/clang/include:${LLVM_BUILD_DIR}/include:${LLVM_BUILD_DIR}/tools/clang/include:$PWD/include" + fi + + # Build CppInterOp next to cling and llvm-project. + mkdir build + cd build + export CPPINTEROP_BUILD_DIR=$PWD + if [[ "${cling_on}" == "ON" ]]; then + emcmake cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ + -DUSE_CLING=ON \ + -DUSE_REPL=OFF \ + -DCMAKE_PREFIX_PATH=$PREFIX \ + -DCling_DIR=$LLVM_BUILD_DIR/tools/cling \ + -DLLVM_DIR=$LLVM_BUILD_DIR/lib/cmake/llvm \ + -DLLD_DIR=$LLVM_BUILD_DIR/lib/cmake/lld \ + -DClang_DIR=$LLVM_BUILD_DIR/lib/cmake/clang \ + -DBUILD_SHARED_LIBS=ON \ + -DCODE_COVERAGE=${{ env.CODE_COVERAGE }} \ + -DCMAKE_INSTALL_PREFIX=$PREFIX \ + -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \ + ../ + else + emcmake cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ + -DCMAKE_PREFIX_PATH=$PREFIX \ + -DLLVM_DIR=$LLVM_BUILD_DIR/lib/cmake/llvm \ + -DLLD_DIR=$LLVM_BUILD_DIR/lib/cmake/lld \ + -DClang_DIR=$LLVM_BUILD_DIR/lib/cmake/clang \ + -DBUILD_SHARED_LIBS=ON \ + -DCODE_COVERAGE=${{ env.CODE_COVERAGE }} \ + -DCMAKE_INSTALL_PREFIX=$PREFIX \ + -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \ + ../ + fi + + emmake make -j ${{ env.ncpus }} + + cd .. + + echo "CB_PYTHON_DIR=$CB_PYTHON_DIR" >> $GITHUB_ENV + echo "CPPINTEROP_BUILD_DIR=$CPPINTEROP_BUILD_DIR" >> $GITHUB_ENV + echo "CPPINTEROP_DIR=$CPPINTEROP_DIR" >> $GITHUB_ENV + echo "LLVM_BUILD_DIR=$LLVM_BUILD_DIR" >> $GITHUB_ENV + echo "CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH" >> $GITHUB_ENV + echo "PREFIX=$PREFIX" >> $GITHUB_ENV + + - name: Build xeus-cpp + shell: bash -l {0} + run: | + ./emsdk/emsdk activate ${{matrix.emsdk_ver}} + source ./emsdk/emsdk_env.sh + micromamba activate CppInterOp-wasm + git clone https://github.com/compiler-research/xeus-cpp.git + cd ./xeus-cpp + mkdir build + pushd build + export CMAKE_PREFIX_PATH=${{ env.PREFIX }} + export CMAKE_SYSTEM_PREFIX_PATH=${{ env.PREFIX }} + emcmake cmake \ + -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ + -DCMAKE_PREFIX_PATH=${{ env.PREFIX }} \ + -DCMAKE_INSTALL_PREFIX=${{ env.PREFIX }} \ + -DXEUS_CPP_EMSCRIPTEN_WASM_BUILD=ON \ + -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \ + -DCppInterOp_DIR="${{ env.CPPINTEROP_BUILD_DIR }}/lib/cmake/CppInterOp" \ + .. + emmake make -j ${{ env.ncpus }} diff --git a/.github/workflows/ci.yml b/.github/workflows/non-emscripten.yml similarity index 70% rename from .github/workflows/ci.yml rename to .github/workflows/non-emscripten.yml index 95f040dca..f0b424667 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/non-emscripten.yml @@ -1,4 +1,4 @@ -name: Main +name: Non Emscripten CppInterOp Builds on: pull_request: branches: [main] @@ -29,16 +29,6 @@ jobs: cppyy: On llvm_enable_projects: "clang" llvm_targets_to_build: "host;NVPTX" - - name: ubu22-x86-gcc12-clang-repl-19-emscripten - os: ubuntu-22.04 - compiler: gcc-12 - clang-runtime: '19' - cling: Off - cppyy: On - llvm_enable_projects: "clang;lld" - llvm_targets_to_build: "WebAssembly" - emscripten: On - emsdk_ver: "3.1.45" - name: ubu22-x86-gcc12-clang-repl-18 os: ubuntu-22.04 compiler: gcc-12 @@ -104,16 +94,6 @@ jobs: cppyy: On llvm_enable_projects: "clang" llvm_targets_to_build: "host;NVPTX" - - name: osx15-arm-clang-clang-repl-19-emscripten - os: macos-15 - compiler: clang - clang-runtime: '19' - cling: Off - cppyy: On - llvm_enable_projects: "clang;lld" - llvm_targets_to_build: "WebAssembly" - emscripten: On - emsdk_ver: "3.1.45" - name: osx15-arm-clang-clang-repl-18 os: macos-15 compiler: clang @@ -155,16 +135,6 @@ jobs: cppyy: On llvm_enable_projects: "clang" llvm_targets_to_build: "host;NVPTX" - - name: osx13-x86-clang-clang-repl-19-emscripten - os: macos-13 - compiler: clang - clang-runtime: '19' - cling: Off - cppyy: On - llvm_enable_projects: "clang;lld" - llvm_targets_to_build: "WebAssembly" - emscripten: On - emsdk_ver: "3.1.45" - name: osx13-x86-clang-clang-repl-18 os: macos-13 compiler: clang @@ -257,24 +227,10 @@ jobs: echo "CLING_HASH=$env:CLING_HASH" >> $GITHUB_ENV echo "LLVM_HASH=$env:LLVM_HASH" >> $GITHUB_ENV - echo "KEY=${{ env.CLING_HASH }}-${{ runner.os }}-${{ matrix.os }}-${{ matrix.compiler }}-clang-${{ matrix.clang-runtime }}.x-patch-${{ hashFiles(format('patches/llvm/clang{0}-*.patch', matrix.clang-runtime)) || 'none' }}" >> $env:GITHUB_ENV - - #FIXME: Shouldn't need 3 distinct restore steps for different situations. - - name: Restore Cache LLVM/Clang runtime build directory (Windows) - if: ${{ runner.os == 'windows' }} - uses: actions/cache/restore@v4 - id: cachewindows - with: - path: | - llvm-project - ${{ matrix.cling=='On' && 'cling' || '' }} - key: ${{ env.key }} - lookup-only: true - name: Restore Cache LLVM/Clang runtime build directory (Unix like systems) - if: ${{ runner.os != 'windows' && matrix.emscripten != 'On' }} uses: actions/cache/restore@v4 - id: cachenotemscripten + id: cache with: path: | llvm-project @@ -282,38 +238,8 @@ jobs: key: ${{ env.CLING_HASH }}-${{ runner.os }}-${{ matrix.os }}-${{ matrix.compiler }}-clang-${{ matrix.clang-runtime }}.x-patch-${{ hashFiles(format('patches/llvm/clang{0}-*.patch', matrix.clang-runtime)) || 'none' }} lookup-only: true - - name: Restore Cache LLVM/Clang runtime build directory (Unix like systems emscripten) - if: ${{ runner.os != 'windows' && matrix.emscripten == 'On' }} - uses: actions/cache/restore@v4 - id: cacheemscripten - with: - path: | - llvm-project - ${{ matrix.cling=='On' && 'cling' || '' }} - key: ${{ env.CLING_HASH }}-${{ runner.os }}-${{ matrix.os }}-${{ matrix.compiler }}-clang-${{ matrix.clang-runtime }}.x-emscripten - lookup-only: true - - - name: Setup emsdk - if: ${{ runner.os != 'windows' && steps.cacheemscripten.outputs.cache-hit != 'true' && matrix.emscripten == 'On' }} - run: | - git clone https://github.com/emscripten-core/emsdk.git - cd emsdk - ./emsdk install ${{ matrix.emsdk_ver }} - - - name: Setup default Build Type on *nux - if: ${{ runner.os != 'windows' && steps.cachenotemscripten.outputs.cache-hit != 'true' && matrix.emscripten != 'On' }} - run: | - echo "BUILD_TYPE=Release" >> $GITHUB_ENV - echo "CODE_COVERAGE=0" >> $GITHUB_ENV - os="${{ matrix.os }}" - if [[ "${os}" == "macos"* ]]; then - echo "ncpus=$(sysctl -n hw.ncpu)" >> $GITHUB_ENV - else - echo "ncpus=$(nproc --all)" >> $GITHUB_ENV - fi - - name: Setup default Build Type on *nux - if: ${{ runner.os != 'windows' && steps.cacheemscripten.outputs.cache-hit != 'true' && matrix.emscripten == 'On' }} + if: ${{ runner.os != 'windows' && steps.cache.outputs.cache-hit != 'true' }} run: | echo "BUILD_TYPE=Release" >> $GITHUB_ENV echo "CODE_COVERAGE=0" >> $GITHUB_ENV @@ -325,7 +251,7 @@ jobs: fi - name: Setup default Build Type on Windows - if: ${{ runner.os == 'windows' && steps.cachewindows.outputs.cache-hit != 'true' }} + if: ${{ runner.os == 'windows' && steps.cache.outputs.cache-hit != 'true' }} run: | echo "BUILD_TYPE=Release" >> $env:GITHUB_ENV echo "CODE_COVERAGE=0" >> $env:GITHUB_ENV @@ -333,31 +259,7 @@ jobs: echo "ncpus=$env:ncpus" >> $env:GITHUB_ENV - name: Setup compiler on Linux - if: ${{ runner.os == 'Linux' && steps.cachenotemscripten.outputs.cache-hit != 'true' && matrix.emscripten != 'On' }} - run: | - # https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html - vers="${compiler#*-}" - os_codename="`cat /etc/os-release | grep UBUNTU_CODENAME | cut -d = -f 2`" - ##sudo apt update - if [[ "${{ matrix.compiler }}" == *"gcc"* ]]; then - sudo apt install -y gcc-${vers} g++-${vers} lld - echo "CC=gcc-${vers}" >> $GITHUB_ENV - echo "CXX=g++-${vers}" >> $GITHUB_ENV - else - if ! sudo apt install -y clang-${vers}; then - curl https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - echo "deb https://apt.llvm.org/${os_codename}/ llvm-toolchain-${os_codename}-${vers} main" | sudo tee -a /etc/apt/sources.list - sudo apt-get update - sudo apt-get install -y clang-${vers} - fi - echo "CC=clang-${vers}" >> $GITHUB_ENV - echo "CXX=clang++-${vers}" >> $GITHUB_ENV - fi - env: - compiler: ${{ matrix.compiler }} - - - name: Setup compiler on Linux - if: ${{ runner.os == 'Linux' && steps.cacheemscripten.outputs.cache-hit != 'true' && matrix.emscripten == 'On' }} + if: ${{ runner.os == 'Linux' && steps.cache.outputs.cache-hit != 'true' }} run: | # https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html vers="${compiler#*-}" @@ -381,44 +283,7 @@ jobs: compiler: ${{ matrix.compiler }} - name: Setup compiler on macOS - if: ${{ runner.os == 'macOS' && steps.cachenotemscripten.outputs.cache-hit != 'true' && matrix.emscripten != 'On' }} - run: | - vers="${compiler#*-}" - if [[ "${{ matrix.compiler }}" == *"gcc"* ]]; then - brew install "gcc@$vers" - echo "CC=gcc-${vers}" >> $GITHUB_ENV - echo "CXX=g++-${vers}" >> $GITHUB_ENV - else - export ARCHITECHURE=$(uname -m) - if [[ "$ARCHITECHURE" == "arm64" ]]; then - cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]') - if [[ "${cling_on}" == "ON" ]]; then - brew install llvm@15 - brew remove llvm@18 - brew cleanup - #FIXME: Do not believe setting all these environment variables are necessary - # They were set to avoid using Xcodes libc++ and to stop CppInterOp using llvm@18 in tests - echo 'LDFLAGS="-L/opt/homebrew/opt/llvm@15/lib/ -L/opt/homebrew/opt/llvm@15/c++/"' >> $GITHUB_ENV - echo 'CPPFLAGS="-I/opt/homebrew/opt/llvm@15/include"' >> $GITHUB_ENV - echo 'CPATH="/opt/homebrew/include/"' >> $GITHUB_ENV - echo 'LIBRARY_PATH="/opt/homebrew/lib/"' >> $GITHUB_ENV - echo "CC=$(brew --prefix llvm@15)/bin/clang" >> $GITHUB_ENV - echo "CXX=$(brew --prefix llvm@15)/bin/clang++" >> $GITHUB_ENV - else - echo "CC=$(brew --prefix llvm@18)/bin/clang" >> $GITHUB_ENV - echo "CXX=$(brew --prefix llvm@18)/bin/clang++" >> $GITHUB_ENV - fi - else - echo "CC=$(brew --prefix llvm@15)/bin/clang" >> $GITHUB_ENV - echo "CXX=$(brew --prefix llvm@15)/bin/clang++" >> $GITHUB_ENV - fi - fi - echo "SDKROOT=$(xcrun --sdk macosx --show-sdk-path)" >> $GITHUB_ENV - env: - compiler: ${{ matrix.compiler }} - - - name: Setup compiler on macOS - if: ${{ runner.os == 'macOS' && steps.cacheemscripten.outputs.cache-hit != 'true' && matrix.emscripten == 'On' }} + if: ${{ runner.os == 'macOS' && steps.cache.outputs.cache-hit != 'true' }} run: | vers="${compiler#*-}" if [[ "${{ matrix.compiler }}" == *"gcc"* ]]; then @@ -457,7 +322,7 @@ jobs: #Section slightly modified version of #https://github.com/vgvassilev/clad/blob/40d8bec11bde47b14a281078183a4f6147abeac5/.github/workflows/ci.yml#L510C1-L534C10 - name: Setup compiler on Windows - if: ${{ runner.os == 'windows' && steps.cachewindows.outputs.cache-hit != 'true' }} + if: ${{ runner.os == 'windows' && steps.cache.outputs.cache-hit != 'true' }} run: | if ( "${{ matrix.compiler }}" -imatch "clang" ) { @@ -480,13 +345,13 @@ jobs: } - name: Install deps on Windows - if: ${{ runner.os == 'windows' && steps.cachewindows.outputs.cache-hit != 'true' }} + if: ${{ runner.os == 'windows' && steps.cache.outputs.cache-hit != 'true' }} run: | choco install findutils $env:PATH="C:\Program Files (x86)\GnuWin32\bin;$env:PATH" - name: Install deps on Linux - if: ${{ runner.os == 'Linux' && steps.cachenotemscripten.outputs.cache-hit != 'true' && matrix.emscripten != 'On' }} + if: ${{ runner.os == 'Linux' && steps.cache.outputs.cache-hit != 'true' }} run: | # Install deps sudo apt-get update @@ -495,34 +360,7 @@ jobs: sudo apt-get clean - name: Install deps on MacOS - if: ${{ runner.os == 'macOS' && steps.cachenotemscripten.outputs.cache-hit != 'true' && matrix.emscripten != 'On' }} - run: | - brew update - export ARCHITECHURE=$(uname -m) - if [[ "$ARCHITECHURE" != "x86_64" ]]; then - brew remove unxip - else - brew remove ruby@3.0 - fi - # workaround for https://github.com/actions/setup-python/issues/577 - for pkg in $(brew list | grep '^python@'); do - brew unlink "$pkg" - brew link --overwrite "$pkg" - done - brew upgrade openssl >/dev/null 2>&1 - brew upgrade - - - name: Install deps on Linux - if: ${{ runner.os == 'Linux' && steps.cacheemscripten.outputs.cache-hit != 'true' && matrix.emscripten == 'On' }} - run: | - # Install deps - sudo apt-get update - sudo apt-get install valgrind - sudo apt-get autoremove - sudo apt-get clean - - - name: Install deps on MacOS - if: ${{ runner.os == 'macOS' && steps.cacheemscripten.outputs.cache-hit != 'true' && matrix.emscripten == 'On' }} + if: ${{ runner.os == 'macOS' && steps.cache.outputs.cache-hit != 'true' }} run: | brew update export ARCHITECHURE=$(uname -m) @@ -540,7 +378,7 @@ jobs: brew upgrade - name: Build LLVM/Cling on Unix systems if the cache is invalid - if: ${{ runner.os != 'windows' && steps.cachenotemscripten.outputs.cache-hit != 'true' && matrix.emscripten != 'On' }} + if: ${{ runner.os != 'windows' && steps.cache.outputs.cache-hit != 'true' }} run: | cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]') if [[ "${cling_on}" == "ON" ]]; then @@ -614,74 +452,8 @@ jobs: cd ../.. fi - - name: Build LLVM/Cling on Unix systems if the cache is invalid (emscripten) - if: ${{ runner.os != 'windows' && steps.cacheemscripten.outputs.cache-hit != 'true' && matrix.emscripten == 'On' }} - run: | - ./emsdk/emsdk activate ${{matrix.emsdk_ver}} - source ./emsdk/emsdk_env.sh - cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]') - if [[ "${cling_on}" == "ON" ]]; then - git clone https://github.com/root-project/cling.git - cd ./cling - git checkout tags/v${{ matrix.cling-version }} - cd .. - git clone --depth=1 -b cling-llvm${{ matrix.clang-runtime }} https://github.com/root-project/llvm-project.git - else # repl - git clone --depth=1 -b release/${{ matrix.clang-runtime }}.x https://github.com/llvm/llvm-project.git - fi - cd llvm-project - # Build - mkdir build - if [[ "${cling_on}" == "ON" ]]; then - cd build - emcmake cmake -DLLVM_EXTERNAL_PROJECTS=cling \ - -DLLVM_EXTERNAL_CLING_SOURCE_DIR=../../cling \ - -DCMAKE_BUILD_TYPE=Release \ - -DLLVM_HOST_TRIPLE=wasm32-unknown-emscripten \ - -DLLVM_ENABLE_ASSERTIONS=ON \ - -DLLVM_TARGETS_TO_BUILD="${{ matrix.llvm_targets_to_build }}" \ - -DLLVM_ENABLE_LIBEDIT=OFF \ - -DLLVM_ENABLE_PROJECTS="${{ matrix.llvm_enable_projects }}" \ - -DLLVM_ENABLE_ZSTD=OFF \ - -DLLVM_ENABLE_LIBXML2=OFF \ - -DCLANG_ENABLE_STATIC_ANALYZER=OFF \ - -DCLANG_ENABLE_ARCMT=OFF \ - -DCLANG_ENABLE_BOOTSTRAP=OFF \ - -DCMAKE_CXX_FLAGS="-Dwait4=__syscall_wait4" \ - ../llvm - emmake make clang -j ${{ env.ncpus }} - emmake make cling -j ${{ env.ncpus }} - # Now build gtest.a and gtest_main for CppInterOp to run its tests. - emmake make gtest_main -j ${{ env.ncpus }} - else - # Apply patches - llvm_vers=$(echo "${{ matrix.clang-runtime }}" | tr '[:lower:]' '[:upper:]') - if [[ "${llvm_vers}" == "19" ]]; then - git apply -v ../patches/llvm/emscripten-clang${{ matrix.clang-runtime }}-*.patch - echo "Apply emscripten-clang${{ matrix.clang-runtime }}-*.patch patches:" - fi - cd build - emcmake cmake -DCMAKE_BUILD_TYPE=Release \ - -DLLVM_HOST_TRIPLE=wasm32-unknown-emscripten \ - -DLLVM_ENABLE_ASSERTIONS=ON \ - -DLLVM_TARGETS_TO_BUILD="${{ matrix.llvm_targets_to_build }}" \ - -DLLVM_ENABLE_LIBEDIT=OFF \ - -DLLVM_ENABLE_PROJECTS="${{ matrix.llvm_enable_projects }}" \ - -DLLVM_ENABLE_ZSTD=OFF \ - -DLLVM_ENABLE_LIBXML2=OFF \ - -DCLANG_ENABLE_STATIC_ANALYZER=OFF \ - -DCLANG_ENABLE_ARCMT=OFF \ - -DCLANG_ENABLE_BOOTSTRAP=OFF \ - -DCMAKE_CXX_FLAGS="-Dwait4=__syscall_wait4" \ - ../llvm - emmake make clang -j ${{ env.ncpus }} - emmake make clang-repl -j ${{ env.ncpus }} - emmake make lld -j ${{ env.ncpus }} - fi - cd ../.. - - name: Build LLVM/Cling on Windows systems if the cache is invalid - if: ${{ runner.os == 'windows' && steps.cachewindows.outputs.cache-hit != 'true' }} + if: ${{ runner.os == 'windows' && steps.cache.outputs.cache-hit != 'true' }} run: | if ( "${{ matrix.cling }}" -imatch "On" ) @@ -776,30 +548,12 @@ jobs: - name: Save Cache LLVM/Clang runtime build directory (Windows) uses: actions/cache/save@v4 - if: ${{ runner.os == 'windows' && steps.cachewindows.outputs.cache-hit != 'true' }} - with: - path: | - llvm-project - ${{ matrix.cling=='On' && 'cling' || '' }} - key: ${{ steps.cachewindows.outputs.cache-primary-key }} - - - name: Save Cache LLVM/Clang runtime build directory (Unix Systems) - uses: actions/cache/save@v4 - if: ${{ runner.os != 'windows' && steps.cachenotemscripten.outputs.cache-hit != 'true' && matrix.emscripten != 'On' }} - with: - path: | - llvm-project - ${{ matrix.cling=='On' && 'cling' || '' }} - key: ${{ steps.cachenotemscripten.outputs.cache-primary-key }} - - - name: Save Cache LLVM/Clang runtime build directory (Unix Systems Emscripten) - uses: actions/cache/save@v4 - if: ${{ runner.os != 'windows' && steps.cacheemscripten.outputs.cache-hit != 'true' && matrix.emscripten == 'On' }} + if: ${{ steps.cache.outputs.cache-hit != 'true' }} with: path: | llvm-project ${{ matrix.cling=='On' && 'cling' || '' }} - key: ${{ steps.cacheemscripten.outputs.cache-primary-key }} + key: ${{ steps.cache.outputs.cache-primary-key }} cppinterop_and_cppyy_build: needs: [build_cache] @@ -1436,185 +1190,3 @@ jobs: uses: mxschmitt/action-tmate@v3 # When debugging increase to a suitable value! timeout-minutes: 30 - - emscripten_wasm_CppInterOp_and_xeus_cpp: - needs: [build_cache] - name: ${{ matrix.name }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - include: - - name: ubu22-x86-gcc12-clang-repl-19-emscripten_wasm - os: ubuntu-22.04 - compiler: gcc-12 - clang-runtime: '19' - cling: Off - micromamba_shell_init: bash - emsdk_ver: "3.1.45" - - name: osx15-arm-clang-clang-repl-19-emscripten_wasm - os: macos-15 - compiler: clang - clang-runtime: '19' - cling: Off - micromamba_shell_init: bash - emsdk_ver: "3.1.45" - - name: osx13-x86-clang-clang-repl-19-emscripten_wasm - os: macos-13 - compiler: clang - clang-runtime: '19' - cling: Off - micromamba_shell_init: bash - emsdk_ver: "3.1.45" - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.11' - - - name: Save PR Info on Unix systems - if: ${{ runner.os != 'windows' }} - run: | - mkdir -p ./pr - echo ${{ github.event.number }} > ./pr/NR - echo ${{ github.repository }} > ./pr/REPO - - cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]') - if [[ "$cling_on" == "ON" ]]; then - export CLING_HASH=$(git ls-remote https://github.com/root-project/cling.git refs/tags/v${{ matrix.cling-version }} | tr '\t' '-') - export LLVM_HASH=$(git ls-remote https://github.com/root-project/llvm-project.git cling-llvm${{ matrix.clang-runtime}} | tr '\t' '-') - else - export CLING_HASH="Repl" - # May need to revert back to both having same llvm_hash, as below cause llvm to be rebuilt everytime commit is made to llvm/llvm-project for release a.x - # which could be quite often for new releases - export LLVM_HASH=$(git ls-remote https://github.com/llvm/llvm-project.git refs/heads/release/${{ matrix.clang-runtime}}.x | tr '\t' '-') - fi - - echo "CLING_HASH=$CLING_HASH" >> $GITHUB_ENV - echo "LLVM_HASH=$LLVM_HASH" >> $GITHUB_ENV - - - name: Setup default Build Type on *nux - if: runner.os != 'windows' - run: | - echo "BUILD_TYPE=Release" >> $GITHUB_ENV - echo "CODE_COVERAGE=0" >> $GITHUB_ENV - os="${{ matrix.os }}" - if [[ "${os}" == "macos"* ]]; then - echo "ncpus=$(sysctl -n hw.ncpu)" >> $GITHUB_ENV - else - echo "ncpus=$(nproc --all)" >> $GITHUB_ENV - fi - - - name: install mamba - uses: mamba-org/setup-micromamba@main - with: - init-shell: >- - ${{ matrix.micromamba_shell_init }} - - - name: Setup emsdk - shell: bash -l {0} - run: | - git clone https://github.com/emscripten-core/emsdk.git - cd emsdk - ./emsdk install ${{ matrix.emsdk_ver }} - - - name: Restore Cache LLVM/Clang runtime build directory - uses: actions/cache/restore@v4 - id: cache - with: - path: | - llvm-project - ${{ matrix.cling=='On' && 'cling' || '' }} - key: ${{ env.CLING_HASH }}-${{ runner.os }}-${{ matrix.os }}-${{ matrix.compiler }}-clang-${{ matrix.clang-runtime }}.x-emscripten - - - name: Emscripten build of CppInterOp on Unix systems - if: ${{ runner.os != 'windows' }} - shell: bash -l {0} - run: | - ./emsdk/emsdk activate ${{matrix.emsdk_ver}} - source ./emsdk/emsdk_env.sh - micromamba create -f environment-wasm.yml --platform=emscripten-wasm32 - - export PREFIX=$MAMBA_ROOT_PREFIX/envs/CppInterOp-wasm - export CMAKE_PREFIX_PATH=$PREFIX - export CMAKE_SYSTEM_PREFIX_PATH=$PREFIX - - LLVM_DIR="$(pwd)/llvm-project" - LLVM_BUILD_DIR="$(pwd)/llvm-project/build" - cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]') - if [[ "${cling_on}" == "ON" ]]; then - CLING_DIR="$(pwd)/cling" - CLING_BUILD_DIR="$(pwd)/cling/build" - CPLUS_INCLUDE_PATH="${CLING_DIR}/tools/cling/include:${CLING_BUILD_DIR}/include:${LLVM_DIR}/llvm/include:${LLVM_DIR}/clang/include:${LLVM_BUILD_DIR}/include:${LLVM_BUILD_DIR}/tools/clang/include:$PWD/include" - else - CPLUS_INCLUDE_PATH="${LLVM_DIR}/llvm/include:${LLVM_DIR}/clang/include:${LLVM_BUILD_DIR}/include:${LLVM_BUILD_DIR}/tools/clang/include:$PWD/include" - fi - - # Build CppInterOp next to cling and llvm-project. - mkdir build - cd build - export CPPINTEROP_BUILD_DIR=$PWD - if [[ "${cling_on}" == "ON" ]]; then - emcmake cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ - -DUSE_CLING=ON \ - -DUSE_REPL=OFF \ - -DCMAKE_PREFIX_PATH=$PREFIX \ - -DCling_DIR=$LLVM_BUILD_DIR/tools/cling \ - -DLLVM_DIR=$LLVM_BUILD_DIR/lib/cmake/llvm \ - -DLLD_DIR=$LLVM_BUILD_DIR/lib/cmake/lld \ - -DClang_DIR=$LLVM_BUILD_DIR/lib/cmake/clang \ - -DBUILD_SHARED_LIBS=ON \ - -DCODE_COVERAGE=${{ env.CODE_COVERAGE }} \ - -DCMAKE_INSTALL_PREFIX=$PREFIX \ - -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \ - ../ - else - emcmake cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ - -DCMAKE_PREFIX_PATH=$PREFIX \ - -DLLVM_DIR=$LLVM_BUILD_DIR/lib/cmake/llvm \ - -DLLD_DIR=$LLVM_BUILD_DIR/lib/cmake/lld \ - -DClang_DIR=$LLVM_BUILD_DIR/lib/cmake/clang \ - -DBUILD_SHARED_LIBS=ON \ - -DCODE_COVERAGE=${{ env.CODE_COVERAGE }} \ - -DCMAKE_INSTALL_PREFIX=$PREFIX \ - -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \ - ../ - fi - - emmake make -j ${{ env.ncpus }} - - cd .. - - echo "CB_PYTHON_DIR=$CB_PYTHON_DIR" >> $GITHUB_ENV - echo "CPPINTEROP_BUILD_DIR=$CPPINTEROP_BUILD_DIR" >> $GITHUB_ENV - echo "CPPINTEROP_DIR=$CPPINTEROP_DIR" >> $GITHUB_ENV - echo "LLVM_BUILD_DIR=$LLVM_BUILD_DIR" >> $GITHUB_ENV - echo "CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH" >> $GITHUB_ENV - echo "PREFIX=$PREFIX" >> $GITHUB_ENV - - - name: Build xeus-cpp - shell: bash -l {0} - run: | - ./emsdk/emsdk activate ${{matrix.emsdk_ver}} - source ./emsdk/emsdk_env.sh - micromamba activate CppInterOp-wasm - git clone https://github.com/compiler-research/xeus-cpp.git - cd ./xeus-cpp - mkdir build - pushd build - export CMAKE_PREFIX_PATH=${{ env.PREFIX }} - export CMAKE_SYSTEM_PREFIX_PATH=${{ env.PREFIX }} - emcmake cmake \ - -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ - -DCMAKE_PREFIX_PATH=${{ env.PREFIX }} \ - -DCMAKE_INSTALL_PREFIX=${{ env.PREFIX }} \ - -DXEUS_CPP_EMSCRIPTEN_WASM_BUILD=ON \ - -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \ - -DCppInterOp_DIR="${{ env.CPPINTEROP_BUILD_DIR }}/lib/cmake/CppInterOp" \ - .. - emmake make -j ${{ env.ncpus }} diff --git a/README.md b/README.md index d248df687..0b056b8c9 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,19 @@ # CppInterOp +[![Build Status](https://github.com/compiler-research/CppInterOp/actions/workflows/non-emscripten.yml/badge.svg)](https://github.com/compiler-research/CppInterOp/actions/workflows/non-emscripten.yml) + +[![Build Status](https://github.com/compiler-research/CppInterOp/actions/workflows/emscripten.yml/badge.svg)](https://github.com/compiler-research/CppInterOp/actions/workflows/emscripten.yml) + [![Build Status](https://github.com/compiler-research/CppInterOp/actions/workflows/ci.yml/badge.svg)](https://github.com/compiler-research/CppInterOp/actions/workflows/ci.yml) + [![codecov](https://codecov.io/gh/compiler-research/CppInterOp/branch/main/graph/badge.svg)](https://codecov.io/gh/compiler-research/CppInterOp) [![Conda-Forge](https://img.shields.io/conda/vn/conda-forge/cppinterop)](https://github.com/conda-forge/cppinterop-feedstock) + [![Anaconda-Server Badge](https://anaconda.org/conda-forge/cppinterop/badges/license.svg)](https://github.com/conda-forge/cppinterop-feedstock) + [![Conda Platforms](https://img.shields.io/conda/pn/conda-forge/cppinterop.svg)](https://anaconda.org/conda-forge/cppinterop) + [![Anaconda-Server Badge](https://anaconda.org/conda-forge/cppinterop/badges/downloads.svg)](https://github.com/conda-forge/cppinterop-feedstock) CppInterOp exposes API from [Clang](http://clang.llvm.org/) and [LLVM](https://llvm.org) in a backward compatible way.