Skip to content

Commit

Permalink
Derive arch in CMakeLists.txt instead of scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
jduo committed Jan 19, 2024
1 parent aaedda7 commit 3607ed8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
16 changes: 1 addition & 15 deletions ci/scripts/java_jni_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ==="
Expand Down Expand Up @@ -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 \
Expand Down
14 changes: 14 additions & 0 deletions java/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions java/c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})

0 comments on commit 3607ed8

Please sign in to comment.