2019-06-03 19:01:53 +08:00
|
|
|
#! /bin/bash
|
|
|
|
|
2020-10-08 17:29:25 +08:00
|
|
|
|
|
|
|
OPTS=`getopt -o h --long python-version: -n 'parse-options' -- "$@"`
|
|
|
|
|
|
|
|
eval set -- "$OPTS"
|
|
|
|
|
|
|
|
PY_VERSION_LIST=3
|
|
|
|
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
|
|
case "$1" in
|
|
|
|
--python-version )
|
|
|
|
PY_VERSION_LIST="$2";
|
|
|
|
shift 2 ;;
|
|
|
|
* )
|
|
|
|
shift ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2019-06-03 19:01:53 +08:00
|
|
|
# ==============================================================================
|
|
|
|
# -- Set up environment --------------------------------------------------------
|
|
|
|
# ==============================================================================
|
|
|
|
source $(dirname "$0")/Environment.sh
|
|
|
|
|
2020-10-08 17:29:25 +08:00
|
|
|
# Convert comma-separated string to array of unique elements.
|
|
|
|
IFS="," read -r -a PY_VERSION_LIST <<< "${PY_VERSION_LIST}"
|
|
|
|
|
2019-06-03 19:01:53 +08:00
|
|
|
# ==============================================================================
|
2020-10-08 17:29:25 +08:00
|
|
|
# -- Get ad-rss -------------------------------------------
|
2019-06-03 19:01:53 +08:00
|
|
|
# ==============================================================================
|
|
|
|
|
2023-11-16 23:03:58 +08:00
|
|
|
ADRSS_VERSION=4.4.4
|
2020-10-08 17:29:25 +08:00
|
|
|
ADRSS_BASENAME=ad-rss-${ADRSS_VERSION}
|
|
|
|
ADRSS_COLCON_WORKSPACE="${CARLA_BUILD_FOLDER}/${ADRSS_BASENAME}"
|
|
|
|
ADRSS_SRC_DIR="${ADRSS_COLCON_WORKSPACE}/src"
|
2020-03-30 18:33:15 +08:00
|
|
|
|
2020-10-08 17:29:25 +08:00
|
|
|
if [[ ! -d "${ADRSS_SRC_DIR}" ]]; then
|
|
|
|
# ad-rss is built inside a colcon workspace, therefore we have to setup the workspace first
|
|
|
|
log "Retrieving ${ADRSS_BASENAME}."
|
2019-06-03 19:01:53 +08:00
|
|
|
|
2020-10-08 17:29:25 +08:00
|
|
|
mkdir -p "${ADRSS_SRC_DIR}"
|
2019-06-03 19:01:53 +08:00
|
|
|
|
2023-11-14 18:22:08 +08:00
|
|
|
# clone ad-rss with all submodules, but remove proj, as CARLA already uses it
|
2020-10-08 17:29:25 +08:00
|
|
|
pushd "${ADRSS_SRC_DIR}" >/dev/null
|
2023-11-14 18:22:08 +08:00
|
|
|
git clone -b v${ADRSS_VERSION} https://github.com/intel/ad-rss-lib.git && cd ad-rss-lib && git submodule update --init --recursive && rm -rf dependencies/map/dependencies/PROJ4 && cd ..
|
|
|
|
|
|
|
|
# ADRSS_VERSION is designed for older boost, update datatype from boost::array to std::array
|
|
|
|
grep -rl "boost::array" | xargs sed -i 's/boost::array/std::array/g'
|
2023-11-16 23:03:58 +08:00
|
|
|
grep -rl "find_package(Boost" | xargs sed -i 's/find_package(Boost/find_package(Boost 1.80/g'
|
2020-10-08 17:29:25 +08:00
|
|
|
popd
|
2020-03-30 18:33:15 +08:00
|
|
|
|
2020-10-08 17:29:25 +08:00
|
|
|
cat >"${ADRSS_COLCON_WORKSPACE}/colcon.meta" <<EOL
|
2020-03-30 18:33:15 +08:00
|
|
|
{
|
|
|
|
"names": {
|
|
|
|
"ad_physics": {
|
2020-07-03 21:54:04 +08:00
|
|
|
"cmake-args": ["-DBUILD_PYTHON_BINDING=ON", "-DCMAKE_POSITION_INDEPENDENT_CODE=ON", "-DBUILD_SHARED_LIBS=OFF", "-DDISABLE_WARNINGS_AS_ERRORS=ON"]
|
2020-03-30 18:33:15 +08:00
|
|
|
},
|
|
|
|
"ad_map_access": {
|
2020-07-03 21:54:04 +08:00
|
|
|
"cmake-args": ["-DBUILD_PYTHON_BINDING=ON", "-DCMAKE_POSITION_INDEPENDENT_CODE=ON", "-DBUILD_SHARED_LIBS=OFF", "-DDISABLE_WARNINGS_AS_ERRORS=ON"]
|
2020-03-30 18:33:15 +08:00
|
|
|
},
|
|
|
|
"ad_map_opendrive_reader": {
|
2023-11-14 18:22:08 +08:00
|
|
|
"cmake-args": ["-DCMAKE_POSITION_INDEPENDENT_CODE=ON", "-DBUILD_SHARED_LIBS=OFF", "-DDISABLE_WARNINGS_AS_ERRORS=ON"],
|
|
|
|
"dependencies": ["odrSpiral"]
|
2020-03-30 18:33:15 +08:00
|
|
|
},
|
|
|
|
"ad_rss": {
|
2020-07-03 21:54:04 +08:00
|
|
|
"cmake-args": ["-DBUILD_PYTHON_BINDING=ON", "-DCMAKE_POSITION_INDEPENDENT_CODE=ON", "-DBUILD_SHARED_LIBS=OFF", "-DDISABLE_WARNINGS_AS_ERRORS=ON"]
|
2020-03-30 18:33:15 +08:00
|
|
|
},
|
|
|
|
"ad_rss_map_integration": {
|
2020-07-03 21:54:04 +08:00
|
|
|
"cmake-args": ["-DBUILD_PYTHON_BINDING=ON", "-DCMAKE_POSITION_INDEPENDENT_CODE=ON", "-DBUILD_SHARED_LIBS=OFF", "-DDISABLE_WARNINGS_AS_ERRORS=ON"]
|
2020-03-30 18:33:15 +08:00
|
|
|
},
|
|
|
|
"spdlog": {
|
|
|
|
"cmake-args": ["-DCMAKE_POSITION_INDEPENDENT_CODE=ON", "-DBUILD_SHARED_LIBS=OFF"]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EOL
|
2020-10-08 17:29:25 +08:00
|
|
|
fi
|
2019-06-03 19:01:53 +08:00
|
|
|
|
2020-10-08 17:29:25 +08:00
|
|
|
# ==============================================================================
|
|
|
|
# -- Build ad-rss -------------------------------------------
|
|
|
|
# ==============================================================================
|
|
|
|
ADRSS_INSTALL_DIR="${CARLA_BUILD_FOLDER}/${ADRSS_BASENAME}/install"
|
2019-06-03 19:01:53 +08:00
|
|
|
|
2023-11-16 23:03:58 +08:00
|
|
|
# Automation doesn't work if the clang installed within the system is not matching the one that is provided by Unreal
|
|
|
|
# Setup.sh would have to be adapted to reflect it
|
|
|
|
# so we need to change
|
|
|
|
#CARLA_LLVM_VERSION_MAJOR=$(cut -d'.' -f1 <<<"$(clang --version | head -n 1 | sed -r 's/^([^.]+).*$/\1/; s/^[^0-9]*([0-9]+).*$/\1/')")
|
|
|
|
#if [ -z "$CARLA_LLVM_VERSION_MAJOR" ] ; then
|
|
|
|
# fatal_error "Failed to retrieve the installed version of the clang compiler."
|
|
|
|
#else
|
|
|
|
# echo "Using clang-$CARLA_LLVM_VERSION_MAJOR as the CARLA compiler."
|
|
|
|
#fi
|
|
|
|
CXX_TAG=c10
|
2022-04-22 20:56:44 +08:00
|
|
|
|
2020-10-08 17:29:25 +08:00
|
|
|
#
|
|
|
|
# Since it it not possible with boost-python to build more than one python version at once (find_package has some bugs)
|
|
|
|
# we have to build it for every version in a separate colcon build
|
|
|
|
#
|
|
|
|
for PY_VERSION in ${PY_VERSION_LIST[@]} ; do
|
|
|
|
ADRSS_BUILD_DIR="${CARLA_BUILD_FOLDER}/${ADRSS_BASENAME}/build-python${PY_VERSION}"
|
2020-03-30 18:33:15 +08:00
|
|
|
|
2020-10-08 17:29:25 +08:00
|
|
|
if [[ -d "${ADRSS_INSTALL_DIR}" && -d "${ADRSS_BUILD_DIR}" ]]; then
|
|
|
|
log "${ADRSS_BASENAME} for python${PY_VERSION} already installed."
|
2020-03-30 18:33:15 +08:00
|
|
|
else
|
2020-10-08 17:29:25 +08:00
|
|
|
log "Building ${ADRSS_BASENAME} for python${PY_VERSION}"
|
2020-03-30 18:33:15 +08:00
|
|
|
|
2020-10-08 17:29:25 +08:00
|
|
|
pushd "${ADRSS_COLCON_WORKSPACE}" >/dev/null
|
2023-11-16 23:03:58 +08:00
|
|
|
if [[ "${CMAKE_PREFIX_PATH}" == "" ]]; then
|
|
|
|
CMAKE_PREFIX_PATH="${CARLA_BUILD_FOLDER}/boost-1.80.0-$CXX_TAG-install;${CARLA_BUILD_FOLDER}/proj-install"
|
|
|
|
else
|
|
|
|
CMAKE_PREFIX_PATH="${CARLA_BUILD_FOLDER}/boost-1.80.0-$CXX_TAG-install;${CARLA_BUILD_FOLDER}/proj-install;${CMAKE_PREFIX_PATH}"
|
|
|
|
fi
|
2020-03-30 23:52:37 +08:00
|
|
|
|
2023-11-16 23:03:58 +08:00
|
|
|
# get the python version of the binding to be built, need to query the binary,
|
|
|
|
# because might be just provided a '3' as PY_VERSION and then the symbolic linked python3 is called
|
|
|
|
PYTHON_VERSION=$(/usr/bin/env python${PY_VERSION} -V 2>&1)
|
|
|
|
PYTHON_BINDING_VERSIONS=${PYTHON_VERSION:7}
|
|
|
|
PYTHON_BINDING_VERSIONS=${PYTHON_BINDING_VERSIONS%.*}
|
2020-10-08 17:29:25 +08:00
|
|
|
echo "PYTHON_BINDING_VERSIONS=${PYTHON_BINDING_VERSIONS}"
|
2020-03-30 18:33:15 +08:00
|
|
|
|
2020-10-08 17:29:25 +08:00
|
|
|
# enforce sequential executor to reduce the required memory for compilation
|
2021-06-16 23:08:55 +08:00
|
|
|
colcon build --executor sequential --packages-up-to ad_rss_map_integration --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_TOOLCHAIN_FILE="${CARLA_BUILD_FOLDER}/LibStdCppToolChain.cmake" -DCMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}" -DPYTHON_BINDING_VERSIONS="${PYTHON_BINDING_VERSIONS}" --build-base ${ADRSS_BUILD_DIR} --install-base ${ADRSS_INSTALL_DIR}
|
2020-03-30 18:33:15 +08:00
|
|
|
|
2020-10-08 17:29:25 +08:00
|
|
|
COLCON_RESULT=$?
|
|
|
|
if (( COLCON_RESULT )); then
|
|
|
|
rm -rf "${ADRSS_INSTALL_DIR}"
|
|
|
|
log "Failed !"
|
|
|
|
else
|
|
|
|
log "Success!"
|
|
|
|
fi
|
|
|
|
popd >/dev/null
|
|
|
|
fi
|
|
|
|
done
|