From 56fc04e4901c02d8e81d8dda72fc5dddd8c01b8b Mon Sep 17 00:00:00 2001 From: Daniel Novillo Villarejo Date: Thu, 24 Jan 2019 12:57:14 +0100 Subject: [PATCH] Improved naming Added support for importing multiple files --- Docs/export_import_dist.md | 41 +++++++++++++++++++ Docs/index.md | 1 + Util/BuildTools/BuildCarlaUE4.sh | 7 ++++ .../{BuildUserContentUE4.sh => ExportMaps.sh} | 10 ++--- Util/BuildTools/Linux.mk | 4 +- Util/BuildTools/Package.sh | 4 +- Util/{InjectUserContent.sh => ImportMaps.sh} | 12 ++++-- mkdocs.yml | 1 + 8 files changed, 68 insertions(+), 12 deletions(-) create mode 100644 Docs/export_import_dist.md rename Util/BuildTools/{BuildUserContentUE4.sh => ExportMaps.sh} (94%) rename Util/{InjectUserContent.sh => ImportMaps.sh} (83%) mode change 100644 => 100755 diff --git a/Docs/export_import_dist.md b/Docs/export_import_dist.md new file mode 100644 index 000000000..c322d68f6 --- /dev/null +++ b/Docs/export_import_dist.md @@ -0,0 +1,41 @@ +

Importing and exporting maps for distribution builds

+ +!!! important + The given scripts only works if the files are kept in the folders + detailed below and on Linux. + +This method and its scripts are aimed to reducing the size of the distribution +build, allowing to import maps on distributed builds with a script, exporting +them with yet another script from the editor. + +

How to export a map

+The current script only work for content placed into the +"CarlaRoot/Unreal/CarlaUE4/Content/Carla/ExportedMaps" folder, inside the unreal's project +structure. Once all the changes are saved in the editor and the maps to export +are located in that folder, running + +```sh +make export-maps +``` + +will clean, cook and pack the necessary assets with the maps. Please, note that +there is no way of knowing what assets are on the project-to-import-to, so the +final package will usually contain assets needed for the current project to work +even though they might not be directly used in the exported map. Also, the maps +referenced inside the Editor Properties will be exported due to the current way +of cooking provided by Unreal. + +Once the script is completed, the packed file can be found under ExportedMaps in +the project's root. + +

How to import a map

+In order to do so, the file generated in the import phase has to be placed in a folder +at the root of the distributed folder called "ExportedMaps". Once the zip is placed there, +by running + +```sh +./ImportMaps.sh +``` + +the content will get extracted and located properly where the executable can reach it. All +the imported maps can be loaded by passing the convenient argument to the CarlaUE4.sh script. \ No newline at end of file diff --git a/Docs/index.md b/Docs/index.md index dbbea3d97..adf500e8d 100644 --- a/Docs/index.md +++ b/Docs/index.md @@ -26,6 +26,7 @@ * [Running in a Docker](carla_docker.md) * [How to make a new map with RoadRunner](how_to_make_a_new_map.md) * [How to link Epic's Automotive Materials](epic_automotive_materials.md) + * [How to export and import maps to distribution builds](export_import_dist.md)

Contributing

diff --git a/Util/BuildTools/BuildCarlaUE4.sh b/Util/BuildTools/BuildCarlaUE4.sh index fc5a0af81..c3002ad9e 100755 --- a/Util/BuildTools/BuildCarlaUE4.sh +++ b/Util/BuildTools/BuildCarlaUE4.sh @@ -119,6 +119,13 @@ if ${BUILD_CARLAUE4} ; then log "Build CarlaUE4 project." make CarlaUE4Editor + #Providing the user with the ExportedMaps folder + EXPORTED_MAPS="${CARLAUE4_ROOT_FOLDER}/Content/Carla/ExportedMaps" + if [ ! -d "${EXPORTED_MAPS}" ]; then + mkdir "${EXPORTED_MAPS}" + fi + + fi # ============================================================================== diff --git a/Util/BuildTools/BuildUserContentUE4.sh b/Util/BuildTools/ExportMaps.sh similarity index 94% rename from Util/BuildTools/BuildUserContentUE4.sh rename to Util/BuildTools/ExportMaps.sh index 4f0801145..e570f9bb2 100755 --- a/Util/BuildTools/BuildUserContentUE4.sh +++ b/Util/BuildTools/ExportMaps.sh @@ -16,7 +16,7 @@ fi # -- Parse arguments ----------------------------------------------------------- # ============================================================================== -DOC_STRING="Build and packs CarlaUE4's UserContent" +DOC_STRING="Build and packs CarlaUE4's ExportedMaps" USAGE_STRING="Usage: $0 [-h|--help] [-d|--dir] [-f|--file] " @@ -48,10 +48,10 @@ while true; do done if [ -z "${OUTPUT_DIRECTORY}" ]; then - OUTPUT_DIRECTORY="${PWD}/UserContent" + OUTPUT_DIRECTORY="${PWD}/ExportedMaps" fi if [ -z "${FILE_NAME}" ]; then - FILE_NAME="CookedUserContent" + FILE_NAME="CookedExportedMaps" fi # ============================================================================== @@ -74,7 +74,7 @@ log "Current project directory: '${PWD}'" MAP_LIST="" for filepath in `find ${PWD}/Content/ -type f -name "*.umap"`; do - if [[ $filepath == *"/UserContent/"* ]]; then + if [[ $filepath == *"/ExportedMaps/"* ]]; then filepath="/Game/"${filepath#"${PWD}/Content/"} if [ -z "${MAP_LIST}" ]; then MAP_LIST=$filepath @@ -138,5 +138,5 @@ rm -Rf ${BUILD_FOLDER}/LinuxNoEditor # -- ...and we are done -------------------------------------------------------- # ============================================================================== -log "UserContent created at ${DESTINATION}" +log "ExportedMaps created at ${DESTINATION}" log "Success!" \ No newline at end of file diff --git a/Util/BuildTools/Linux.mk b/Util/BuildTools/Linux.mk index 1d2f35bfe..e0e041222 100644 --- a/Util/BuildTools/Linux.mk +++ b/Util/BuildTools/Linux.mk @@ -32,8 +32,8 @@ hard-clean: @${CARLA_BUILD_TOOLS_FOLDER}/BuildLibCarla.sh --clean @echo "To force recompiling dependencies run: rm -Rf ${CARLA_BUILD_FOLDER}" -build-usercontent: - @${CARLA_BUILD_TOOLS_FOLDER}/BuildUserContentUE4.sh ${ARGS} +export-maps: + @${CARLA_BUILD_TOOLS_FOLDER}/ExportMaps.sh ${ARGS} check: LibCarla PythonAPI @${CARLA_BUILD_TOOLS_FOLDER}/Check.sh --all $(ARGS) diff --git a/Util/BuildTools/Package.sh b/Util/BuildTools/Package.sh index 9c0466a28..4863fbaac 100755 --- a/Util/BuildTools/Package.sh +++ b/Util/BuildTools/Package.sh @@ -93,7 +93,7 @@ if $DO_COPY_FILES ; then pushd ${CARLA_ROOT_FOLDER} >/dev/null - mkdir "${DESTINATION}/UserContent" + mkdir "${DESTINATION}/ExportedMaps" copy_if_changed "./LICENSE" "${DESTINATION}/LICENSE" copy_if_changed "./CHANGELOG.md" "${DESTINATION}/CHANGELOG" @@ -109,7 +109,7 @@ if $DO_COPY_FILES ; then copy_if_changed "./PythonAPI/spawn_npc.py" "${DESTINATION}/spawn_npc.py" copy_if_changed "./PythonAPI/tutorial.py" "${DESTINATION}/tutorial.py" copy_if_changed "./PythonAPI/vehicle_gallery.py" "${DESTINATION}/vehicle_gallery.py" - copy_if_changed "./Util/InjectUserContent.sh" "${DESTINATION}/InjectUserContent.sh" + copy_if_changed "./Util/ImportMaps.sh" "${DESTINATION}/ImportMaps.sh" popd >/dev/null diff --git a/Util/InjectUserContent.sh b/Util/ImportMaps.sh old mode 100644 new mode 100755 similarity index 83% rename from Util/InjectUserContent.sh rename to Util/ImportMaps.sh index a28d09766..25c61df79 --- a/Util/InjectUserContent.sh +++ b/Util/ImportMaps.sh @@ -16,7 +16,7 @@ fi # -- Parse arguments ----------------------------------------------------------- # ============================================================================== -DOC_STRING="Unpack and copy over CarlaUE4's UserContent" +DOC_STRING="Unpack and copy over CarlaUE4's Exported Maps" USAGE_STRING="Usage: $0 [-h|--help] [-d|--dir] [-f|--file] " @@ -47,6 +47,12 @@ while true; do esac done -#Tar.gz the stuff -tar --keep-newer-files -xvf UserContent/CookedUserContent.tar.gz +if [ -z "${FILE_NAME}" ]; then + FILE_NAME="CookedExportedMaps" +fi + +#Tar.gz the stuff +for filepath in `find ExportedMaps/ -type f -name "*.tar.gz"`; do + tar --keep-newer-files -xvf ExportedMaps/${filepath}.tar.gz +done diff --git a/mkdocs.yml b/mkdocs.yml index e4d6bb107..899801cfa 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -21,6 +21,7 @@ pages: - 'Running in a Docker': 'carla_docker.md' - "How to make a new map with RoadRunner": 'how_to_make_a_new_map.md' - "How to link Epic's Automotive Materials": 'epic_automotive_materials.md' + - "How to export and import maps to distribution builds": 'export_import_dist.md' - Contributing: - 'Contribution guidelines': 'CONTRIBUTING.md' - 'Coding standard': 'coding_standard.md'