diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..68ba490 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,62 @@ +name: CI + +on: [push, pull_request] + +jobs: + build: + strategy: + matrix: + os: [ubuntu-22.04, macos-12, macos-14, windows-2022] + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + + - name: Install ninja + shell: bash + run: | + if [[ "${{ runner.os }}" == "macOS" ]]; then + brew install ninja + elif [[ "${{ runner.os }}" == "Linux" ]]; then + sudo apt-get -y update + sudo apt-get -y install ninja-build + fi + + - name: Build + if: matrix.os != 'windows-2022' + run: | + cmake -Bbuild -S. -GNinja + ninja -Cbuild + + - name: Build + if: matrix.os == 'windows-2022' + shell: cmd + run: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" + cmake -Bbuild -S. -GNinja + ninja -Cbuild + + - name: Test + run: | + cd build/castxml-prefix/src/castxml-build + ctest --output-on-failure + + - name: Archive + shell: cmd + run: | + cd build + if [[ "${{ runner.os }}" == "Windows" ]]; then + 7z a castxml-windows.zip castxml + mv castxml-windows.zip .. + else + tar cvf castxml-${{ matrix.os }}.tar castxml + gzip -9 castxml-${{ matrix.os }}.tar + mv castxml-${{ matrix.os }}.tar.gz .. + fi + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.os }}-archive + path: ./castxml-${{ matrix.os }}.* diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..36fba4f --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +dockcross-x64 +castxml-linux.tar.gz +castxml-linux-aarch64.tar.gz diff --git a/CMakeLists.txt b/CMakeLists.txt index 4632966..26d185f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.20) project(CastXMLSuperbuild NONE) # Set a default build type if none was specified @@ -12,32 +12,24 @@ enable_language(C) enable_language(CXX) -# Use a static runtime with MSVC -if(MSVC) - foreach(flag - CMAKE_CXX_FLAGS - CMAKE_CXX_FLAGS_RELEASE - CMAKE_C_FLAGS - CMAKE_C_FLAGS_RELEASE - ) - if(${flag} MATCHES "/MD") - string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}") - endif() - endforeach() -else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") -endif() +set(CMAKE_CXX_STANDARD "17") if(APPLE) set(osx_args - -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.9 + -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.11 ) endif() include(ExternalProject) +if(${CMAKE_VERSION} VERSION_LESS 3.24) + set(download_extract_timestamp_flag) +else() + set(download_extract_timestamp_flag DOWNLOAD_EXTRACT_TIMESTAMP TRUE) +endif() + find_program(NINJA_EXECUTABLE ninja) if(NINJA_EXECUTABLE) set(CMAKE_GENERATOR "Ninja") @@ -51,74 +43,87 @@ if(USE_SYSTEM_LLVM) set(castxml_deps) else() - set(llvm_version 13.0.0) - set(llvm_folder 13.0.0) - set(llvm_md5 8c24626dce3ee9d87d1079ebf0897db5) + set(llvm_version 18.1.3) + set(llvm_folder 18.1.3) + set(LLVM_DIR ${CMAKE_CURRENT_BINARY_DIR}/llvm/lib/cmake/llvm/) + + set(llvm_cmake_sha256 acfecb615d41c5b1a0a31e15324994ca06f7a3f37d8958d719b20de0d217b71b) + ExternalProject_Add(llvm-cmake + URL "https://github.com/llvm/llvm-project/releases/download/llvmorg-${llvm_folder}/cmake-${llvm_version}.src.tar.xz" + URL_HASH SHA256=${llvm_cmake_sha256} + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + ${download_extract_timestamp_flag} + LOG_BUILD 0 + SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/llvm-prefix/src/cmake + ) + + set(llvm_sha256 fa6db8951f5ef576ac6bad43d5e1ed83962754538c998fbfa0397cd4521abc00) ExternalProject_Add(llvm - URL https://github.com/llvm/llvm-project/releases/download/llvmorg-${llvm_folder}/llvm-${llvm_version}.src.tar.xz - URL_MD5 ${llvm_md5} + URL "https://github.com/llvm/llvm-project/releases/download/llvmorg-${llvm_folder}/llvm-${llvm_version}.src.tar.xz" + URL_HASH SHA256=${llvm_sha256} + DEPENDS llvm-cmake CMAKE_ARGS -Wno-dev CMAKE_GENERATOR "${CMAKE_GENERATOR}" CMAKE_CACHE_ARGS -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} - "-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS} -w" - "-DCMAKE_CXX_FLAGS_RELEASE:STRING=${CMAKE_CXX_FLAGS_RELEASE}" + -DCMAKE_CXX_STANDARD:STRING=${CMAKE_CXX_STANDARD} -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} - "-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS} -w" - "-DCMAKE_C_FLAGS_RELEASE:STRING=${CMAKE_C_FLAGS_RELEASE}" + -DLLVM_STATIC_LINK_CXX_STDLIB:BOOL=ON -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} - -DLLVM_USE_CRT_RELEASE:STRING=MT -DCMAKE_INSTALL_PREFIX:PATH= + -DLLVM_INSTALL_PREFIX:PATH= -DLLVM_ENABLE_TERMINFO:BOOL=OFF -DLLVM_INCLUDE_TESTS:BOOL=OFF - -DLLVM_INCLUDE_EXAMPLES:BOOL=OFF + -DLLVM_INCLUDE_BENCHMARKS:BOOL=OFF -DLLVM_INCLUDE_DOCS:BOOL=OFF -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN:BOOL=ON ${osx_args} ${verbose_command} + ${download_extract_timestamp_flag} LOG_BUILD 0 INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/llvm ) - set(clang_md5 020cbac6e5786094fe4f96f72e290763) + set(clang_sha256 e43e1729713ac0241aa026fa2f98bb54e74a196a6fed60ab4819134a428eb6d8) ExternalProject_Add(clang - URL https://github.com/llvm/llvm-project/releases/download/llvmorg-${llvm_folder}/clang-${llvm_version}.src.tar.xz - URL_MD5 ${clang_md5} + URL "https://github.com/llvm/llvm-project/releases/download/llvmorg-${llvm_folder}/clang-${llvm_version}.src.tar.xz" + URL_HASH SHA256=${clang_sha256} DEPENDS llvm - SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/cfe-${llvm_version} + SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/llvm-prefix/src/cfe-${llvm_version} CMAKE_ARGS -Wno-dev CMAKE_GENERATOR "${CMAKE_GENERATOR}" CMAKE_CACHE_ARGS -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} - "-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS} -w" - "-DCMAKE_CXX_FLAGS_RELEASE:STRING=${CMAKE_CXX_FLAGS_RELEASE}" + -DCMAKE_CXX_STANDARD:STRING=${CMAKE_CXX_STANDARD} -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} - "-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS} -w" - "-DCMAKE_C_FLAGS_RELEASE:STRING=${CMAKE_C_FLAGS_RELEASE}" -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH= -DCLANG_INCLUDE_DOCS:BOOL=OFF -DCLANG_INCLUDE_TESTS:BOOL=OFF + -DLLVM_INCLUDE_TESTS:BOOL=OFF -DLLVM_CONFIG:PATH=${CMAKE_CURRENT_BINARY_DIR}/llvm/bin/llvm-config + -DLLVM_DIR:PATH=${LLVM_DIR} -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN:BOOL=ON ${osx_args} ${verbose_command} + ${download_extract_timestamp_flag} LOG_BUILD 0 INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/llvm ) set(castxml_deps llvm clang) - set(LLVM_DIR ${CMAKE_CURRENT_BINARY_DIR}/llvm/lib/cmake/llvm/) endif() # Use a static C++ library on GCC/Linux if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_SYSTEM_NAME MATCHES "Linux") - set(extra_flags "-static-libstdc++") + set(linux_args "-DCMAKE_CXX_FLAGS:STRING=-static-libstdc++") endif() -# 2022-12-06 master -set(CastXML_GIT_TAG v0.5.0 CACHE STRING "CastXML Git revision.") +# 2024-04-12 master +set(CastXML_GIT_TAG v0.6.5 CACHE STRING "CastXML Git revision.") ExternalProject_Add(castxml GIT_REPOSITORY https://github.com/CastXML/CastXML.git GIT_TAG ${CastXML_GIT_TAG} @@ -127,15 +132,13 @@ ExternalProject_Add(castxml CMAKE_GENERATOR "${CMAKE_GENERATOR}" CMAKE_CACHE_ARGS -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} - "-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS} -w ${extra_flags}" - "-DCMAKE_CXX_FLAGS_RELEASE:STRING=${CMAKE_CXX_FLAGS_RELEASE}" + -DCMAKE_CXX_STANDARD:STRING=${CMAKE_CXX_STANDARD} -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} - "-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS} -w" - "-DCMAKE_C_FLAGS_RELEASE:STRING=${CMAKE_C_FLAGS_RELEASE}" -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH= -DLLVM_DIR:PATH=${LLVM_DIR} ${osx_args} + ${linux_args} ${verbose_command} LOG_BUILD 0 INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/castxml diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index 6191391..0000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,102 +0,0 @@ -trigger: -- master - -jobs: - - job: Linux - timeoutInMinutes: 0 - cancelTimeoutInMinutes: 300 - pool: - vmImage: 'ubuntu-18.04' - - steps: - - script: | - docker run --rm dockbuild/centos7:latest > ./dockbuild - chmod +x ./dockbuild - - mkdir build - ./dockbuild cmake -Bbuild -S. -GNinja - ./dockbuild ninja -Cbuild - displayName: 'Build' - - - script: | - ./dockbuild bash -c 'cd build/castxml-prefix/src/castxml-build && ctest --output-on-failure' - displayName: 'Test' - - - script: | - cd build - tar cvf castxml-linux.tar castxml - gzip -9 castxml-linux.tar - mv castxml-linux.tar.gz .. - displayName: 'Archive' - - - task: PublishPipelineArtifact@0 - inputs: - artifactName: 'LinuxArchive' - targetPath: './castxml-linux.tar.gz' - - - job: macOS - timeoutInMinutes: 0 - cancelTimeoutInMinutes: 300 - pool: - vmImage: 'macOS-10.15' - - steps: - - script: | - mkdir build - cd build - brew install ninja - cmake -GNinja ../ - ninja - displayName: 'Build' - - - script: | - cd build/castxml-prefix/src/castxml-build - ctest --output-on-failure - displayName: 'Test' - - - script: | - cd build - tar cvf castxml-macosx.tar castxml - gzip -9 castxml-macosx.tar - mv castxml-macosx.tar.gz .. - displayName: 'Archive' - - - task: PublishPipelineArtifact@0 - inputs: - artifactName: 'MacOSArchive' - targetPath: './castxml-macosx.tar.gz' - - - job: Windows - timeoutInMinutes: 0 - cancelTimeoutInMinutes: 300 - pool: - vmImage: 'windows-2019' - - steps: - - script: | - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" - pip3 install ninja - set CC=cl.exe - set CXX=cl.exe - - mkdir build - cd build - cmake -GNinja ../ - ninja - displayName: 'Build' - - - script: | - cd build/castxml-prefix/src/castxml-build - ctest --output-on-failure - displayName: 'Test' - - - script: | - cd build - 7z a castxml-windows.zip castxml - mv castxml-windows.zip .. - displayName: 'Archive' - - - task: PublishPipelineArtifact@0 - inputs: - artifactName: 'WindowsArchive' - targetPath: './castxml-windows.zip' diff --git a/centos-build.sh b/centos-build.sh deleted file mode 100755 index db34a05..0000000 --- a/centos-build.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -# This script runs the Superbuild in the dockbuild/centos7 docker image -# from CircleCI. It packages the result and uploads it as an artifact. - -set -x - -die() { - echo "Error: $@" 1>&2 - exit 1; -} - -mkdir -p /usr/src/CastXMLSuperbuild-build -cd /usr/src/CastXMLSuperbuild-build || die "Could not cd into the build directory" - -cmake \ - -DBUILD_FLAGS:STRING="-j4" \ - /usr/src/CastXMLSuperbuild || die "CMake configuration failed" -make VERBOSE=1 || die "Build failed" -cd castxml-prefix/src/castxml-build -ctest || die "CTest failed" - -cd /usr/src/CastXMLSuperbuild-build -tar cvf castxml-linux.tar castxml -gzip -9 castxml-linux.tar diff --git a/manylinux-build.sh b/manylinux-build.sh new file mode 100755 index 0000000..726ecd5 --- /dev/null +++ b/manylinux-build.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +set -e -x -o pipefail + + +dockcross_version=20240404-2c6c0a5 + +podman pull docker.io/dockcross/manylinux2014-x64:$dockcross_version +podman run --rm docker.io/dockcross/manylinux2014-x64:$dockcross_version > ./dockcross-x64 +chmod +x ./dockcross-x64 + +./dockcross-x64 cmake -Bbuild -S. -GNinja +./dockcross-x64 ninja -Cbuild + +pushd build +tar cvf ../castxml-linux.tar castxml +gzip -9 ../castxml-linux.tar +popd +rm -rf build + + +manylinux_version=2024-04-02-96b33b9 + +cat << EOF + +Note! +Need to run: + + sudo podman run --privileged --rm tonistiigi/binfmt --install all + +once before running the following commands on an amd64 system. + +EOF + +podman pull quay.io/pypa/manylinux2014_aarch64:$manylinux_version +podman run -it --rm -v $(pwd):/work quay.io/pypa/manylinux2014_aarch64:$manylinux_version /work/manylinux-internal.sh diff --git a/manylinux-internal.sh b/manylinux-internal.sh new file mode 100755 index 0000000..e61fe43 --- /dev/null +++ b/manylinux-internal.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +set -e -x -o pipefail + +# This script is executed inside the manylinux container to build castxml for an aarch64 linux system +cd /work + +git clone https://github.com/ninja-build/ninja.git +pushd ninja +git checkout release +cmake -DBUILD_TESTING:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=Release -Bbuild-cmake -S. +cmake --build build-cmake --parallel 8 +cp build-cmake/ninja /usr/local/bin/ +popd +rm -rf ninja + +cmake -Bbuild -S. -GNinja +ninja -Cbuild + +pushd build +tar cvf ../castxml-linux-aarch64.tar castxml +gzip -9 ../castxml-linux-aarch64.tar +popd +rm -rf build