Skip to content

Commit 470e2ef

Browse files
author
Emery Conrad
committed
[build] Add a Bazel build: shared module, standalone pin, layout parity
Move the shared cppjit_bazel module out of the archived cppyy repo, add a root Bazel build that mirrors the CMake/wheel layout, and restore the best-effort CI job. - bazel/: the shared module (copts, the @llvm extension, the wheel-layout staging rule, the test macros) as its own Bazel module. - Root build: one merged cc_shared_library links into python/cppjit/libcppjit.so; stage_files recreates the wheel layout; test_selflocation gates the dladdr-relative resource lookup. - CppInterOp comes from the commit CMakeLists.txt pins, so a fresh clone needs no sibling checkout. Only LLVM_DIR comes from the host. - libcppjit.so expands the ${ORIGIN} token in CPPINTEROP_EXTRA_INTERPRETER_ARGS. - cppinterop_cc_test takes extra_tags for --test_tag_filters. - test/test_main.py imports the cppjit_bazel path fixups. The py_test bootstrap builds sys.path in-process, so site cannot auto-import them. - ci: the best-effort, non-gating bazel workflow, restored from the archived repo without the sibling clones. Co-developed-with-the-help-of: Claude Code (Fable 5, human in the loop)
1 parent 9d162d5 commit 470e2ef

21 files changed

Lines changed: 1896 additions & 0 deletions

‎.bazelignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bazel

‎.bazelrc‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
common --enable_bzlmod
2+
test --test_output=errors
3+
4+
# The C++ toolchain (clang from the LLVM tree) and all ABI-critical flags are
5+
# centralized in the cppjit_bazel module, which registers @llvm//:cc_toolchain.
6+
# No per-repo compiler wiring needed.

‎.bazelversion‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8.3.1

‎.github/workflows/bazel.yml‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Best-effort, NON-GATING Bazel build. The supported build is setup.py/CMake;
2+
# this job never blocks a PR (continue-on-error). The build and test steps run
3+
# for real and surface a regression as a warning, not a false green.
4+
#
5+
# The build is standalone: CppInterOp comes from the pinned commit in
6+
# MODULE.bazel, so no sibling clone is needed. Only LLVM comes from the host.
7+
name: bazel (best-effort)
8+
9+
on:
10+
pull_request:
11+
branches: [main]
12+
push:
13+
branches: [main]
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
bazel:
20+
name: bazel (best-effort) llvm${{ matrix.llvm }}
21+
runs-on: ubuntu-24.04
22+
continue-on-error: true
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
llvm: ["22"]
27+
steps:
28+
- name: Checkout cppjit
29+
uses: actions/checkout@v7
30+
31+
- name: Setup LLVM ${{ matrix.llvm }}
32+
uses: compiler-research/ci-workflows/actions/setup-llvm@main
33+
with:
34+
version: ${{ matrix.llvm }}
35+
os: ubuntu-24.04
36+
37+
- name: Point LLVM_DIR at the tree root for the @llvm Bazel extension
38+
run: |
39+
# setup-llvm sets LLVM_DIR=<prefix>/lib/cmake/llvm (CMake convention);
40+
# bazel/llvm.bzl needs the tree root holding bin/llvm-config.
41+
echo "LLVM_DIR=${GITHUB_WORKSPACE}/install" >> "$GITHUB_ENV"
42+
43+
- name: bazel build //...
44+
run: |
45+
bazelisk build //... \
46+
|| echo "::warning::bazel build //... failed (best-effort, non-gating)"
47+
48+
- name: bazel test //...
49+
run: |
50+
bazelisk test //... \
51+
|| echo "::warning::bazel test //... failed (best-effort, non-gating)"

‎.gitignore‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ venv/
2727
.envrc
2828
.python-version
2929

30+
# Bazel convenience symlinks and module lock
31+
/bazel-bin
32+
/bazel-out
33+
/bazel-testlogs
34+
/bazel-cppjit
35+
MODULE.bazel.lock
36+
3037
# Editors / OS
3138
.idea/
3239
.vscode/

0 commit comments

Comments
 (0)