2018-07-04 17:59:59 +08:00
|
|
|
#! /bin/bash
|
|
|
|
|
|
|
|
# ==============================================================================
|
|
|
|
# -- Parse arguments -----------------------------------------------------------
|
|
|
|
# ==============================================================================
|
|
|
|
|
|
|
|
DOC_STRING="Build and launch CarlaUE4."
|
|
|
|
|
2019-06-05 00:48:11 +08:00
|
|
|
USAGE_STRING="Usage: $0 [-h|--help] [--build] [--rebuild] [--launch] [--clean] [--hard-clean] [--opengl]"
|
2018-07-04 17:59:59 +08:00
|
|
|
|
|
|
|
REMOVE_INTERMEDIATE=false
|
|
|
|
HARD_CLEAN=false
|
|
|
|
BUILD_CARLAUE4=false
|
|
|
|
LAUNCH_UE4_EDITOR=false
|
2020-12-04 23:09:46 +08:00
|
|
|
USE_CARSIM=false
|
2021-01-28 19:53:40 +08:00
|
|
|
USE_CHRONO=false
|
2022-09-23 21:39:09 +08:00
|
|
|
USE_PYTORCH=false
|
2023-03-20 19:09:39 +08:00
|
|
|
USE_UNITY=true
|
2023-11-06 19:34:07 +08:00
|
|
|
USE_ROS2=false
|
2023-03-20 19:09:39 +08:00
|
|
|
|
2022-06-09 05:22:30 +08:00
|
|
|
EDITOR_FLAGS=""
|
2018-07-04 17:59:59 +08:00
|
|
|
|
2019-03-29 04:11:15 +08:00
|
|
|
GDB=
|
2019-06-05 00:48:11 +08:00
|
|
|
RHI="-vulkan"
|
2019-03-29 04:11:15 +08:00
|
|
|
|
2023-11-06 19:34:07 +08:00
|
|
|
OPTS=`getopt -o h --long help,build,rebuild,launch,clean,hard-clean,gdb,opengl,carsim,pytorch,chrono,ros2,no-unity,editor-flags: -n 'parse-options' -- "$@"`
|
2018-07-04 17:59:59 +08:00
|
|
|
|
|
|
|
eval set -- "$OPTS"
|
|
|
|
|
2020-10-01 22:35:12 +08:00
|
|
|
while [[ $# -gt 0 ]]; do
|
2018-07-04 17:59:59 +08:00
|
|
|
case "$1" in
|
2022-06-09 05:22:30 +08:00
|
|
|
--editor-flags )
|
|
|
|
EDITOR_FLAGS=$2
|
|
|
|
shift ;;
|
2019-03-29 04:11:15 +08:00
|
|
|
--gdb )
|
|
|
|
GDB="gdb --args";
|
|
|
|
shift ;;
|
2018-07-04 17:59:59 +08:00
|
|
|
--build )
|
|
|
|
BUILD_CARLAUE4=true;
|
|
|
|
shift ;;
|
|
|
|
--rebuild )
|
|
|
|
REMOVE_INTERMEDIATE=true;
|
|
|
|
BUILD_CARLAUE4=true;
|
|
|
|
shift ;;
|
|
|
|
--launch )
|
|
|
|
LAUNCH_UE4_EDITOR=true;
|
|
|
|
shift ;;
|
|
|
|
--clean )
|
|
|
|
REMOVE_INTERMEDIATE=true;
|
|
|
|
shift ;;
|
|
|
|
--hard-clean )
|
|
|
|
REMOVE_INTERMEDIATE=true;
|
|
|
|
HARD_CLEAN=true;
|
|
|
|
shift ;;
|
2019-06-05 00:48:11 +08:00
|
|
|
--opengl )
|
|
|
|
RHI="-opengl";
|
|
|
|
shift ;;
|
2020-12-04 23:09:46 +08:00
|
|
|
--carsim )
|
|
|
|
USE_CARSIM=true;
|
|
|
|
shift ;;
|
2021-01-28 19:53:40 +08:00
|
|
|
--chrono )
|
|
|
|
USE_CHRONO=true
|
|
|
|
shift ;;
|
2022-09-23 21:39:09 +08:00
|
|
|
--pytorch )
|
|
|
|
USE_PYTORCH=true;
|
|
|
|
shift ;;
|
2023-11-06 19:34:07 +08:00
|
|
|
--ros2 )
|
|
|
|
USE_ROS2=true;
|
|
|
|
shift ;;
|
2023-03-20 19:09:39 +08:00
|
|
|
--no-unity )
|
|
|
|
USE_UNITY=false
|
|
|
|
shift ;;
|
2018-07-04 17:59:59 +08:00
|
|
|
-h | --help )
|
|
|
|
echo "$DOC_STRING"
|
|
|
|
echo "$USAGE_STRING"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
* )
|
2020-09-30 22:57:53 +08:00
|
|
|
shift ;;
|
2018-07-04 17:59:59 +08:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2020-12-17 17:53:03 +08:00
|
|
|
# ==============================================================================
|
|
|
|
# -- Set up environment --------------------------------------------------------
|
|
|
|
# ==============================================================================
|
|
|
|
|
|
|
|
source $(dirname "$0")/Environment.sh
|
|
|
|
|
|
|
|
if [ ! -d "${UE4_ROOT}" ]; then
|
|
|
|
fatal_error "UE4_ROOT is not defined, or points to a non-existant directory, please set this environment variable."
|
|
|
|
else
|
|
|
|
log "Using Unreal Engine at '$UE4_ROOT'"
|
|
|
|
fi
|
|
|
|
|
2018-07-04 17:59:59 +08:00
|
|
|
if ! { ${REMOVE_INTERMEDIATE} || ${BUILD_CARLAUE4} || ${LAUNCH_UE4_EDITOR}; }; then
|
|
|
|
fatal_error "Nothing selected to be done."
|
|
|
|
fi
|
|
|
|
|
|
|
|
pushd "${CARLAUE4_ROOT_FOLDER}" >/dev/null
|
|
|
|
|
|
|
|
# ==============================================================================
|
|
|
|
# -- Clean CarlaUE4 ------------------------------------------------------------
|
|
|
|
# ==============================================================================
|
|
|
|
|
|
|
|
if ${HARD_CLEAN} ; then
|
|
|
|
|
|
|
|
if [ ! -f Makefile ]; then
|
|
|
|
fatal_error "The project wasn't built before!"
|
|
|
|
fi
|
|
|
|
|
|
|
|
log "Doing a \"hard\" clean of the Unreal Engine project."
|
|
|
|
|
|
|
|
make CarlaUE4Editor ARGS=-clean
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ${REMOVE_INTERMEDIATE} ; then
|
|
|
|
|
2018-10-27 19:21:35 +08:00
|
|
|
log "Cleaning intermediate files and folders."
|
|
|
|
|
|
|
|
UE4_INTERMEDIATE_FOLDERS="Binaries Build Intermediate DerivedDataCache"
|
|
|
|
|
|
|
|
rm -Rf ${UE4_INTERMEDIATE_FOLDERS}
|
|
|
|
|
2019-01-31 19:32:37 +08:00
|
|
|
rm -f Makefile
|
|
|
|
|
2018-10-27 19:21:35 +08:00
|
|
|
pushd "${CARLAUE4_PLUGIN_ROOT_FOLDER}" >/dev/null
|
|
|
|
|
|
|
|
rm -Rf ${UE4_INTERMEDIATE_FOLDERS}
|
|
|
|
|
2024-05-13 22:17:26 +08:00
|
|
|
cd Plugins
|
|
|
|
rm -Rf HoudiniEngine
|
|
|
|
cd ..
|
|
|
|
|
2018-10-27 19:21:35 +08:00
|
|
|
popd >/dev/null
|
|
|
|
|
2018-07-04 17:59:59 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
# ==============================================================================
|
|
|
|
# -- Build CarlaUE4 ------------------------------------------------------------
|
|
|
|
# ==============================================================================
|
|
|
|
|
|
|
|
if ${BUILD_CARLAUE4} ; then
|
|
|
|
|
2021-01-29 23:57:40 +08:00
|
|
|
OPTIONAL_MODULES_TEXT=""
|
2020-12-11 19:17:17 +08:00
|
|
|
if ${USE_CARSIM} ; then
|
|
|
|
python ${PWD}/../../Util/BuildTools/enable_carsim_to_uproject.py -f="CarlaUE4.uproject" -e
|
2021-01-29 23:57:40 +08:00
|
|
|
OPTIONAL_MODULES_TEXT="CarSim ON"$'\n'"${OPTIONAL_MODULES_TEXT}"
|
2020-12-11 19:17:17 +08:00
|
|
|
else
|
|
|
|
python ${PWD}/../../Util/BuildTools/enable_carsim_to_uproject.py -f="CarlaUE4.uproject"
|
2021-01-29 23:57:40 +08:00
|
|
|
OPTIONAL_MODULES_TEXT="CarSim OFF"$'\n'"${OPTIONAL_MODULES_TEXT}"
|
2021-01-28 19:53:40 +08:00
|
|
|
fi
|
|
|
|
if ${USE_CHRONO} ; then
|
2021-01-29 23:57:40 +08:00
|
|
|
OPTIONAL_MODULES_TEXT="Chrono ON"$'\n'"${OPTIONAL_MODULES_TEXT}"
|
2021-01-28 19:53:40 +08:00
|
|
|
else
|
2021-01-29 23:57:40 +08:00
|
|
|
OPTIONAL_MODULES_TEXT="Chrono OFF"$'\n'"${OPTIONAL_MODULES_TEXT}"
|
2020-12-11 19:17:17 +08:00
|
|
|
fi
|
2022-09-23 21:39:09 +08:00
|
|
|
if ${USE_PYTORCH} ; then
|
|
|
|
OPTIONAL_MODULES_TEXT="Pytorch ON"$'\n'"${OPTIONAL_MODULES_TEXT}"
|
|
|
|
else
|
|
|
|
OPTIONAL_MODULES_TEXT="Pytorch OFF"$'\n'"${OPTIONAL_MODULES_TEXT}"
|
|
|
|
fi
|
2023-11-06 19:34:07 +08:00
|
|
|
if ${USE_ROS2} ; then
|
|
|
|
OPTIONAL_MODULES_TEXT="Ros2 ON"$'\n'"${OPTIONAL_MODULES_TEXT}"
|
|
|
|
else
|
|
|
|
OPTIONAL_MODULES_TEXT="Ros2 OFF"$'\n'"${OPTIONAL_MODULES_TEXT}"
|
|
|
|
fi
|
2023-03-20 19:09:39 +08:00
|
|
|
if ${USE_UNITY} ; then
|
|
|
|
OPTIONAL_MODULES_TEXT="Unity ON"$'\n'"${OPTIONAL_MODULES_TEXT}"
|
|
|
|
else
|
|
|
|
OPTIONAL_MODULES_TEXT="Unity OFF"$'\n'"${OPTIONAL_MODULES_TEXT}"
|
|
|
|
fi
|
2023-11-06 19:34:07 +08:00
|
|
|
OPTIONAL_MODULES_TEXT="Fast_dds ON"$'\n'"${OPTIONAL_MODULES_TEXT}"
|
2021-01-29 23:57:40 +08:00
|
|
|
echo ${OPTIONAL_MODULES_TEXT} > ${PWD}/Config/OptionalModules.ini
|
2018-07-04 17:59:59 +08:00
|
|
|
|
2020-12-11 19:17:17 +08:00
|
|
|
if [ ! -f Makefile ]; then
|
2020-12-04 23:24:36 +08:00
|
|
|
|
2018-07-04 17:59:59 +08:00
|
|
|
# This command fails sometimes but normally we can continue anyway.
|
|
|
|
set +e
|
|
|
|
log "Generate Unreal project files."
|
|
|
|
${UE4_ROOT}/GenerateProjectFiles.sh -project="${PWD}/CarlaUE4.uproject" -game -engine -makefiles
|
|
|
|
set -e
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
log "Build CarlaUE4 project."
|
|
|
|
make CarlaUE4Editor
|
|
|
|
|
2019-01-24 19:57:14 +08:00
|
|
|
#Providing the user with the ExportedMaps folder
|
|
|
|
EXPORTED_MAPS="${CARLAUE4_ROOT_FOLDER}/Content/Carla/ExportedMaps"
|
2019-01-25 18:34:41 +08:00
|
|
|
mkdir -p "${EXPORTED_MAPS}"
|
2019-01-24 19:57:14 +08:00
|
|
|
|
|
|
|
|
2018-07-04 17:59:59 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
# ==============================================================================
|
|
|
|
# -- Launch UE4Editor ----------------------------------------------------------
|
|
|
|
# ==============================================================================
|
|
|
|
|
|
|
|
if ${LAUNCH_UE4_EDITOR} ; then
|
|
|
|
|
|
|
|
log "Launching UE4Editor..."
|
2022-06-09 05:22:30 +08:00
|
|
|
${GDB} ${UE4_ROOT}/Engine/Binaries/Linux/UE4Editor "${PWD}/CarlaUE4.uproject" ${RHI} ${EDITOR_FLAGS}
|
2018-07-04 17:59:59 +08:00
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
log "Success!"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
# ==============================================================================
|
|
|
|
# -- ...and we are done --------------------------------------------------------
|
|
|
|
# ==============================================================================
|
|
|
|
|
|
|
|
popd >/dev/null
|