diff --git a/.github/workflows/clp-core-build-macos.yaml b/.github/workflows/clp-core-build-macos.yaml index 8196e75d8..ab3dea7dc 100644 --- a/.github/workflows/clp-core-build-macos.yaml +++ b/.github/workflows/clp-core-build-macos.yaml @@ -41,9 +41,12 @@ jobs: build-macos: strategy: matrix: - runner: ["macos-13", "macos-14"] + os: + - "macos-13" + - "macos-14" + - "macos-15" use_shared_libs: [true, false] - runs-on: "${{matrix.runner}}" + runs-on: "${{matrix.os}}" steps: - uses: "actions/checkout@v4" with: @@ -67,14 +70,35 @@ jobs: - run: "task deps:core" shell: "bash" + - if: "'macos-13' == matrix.os || 'macos-14' == matrix.os" + name: "Upgrade the default AppleClang to LLVM Clang for C++20 features" + shell: "bash" + run: | + brew install llvm@16 + echo "USE_LLVM_COMPILER=true" >> $GITHUB_ENV + echo "LLVM_INSTALL_BINDIR=$(brew --prefix llvm@16)/bin" >> $GITHUB_ENV + - name: "Build CLP-core and run unit tests" shell: "bash" working-directory: "./components/core" # NOTE: We omit the Stopwatch tests since GH's macOS runner is too slow run: >- + $( + [[ "${{ env.USE_LLVM_COMPILER }}" == "true" ]] + && echo + "env" + "CC=${{ env.LLVM_INSTALL_BINDIR }}/clang" + "CXX=${{ env.LLVM_INSTALL_BINDIR }}/clang++" + ) python3 ./tools/scripts/utils/build-and-run-unit-tests.py ${{matrix.use_shared_libs == 'true' && '--use-shared-libs' || ''}} --source-dir . --build-dir build --num-jobs $(getconf _NPROCESSORS_ONLN) --test-spec "~[Stopwatch]" + $( + [[ "${{ env.USE_LLVM_COMPILER }}" == "true" ]] + && echo + "--ar ${{ env.LLVM_INSTALL_BINDIR }}/llvm-ar" + "--ranlib ${{ env.LLVM_INSTALL_BINDIR }}/llvm-ranlib" + ) diff --git a/components/core/tools/scripts/utils/build-and-run-unit-tests.py b/components/core/tools/scripts/utils/build-and-run-unit-tests.py index 7c4b13617..db0ec496f 100644 --- a/components/core/tools/scripts/utils/build-and-run-unit-tests.py +++ b/components/core/tools/scripts/utils/build-and-run-unit-tests.py @@ -21,7 +21,13 @@ logger = logging.getLogger(__name__) -def _config_cmake_project(src_dir: Path, build_dir: Path, use_shared_libs: bool): +def _config_cmake_project( + src_dir: Path, + build_dir: Path, + use_shared_libs: bool, + ar: Optional[Path], + ranlib: Optional[Path], +): cmd = [ "cmake", "-S", @@ -31,6 +37,10 @@ def _config_cmake_project(src_dir: Path, build_dir: Path, use_shared_libs: bool) ] if use_shared_libs: cmd.append("-DCLP_USE_STATIC_LIBS=OFF") + if ar: + cmd.append(f"-DCMAKE_AR={ar}") + if ranlib: + cmd.append(f"-DCMAKE_RANLIB={ranlib}") subprocess.run(cmd, check=True) @@ -82,6 +92,8 @@ def main(argv: List[str]) -> int: "--num-jobs", type=int, help="Max number of jobs to run when building." ) args_parser.add_argument("--test-spec", help="Catch2 test specification.") + args_parser.add_argument("--ar", help="Archiver tool to use.") + args_parser.add_argument("--ranlib", help="Ranlib indexing tool to use.") parsed_args = args_parser.parse_args(argv[1:]) src_dir: Path = Path(parsed_args.source_dir) @@ -89,8 +101,10 @@ def main(argv: List[str]) -> int: use_shared_libs: bool = parsed_args.use_shared_libs num_jobs: Optional[int] = parsed_args.num_jobs test_spec: Optional[str] = parsed_args.test_spec + ar: Optional[Path] = parsed_args.ar + ranlib: Optional[Path] = parsed_args.ranlib - _config_cmake_project(src_dir, build_dir, use_shared_libs) + _config_cmake_project(src_dir, build_dir, use_shared_libs, ar, ranlib) _build_project(build_dir, num_jobs) _run_unit_tests(build_dir, test_spec)