2018-01-24 19:36:18 +08:00
|
|
|
#! /bin/bash
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Packages a CARLA build.
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
DOC_STRING="Makes a packaged version of CARLA for distribution.
|
|
|
|
Please make sure to run Rebuild.sh before!"
|
|
|
|
|
2018-01-25 02:47:57 +08:00
|
|
|
USAGE_STRING="Usage: $0 [-h|--help] [--no-packaging] [--no-zip] [--clean-intermediate]"
|
2018-01-24 19:36:18 +08:00
|
|
|
|
|
|
|
# ==============================================================================
|
|
|
|
# -- Parse arguments -----------------------------------------------------------
|
|
|
|
# ==============================================================================
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
# ==============================================================================
|
|
|
|
# -- Set up environment --------------------------------------------------------
|
|
|
|
# ==============================================================================
|
|
|
|
|
|
|
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
pushd "$SCRIPT_DIR" >/dev/null
|
|
|
|
|
|
|
|
REPOSITORY_TAG=`git describe --tags --dirty --always`
|
|
|
|
|
|
|
|
echo "Packaging version '$REPOSITORY_TAG'."
|
|
|
|
|
|
|
|
UNREAL_PROJECT_FOLDER=${PWD}/Unreal/CarlaUE4
|
|
|
|
DIST_FOLDER=${PWD}/Dist
|
|
|
|
BUILD_FOLDER=${DIST_FOLDER}/${REPOSITORY_TAG}
|
|
|
|
|
|
|
|
function fatal_error {
|
|
|
|
echo -e "\033[0;31mERROR: $1\033[0m"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
function log {
|
|
|
|
echo -e "\033[0;33m$1\033[0m"
|
|
|
|
}
|
|
|
|
|
|
|
|
# ==============================================================================
|
|
|
|
# -- Package project -----------------------------------------------------------
|
|
|
|
# ==============================================================================
|
|
|
|
|
|
|
|
if $DO_PACKAGE ; then
|
|
|
|
|
|
|
|
pushd "$UNREAL_PROJECT_FOLDER" >/dev/null
|
|
|
|
|
|
|
|
log "Packaging the project..."
|
|
|
|
|
|
|
|
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}
|
2018-01-25 06:39:26 +08:00
|
|
|
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 \
|
|
|
|
-pak -prereqs -nodebuginfo \
|
|
|
|
-targetplatform=Linux -build -CrashReporter -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
|
|
|
|
|
|
|
|
# ==============================================================================
|
|
|
|
# -- Copy files (Python server, README, etc) -----------------------------------
|
|
|
|
# ==============================================================================
|
|
|
|
|
|
|
|
if $DO_COPY_FILES ; then
|
|
|
|
|
|
|
|
DESTINATION=${BUILD_FOLDER}/LinuxNoEditor
|
|
|
|
|
|
|
|
log "Copying extra files..."
|
|
|
|
|
|
|
|
cp -v ./LICENSE ${DESTINATION}/LICENSE
|
|
|
|
cp -v ./CHANGELOG.md ${DESTINATION}/CHANGELOG
|
|
|
|
cp -v ./Docs/release_readme.md ${DESTINATION}/README
|
|
|
|
cp -v ./Docs/Example.CarlaSettings.ini ${DESTINATION}/Example.CarlaSettings.ini
|
2018-06-07 01:49:58 +08:00
|
|
|
cp -v ./Util/Docker/Release.Dockerfile ${DESTINATION}/Dockerfile
|
2018-01-24 19:36:18 +08:00
|
|
|
|
|
|
|
rsync -vhr --delete --delete-excluded \
|
2018-03-02 21:10:59 +08:00
|
|
|
--exclude "*.egg-info" \
|
|
|
|
--exclude "*.log" \
|
2018-01-24 19:36:18 +08:00
|
|
|
--exclude "*.pyc" \
|
|
|
|
--exclude ".*" \
|
2018-03-02 21:10:59 +08:00
|
|
|
--exclude ".tags*" \
|
|
|
|
--exclude "__pycache__" \
|
|
|
|
--exclude "_benchmarks_results*" \
|
|
|
|
--exclude "_images*" \
|
|
|
|
--exclude "_out*" \
|
2018-01-24 19:36:18 +08:00
|
|
|
PythonClient/ ${DESTINATION}/PythonClient
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
# ==============================================================================
|
|
|
|
# -- Zip the project -----------------------------------------------------------
|
|
|
|
# ==============================================================================
|
|
|
|
|
|
|
|
if $DO_TARBALL ; then
|
|
|
|
|
|
|
|
DESTINATION=${DIST_FOLDER}/CARLA_${REPOSITORY_TAG}.tar.gz
|
|
|
|
SOURCE=${BUILD_FOLDER}/LinuxNoEditor
|
|
|
|
|
|
|
|
pushd "$SOURCE" >/dev/null
|
|
|
|
|
|
|
|
log "Packaging build..."
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
log "Removing intermediate build..."
|
|
|
|
|
|
|
|
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
|
|
|
|
FINAL_PACKAGE=Dist/CARLA_${REPOSITORY_TAG}.tar.gz
|
|
|
|
else
|
|
|
|
FINAL_PACKAGE=Dist/${REPOSITORY_TAG}
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "Packaged version created at ${FINAL_PACKAGE}"
|
|
|
|
echo
|
2018-01-24 19:36:18 +08:00
|
|
|
echo "****************"
|
|
|
|
echo "*** Success! ***"
|
|
|
|
echo "****************"
|
|
|
|
|
|
|
|
popd >/dev/null
|