Skip to content
Draft
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
37 changes: 23 additions & 14 deletions .github/workflows/generate-c-bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,25 @@ jobs:
timeout-minutes: 60
runs-on: ubuntu-24.04-arm
permissions:
contents: read # This is required for actions/checkout
# required for actions/checkout
# change to write if you require draft MRBind release
contents: write
container:
image: meshlib/meshlib-emscripten-c-bindings-arm64:${{inputs.docker_image_tag}}
options: --user root

steps:
- name: Fix git permissions
run: |
git config --global --add safe.directory '*'

- name: Checkout
uses: actions/checkout@v7

- name: Checkout third-party submodules
run: |
# have to checkout selective submodules by our own
# related issue: https://github.com/actions/checkout/issues/1779
export HOME=${RUNNER_TEMP}
git config --global --add safe.directory '*'
# Retried via retry.sh: submodule endpoints occasionally 500.
bash scripts/retry.sh -- git submodule update --init --depth 1 \
thirdparty/imgui \
Expand All @@ -39,25 +43,30 @@ jobs:
thirdparty/onetbb \
thirdparty/openvdb/v10/openvdb \
thirdparty/spdlog
# mrbind needs deps/cppdecl; recurse only there
bash scripts/retry.sh -- git -C thirdparty/mrbind submodule update --init --depth 1 deps/cppdecl

- name: Install MRBind
uses: ./.github/actions/build-mrbind
with:
# The Dockerfile hash in extra-cache-key busts the cache whenever the
# toolchain inside the image changes (e.g. glibc, clang upgrade).
cache-key-prefix: ubuntu-arm64-emscripten
build-script: scripts/mrbind/install_mrbind_ubuntu.sh
extra-cache-key: ${{ hashFiles('scripts/mrbind/clang_version.txt') }}
- name: Download and unpack MRBind
env:
GH_TOKEN: ${{ github.token }}
run: |
MRBIND_VERSION=$(cat scripts/mrbind/mrbind_version.txt | xargs)
curl -sL https://github.com/cli/cli/releases/download/v2.95.0/gh_2.95.0_linux_arm64.tar.gz | tar xz
alias gh=gh_2.95.0_linux_arm64/bin/gh
gh release list \
--repo MeshInspector/mrbind
gh api repos/MeshInspector/mrbind/releases --jq '.[] | select(.draft) | .assets[].url'
gh release download $MRBIND_VERSION \
--repo MeshInspector/mrbind \
--pattern "mrbind-linux-$(uname -m).zip"
unzip "mrbind-linux-$(uname -m).zip"
mv mrbind thirdparty/mrbind/build

# We're not using the host headers here because it's more important to check that the normal way of building the bindings (i.e. using Emscripten headers) works,
# because you can do this on every OS, as opposed to using host headers, which only works on Linux x64.
- name: Generate C bindings
# I get `sh` by default.
shell: bash
run: |
make -f scripts/mrbind/generate.mk TARGET=c -B --trace EM_USE_HOST_HEADERS=0 ENABLE_CUDA=1
make -f scripts/mrbind/generate.mk TARGET=c -B --trace EM_USE_HOST_HEADERS=0 ENABLE_CUDA=1 CLANG_RESOURCE_DIR=thirdparty/mrbind/build/resource-dir

- name: Upload C bindings
uses: actions/upload-artifact@v7
Expand Down
4 changes: 4 additions & 0 deletions scripts/mrbind/generate.mk
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,11 @@ LINKER_FLAGS := $(EXTRA_LDFLAGS) $(if $(DEPS_LIB_DIR),-L$(DEPS_LIB_DIR)) $(if $(
# Set resource directory. Otherwise e.g. `offsetof` becomes non-constexpr,
# because the header override with it being constexpr is in this resource directory.
# We certainly need this on Windows and MacOS. It's not strictly necessary on Ubuntu, but is needed on Arch, so better make it unconditional.
ifneq ($(CLANG_RESOURCE_DIR),)
COMPILER_FLAGS += -resource-dir=$(CLANG_RESOURCE_DIR)
else
COMPILER_FLAGS += -resource-dir=$(strip $(call safe_shell,$(CXX_FOR_BINDINGS) -print-resource-dir))
endif


MRBIND_GEN_C_FLAGS := $(call load_file,$(makefile_dir)mrbind_gen_c_flags.txt)
Expand Down
1 change: 1 addition & 0 deletions scripts/mrbind/mrbind_version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v0.0.1
Loading