-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an actions job for capturing compile commands on all platforms (#11)
This should help to make flags and options more comparable between Bazel and CMake.
- Loading branch information
1 parent
5b82019
commit 1a175a3
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Extract nanobind_example compile commands for CMake and Bazel | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
nb-compile-commands: | ||
name: Capture nanobind CMake compile commands on ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ ubuntu-latest, macos-latest, windows-latest ] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
repository: wjakob/nanobind_example | ||
fetch-depth: 0 | ||
- name: Set up Python and dependencies | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.12 | ||
- run: python -m pip install --upgrade build | ||
- name: Build and capture CMake compile commands | ||
run: python -m build . --wheel -Ccmake.args=-DCMAKE_EXPORT_COMPILE_COMMANDS=ON | ||
- name: Upload commands and Ninja build artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: compile-commands-${{ matrix.os}}-cmake | ||
path: | | ||
# the build subfolder name is autogenerated, so just use a glob. | ||
build/cp312-*/build.ninja # this has the linker command section. | ||
build/cp312-*/CMakeCache.txt | ||
build/cp312-*/compile_commands.json | ||
if-no-files-found: error | ||
- name: Clean repo and switch to Bazel | ||
run: git clean -xdf && git checkout bazel | ||
- name: Extract Bazel compile commands for ${{ matrix.os}} | ||
run: | | ||
bazel run @hedron_compile_commands//:refresh_all \ | ||
-- \ | ||
--compilation_mode=opt \ | ||
--cxxopt=-std=c++17 \ | ||
--@rules_python//python/config_settings:python_version=3.12 \ | ||
--@nanobind_bazel//:minsize \ | ||
--@nanobind_bazel//:py-limited-api=cp312 | ||
- name: Upload Bazel compile commands and flag files for ${{ matrix.os }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: compile-commands-${{ matrix.os}}-bazel | ||
path: | | ||
compile_commands.json | ||
bazel-out/*-opt/**/*.params # these should be two - the libnanobind params, and the nanobind_example_ext params. | ||
if-no-files-found: error |