Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,9 @@ jobs:
platform: OSX
secrets:
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}

FreeBSD:
uses: ./.github/workflows/build-job-freebsd.yml
with:
name: FreeBSD
platform: FreeBSD
130 changes: 130 additions & 0 deletions .github/workflows/build-job-freebsd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
name: Build Bindings (FreeBSD)

# FreeBSD cannot use micromamba/conda-forge (no FreeBSD packages exist).
# Uses vmactions/freebsd-vm to run in a FreeBSD bhyve VM on a Linux runner,
# with system packages (pkg "latest" repo) instead of conda environments.

on:
workflow_call:
inputs:
name:
required: true
type: string
platform:
required: true
type: string
env:
FBSD_PKGS: >-
opencascade llvm-devel cmake ninja pybind11 py311-pybind11 vtk9
rapidjson libfmt python311 py311-numpy py311-pandas py311-joblib
py311-Jinja2 py311-click py311-toml py311-pyparsing py311-tqdm
py311-lief py311-pip py311-logzero py311-path py311-schema
py311-toposort py311-pybind11-stubgen gcc
jobs:
# ---------------------------------------------------------------------------
# Phase 1: Generate bindings
# ---------------------------------------------------------------------------
generate:
name: Generate ${{ inputs.name }}
runs-on: ubuntu-latest
timeout-minutes: 120

steps:
- uses: actions/checkout@v5
with:
submodules: true

- name: Restore OCP_src cache
id: cache-ocp-src-restore
uses: actions/cache/restore@v4
with:
path: build/OCP
key: OCP-src-${{ inputs.platform }}-

- name: Generate bindings on FreeBSD
if: steps.cache-ocp-src-restore.outputs.cache-hit != 'true'
uses: vmactions/freebsd-vm@v1
with:
release: '15.0'
usesh: true
prepare: |
pkg install -y ${{ env.FBSD_PKGS }}
python3.11 -m pip install clang
run: |
set -ex
cmake -S . -B build -G Ninja \
-DCMAKE_PREFIX_PATH="/usr/local;/usr/local/llvm-devel"
cmake --build build
- name: Cache OCP_src
if: steps.cache-ocp-src-restore.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: build/OCP
key: ${{ steps.cache-ocp-src-restore.outputs.cache-primary-key }}

# ---------------------------------------------------------------------------
# Phase 2: Compile + test + stubs
# ---------------------------------------------------------------------------
compile:
name: Compile ${{ inputs.name }} (3.${{ matrix.py_min }})
needs: generate
runs-on: ubuntu-latest
timeout-minutes: 240
strategy:
fail-fast: false
matrix:
py_min: ['11']

steps:
- uses: actions/checkout@v5
with:
submodules: true

- name: Restore OCP_src cache
uses: actions/cache/restore@v4
with:
path: build/OCP
key: OCP-src-${{ inputs.platform }}-

- name: Compile and test on FreeBSD
uses: vmactions/freebsd-vm@v1
with:
release: '15.0'
usesh: true
prepare: |
pkg install -y ${{ env.FBSD_PKGS }}
run: |
set -ex
cmake -B build_native -S build/OCP -G Ninja \
-DCMAKE_PREFIX_PATH="/usr/local;/usr/local/llvm-devel" \
-DCMAKE_BUILD_TYPE=Release
ninja -C build_native -j 2 -k 0
# --- Test ---
cd build_native && python3.11 -c "import OCP; print('OCP import OK')"
# --- Generate stubs ---
cd ${GITHUB_WORKSPACE}/build_native
python3.11 -m pybind11_stubgen -o . OCP
# --- Prepare upload (sources + stubs) ---
mkdir -p ${GITHUB_WORKSPACE}/upload
cp -r ${GITHUB_WORKSPACE}/build/OCP ${GITHUB_WORKSPACE}/upload/
cp -r OCP ${GITHUB_WORKSPACE}/upload/OCP-stubs
- name: Upload Compilation
uses: actions/upload-artifact@v5
with:
name: OCP_${{ inputs.platform }}_py3${{ matrix.py_min }}
path: build_native/OCP.cpython-*.so

- name: Upload Sources and Stubs
uses: actions/upload-artifact@v5
with:
name: OCP_src_stubs_${{ inputs.platform }}_py3${{ matrix.py_min }}
path: upload
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ else()
set(PLATFORM Windows)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
set(PLATFORM OSX)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
set(PLATFORM FreeBSD)
else()
set(PLATFORM Linux)
endif()
Expand Down
19 changes: 14 additions & 5 deletions dump_symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,30 @@

exported_symbols = []

# lief <0.14 uses lief.EXE_FORMATS; 0.14+ uses lief.Binary.FORMATS
FORMATS = getattr(lief, 'EXE_FORMATS', None) or lief.Binary.FORMATS

for lib in libs:

logger.info(f'Analyzing {lib}')

lib = lib.strip()
if not lib:
continue

p = lief.parse(lib)
format = p.format

if p is None:
continue
raise RuntimeError(f'lief.parse failed for {lib!r}')

format = p.format

if format==p.FORMATS.ELF:
name = "linux"
if format == FORMATS.ELF:
import platform as _platform
name = "freebsd" if _platform.system() == "FreeBSD" else "linux"
for s in p.exported_symbols:
exported_symbols.append(f'{s.name}\n')
elif format==p.FORMATS.MACHO:
elif format == FORMATS.MACHO:
name = "mac"
for s in p.symbols:
if s.raw_type>1:
Expand Down
8 changes: 8 additions & 0 deletions ocp.toml
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,14 @@ class Adaptor3d_Surface;
exclude_classes = ["Handle_*"]
symbols = "symbols_mangled_win.dat"

[FreeBSD]
modules = ["Xw"]
symbols = "symbols_mangled_freebsd.dat"
includes = ['/usr/include/c++/v1',
'/usr/local/llvm-devel/lib/clang/22/include',
'/usr/local/include',
'/usr/include']

[OSX]
modules = ["Cocoa"]
symbols = "symbols_mangled_mac.dat"
Expand Down