1 #!/bin/bash
 2 
 3 # Check if the search path is provided
 4 if [ -z "$1" ]; then
 5     echo "Please provide the path to search for libonnxruntime.*.dylib"
 6     exit 1
 7 fi
 8 
 9 # Search for libonnxruntime.dylib in the given path
10 LIB_PATH="$(find "$1" -name libonnxruntime.*.dylib -print -quit)"
11 
12 if [ -z "$LIB_PATH" ]; then
13     echo "libonnxruntime.*.dylib not found in $1"
14     exit 1
15 fi
16 
17 # Infer other paths based on the location of libonnxruntime.*.dylib
18 ONNXRT_DIR=$(dirname $(dirname $(dirname $(dirname $LIB_PATH))))
19 INCLUDE_DIR=$ONNXRT_DIR/include/onnxruntime
20 OUTPUT_DIR=../src/main/java
21 
22 # Run jextract
23 jextract --target-package oracle.code.onnx.foreign \
24   -l :$LIB_PATH \
25   --use-system-load-library \
26   -I $INCLUDE_DIR/core/session \
27   @symbols \
28   --output $OUTPUT_DIR \
29   $INCLUDE_DIR/core/providers/coreml/coreml_provider_factory.h