From 947a514d6e35a5bd15e6dbe4be80b0179c530d03 Mon Sep 17 00:00:00 2001 From: Artur Sharafutdinov Date: Tue, 23 Jun 2026 23:22:29 +0200 Subject: [PATCH 1/6] CI: Use static MRBind binaries for generating C bindings --- .github/workflows/generate-c-bindings.yml | 26 +++++++++++------------ scripts/mrbind/generate.mk | 4 ++++ scripts/mrbind/mrbind_version.txt | 1 + 3 files changed, 18 insertions(+), 13 deletions(-) create mode 100644 scripts/mrbind/mrbind_version.txt diff --git a/.github/workflows/generate-c-bindings.yml b/.github/workflows/generate-c-bindings.yml index 4585868b8987..91157b13d691 100644 --- a/.github/workflows/generate-c-bindings.yml +++ b/.github/workflows/generate-c-bindings.yml @@ -18,6 +18,10 @@ jobs: options: --user root steps: + - name: Fix git permissions + run: | + git config --global --add safe.directory '*' + - name: Checkout uses: actions/checkout@v7 @@ -25,8 +29,6 @@ jobs: 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 \ @@ -39,17 +41,15 @@ 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 + run: | + MRBIND_VERSION=$(cat scripts/mrbind/mrbind_version.txt | xargs) + 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. @@ -57,7 +57,7 @@ jobs: # 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 diff --git a/scripts/mrbind/generate.mk b/scripts/mrbind/generate.mk index a8d1a75aeb64..e105f6a61bee 100644 --- a/scripts/mrbind/generate.mk +++ b/scripts/mrbind/generate.mk @@ -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) diff --git a/scripts/mrbind/mrbind_version.txt b/scripts/mrbind/mrbind_version.txt new file mode 100644 index 000000000000..96f29a32fd96 --- /dev/null +++ b/scripts/mrbind/mrbind_version.txt @@ -0,0 +1 @@ +v0.0.0-756 From e6e1a534a9c20b553319f1c4dd83d5a0cbd04204 Mon Sep 17 00:00:00 2001 From: Artur Sharafutdinov Date: Tue, 23 Jun 2026 23:27:49 +0200 Subject: [PATCH 2/6] WIP: Download GitHub CLI --- .github/workflows/generate-c-bindings.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/generate-c-bindings.yml b/.github/workflows/generate-c-bindings.yml index 91157b13d691..7018fdc89466 100644 --- a/.github/workflows/generate-c-bindings.yml +++ b/.github/workflows/generate-c-bindings.yml @@ -45,7 +45,8 @@ jobs: - name: Download and unpack MRBind run: | MRBIND_VERSION=$(cat scripts/mrbind/mrbind_version.txt | xargs) - gh release download $MRBIND_VERSION \ + curl -sL https://github.com/cli/cli/releases/download/v2.95.0/gh_2.95.0_linux_arm64.tar.gz | tar xz + gh_2.95.0_linux_arm64/bin/gh release download $MRBIND_VERSION \ --repo MeshInspector/mrbind \ --pattern "mrbind-linux-$(uname -m).zip" unzip "mrbind-linux-$(uname -m).zip" From d374127d1fa47992034695c68a5f09946e607e4f Mon Sep 17 00:00:00 2001 From: Artur Sharafutdinov Date: Tue, 23 Jun 2026 23:30:16 +0200 Subject: [PATCH 3/6] WIP: Fix GitHub auth --- .github/workflows/generate-c-bindings.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/generate-c-bindings.yml b/.github/workflows/generate-c-bindings.yml index 7018fdc89466..ae5a65fada2b 100644 --- a/.github/workflows/generate-c-bindings.yml +++ b/.github/workflows/generate-c-bindings.yml @@ -43,6 +43,8 @@ jobs: thirdparty/spdlog - 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 From 8028fc22e8a6d4baafd7f59e85349e87899a8fe7 Mon Sep 17 00:00:00 2001 From: Artur Sharafutdinov Date: Tue, 23 Jun 2026 23:37:45 +0200 Subject: [PATCH 4/6] WIP: Debug output --- .github/workflows/generate-c-bindings.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/generate-c-bindings.yml b/.github/workflows/generate-c-bindings.yml index ae5a65fada2b..3af56b8705e0 100644 --- a/.github/workflows/generate-c-bindings.yml +++ b/.github/workflows/generate-c-bindings.yml @@ -48,7 +48,11 @@ jobs: 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 - gh_2.95.0_linux_arm64/bin/gh release download $MRBIND_VERSION \ + 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" From 835c401dbf1e7262e942fc8a5fa8d9d936d69570 Mon Sep 17 00:00:00 2001 From: Artur Sharafutdinov Date: Tue, 23 Jun 2026 23:42:38 +0200 Subject: [PATCH 5/6] WIP: Fix permissions --- .github/workflows/generate-c-bindings.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/generate-c-bindings.yml b/.github/workflows/generate-c-bindings.yml index 3af56b8705e0..13d373995c26 100644 --- a/.github/workflows/generate-c-bindings.yml +++ b/.github/workflows/generate-c-bindings.yml @@ -12,7 +12,9 @@ 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 From 585241145208a7337c6101b3654b4106de2e01a2 Mon Sep 17 00:00:00 2001 From: Artur Sharafutdinov Date: Tue, 23 Jun 2026 23:48:37 +0200 Subject: [PATCH 6/6] WIP: Update version --- scripts/mrbind/mrbind_version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mrbind/mrbind_version.txt b/scripts/mrbind/mrbind_version.txt index 96f29a32fd96..45c7a584f300 100644 --- a/scripts/mrbind/mrbind_version.txt +++ b/scripts/mrbind/mrbind_version.txt @@ -1 +1 @@ -v0.0.0-756 +v0.0.1