2018-01-24 19:36:18 +08:00
|
|
|
#! /bin/bash
|
|
|
|
|
2018-07-04 17:59:59 +08:00
|
|
|
source $(dirname "$0")/Environment.sh
|
2018-01-24 19:36:18 +08:00
|
|
|
|
|
|
|
# ==============================================================================
|
|
|
|
# -- Parse arguments -----------------------------------------------------------
|
|
|
|
# ==============================================================================
|
|
|
|
|
2019-06-19 18:18:12 +08:00
|
|
|
DOC_STRING="Makes a packaged version of CARLA and other content packages ready for distribution."
|
2018-07-04 17:59:59 +08:00
|
|
|
|
2019-06-19 18:18:12 +08:00
|
|
|
USAGE_STRING="Usage: $0 [-h|--help] [--no-zip] [--clean-intermediate] [--packages=Name1,Name2,...]"
|
2018-07-04 17:59:59 +08:00
|
|
|
|
2019-06-19 18:18:12 +08:00
|
|
|
PACKAGES="Carla"
|
2018-01-24 19:36:18 +08:00
|
|
|
DO_TARBALL=true
|
2018-01-25 02:47:57 +08:00
|
|
|
DO_CLEAN_INTERMEDIATE=false
|
2018-01-24 19:36:18 +08:00
|
|
|
|
2019-06-19 18:18:12 +08:00
|
|
|
OPTS=`getopt -o h --long help,no-zip,clean-intermediate,packages: -n 'parse-options' -- "$@"`
|
2018-01-24 19:36:18 +08:00
|
|
|
|
|
|
|
if [ $? != 0 ] ; then echo "$USAGE_STRING" ; exit 2 ; fi
|
|
|
|
|
|
|
|
eval set -- "$OPTS"
|
|
|
|
|
|
|
|
while true; do
|
|
|
|
case "$1" in
|
2018-01-25 02:47:57 +08:00
|
|
|
--no-zip )
|
|
|
|
DO_TARBALL=false
|
|
|
|
shift ;;
|
|
|
|
--clean-intermediate )
|
|
|
|
DO_CLEAN_INTERMEDIATE=true
|
|
|
|
shift ;;
|
2019-06-19 18:18:12 +08:00
|
|
|
--packages )
|
|
|
|
PACKAGES="$2"
|
|
|
|
shift 2 ;;
|
2018-01-24 19:36:18 +08:00
|
|
|
-h | --help )
|
|
|
|
echo "$DOC_STRING"
|
|
|
|
echo "$USAGE_STRING"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
* )
|
|
|
|
break ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
# ==============================================================================
|
2019-06-19 18:18:12 +08:00
|
|
|
# -- Prepare environment -------------------------------------------------------
|
2018-01-24 19:36:18 +08:00
|
|
|
# ==============================================================================
|
|
|
|
|
2019-06-19 18:18:12 +08:00
|
|
|
if [ ! -d "${UE4_ROOT}" ]; then
|
|
|
|
fatal_error "UE4_ROOT is not defined, or points to a non-existent directory, please set this environment variable."
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -n "${PACKAGES}" ] ; then
|
|
|
|
fatal_error "Nothing to be done."
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Convert comma-separated string to array of unique elements.
|
|
|
|
PACKAGES="$(echo "${PACKAGES}" | tr ',' '\n' | sort -u | tr '\n' ',')"
|
|
|
|
IFS=',' read -r -a PACKAGES <<< "${PACKAGES}"
|
|
|
|
|
|
|
|
# If contains an element called "Carla".
|
|
|
|
if [[ "${PACKAGES[@]}" =~ "Carla" ]] ; then
|
|
|
|
DO_CARLA_RELEASE=true
|
|
|
|
else
|
|
|
|
DO_CARLA_RELEASE=false
|
|
|
|
fi
|
|
|
|
|
2019-03-20 05:41:42 +08:00
|
|
|
REPOSITORY_TAG=$(get_git_repository_version)
|
2018-01-24 19:36:18 +08:00
|
|
|
|
2019-06-19 18:18:12 +08:00
|
|
|
RELEASE_BUILD_FOLDER=${CARLA_DIST_FOLDER}/CARLA_${REPOSITORY_TAG}
|
|
|
|
|
|
|
|
log "Packaging version '${REPOSITORY_TAG}'."
|
2018-01-24 19:36:18 +08:00
|
|
|
|
2019-06-19 18:18:12 +08:00
|
|
|
# ==============================================================================
|
|
|
|
# -- Cook CARLA project --------------------------------------------------------
|
|
|
|
# ==============================================================================
|
2018-01-24 19:36:18 +08:00
|
|
|
|
2019-06-19 18:18:12 +08:00
|
|
|
if ${DO_CARLA_RELEASE} ; then
|
2018-01-24 19:36:18 +08:00
|
|
|
|
2018-07-04 17:59:59 +08:00
|
|
|
pushd "${CARLAUE4_ROOT_FOLDER}" >/dev/null
|
2018-01-24 19:36:18 +08:00
|
|
|
|
2019-06-19 18:18:12 +08:00
|
|
|
log "Cooking CARLA project."
|
2018-01-24 19:36:18 +08:00
|
|
|
|
2019-06-19 18:18:12 +08:00
|
|
|
rm -Rf ${RELEASE_BUILD_FOLDER}
|
|
|
|
mkdir -p ${RELEASE_BUILD_FOLDER}
|
2018-01-24 19:36:18 +08:00
|
|
|
|
|
|
|
${UE4_ROOT}/Engine/Build/BatchFiles/RunUAT.sh BuildCookRun \
|
|
|
|
-project="${PWD}/CarlaUE4.uproject" \
|
2018-01-25 02:35:16 +08:00
|
|
|
-nocompileeditor -nop4 -cook -stage -archive -package \
|
2019-07-02 23:40:53 +08:00
|
|
|
-clientconfig=Shipping -ue4exe=UE4Editor \
|
2019-05-24 23:24:12 +08:00
|
|
|
-prereqs -targetplatform=Linux -build -utf8output \
|
2019-06-19 18:18:12 +08:00
|
|
|
-archivedirectory="${RELEASE_BUILD_FOLDER}"
|
2018-01-24 19:36:18 +08:00
|
|
|
|
|
|
|
popd >/dev/null
|
|
|
|
|
2019-06-19 18:18:12 +08:00
|
|
|
if [[ ! -d ${RELEASE_BUILD_FOLDER}/LinuxNoEditor ]] ; then
|
|
|
|
fatal_error "Failed to cook the project!"
|
|
|
|
fi
|
2018-01-24 19:36:18 +08:00
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
# ==============================================================================
|
2018-07-04 17:59:59 +08:00
|
|
|
# -- Copy files (Python API, README, etc) --------------------------------------
|
2018-01-24 19:36:18 +08:00
|
|
|
# ==============================================================================
|
|
|
|
|
2019-06-19 18:18:12 +08:00
|
|
|
if ${DO_CARLA_RELEASE} ; then
|
2018-01-24 19:36:18 +08:00
|
|
|
|
2019-06-19 18:18:12 +08:00
|
|
|
DESTINATION=${RELEASE_BUILD_FOLDER}/LinuxNoEditor
|
2018-01-24 19:36:18 +08:00
|
|
|
|
2019-06-19 18:18:12 +08:00
|
|
|
log "Adding extra files to CARLA package."
|
2018-01-24 19:36:18 +08:00
|
|
|
|
2018-07-04 17:59:59 +08:00
|
|
|
pushd ${CARLA_ROOT_FOLDER} >/dev/null
|
2018-01-24 19:36:18 +08:00
|
|
|
|
2019-06-19 18:18:12 +08:00
|
|
|
mkdir -p "${DESTINATION}/Import"
|
2019-01-22 16:47:32 +08:00
|
|
|
|
2019-03-29 01:35:31 +08:00
|
|
|
echo "${REPOSITORY_TAG}" > ${DESTINATION}/VERSION
|
|
|
|
|
2018-07-04 17:59:59 +08:00
|
|
|
copy_if_changed "./LICENSE" "${DESTINATION}/LICENSE"
|
|
|
|
copy_if_changed "./CHANGELOG.md" "${DESTINATION}/CHANGELOG"
|
|
|
|
copy_if_changed "./Docs/release_readme.md" "${DESTINATION}/README"
|
2019-03-29 02:17:05 +08:00
|
|
|
copy_if_changed "./Docs/python_api.md" "${DESTINATION}/PythonAPI/python_api.md"
|
2018-07-04 17:59:59 +08:00
|
|
|
copy_if_changed "./Util/Docker/Release.Dockerfile" "${DESTINATION}/Dockerfile"
|
2019-06-11 23:07:45 +08:00
|
|
|
copy_if_changed "./Util/ImportAssets.sh" "${DESTINATION}/ImportAssets.sh"
|
2018-01-24 19:36:18 +08:00
|
|
|
|
2019-03-29 01:35:31 +08:00
|
|
|
copy_if_changed "./PythonAPI/carla/dist/*.egg" "${DESTINATION}/PythonAPI/carla/dist/"
|
|
|
|
copy_if_changed "./PythonAPI/carla/agents/" "${DESTINATION}/PythonAPI/carla/agents"
|
|
|
|
copy_if_changed "./PythonAPI/carla/scene_layout.py" "${DESTINATION}/PythonAPI/carla/"
|
|
|
|
copy_if_changed "./PythonAPI/carla/requirements.txt" "${DESTINATION}/PythonAPI/carla/"
|
|
|
|
|
|
|
|
copy_if_changed "./PythonAPI/examples/*.py" "${DESTINATION}/PythonAPI/examples/"
|
|
|
|
copy_if_changed "./PythonAPI/examples/requirements.txt" "${DESTINATION}/PythonAPI/examples/"
|
|
|
|
|
|
|
|
copy_if_changed "./PythonAPI/util/*.py" "${DESTINATION}/PythonAPI/util/"
|
|
|
|
copy_if_changed "./PythonAPI/util/requirements.txt" "${DESTINATION}/PythonAPI/util/"
|
2019-03-27 23:39:09 +08:00
|
|
|
|
2019-03-29 04:45:08 +08:00
|
|
|
copy_if_changed "./Unreal/CarlaUE4/Content/Carla/HDMaps/*.pcd" "${DESTINATION}/HDMaps/"
|
|
|
|
copy_if_changed "./Unreal/CarlaUE4/Content/Carla/HDMaps/Readme.md" "${DESTINATION}/HDMaps/README"
|
|
|
|
|
2018-07-04 17:59:59 +08:00
|
|
|
popd >/dev/null
|
2018-01-24 19:36:18 +08:00
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
# ==============================================================================
|
|
|
|
# -- Zip the project -----------------------------------------------------------
|
|
|
|
# ==============================================================================
|
|
|
|
|
2019-06-19 18:18:12 +08:00
|
|
|
if ${DO_CARLA_RELEASE} && ${DO_TARBALL} ; then
|
2018-01-24 19:36:18 +08:00
|
|
|
|
2018-07-04 17:59:59 +08:00
|
|
|
DESTINATION=${CARLA_DIST_FOLDER}/CARLA_${REPOSITORY_TAG}.tar.gz
|
2019-06-19 18:18:12 +08:00
|
|
|
SOURCE=${RELEASE_BUILD_FOLDER}/LinuxNoEditor
|
2018-01-24 19:36:18 +08:00
|
|
|
|
2018-07-04 17:59:59 +08:00
|
|
|
pushd "${SOURCE}" >/dev/null
|
2018-01-24 19:36:18 +08:00
|
|
|
|
2019-06-19 18:18:12 +08:00
|
|
|
log "Packaging CARLA release."
|
2018-01-24 19:36:18 +08:00
|
|
|
|
|
|
|
rm -f ./Manifest_NonUFSFiles_Linux.txt
|
2019-04-01 18:19:47 +08:00
|
|
|
rm -f ./Manifest_UFSFiles_Linux.txt
|
2018-01-24 19:36:18 +08:00
|
|
|
rm -Rf ./CarlaUE4/Saved
|
|
|
|
rm -Rf ./Engine/Saved
|
|
|
|
|
|
|
|
tar -czvf ${DESTINATION} *
|
|
|
|
|
|
|
|
popd >/dev/null
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
2018-01-25 02:47:57 +08:00
|
|
|
# ==============================================================================
|
|
|
|
# -- Remove intermediate files -------------------------------------------------
|
|
|
|
# ==============================================================================
|
|
|
|
|
2019-06-19 18:18:12 +08:00
|
|
|
if ${DO_CARLA_RELEASE} && ${DO_CLEAN_INTERMEDIATE} ; then
|
2018-01-25 02:47:57 +08:00
|
|
|
|
2018-07-04 17:59:59 +08:00
|
|
|
log "Removing intermediate build."
|
2018-01-25 02:47:57 +08:00
|
|
|
|
2019-06-19 18:18:12 +08:00
|
|
|
rm -Rf ${RELEASE_BUILD_FOLDER}
|
2018-01-25 02:47:57 +08:00
|
|
|
|
|
|
|
fi
|
|
|
|
|
2018-01-24 19:36:18 +08:00
|
|
|
# ==============================================================================
|
2019-06-19 18:18:12 +08:00
|
|
|
# -- Cook other packages -------------------------------------------------------
|
2018-01-24 19:36:18 +08:00
|
|
|
# ==============================================================================
|
|
|
|
|
2019-06-19 18:18:12 +08:00
|
|
|
for PACKAGE_NAME in "${PACKAGES[@]}" ; do if [[ ${PACKAGE_NAME} != "Carla" ]] ; then
|
|
|
|
|
|
|
|
BUILD_FOLDER=${CARLA_DIST_FOLDER}/${PACKAGE_NAME}_${REPOSITORY_TAG}
|
|
|
|
|
|
|
|
DESTINATION=${BUILD_FOLDER}.tar.gz
|
|
|
|
|
|
|
|
mkdir -p ${BUILD_FOLDER}
|
|
|
|
|
|
|
|
log "Preparing environment for cooking '${PACKAGE_NAME}'."
|
|
|
|
|
|
|
|
fatal_error "TODO: Call command-let here."
|
|
|
|
|
|
|
|
pushd "${CARLAUE4_ROOT_FOLDER}" > /dev/null
|
|
|
|
|
|
|
|
log "Cooking '${PACKAGE_NAME}'."
|
|
|
|
|
|
|
|
${UE4_ROOT}/Engine/Binaries/Linux/UE4Editor "${PWD}/CarlaUE4.uproject" \
|
|
|
|
-run=cook -cooksinglepackage -targetplatform="LinuxNoEditor" \
|
|
|
|
-OutputDir="${BUILD_FOLDER}" \
|
|
|
|
-Map=${MAP_TO_COOK}
|
|
|
|
|
|
|
|
popd >/dev/null
|
|
|
|
|
|
|
|
if ${DO_TARBALL} ; then
|
|
|
|
|
|
|
|
pushd "${BUILD_FOLDER}" > /dev/null
|
|
|
|
|
|
|
|
log "Packaging '${PACKAGE_NAME}'."
|
|
|
|
|
|
|
|
rm -Rf ./CarlaUE4/Metadata
|
|
|
|
rm -Rf ./CarlaUE4/Plugins
|
|
|
|
rm ./CarlaUE4/AssetRegistry.bin
|
|
|
|
|
|
|
|
fatal_error "TODO: Remove intermediate maps here."
|
|
|
|
|
|
|
|
tar -czvf ${DESTINATION} *
|
|
|
|
|
|
|
|
popd >/dev/null
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ${DO_CLEAN_INTERMEDIATE} ; then
|
|
|
|
log "Removing intermediate build."
|
|
|
|
rm -Rf ${BUILD_FOLDER}
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi ; done
|
|
|
|
|
|
|
|
# ==============================================================================
|
|
|
|
# -- Log paths of generated packages -------------------------------------------
|
|
|
|
# ==============================================================================
|
|
|
|
|
|
|
|
for PACKAGE_NAME in "${PACKAGES[@]}" ; do if [[ ${PACKAGE_NAME} != "Carla" ]] ; then
|
|
|
|
FINAL_PACKAGE=${CARLA_DIST_FOLDER}/${PACKAGE_NAME}_${REPOSITORY_TAG}.tar.gz
|
|
|
|
log "Package '${PACKAGE_NAME}' created at ${FINAL_PACKAGE}"
|
|
|
|
fi ; done
|
|
|
|
|
|
|
|
if ${DO_CARLA_RELEASE} ; then
|
|
|
|
if ${DO_TARBALL} ; then
|
|
|
|
FINAL_PACKAGE=${CARLA_DIST_FOLDER}/CARLA_${REPOSITORY_TAG}.tar.gz
|
|
|
|
else
|
|
|
|
FINAL_PACKAGE=${RELEASE_BUILD_FOLDER}
|
|
|
|
fi
|
|
|
|
log "CARLA release created at ${FINAL_PACKAGE}"
|
2018-03-16 18:47:42 +08:00
|
|
|
fi
|
|
|
|
|
2019-06-19 18:18:12 +08:00
|
|
|
# ==============================================================================
|
|
|
|
# -- ...and we are done --------------------------------------------------------
|
|
|
|
# ==============================================================================
|
|
|
|
|
2018-07-04 17:59:59 +08:00
|
|
|
log "Success!"
|