|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +############################################################################### |
| 4 | +# Copyright 2024 The Apollo Authors. All Rights Reserved. |
| 5 | +# |
| 6 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +# you may not use this file except in compliance with the License. |
| 8 | +# 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, software |
| 13 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +# See the License for the specific language governing permissions and |
| 16 | +# limitations under the License. |
| 17 | +############################################################################### |
| 18 | + |
| 19 | +# Fail on first error. |
| 20 | +set -e |
| 21 | + |
| 22 | +INSTALL_ATOM=${INSTALL_ATOM:-gtsam-4.2} |
| 23 | + |
| 24 | +SCRIPT_DIR="$( |
| 25 | + cd "$(dirname "${BASH_SOURCE[0]}")" |
| 26 | + pwd -P |
| 27 | +)" |
| 28 | +[[ -f "${SCRIPT_DIR}/installer_base.sh" ]] && source ${SCRIPT_DIR}/installer_base.sh |
| 29 | +[[ -f "${SCRIPT_DIR}/cmake_package_install_funcs.sh" ]] && source ${SCRIPT_DIR}/cmake_package_install_funcs.sh |
| 30 | + |
| 31 | +if ldconfig -p | grep libgtsam.so | grep -q /usr/lib; then |
| 32 | + info "gtsam was already installed" |
| 33 | + exit 0 |
| 34 | +fi |
| 35 | + |
| 36 | +# fallback |
| 37 | +# SRC_URI="${SRC_URI:-https://github.com/borglab/gtsam/archive/refs/tags/${PV}.tar.gz} -> ${PN}-${PV}.tar.gz}" |
| 38 | +SRC_URI="${SRC_URI:-https://apollo-system.cdn.bcebos.com/archive/10.0/${PN}-${PV}.tar.gz}" |
| 39 | +PATCHES=( |
| 40 | + "${FILESDIR}/gtsam-4.2_compilation_flags_$(uname -m).patch" |
| 41 | +) |
| 42 | + |
| 43 | +src_prepare_pre() { |
| 44 | + # apt_get_update_and_install libboost-all-dev |
| 45 | + apt_get_update_and_install apollo-neo-3rd-boost |
| 46 | + # TODO: pack to 3rd-boost release tarball |
| 47 | + boost_cmake_files_url='https://apollo-system.cdn.bcebos.com/archive/10.0/3rd-boost_1.74.0_cmake_files.tar.gz' |
| 48 | + curl -sSL "${boost_cmake_files_url}" | tar xz -C /opt/apollo/neo/packages/3rd-boost/latest |
| 49 | +} |
| 50 | + |
| 51 | +cmake_src_configure() { |
| 52 | + mkdir -p "${WORKDIR}/${PF}_build" |
| 53 | + pushd "${WORKDIR}/${PF}_build" |
| 54 | + cmake ${WORKDIR}/${PF} \ |
| 55 | + -DBUILD_SHARED_LIBS=ON \ |
| 56 | + -DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" \ |
| 57 | + -DBoost_NO_SYSTEM_PATHS="true" \ |
| 58 | + -DBOOST_ROOT="${BOOST_ROOT:-/opt/apollo/neo/packages/3rd-boost/latest}" \ |
| 59 | + -DCMAKE_BUILD_TYPE=Release |
| 60 | + popd |
| 61 | +} |
| 62 | + |
| 63 | +if [[ "${BASH_SOURCE[0]}" != "${0}" ]]; then |
| 64 | + # Being sourced, do nothing |
| 65 | + : |
| 66 | +else |
| 67 | + install_package "$@" |
| 68 | +fi |
0 commit comments