carla/Util/BuildTools/Package.sh

169 lines
5.1 KiB
Bash
Raw Normal View History

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 -----------------------------------------------------------
# ==============================================================================
2018-07-04 17:59:59 +08:00
DOC_STRING="Makes a packaged version of CARLA for distribution."
USAGE_STRING="Usage: $0 [-h|--help] [--no-packaging] [--no-zip] [--clean-intermediate]"
2018-01-24 19:36:18 +08:00
DO_PACKAGE=true
DO_COPY_FILES=true
DO_TARBALL=true
2018-01-25 02:47:57 +08:00
DO_CLEAN_INTERMEDIATE=false
2018-01-24 19:36:18 +08:00
2018-01-25 02:47:57 +08:00
OPTS=`getopt -o h --long help,no-packaging,no-zip,clean-intermediate -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-packaging )
2018-01-24 19:36:18 +08:00
DO_PACKAGE=false
shift ;;
2018-01-25 02:47:57 +08:00
--no-zip )
DO_TARBALL=false
shift ;;
--clean-intermediate )
DO_CLEAN_INTERMEDIATE=true
shift ;;
2018-01-24 19:36:18 +08:00
-h | --help )
echo "$DOC_STRING"
echo "$USAGE_STRING"
exit 1
;;
* )
break ;;
esac
done
# ==============================================================================
2018-07-04 17:59:59 +08:00
# -- Package project -----------------------------------------------------------
2018-01-24 19:36:18 +08:00
# ==============================================================================
2019-03-20 05:41:42 +08:00
REPOSITORY_TAG=$(get_git_repository_version)
2018-01-24 19:36:18 +08:00
2018-07-04 17:59:59 +08:00
BUILD_FOLDER=${CARLA_DIST_FOLDER}/${REPOSITORY_TAG}
2018-01-24 19:36:18 +08:00
2018-07-04 17:59:59 +08:00
log "Packaging version '$REPOSITORY_TAG'."
2018-01-24 19:36:18 +08:00
if $DO_PACKAGE ; then
2018-07-04 17:59:59 +08:00
pushd "${CARLAUE4_ROOT_FOLDER}" >/dev/null
2018-01-24 19:36:18 +08:00
2018-07-04 17:59:59 +08:00
log "Packaging the project."
2018-01-24 19:36:18 +08:00
if [ ! -d "${UE4_ROOT}" ]; then
fatal_error "UE4_ROOT is not defined, or points to a non-existant directory, please set this environment variable."
fi
rm -Rf ${BUILD_FOLDER}
mkdir -p ${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 \
-clientconfig=Development -ue4exe=UE4Editor \
2019-01-22 16:47:32 +08:00
-prereqs -nodebuginfo \
2019-01-26 00:48:10 +08:00
-targetplatform=Linux -build -utf8output \
2018-01-24 19:36:18 +08:00
-archivedirectory="${BUILD_FOLDER}"
popd >/dev/null
fi
if [[ ! -d ${BUILD_FOLDER}/LinuxNoEditor ]] ; then
fatal_error "Failed to package the project!"
fi
# ==============================================================================
2018-07-04 17:59:59 +08:00
# -- Copy files (Python API, README, etc) --------------------------------------
2018-01-24 19:36:18 +08:00
# ==============================================================================
if $DO_COPY_FILES ; then
DESTINATION=${BUILD_FOLDER}/LinuxNoEditor
2018-07-04 17:59:59 +08:00
log "Adding extra files to 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
mkdir -p "${DESTINATION}/ExportedMaps"
2019-01-22 16:47:32 +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"
2018-10-10 00:04:50 +08:00
copy_if_changed "./Docs/python_api.md" "${DESTINATION}/python_api.md"
2018-07-04 17:59:59 +08:00
copy_if_changed "./Util/Docker/Release.Dockerfile" "${DESTINATION}/Dockerfile"
copy_if_changed "./Util/ImportMaps.sh" "${DESTINATION}/ImportMaps.sh"
2018-01-24 19:36:18 +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
2018-07-04 17:59:59 +08:00
popd >/dev/null
2018-01-24 19:36:18 +08:00
fi
# ==============================================================================
# -- Zip the project -----------------------------------------------------------
# ==============================================================================
if $DO_TARBALL ; then
2018-07-04 17:59:59 +08:00
DESTINATION=${CARLA_DIST_FOLDER}/CARLA_${REPOSITORY_TAG}.tar.gz
2018-01-24 19:36:18 +08:00
SOURCE=${BUILD_FOLDER}/LinuxNoEditor
2018-07-04 17:59:59 +08:00
pushd "${SOURCE}" >/dev/null
2018-01-24 19:36:18 +08:00
2018-07-04 17:59:59 +08:00
log "Packaging build."
2018-01-24 19:36:18 +08:00
rm -f ./Manifest_NonUFSFiles_Linux.txt
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 -------------------------------------------------
# ==============================================================================
if $DO_CLEAN_INTERMEDIATE ; then
2018-07-04 17:59:59 +08:00
log "Removing intermediate build."
2018-01-25 02:47:57 +08:00
rm -Rf ${BUILD_FOLDER}
fi
2018-01-24 19:36:18 +08:00
# ==============================================================================
# -- ...and we are done --------------------------------------------------------
# ==============================================================================
2018-03-16 18:47:42 +08:00
if $DO_TARBALL ; then
2018-07-04 17:59:59 +08:00
FINAL_PACKAGE=${CARLA_DIST_FOLDER}/CARLA_${REPOSITORY_TAG}.tar.gz
2018-03-16 18:47:42 +08:00
else
2018-07-04 17:59:59 +08:00
FINAL_PACKAGE=${BUILD_FOLDER}
2018-03-16 18:47:42 +08:00
fi
2018-07-04 17:59:59 +08:00
log "Packaged version created at ${FINAL_PACKAGE}"
log "Success!"