Skip to content

Commit

Permalink
ARROW-17561: [Java][ORC] Move JNI build configuration from cpp/ to ja…
Browse files Browse the repository at this point in the history
…va/ (#14162)

Authored-by: Sutou Kouhei <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
  • Loading branch information
kou authored Sep 18, 2022
1 parent 9917960 commit a866f2f
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 80 deletions.
9 changes: 8 additions & 1 deletion ci/scripts/java_jni_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ build_dir=${3}/java_jni
# The directory where the final binaries will be stored when scripts finish
dist_dir=${4}

prefix_dir="${build_dir}/java-jni"

echo "=== Clear output directories and leftovers ==="
# Clear output directories and leftovers
rm -rf ${build_dir}
Expand All @@ -50,10 +52,12 @@ esac
cmake \
-DARROW_JAVA_JNI_ENABLE_DATASET=${ARROW_DATASET:-ON} \
-DARROW_JAVA_JNI_ENABLE_GANDIVA=${ARROW_GANDIVA:-ON} \
-DARROW_JAVA_JNI_ENABLE_ORC=${ARROW_ORC:-ON} \
-DBUILD_TESTING=${ARROW_JAVA_BUILD_TESTS} \
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
-DCMAKE_PREFIX_PATH=${arrow_install_dir} \
-DCMAKE_INSTALL_PREFIX=${dist_dir} \
-DCMAKE_INSTALL_PREFIX=${prefix_dir} \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_UNITY_BUILD=${CMAKE_UNITY_BUILD:-OFF} \
-GNinja \
${JAVA_JNI_CMAKE_ARGS:-} \
Expand All @@ -68,3 +72,6 @@ if [ "${ARROW_JAVA_BUILD_TESTS}" = "ON" ]; then
fi
cmake --build . --config ${CMAKE_BUILD_TYPE} --target install
popd

mkdir -p ${dist_dir}
mv ${prefix_dir}/lib/* ${dist_dir}/
1 change: 0 additions & 1 deletion ci/scripts/java_jni_macos_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ fi

echo "=== Copying libraries to the distribution folder ==="
mkdir -p "${dist_dir}"
cp -L ${install_dir}/lib/libarrow_orc_jni.dylib ${dist_dir}
cp -L ${build_dir}/cpp/*/libplasma_java.dylib ${dist_dir}

echo "=== Checking shared dependencies for libraries ==="
Expand Down
1 change: 0 additions & 1 deletion ci/scripts/java_jni_manylinux_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ fi


echo "=== Copying libraries to the distribution folder ==="
cp -L ${ARROW_HOME}/lib/libarrow_orc_jni.so ${dist_dir}
cp -L ${build_dir}/cpp/*/libplasma_java.so ${dist_dir}

echo "=== Checking shared dependencies for libraries ==="
Expand Down
6 changes: 0 additions & 6 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1023,12 +1023,6 @@ if(ARROW_PARQUET)
endif()
endif()

if(ARROW_JNI)
if(ARROW_ORC)
add_subdirectory(../java/adapter/orc/src/main/cpp ./java/orc/jni)
endif()
endif()

if(ARROW_GANDIVA)
add_subdirectory(src/gandiva)
endif()
Expand Down
6 changes: 6 additions & 0 deletions java/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ option(ARROW_JAVA_JNI_ENABLE_DEFAULT "Whether enable components by default or no
option(ARROW_JAVA_JNI_ENABLE_C "Enable C data interface" ${ARROW_JAVA_JNI_ENABLE_DEFAULT})
option(ARROW_JAVA_JNI_ENABLE_DATASET "Enable dataset" ${ARROW_JAVA_JNI_ENABLE_DEFAULT})
option(ARROW_JAVA_JNI_ENABLE_GANDIVA "Enable Gandiva" ${ARROW_JAVA_JNI_ENABLE_DEFAULT})
option(ARROW_JAVA_JNI_ENABLE_ORC "Enable ORC" ${ARROW_JAVA_JNI_ENABLE_DEFAULT})

include(GNUInstallDirs)

# ccache
option(ARROW_JAVA_JNI_USE_CCACHE "Use ccache when compiling (if available)" ON)
Expand Down Expand Up @@ -74,3 +77,6 @@ endif()
if(ARROW_JAVA_JNI_ENABLE_GANDIVA)
add_subdirectory(gandiva)
endif()
if(ARROW_JAVA_JNI_ENABLE_ORC)
add_subdirectory(adapter/orc)
endif()
27 changes: 12 additions & 15 deletions java/adapter/orc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,26 @@
# specific language governing permissions and limitations
# under the License.

#
# arrow_orc_java
#

# Headers: top level

project(arrow_orc_java)
find_package(Arrow REQUIRED)

# Find java/jni
include(FindJava)
include(UseJava)
include(FindJNI)
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
${JNI_INCLUDE_DIRS} ${JNI_HEADERS_DIR})

message("generating headers to ${JNI_HEADERS_DIR}")

add_jar(arrow_orc_java
add_jar(arrow_java_jni_orc_jar
src/main/java/org/apache/arrow/adapter/orc/OrcReaderJniWrapper.java
src/main/java/org/apache/arrow/adapter/orc/OrcStripeReaderJniWrapper.java
src/main/java/org/apache/arrow/adapter/orc/OrcMemoryJniWrapper.java
src/main/java/org/apache/arrow/adapter/orc/OrcJniUtils.java
src/main/java/org/apache/arrow/adapter/orc/OrcRecordBatch.java
src/main/java/org/apache/arrow/adapter/orc/OrcFieldNode.java
GENERATE_NATIVE_HEADERS
arrow_orc_java-native
arrow_java_jni_orc_headers
DESTINATION
${JNI_HEADERS_DIR})

add_library(arrow_java_jni_orc SHARED src/main/cpp/jni_wrapper.cpp)
set_property(TARGET arrow_java_jni_orc PROPERTY OUTPUT_NAME "arrow_orc_jni")
target_link_libraries(arrow_java_jni_orc arrow_java_jni_orc_headers jni
Arrow::arrow_static)

install(TARGETS arrow_java_jni_orc DESTINATION ${CMAKE_INSTALL_LIBDIR})
53 changes: 0 additions & 53 deletions java/adapter/orc/src/main/cpp/CMakeLists.txt

This file was deleted.

2 changes: 1 addition & 1 deletion java/c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ 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)

install(TARGETS arrow_java_jni_cdata DESTINATION ${CMAKE_INSTALL_PREFIX})
install(TARGETS arrow_java_jni_cdata DESTINATION ${CMAKE_INSTALL_LIBDIR})
2 changes: 1 addition & 1 deletion java/dataset/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ if(BUILD_TESTING)
add_test(NAME arrow-java-jni-dataset-test COMMAND arrow-java-jni-dataset-test)
endif()

install(TARGETS arrow_java_jni_dataset DESTINATION ${CMAKE_INSTALL_PREFIX})
install(TARGETS arrow_java_jni_dataset DESTINATION ${CMAKE_INSTALL_LIBDIR})
2 changes: 1 addition & 1 deletion java/gandiva/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ if(CXX_LINKER_SUPPORTS_VERSION_SCRIPT)
)
endif()

install(TARGETS arrow_java_jni_gandiva DESTINATION ${CMAKE_INSTALL_PREFIX})
install(TARGETS arrow_java_jni_gandiva DESTINATION ${CMAKE_INSTALL_LIBDIR})

0 comments on commit a866f2f

Please sign in to comment.