diff --git a/ci/scripts/java_jni_build.sh b/ci/scripts/java_jni_build.sh index 9c3f031b61d06..cbb754b3e4822 100755 --- a/ci/scripts/java_jni_build.sh +++ b/ci/scripts/java_jni_build.sh @@ -24,19 +24,6 @@ arrow_install_dir=${2} build_dir=${3}/java_jni # The directory where the final binaries will be stored when scripts finish dist_dir=${4} -normalized_arch=$(arch) -case ${normalized_arch} in - aarch64) - normalized_arch=aarch_64 - ;; - i386) - normalized_arch=x86_64 - ;; - arm64) - normalized_arch=aarch_64 - ;; - esac - prefix_dir="${build_dir}/java-jni" echo "=== Clear output directories and leftovers ===" @@ -68,8 +55,7 @@ cmake \ -DBUILD_TESTING=${ARROW_JAVA_BUILD_TESTS} \ -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \ -DCMAKE_PREFIX_PATH=${arrow_install_dir} \ - -DARROW_JAVA_JNI_ARCH_DIR=${normalized_arch} \ - -DCMAKE_INSTALL_PREFIX=${prefix_dir} \ +\ -DCMAKE_INSTALL_PREFIX=${prefix_dir} \ -DCMAKE_UNITY_BUILD=${CMAKE_UNITY_BUILD:-OFF} \ -DProtobuf_USE_STATIC_LIBS=ON \ -GNinja \ diff --git a/java/CMakeLists.txt b/java/CMakeLists.txt index 04fa51ff98ca0..e4c4dfd95fb00 100644 --- a/java/CMakeLists.txt +++ b/java/CMakeLists.txt @@ -74,6 +74,20 @@ if(BUILD_TESTING) GTest::gtest_main) endif() +# If the user hasn't set ARROW_JAVA_JNI_ARCH_DIR, derive the normalized +# operating system from the host processor. +if("${ARROW_JAVA_JNI_ARCH_DIR}" STREQUAL "") + if("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "aarch64") + set(ARROW_JAVA_JNI_ARCH_DIR "aarch_64") + elseif("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "i386") + set(ARROW_JAVA_JNI_ARCH_DIR "x86_64") + elseif("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "arm64") + set(ARROW_JAVA_JNI_ARCH_DIR "aarch_64") + else() + set(ARROW_JAVA_JNI_ARCH_DIR "${CMAKE_HOST_SYSTEM_PROCESSOR}") + endif() +endif() + if(ARROW_JAVA_JNI_ENABLE_C) add_subdirectory(c) endif() diff --git a/java/c/CMakeLists.txt b/java/c/CMakeLists.txt index 8e307672d0e1d..83909c5e13e1b 100644 --- a/java/c/CMakeLists.txt +++ b/java/c/CMakeLists.txt @@ -30,11 +30,11 @@ add_library(arrow_java_jni_cdata SHARED src/main/cpp/jni_wrapper.cc) set_property(TARGET arrow_java_jni_cdata PROPERTY OUTPUT_NAME "arrow_cdata_jni") target_link_libraries(arrow_java_jni_cdata arrow_java_jni_cdata_headers jni) -set(ARROW_JAVA_JNI_CDATA_LIBDIR +set(ARROW_JAVA_JNI_C_LIBDIR "${CMAKE_INSTALL_PREFIX}/lib/arrow_cdata_jni/${ARROW_JAVA_JNI_ARCH_DIR}") -set(ARROW_JAVA_JNI_CDATA_BINDIR +set(ARROW_JAVA_JNI_C_BINDIR "${CMAKE_INSTALL_PREFIX}/bin/arrow_cdata_jni/${ARROW_JAVA_JNI_ARCH_DIR}") install(TARGETS arrow_java_jni_cdata - LIBRARY DESTINATION ${ARROW_JAVA_JNI_CDATA_LIBDIR} - RUNTIME DESTINATION ${ARROW_JAVA_JNI_CDATA_BINDIR}) + LIBRARY DESTINATION ${ARROW_JAVA_JNI_C_LIBDIR} + RUNTIME DESTINATION ${ARROW_JAVA_JNI_C_BINDIR})