From fb62780b584831e1b63c931fe387ec9ef094b3a4 Mon Sep 17 00:00:00 2001 From: MarcelPiNacy-CVC <169088301+MarcelPiNacy-CVC@users.noreply.github.com> Date: Mon, 30 Sep 2024 19:08:27 +0200 Subject: [PATCH] Improve package folder layout. (#8229) * Improve package naming and build directory structure. * Fix recastbuilder path. * Remove co-simulation copy command + minor cleanup. --- CMakeLists.txt | 7 ++- Unreal/CMakeLists.txt | 52 ++++++++++++----- .../Carla/Source/Carla/Game/CarlaEpisode.cpp | 5 +- Unreal/Package/Compress.cmake | 42 +++++++++++--- Unreal/Package/CopyCarlaAdditionalFiles.cmake | 58 +++++++++---------- Unreal/Package/CreateCarlaVersionFile.cmake | 27 ++++++--- 6 files changed, 123 insertions(+), 68 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f181a0003..9602dc7bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,9 +56,14 @@ set ( ${CMAKE_CURRENT_SOURCE_DIR} ) +set ( + CARLA_BUILD_PATH + ${CMAKE_BINARY_DIR} +) + set ( CARLA_PACKAGE_PATH - ${CMAKE_BINARY_DIR}/Package + ${CARLA_BUILD_PATH}/Package ) set ( diff --git a/Unreal/CMakeLists.txt b/Unreal/CMakeLists.txt index d5932bb7e..0f1575309 100644 --- a/Unreal/CMakeLists.txt +++ b/Unreal/CMakeLists.txt @@ -14,11 +14,6 @@ carla_option ( ON ) -set ( - CARLA_BUILD_PATH - ${CARLA_WORKSPACE_PATH}/Build/ -) - set ( CARLA_UE_PATH ${CARLA_WORKSPACE_PATH}/Unreal/CarlaUnreal @@ -375,16 +370,38 @@ add_dependencies ( ${UE_DEPENDENCIES_ORDER_ONLY} ) + + function ( add_carla_ue_package_target PACKAGE_CONFIGURATION UE_BUILD_CONFIGURATION) set ( - CARLA_TARGET_PACKAGE_PATH - ${CARLA_PACKAGE_PATH}/${UE_SYSTEM_NAME} + CARLA_PACKAGE_NAME + Carla-${CARLA_VERSION}-${UE_SYSTEM_NAME}-${UE_BUILD_CONFIGURATION} ) + set ( + CARLA_CURRENT_PACKAGE_PATH + ${CARLA_PACKAGE_PATH}/${CARLA_PACKAGE_NAME} + ) + + set ( + CARLA_CURRENT_PACKAGE_ARCHIVE_PATH + ${CARLA_PACKAGE_PATH}/${CARLA_PACKAGE_NAME} + ) + + set ( + CARLA_PACKAGE_STAGING_PATH + ${CARLA_PACKAGE_PATH}/StagedBuilds/${CARLA_PACKAGE_NAME} + ) + + set ( + CARLA_PACKAGE_ARCHIVE_PATH + ${CARLA_CURRENT_PACKAGE_PATH} + ) + if (NOT "${PACKAGE_CONFIGURATION}" STREQUAL "") set (TARGET_NAME_SUFFIX -${PACKAGE_CONFIGURATION}) string (TOLOWER "${TARGET_NAME_SUFFIX}" TARGET_NAME_SUFFIX) @@ -422,7 +439,8 @@ function ( -Platform=${UE_SYSTEM_NAME} -prereqs -build - -archivedirectory=${CARLA_PACKAGE_PATH} + -stagingdirectory=${CARLA_PACKAGE_STAGING_PATH} + -archivedirectory=${CARLA_PACKAGE_ARCHIVE_PATH} USES_TERMINAL VERBATIM ) @@ -432,33 +450,35 @@ function ( POST_BUILD COMMAND ${CMAKE_COMMAND} -E echo "********** PACKAGE CREATING VERSION FILE UNREAL PACKAGE EXTRA FILES STARTED **********" COMMAND ${CMAKE_COMMAND} - -DCARLA_SOURCE_DIR=${CARLA_SOURCE_DIR} + -DCARLA_WORKSPACE_PATH=${CARLA_WORKSPACE_PATH} -DCARLA_UNREAL_ENGINE_PATH=${CARLA_UNREAL_ENGINE_PATH} - -DCARLA_PACKAGE_VERSION_FILE=${CARLA_TARGET_PACKAGE_PATH}/VERSION + -DCARLA_PACKAGE_VERSION_FILE=${CARLA_PACKAGE_ARCHIVE_PATH}/VERSION -P${CMAKE_CURRENT_SOURCE_DIR}/Package/CreateCarlaVersionFile.cmake COMMAND ${CMAKE_COMMAND} -E echo "********** PACKAGE VERSION FILE UNREAL PACKAGE EXTRA FILES COMPLETED **********" COMMAND ${CMAKE_COMMAND} -E echo "********** PACKAGE REMOVING UNREAL PACKAGE EXTRA FILES STARTED **********" COMMAND ${CMAKE_COMMAND} - -DCARLA_TARGET_PACKAGE_PATH=${CARLA_TARGET_PACKAGE_PATH} + -DCARLA_PACKAGE_ARCHIVE_PATH=${CARLA_PACKAGE_ARCHIVE_PATH} -P${CMAKE_CURRENT_SOURCE_DIR}/Package/RemoveUnrealPackageExtraFiles.cmake COMMAND ${CMAKE_COMMAND} -E echo "********** PACKAGE REMOVING UNREAL PACKAGE EXTRA FILES COMPLETED **********" COMMAND ${CMAKE_COMMAND} -E echo "********** PACKAGE COPYING CARLA ADDITIONAL FILES STARTED **********" COMMAND ${CMAKE_COMMAND} - -DCARLA_SOURCE_DIR=${CARLA_SOURCE_DIR} - -DCARLA_TARGET_PACKAGE_PATH=${CARLA_TARGET_PACKAGE_PATH} - -DCARLA_BINARY_DIR=${CARLA_BINARY_DIR} + -DCARLA_BUILD_PATH=${CARLA_BUILD_PATH} + -DCARLA_WORKSPACE_PATH=${CARLA_WORKSPACE_PATH} + -DCARLA_PACKAGE_ARCHIVE_PATH=${CARLA_PACKAGE_ARCHIVE_PATH} -P${CMAKE_CURRENT_SOURCE_DIR}/Package/CopyCarlaAdditionalFiles.cmake COMMAND ${CMAKE_COMMAND} -E echo "********** PACKAGE COPYING CARLA ADDITIONAL FILES COMPLETED **********" COMMAND ${CMAKE_COMMAND} -E echo "********** COMPRESSING PACKAGE STARTED **********" COMMAND ${CMAKE_COMMAND} -DCARLA_PACKAGE_PATH=${CARLA_PACKAGE_PATH} - -DCARLA_TARGET_PACKAGE_PATH=${CARLA_TARGET_PACKAGE_PATH} - -DTARGET_NAME_SUFFIX=${TARGET_NAME_SUFFIX} + -DCARLA_PACKAGE_ARCHIVE_PATH=${CARLA_PACKAGE_ARCHIVE_PATH} + -DCARLA_CURRENT_PACKAGE_PATH=${CARLA_CURRENT_PACKAGE_PATH} -P${CMAKE_CURRENT_SOURCE_DIR}/Package/Compress.cmake COMMAND ${CMAKE_COMMAND} -E echo "********** COMPRESSING PACKAGE COMPLETED **********" + USES_TERMINAL + VERBATIM ) add_dependencies ( diff --git a/Unreal/CarlaUnreal/Plugins/Carla/Source/Carla/Game/CarlaEpisode.cpp b/Unreal/CarlaUnreal/Plugins/Carla/Source/Carla/Game/CarlaEpisode.cpp index ea5fd7da5..4aebca48b 100644 --- a/Unreal/CarlaUnreal/Plugins/Carla/Source/Carla/Game/CarlaEpisode.cpp +++ b/Unreal/CarlaUnreal/Plugins/Carla/Source/Carla/Game/CarlaEpisode.cpp @@ -31,10 +31,7 @@ #include "Misc/FileHelper.h" #include "Misc/Paths.h" -#define TO_STRING_EXPAND(s) #s -#define TO_STRING(s) TO_STRING_EXPAND(s) - -constexpr TCHAR DefaultRecastBuilderPath[] = TEXT(TO_STRING(RECASTBUILDER_PATH)); +constexpr TCHAR DefaultRecastBuilderPath[] = TEXT(RECASTBUILDER_PATH); static FString BuildRecastBuilderFile() { diff --git a/Unreal/Package/Compress.cmake b/Unreal/Package/Compress.cmake index c749c7cc7..39eb21515 100644 --- a/Unreal/Package/Compress.cmake +++ b/Unreal/Package/Compress.cmake @@ -1,12 +1,36 @@ -set (CARLA_PACKAGE_FILE_NAME_WITHOUT_EXTENSION ${CARLA_PACKAGE_PATH}/CARLA${TARGET_NAME_SUFFIX}) +file ( + GLOB + CARLA_PACKAGE_FILES + ${CARLA_PACKAGE_ARCHIVE_PATH}/* +) + if (WIN32) - set(CARLA_PACKAGE_FILE_NAME_AND_ARGS cvf ${CARLA_PACKAGE_FILE_NAME_WITHOUT_EXTENSION}.zip --format=zip) -else() - set(CARLA_PACKAGE_FILE_NAME_AND_ARGS cvfz ${CARLA_PACKAGE_FILE_NAME_WITHOUT_EXTENSION}.tar.gz) -endif() + set ( + COMPRESS_PACKAGE_COMMAND + ${CMAKE_COMMAND} + -E tar cvf + ${CARLA_CURRENT_PACKAGE_PATH}.zip + --format=zip + ${CARLA_PACKAGE_FILES} + ) +else () + set ( + COMPRESS_PACKAGE_COMMAND + ${CMAKE_COMMAND} + -E tar cvfz + ${CARLA_CURRENT_PACKAGE_PATH}.tar.gz + ${CARLA_PACKAGE_FILES} + ) +endif () -file(GLOB CARLA_PACKAGE_FILES ${CARLA_TARGET_PACKAGE_PATH}/*) +message ( + STATUS + "Running \"${COMPRESS_PACKAGE_COMMAND}\"" +) -execute_process( - COMMAND cmake -E tar ${CARLA_PACKAGE_FILE_NAME_AND_ARGS} ${CARLA_PACKAGE_FILES} - WORKING_DIRECTORY ${CARLA_TARGET_PACKAGE_PATH}) +execute_process ( + COMMAND + ${COMPRESS_PACKAGE_COMMAND} + WORKING_DIRECTORY + ${CARLA_PACKAGE_PATH} +) diff --git a/Unreal/Package/CopyCarlaAdditionalFiles.cmake b/Unreal/Package/CopyCarlaAdditionalFiles.cmake index 51430c2f0..381622d1c 100644 --- a/Unreal/Package/CopyCarlaAdditionalFiles.cmake +++ b/Unreal/Package/CopyCarlaAdditionalFiles.cmake @@ -1,41 +1,41 @@ -file (COPY_FILE ${CARLA_SOURCE_DIR}/LICENSE ${CARLA_TARGET_PACKAGE_PATH}/LICENSE) -file (COPY_FILE ${CARLA_SOURCE_DIR}/CHANGELOG.md ${CARLA_TARGET_PACKAGE_PATH}/CHANGELOG) -file (COPY_FILE ${CARLA_SOURCE_DIR}/Docs/release_readme.md ${CARLA_TARGET_PACKAGE_PATH}/README) +file (COPY_FILE ${CARLA_WORKSPACE_PATH}/LICENSE ${CARLA_PACKAGE_ARCHIVE_PATH}/LICENSE) +file (COPY_FILE ${CARLA_WORKSPACE_PATH}/CHANGELOG.md ${CARLA_PACKAGE_ARCHIVE_PATH}/CHANGELOG) +file (COPY_FILE ${CARLA_WORKSPACE_PATH}/Docs/release_readme.md ${CARLA_PACKAGE_ARCHIVE_PATH}/README) if (WIN32) set (EXE_EXT .exe) else () set (EXE_EXT) endif () -make_directory (${CARLA_TARGET_PACKAGE_PATH}/Tools) +make_directory (${CARLA_PACKAGE_ARCHIVE_PATH}/Tools) # @TODO Temporary hack: -file (COPY_FILE ${CARLA_BINARY_DIR}/_deps/recastnavigation-build/RecastBuilder/RecastBuilder${EXE_EXT} ${CARLA_TARGET_PACKAGE_PATH}/Tools/RecastBuilder${EXE_EXT}) +file (COPY_FILE ${CARLA_BUILD_PATH}/_deps/recastnavigation-build/RecastBuilder/RecastBuilder${EXE_EXT} ${CARLA_PACKAGE_ARCHIVE_PATH}/Tools/RecastBuilder${EXE_EXT}) -make_directory (${CARLA_TARGET_PACKAGE_PATH}/PythonAPI/carla/dist) -file (GLOB PYTHON_WHL_FILES ${CARLA_BINARY_DIR}/PythonAPI/dist/carla-*.whl) -file (COPY ${PYTHON_WHL_FILES} DESTINATION ${CARLA_TARGET_PACKAGE_PATH}/PythonAPI/carla/dist/) -file (COPY_FILE ${CARLA_SOURCE_DIR}/Docs/python_api.md ${CARLA_TARGET_PACKAGE_PATH}/PythonAPI/python_api.md) -file (COPY ${CARLA_SOURCE_DIR}/PythonAPI/carla/agents/ DESTINATION ${CARLA_TARGET_PACKAGE_PATH}/PythonAPI/carla/agents/) -file (COPY_FILE ${CARLA_SOURCE_DIR}/PythonAPI/carla/scene_layout.py ${CARLA_TARGET_PACKAGE_PATH}/PythonAPI/carla/scene_layout.py) -file (COPY_FILE ${CARLA_SOURCE_DIR}/PythonAPI/carla/requirements.txt ${CARLA_TARGET_PACKAGE_PATH}/PythonAPI/carla/requirements.txt) +make_directory (${CARLA_PACKAGE_ARCHIVE_PATH}/PythonAPI/carla/dist) +file (GLOB PYTHON_WHL_FILES ${CARLA_BUILD_PATH}/PythonAPI/dist/carla-*.whl) +file (COPY ${PYTHON_WHL_FILES} DESTINATION ${CARLA_PACKAGE_ARCHIVE_PATH}/PythonAPI/carla/dist/) +file (COPY_FILE ${CARLA_WORKSPACE_PATH}/Docs/python_api.md ${CARLA_PACKAGE_ARCHIVE_PATH}/PythonAPI/python_api.md) +file (COPY ${CARLA_WORKSPACE_PATH}/PythonAPI/carla/agents/ DESTINATION ${CARLA_PACKAGE_ARCHIVE_PATH}/PythonAPI/carla/agents/) +file (COPY_FILE ${CARLA_WORKSPACE_PATH}/PythonAPI/carla/scene_layout.py ${CARLA_PACKAGE_ARCHIVE_PATH}/PythonAPI/carla/scene_layout.py) +file (COPY_FILE ${CARLA_WORKSPACE_PATH}/PythonAPI/carla/requirements.txt ${CARLA_PACKAGE_ARCHIVE_PATH}/PythonAPI/carla/requirements.txt) -make_directory (${CARLA_TARGET_PACKAGE_PATH}/PythonAPI/examples/) -file (GLOB PYTHON_EXAMPLE_FILES ${CARLA_SOURCE_DIR}/PythonAPI/examples/*.py) -file (COPY ${PYTHON_EXAMPLE_FILES} DESTINATION ${CARLA_TARGET_PACKAGE_PATH}/PythonAPI/examples/) -make_directory (${CARLA_TARGET_PACKAGE_PATH}/PythonAPI/examples/rss/) -file (GLOB PYTHON_EXAMPLE_RSS_FILES ${CARLA_SOURCE_DIR}/PythonAPI/examples/rss/*.py) -file (COPY ${PYTHON_EXAMPLE_RSS_FILES} DESTINATION ${CARLA_TARGET_PACKAGE_PATH}/PythonAPI/examples/rss/) -file (COPY_FILE ${CARLA_SOURCE_DIR}/PythonAPI/examples/requirements.txt ${CARLA_TARGET_PACKAGE_PATH}/PythonAPI/examples/requirements.txt) +make_directory (${CARLA_PACKAGE_ARCHIVE_PATH}/PythonAPI/examples/) +file (GLOB PYTHON_EXAMPLE_FILES ${CARLA_WORKSPACE_PATH}/PythonAPI/examples/*.py) +file (COPY ${PYTHON_EXAMPLE_FILES} DESTINATION ${CARLA_PACKAGE_ARCHIVE_PATH}/PythonAPI/examples/) +make_directory (${CARLA_PACKAGE_ARCHIVE_PATH}/PythonAPI/examples/rss/) +file (GLOB PYTHON_EXAMPLE_RSS_FILES ${CARLA_WORKSPACE_PATH}/PythonAPI/examples/rss/*.py) +file (COPY ${PYTHON_EXAMPLE_RSS_FILES} DESTINATION ${CARLA_PACKAGE_ARCHIVE_PATH}/PythonAPI/examples/rss/) +file (COPY_FILE ${CARLA_WORKSPACE_PATH}/PythonAPI/examples/requirements.txt ${CARLA_PACKAGE_ARCHIVE_PATH}/PythonAPI/examples/requirements.txt) -make_directory (${CARLA_TARGET_PACKAGE_PATH}/PythonAPI/util/) -file (GLOB PYTHON_UTIL_FILES ${CARLA_SOURCE_DIR}/PythonAPI/util/*.py) -file (COPY ${PYTHON_UTIL_FILES} DESTINATION ${CARLA_TARGET_PACKAGE_PATH}/PythonAPI/util/) -file (COPY_FILE ${CARLA_SOURCE_DIR}/PythonAPI/util/requirements.txt ${CARLA_TARGET_PACKAGE_PATH}/PythonAPI/util/requirements.txt) -file (COPY ${CARLA_SOURCE_DIR}/PythonAPI/util/opendrive/ DESTINATION ${CARLA_TARGET_PACKAGE_PATH}/PythonAPI/util/opendrive/) +make_directory (${CARLA_PACKAGE_ARCHIVE_PATH}/PythonAPI/util/) +file (GLOB PYTHON_UTIL_FILES ${CARLA_WORKSPACE_PATH}/PythonAPI/util/*.py) +file (COPY ${PYTHON_UTIL_FILES} DESTINATION ${CARLA_PACKAGE_ARCHIVE_PATH}/PythonAPI/util/) +file (COPY_FILE ${CARLA_WORKSPACE_PATH}/PythonAPI/util/requirements.txt ${CARLA_PACKAGE_ARCHIVE_PATH}/PythonAPI/util/requirements.txt) +file (COPY ${CARLA_WORKSPACE_PATH}/PythonAPI/util/opendrive/ DESTINATION ${CARLA_PACKAGE_ARCHIVE_PATH}/PythonAPI/util/opendrive/) -file (COPY ${CARLA_SOURCE_DIR}/Co-Simulation/ DESTINATION ${CARLA_TARGET_PACKAGE_PATH}/Co-Simulation/) +# file (COPY ${CARLA_WORKSPACE_PATH}/Co-Simulation/ DESTINATION ${CARLA_PACKAGE_ARCHIVE_PATH}/Co-Simulation/) -make_directory (${CARLA_TARGET_PACKAGE_PATH}/HDMaps/) -file (GLOB PYTHON_HDMAP_FILES ${CARLA_SOURCE_DIR}/Unreal/CarlaUnreal/Content/Carla/HDMaps/*.pcd) -file (COPY ${PYTHON_HDMAP_FILES} DESTINATION ${CARLA_TARGET_PACKAGE_PATH}/HDMaps/) -file (COPY_FILE ${CARLA_SOURCE_DIR}/Unreal/CarlaUnreal/Content/Carla/HDMaps/Readme.md ${CARLA_TARGET_PACKAGE_PATH}/HDMaps/README) +make_directory (${CARLA_PACKAGE_ARCHIVE_PATH}/HDMaps/) +file (GLOB PYTHON_HDMAP_FILES ${CARLA_WORKSPACE_PATH}/Unreal/CarlaUnreal/Content/Carla/HDMaps/*.pcd) +file (COPY ${PYTHON_HDMAP_FILES} DESTINATION ${CARLA_PACKAGE_ARCHIVE_PATH}/HDMaps/) +file (COPY_FILE ${CARLA_WORKSPACE_PATH}/Unreal/CarlaUnreal/Content/Carla/HDMaps/Readme.md ${CARLA_PACKAGE_ARCHIVE_PATH}/HDMaps/README) diff --git a/Unreal/Package/CreateCarlaVersionFile.cmake b/Unreal/Package/CreateCarlaVersionFile.cmake index 8e0c1bbfd..e5c97c1d5 100644 --- a/Unreal/Package/CreateCarlaVersionFile.cmake +++ b/Unreal/Package/CreateCarlaVersionFile.cmake @@ -1,21 +1,30 @@ execute_process( - COMMAND git log -1 --format=%H - WORKING_DIRECTORY ${CARLA_SOURCE_DIR} - OUTPUT_VARIABLE CARLA_GIT_HASH + COMMAND + git log -1 --format=%H + WORKING_DIRECTORY + ${CARLA_WORKSPACE_PATH} + OUTPUT_VARIABLE + CARLA_GIT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE ) execute_process( - COMMAND git log -1 --format=%H - WORKING_DIRECTORY ${CARLA_SOURCE_DIR}/Unreal/CarlaUnreal/Content/Carla - OUTPUT_VARIABLE CONTENT_GIT_HASH + COMMAND + git log -1 --format=%H + WORKING_DIRECTORY + ${CARLA_WORKSPACE_PATH}/Unreal/CarlaUnreal/Content/Carla + OUTPUT_VARIABLE + CONTENT_GIT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE ) execute_process( - COMMAND git log -1 --format=%H - WORKING_DIRECTORY ${CARLA_UNREAL_ENGINE_PATH} - OUTPUT_VARIABLE UNREAL_ENGINE_GIT_HASH + COMMAND + git log -1 --format=%H + WORKING_DIRECTORY + ${CARLA_UNREAL_ENGINE_PATH} + OUTPUT_VARIABLE + UNREAL_ENGINE_GIT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE )