This is an automated email from the ASF dual-hosted git repository.

xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git


The following commit(s) were added to refs/heads/main by this push:
     new 2a41a2586 ci(bindings/ocaml): Use dyn link instead (#6988)
2a41a2586 is described below

commit 2a41a2586221ec1db24835f24c6a959d40941047
Author: Xuanwo <[email protected]>
AuthorDate: Fri Dec 12 18:09:32 2025 +0800

    ci(bindings/ocaml): Use dyn link instead (#6988)
    
    * ci(bindings/ocaml): Use dyn link instead
    
    Signed-off-by: Xuanwo <[email protected]>
    
    * Try fix
    
    Signed-off-by: Xuanwo <[email protected]>
    
    * format code
    
    Signed-off-by: Xuanwo <[email protected]>
    
    ---------
    
    Signed-off-by: Xuanwo <[email protected]>
---
 .github/workflows/ci_bindings_ocaml.yml | 24 ++++++++++++++++++------
 bindings/ocaml/Cargo.toml               |  2 +-
 bindings/ocaml/src/dune                 | 14 ++++++++++----
 bindings/ocaml/test/dune                | 10 +++++++++-
 4 files changed, 38 insertions(+), 12 deletions(-)

diff --git a/.github/workflows/ci_bindings_ocaml.yml 
b/.github/workflows/ci_bindings_ocaml.yml
index 0e2b4f97b..d5006a6f9 100644
--- a/.github/workflows/ci_bindings_ocaml.yml
+++ b/.github/workflows/ci_bindings_ocaml.yml
@@ -33,6 +33,23 @@ on:
   workflow_dispatch:
 
 jobs:
+  build:
+    runs-on: ubuntu-22.04
+    steps:
+      - name: Checkout PR
+        uses: actions/checkout@v5
+
+      - name: Setup OCaml toolchain
+        uses: ./.github/actions/setup-ocaml
+        with:
+          need-depext: true
+          need-pin: true
+
+      - name: Clippy Check
+        working-directory: "bindings/ocaml"
+        run: |
+          cargo clippy -- -D warnings
+
   test:
     # Wait for https://github.com/ocaml/setup-ocaml/issues/872 fixes
     runs-on: ubuntu-22.04
@@ -56,16 +73,11 @@ jobs:
           need-depext: true
           need-pin: true
 
-      - name: Clippy Check
-        working-directory: "bindings/ocaml"
-        run: |
-          cargo clippy -- -D warnings
-
       - name: Checks
         run: |
           # make sure tests pass
           opam install -y dune ounit2 ocamlformat
           eval $(opam env)
           cd bindings/ocaml
-          dune runtest
           dune build @fmt
+          dune runtest
diff --git a/bindings/ocaml/Cargo.toml b/bindings/ocaml/Cargo.toml
index 1b9cdc4fc..82bb8d277 100644
--- a/bindings/ocaml/Cargo.toml
+++ b/bindings/ocaml/Cargo.toml
@@ -27,7 +27,7 @@ repository = "https://github.com/apache/opendal";
 rust-version = "1.85"
 
 [lib]
-crate-type = ["staticlib", "cdylib"]
+crate-type = ["cdylib"]
 doc = false
 
 [dependencies]
diff --git a/bindings/ocaml/src/dune b/bindings/ocaml/src/dune
index bcd2d45a8..d3b4770e1 100644
--- a/bindings/ocaml/src/dune
+++ b/bindings/ocaml/src/dune
@@ -16,16 +16,16 @@
 ; under the License.
 
 (rule
- (targets libopendal_core.a dllopendal_core.so)
+ (targets libopendal_core.a dllopendal_core.so libopendal_core.so)
  (deps
   (glob_files *.rs))
  (action
   (progn
    (run sh -c "cd %{project_root}/../.. && cargo build --release")
    (run sh -c
-     "mv %{project_root}/../../target/release/libopendal_ocaml.so 
./dllopendal_core.so 2> /dev/null || mv 
%{project_root}/../../target/release/libopendal_ocaml.dylib 
./dllopendal_core.so")
-   (run mv %{project_root}/../../target/release/libopendal_ocaml.a
-     libopendal_core.a))))
+     "if [ -f %{project_root}/../../target/release/libopendal_ocaml.so ]; then 
cp %{project_root}/../../target/release/libopendal_ocaml.so 
./dllopendal_core.so; cp 
%{project_root}/../../target/release/libopendal_ocaml.so ./libopendal_core.so; 
else cp %{project_root}/../../target/release/libopendal_ocaml.dylib 
./dllopendal_core.so; cp 
%{project_root}/../../target/release/libopendal_ocaml.dylib 
./libopendal_core.so; fi")
+   (run sh -c
+     "echo 'void __opendal_core_dummy(void) {}' | cc -c -x c - -o 
opendal_core_dummy.o && ar crs libopendal_core.a opendal_core_dummy.o && rm 
opendal_core_dummy.o"))))
 
 (library
  (name opendal_core)
@@ -33,3 +33,9 @@
  (foreign_archives opendal_core)
  (c_library_flags
   (-lpthread -lc -lm)))
+
+(install
+ (section lib)
+ (package opendal)
+ (files
+  (libopendal_core.so as opendal_core/libopendal_core.so)))
diff --git a/bindings/ocaml/test/dune b/bindings/ocaml/test/dune
index 9c0f13fec..bba172c3f 100644
--- a/bindings/ocaml/test/dune
+++ b/bindings/ocaml/test/dune
@@ -22,5 +22,13 @@
 
 (rule
  (alias runtest)
+ (deps ../src/libopendal_core.so)
  (action
-  (run ./test.exe)))
+  (progn
+   (setenv
+    LD_LIBRARY_PATH
+    "../src:%{env:LD_LIBRARY_PATH=}"
+    (setenv
+     DYLD_LIBRARY_PATH
+     "../src:%{env:DYLD_LIBRARY_PATH=}"
+     (run ./test.exe))))))

Reply via email to