2018-07-04 17:59:59 +08:00
|
|
|
#! /bin/bash
|
|
|
|
|
|
|
|
source $(dirname "$0")/Environment.sh
|
|
|
|
|
2019-04-30 19:41:13 +08:00
|
|
|
export CC=clang-7
|
|
|
|
export CXX=clang++-7
|
2018-07-04 17:59:59 +08:00
|
|
|
|
|
|
|
# ==============================================================================
|
|
|
|
# -- Parse arguments -----------------------------------------------------------
|
|
|
|
# ==============================================================================
|
|
|
|
|
|
|
|
DOC_STRING="Build and package CARLA Python API."
|
|
|
|
|
|
|
|
USAGE_STRING="Usage: $0 [-h|--help] [--rebuild] [--py2] [--py3] [--clean]"
|
|
|
|
|
|
|
|
REMOVE_INTERMEDIATE=false
|
|
|
|
BUILD_FOR_PYTHON2=false
|
|
|
|
BUILD_FOR_PYTHON3=false
|
2019-06-03 19:01:53 +08:00
|
|
|
BUILD_RSS_VARIANT=false
|
2018-07-04 17:59:59 +08:00
|
|
|
|
2019-06-03 19:01:53 +08:00
|
|
|
OPTS=`getopt -o h --long help,rebuild,py2,py3,clean,rss -n 'parse-options' -- "$@"`
|
2018-07-04 17:59:59 +08:00
|
|
|
|
|
|
|
if [ $? != 0 ] ; then echo "$USAGE_STRING" ; exit 2 ; fi
|
|
|
|
|
|
|
|
eval set -- "$OPTS"
|
|
|
|
|
|
|
|
while true; do
|
|
|
|
case "$1" in
|
|
|
|
--rebuild )
|
|
|
|
REMOVE_INTERMEDIATE=true;
|
|
|
|
BUILD_FOR_PYTHON2=true;
|
|
|
|
BUILD_FOR_PYTHON3=true;
|
|
|
|
shift ;;
|
|
|
|
--py2 )
|
|
|
|
BUILD_FOR_PYTHON2=true;
|
|
|
|
shift ;;
|
|
|
|
--py3 )
|
|
|
|
BUILD_FOR_PYTHON3=true;
|
|
|
|
shift ;;
|
2019-06-03 19:01:53 +08:00
|
|
|
--rss )
|
|
|
|
BUILD_RSS_VARIANT=true;
|
|
|
|
shift ;;
|
2018-07-04 17:59:59 +08:00
|
|
|
--clean )
|
|
|
|
REMOVE_INTERMEDIATE=true;
|
|
|
|
shift ;;
|
|
|
|
-h | --help )
|
|
|
|
echo "$DOC_STRING"
|
|
|
|
echo "$USAGE_STRING"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
* )
|
|
|
|
break ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if ! { ${REMOVE_INTERMEDIATE} || ${BUILD_FOR_PYTHON2} || ${BUILD_FOR_PYTHON3}; }; then
|
|
|
|
fatal_error "Nothing selected to be done."
|
|
|
|
fi
|
|
|
|
|
2019-03-29 01:35:31 +08:00
|
|
|
pushd "${CARLA_PYTHONAPI_SOURCE_FOLDER}" >/dev/null
|
2018-07-04 17:59:59 +08:00
|
|
|
|
|
|
|
# ==============================================================================
|
|
|
|
# -- Clean intermediate files --------------------------------------------------
|
|
|
|
# ==============================================================================
|
|
|
|
|
|
|
|
if ${REMOVE_INTERMEDIATE} ; then
|
|
|
|
|
|
|
|
log "Cleaning intermediate files and folders."
|
|
|
|
|
|
|
|
rm -Rf build dist carla.egg-info source/carla.egg-info
|
|
|
|
|
|
|
|
find source -name "*.so" -delete
|
|
|
|
find source -name "__pycache__" -type d -exec rm -r "{}" \;
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
# ==============================================================================
|
|
|
|
# -- Build API -----------------------------------------------------------------
|
|
|
|
# ==============================================================================
|
|
|
|
|
2019-06-03 19:01:53 +08:00
|
|
|
if ${BUILD_RSS_VARIANT} ; then
|
|
|
|
export BUILD_RSS_VARIANT=${BUILD_RSS_VARIANT}
|
|
|
|
fi
|
|
|
|
|
2018-07-04 17:59:59 +08:00
|
|
|
if ${BUILD_FOR_PYTHON2} ; then
|
|
|
|
|
|
|
|
log "Building Python API for Python 2."
|
|
|
|
|
|
|
|
/usr/bin/env python2 setup.py bdist_egg
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ${BUILD_FOR_PYTHON3} ; then
|
|
|
|
|
|
|
|
log "Building Python API for Python 3."
|
|
|
|
|
|
|
|
/usr/bin/env python3 setup.py bdist_egg
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
# ==============================================================================
|
|
|
|
# -- ...and we are done --------------------------------------------------------
|
|
|
|
# ==============================================================================
|
|
|
|
|
|
|
|
popd >/dev/null
|
|
|
|
|
|
|
|
log "Success!"
|