|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 3 | +# or more contributor license agreements. See the NOTICE file |
| 4 | +# distributed with this work for additional information |
| 5 | +# regarding copyright ownership. The ASF licenses this file |
| 6 | +# to you under the Apache License, Version 2.0 (the |
| 7 | +# "License"); you may not use this file except in compliance |
| 8 | +# with the License. You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, |
| 13 | +# software distributed under the License is distributed on an |
| 14 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | +# KIND, either express or implied. See the License for the |
| 16 | +# specific language governing permissions and limitations |
| 17 | +# under the License. |
| 18 | + |
| 19 | +set -eo pipefail |
| 20 | + |
| 21 | +arrow_dir=${1} |
| 22 | +arrow_install_dir=${2} |
| 23 | +build_dir=${3}/java_jni |
| 24 | +# The directory where the final binaries will be stored when scripts finish |
| 25 | +dist_dir=${4} |
| 26 | +prefix_dir="${build_dir}/java-jni" |
| 27 | + |
| 28 | +echo "=== Clear output directories and leftovers ===" |
| 29 | +# Clear output directories and leftovers |
| 30 | +rm -rf ${build_dir} |
| 31 | + |
| 32 | +echo "=== Building Arrow Java C Data Interface native library ===" |
| 33 | +mkdir -p "${build_dir}" |
| 34 | +pushd "${build_dir}" |
| 35 | + |
| 36 | +case "$(uname)" in |
| 37 | + Linux) |
| 38 | + n_jobs=$(nproc) |
| 39 | + ;; |
| 40 | + Darwin) |
| 41 | + n_jobs=$(sysctl -n hw.logicalcpu) |
| 42 | + ;; |
| 43 | + *) |
| 44 | + n_jobs=${NPROC:-1} |
| 45 | + ;; |
| 46 | +esac |
| 47 | + |
| 48 | +: ${ARROW_JAVA_BUILD_TESTS:=${ARROW_BUILD_TESTS:-OFF}} |
| 49 | +: ${CMAKE_BUILD_TYPE:=release} |
| 50 | +cmake \ |
| 51 | + -DARROW_JAVA_JNI_ENABLE_DATASET=${ARROW_DATASET:-OFF} \ |
| 52 | + -DARROW_JAVA_JNI_ENABLE_GANDIVA=${ARROW_GANDIVA:-OFF} \ |
| 53 | + -DARROW_JAVA_JNI_ENABLE_ORC=${ARROW_ORC:-OFF} \ |
| 54 | + -DBUILD_TESTING=${ARROW_JAVA_BUILD_TESTS} \ |
| 55 | + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \ |
| 56 | + -DCMAKE_PREFIX_PATH=${arrow_install_dir} \ |
| 57 | + -DCMAKE_INSTALL_PREFIX=${prefix_dir} \ |
| 58 | + -DCMAKE_UNITY_BUILD=${CMAKE_UNITY_BUILD:-OFF} \ |
| 59 | + -DProtobuf_USE_STATIC_LIBS=ON \ |
| 60 | + -GNinja \ |
| 61 | + ${JAVA_JNI_CMAKE_ARGS:-} \ |
| 62 | + ${arrow_dir} |
| 63 | +export CMAKE_BUILD_PARALLEL_LEVEL=${n_jobs} |
| 64 | +cmake --build . --config ${CMAKE_BUILD_TYPE} |
| 65 | +if [ "${ARROW_JAVA_BUILD_TESTS}" = "ON" ]; then |
| 66 | + ctest \ |
| 67 | + --output-on-failure \ |
| 68 | + --parallel ${n_jobs} \ |
| 69 | + --timeout 300 |
| 70 | +fi |
| 71 | +cmake --build . --config ${CMAKE_BUILD_TYPE} --target install |
| 72 | +popd |
| 73 | + |
| 74 | +mkdir -p ${dist_dir} |
| 75 | +# For Windows. *.dll are installed into bin/ on Windows. |
| 76 | +if [ -d "${prefix_dir}/bin" ]; then |
| 77 | + mv ${prefix_dir}/bin/* ${dist_dir}/ |
| 78 | +else |
| 79 | + mv ${prefix_dir}/lib/* ${dist_dir}/ |
| 80 | +fi |
0 commit comments