carla/Util/BuildTools/BuildOSM2ODR.sh

109 lines
2.8 KiB
Bash
Raw Normal View History

2020-06-15 23:54:51 +08:00
#! /bin/bash
2020-07-28 17:29:06 +08:00
DOC_STRING="Build OSM2ODR."
2020-06-15 23:54:51 +08:00
2020-07-28 17:29:06 +08:00
USAGE_STRING=$(cat <<- END
Usage: $0 [-h|--help]
2020-06-15 23:54:51 +08:00
2020-07-28 17:29:06 +08:00
commands
2020-06-15 23:54:51 +08:00
2020-07-28 17:29:06 +08:00
[--clean] Clean intermediate files.
[--rebuild] Clean and rebuild both configurations.
END
)
2020-06-15 23:54:51 +08:00
2020-07-28 17:29:06 +08:00
REMOVE_INTERMEDIATE=false
BUILD_OSM2ODR=false
2021-03-15 18:07:03 +08:00
GIT_PULL=true
2021-06-11 22:45:06 +08:00
CURRENT_OSM2ODR_COMMIT=ee0c2b9241fef5365a6bc044ac82e6580b8ce936
2021-03-15 18:07:03 +08:00
OSM2ODR_BRANCH=carla_osm2odr
OSM2ODR_REPO=https://github.com/carla-simulator/sumo.git
2020-07-28 17:29:06 +08:00
2021-03-15 18:07:03 +08:00
OPTS=`getopt -o h --long help,rebuild,build,clean,carsim,no-pull -n 'parse-options' -- "$@"`
2020-07-28 17:29:06 +08:00
eval set -- "$OPTS"
2020-10-01 22:35:12 +08:00
while [[ $# -gt 0 ]]; do
case "$1" in
2020-07-28 17:29:06 +08:00
--rebuild )
REMOVE_INTERMEDIATE=true;
BUILD_OSM2ODR=true;
shift ;;
--build )
BUILD_OSM2ODR=true;
shift ;;
2021-03-15 18:07:03 +08:00
--no-pull )
GIT_PULL=false
shift ;;
2020-07-28 17:29:06 +08:00
--clean )
REMOVE_INTERMEDIATE=true;
shift ;;
-h | --help )
echo "$DOC_STRING"
echo "$USAGE_STRING"
exit 1
;;
* )
shift ;;
2020-07-28 17:29:06 +08:00
esac
done
source $(dirname "$0")/Environment.sh
function get_source_code_checksum {
local EXCLUDE='*__pycache__*'
2021-03-15 18:07:03 +08:00
find "${OSM2ODR_SOURCE_FOLDER}"/* \! -path "${EXCLUDE}" -print0 | sha1sum | awk '{print $1}'
}
2020-07-28 17:29:06 +08:00
if ! { ${REMOVE_INTERMEDIATE} || ${BUILD_OSM2ODR}; }; then
fatal_error "Nothing selected to be done."
fi
# ==============================================================================
# -- Clean intermediate files --------------------------------------------------
# ==============================================================================
if ${REMOVE_INTERMEDIATE} ; then
log "Cleaning intermediate files and folders."
rm -Rf ${OSM2ODR_BUILD_FOLDER}*
fi
# ==============================================================================
# -- Build library -------------------------------------------------------------
# ==============================================================================
if ${BUILD_OSM2ODR} ; then
log "Building OSM2ODR."
2021-03-15 18:07:03 +08:00
# [ ! -d ${OSM2ODR_BUILD_FOLDER} ] && mkdir ${OSM2ODR_BUILD_FOLDER}
if ${GIT_PULL} ; then
if [ ! -d ${OSM2ODR_SOURCE_FOLDER} ] ; then
git clone -b ${OSM2ODR_BRANCH} ${OSM2ODR_REPO} ${OSM2ODR_SOURCE_FOLDER}
fi
cd ${OSM2ODR_SOURCE_FOLDER}
git fetch
git checkout ${CURRENT_OSM2ODR_COMMIT}
fi
mkdir -p ${OSM2ODR_BUILD_FOLDER}
2020-07-28 17:29:06 +08:00
cd ${OSM2ODR_BUILD_FOLDER}
# define clang compiler
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++
2020-07-28 17:29:06 +08:00
2021-03-15 18:07:03 +08:00
cmake ${OSM2ODR_SOURCE_FOLDER} \
2020-07-28 17:29:06 +08:00
-G "Eclipse CDT4 - Ninja" \
-DCMAKE_INSTALL_PREFIX=${LIBCARLA_INSTALL_CLIENT_FOLDER} \
-DPROJ_INCLUDE_DIR=${CARLA_BUILD_FOLDER}/proj-install/include \
2021-03-15 18:07:03 +08:00
-DPROJ_LIBRARY=${CARLA_BUILD_FOLDER}/proj-install/lib/libproj.a \
-DXercesC_INCLUDE_DIR=${CARLA_BUILD_FOLDER}/xerces-c-3.2.3-install/include \
-DXercesC_LIBRARY=${CARLA_BUILD_FOLDER}/xerces-c-3.2.3-install/lib/libxerces-c.a
2020-07-28 17:29:06 +08:00
ninja osm2odr
ninja install
fi
log "Success!"