Skip to content

Commit a7cd82b

Browse files
committed
Make JNI CMake args more robust
- Check if protobuf_ep-install exists before adding Protobuf_ROOT - Check if re2_ep-install exists before adding re2_ROOT - This handles cases where system dependencies are used instead of bundled
1 parent 13ea8ca commit a7cd82b

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

ci/scripts/jni_macos_build.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,21 @@ if [ "${ARROW_RUN_TESTS:-}" == "ON" ]; then
168168
fi
169169

170170
# Pass paths to bundled dependencies so the JNI build can find them
171-
# RE2 is needed by Gandiva but bundled in libarrow_bundled_dependencies.a
172-
# The JNI build needs to find RE2 to satisfy the transitive dependency
173-
export JAVA_JNI_CMAKE_ARGS="-DProtobuf_ROOT=${build_dir}/cpp/protobuf_ep-install -Dre2_ROOT=${build_dir}/cpp/re2_ep-install ${llvm_dir_arg}"
171+
# Build up the JNI CMake args based on what's available
172+
jni_cmake_args="${llvm_dir_arg}"
173+
174+
# Add Protobuf path if bundled, otherwise CMake will find system Protobuf
175+
if [ -d "${build_dir}/cpp/protobuf_ep-install" ]; then
176+
jni_cmake_args="${jni_cmake_args} -DProtobuf_ROOT=${build_dir}/cpp/protobuf_ep-install"
177+
fi
178+
179+
# RE2 is bundled in libarrow_bundled_dependencies.a but the JNI build needs
180+
# to find the RE2 CMake config to satisfy Gandiva's transitive dependency
181+
if [ -d "${build_dir}/cpp/re2_ep-install" ]; then
182+
jni_cmake_args="${jni_cmake_args} -Dre2_ROOT=${build_dir}/cpp/re2_ep-install"
183+
fi
184+
185+
export JAVA_JNI_CMAKE_ARGS="${jni_cmake_args}"
174186
"${source_dir}/ci/scripts/jni_build.sh" \
175187
"${source_dir}" \
176188
"${install_dir}" \

0 commit comments

Comments
 (0)