From bf393ec85c62129de801d0e65d5a968bb99d0133 Mon Sep 17 00:00:00 2001 From: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> Date: Fri, 1 Oct 2021 08:38:46 -0700 Subject: [PATCH] fixes some install paths issues in monolithic release (#4422) * fixes some install paths issues in monolithic release Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> * PR comments Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> --- Code/LauncherUnified/launcher_generator.cmake | 17 ++--- Code/Legacy/CryCommon/ProjectDefines.h | 3 - Code/Legacy/CryCommon/platform_impl.cpp | 3 - Registry/CMakeLists.txt | 4 +- cmake/Packaging.cmake | 66 +++++++++++-------- cmake/Platform/Common/Install_common.cmake | 15 +++++ .../Platform/Windows/Packaging_windows.cmake | 1 + cmake/Projects.cmake | 20 ++++-- 8 files changed, 74 insertions(+), 55 deletions(-) diff --git a/Code/LauncherUnified/launcher_generator.cmake b/Code/LauncherUnified/launcher_generator.cmake index b30f752c85..5c9ee68e27 100644 --- a/Code/LauncherUnified/launcher_generator.cmake +++ b/Code/LauncherUnified/launcher_generator.cmake @@ -19,19 +19,10 @@ foreach(project_name project_path IN ZIP_LISTS LY_PROJECTS_TARGET_NAME LY_PROJEC # Otherwise the the absolute project_path is returned with symlinks resolved file(REAL_PATH ${project_path} project_real_path BASE_DIRECTORY ${LY_ROOT_FOLDER}) if(NOT project_name) - if(NOT EXISTS ${project_real_path}/project.json) - message(FATAL_ERROR "The specified project path of ${project_real_path} does not contain a project.json file") - else() - # Add the project_name to global LY_PROJECTS_TARGET_NAME property - ly_file_read("${project_real_path}/project.json" project_json) - string(JSON project_name ERROR_VARIABLE json_error GET ${project_json} "project_name") - if(json_error) - message(FATAL_ERROR "There is an error reading the \"project_name\" key from the '${project_real_path}/project.json' file: ${json_error}") - endif() - message(WARNING "The project located at path ${project_real_path} has a valid \"project name\" of '${project_name}' read from it's project.json file." - " This indicates that the ${project_real_path}/CMakeLists.txt is not properly appending the \"project name\" " - "to the LY_PROJECTS_TARGET_NAME global property. Other configuration errors might occur") - endif() + o3de_read_json_key(project_name ${project_real_path}/project.json "project_name") + message(WARNING "The project located at path ${project_real_path} has a valid \"project name\" of '${project_name}' read from it's project.json file." + " This indicates that the ${project_real_path}/CMakeLists.txt is not properly appending the \"project name\" " + "to the LY_PROJECTS_TARGET_NAME global property. Other configuration errors might occur") endif() ################################################################################ diff --git a/Code/Legacy/CryCommon/ProjectDefines.h b/Code/Legacy/CryCommon/ProjectDefines.h index 203bd304c9..2c3df4e37f 100644 --- a/Code/Legacy/CryCommon/ProjectDefines.h +++ b/Code/Legacy/CryCommon/ProjectDefines.h @@ -81,9 +81,6 @@ #include AZ_RESTRICTED_FILE(ProjectDefines_h) #else #define PROJECTDEFINES_H_TRAIT_DISABLE_MONOLITHIC_PROFILING_MARKERS 1 - #if !defined(LINUX) && !defined(APPLE) - #define PROJECTDEFINES_H_TRAIT_ENABLE_SOFTCODE_SYSTEM 1 - #endif #if defined(WIN32) || defined(WIN64) || defined(LINUX) || defined(APPLE) #define PROJECTDEFINES_H_TRAIT_USE_GPU_PARTICLES 1 #endif diff --git a/Code/Legacy/CryCommon/platform_impl.cpp b/Code/Legacy/CryCommon/platform_impl.cpp index 323d3daf65..a68a5150db 100644 --- a/Code/Legacy/CryCommon/platform_impl.cpp +++ b/Code/Legacy/CryCommon/platform_impl.cpp @@ -71,7 +71,6 @@ void InitCRTHandlers() void InitCRTHandlers() {} #endif -#ifndef SOFTCODE ////////////////////////////////////////////////////////////////////////// // This is an entry to DLL initialization function that must be called for each loaded module ////////////////////////////////////////////////////////////////////////// @@ -136,8 +135,6 @@ void* GetDetachEnvironmentSymbol() return reinterpret_cast(&DetachEnvironment); } -#endif // !defined(SOFTCODE) - bool g_bProfilerEnabled = false; ////////////////////////////////////////////////////////////////////////// diff --git a/Registry/CMakeLists.txt b/Registry/CMakeLists.txt index 100867010d..773adac07f 100644 --- a/Registry/CMakeLists.txt +++ b/Registry/CMakeLists.txt @@ -12,8 +12,6 @@ endif() ly_install_directory(DIRECTORIES .) -cmake_path(RELATIVE_PATH CMAKE_RUNTIME_OUTPUT_DIRECTORY BASE_DIRECTORY ${CMAKE_BINARY_DIR} OUTPUT_VARIABLE runtime_output_directory) - ly_install_directory(DIRECTORIES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$/Registry - DESTINATION ${runtime_output_directory}/${PAL_PLATFORM_NAME}/$ + DESTINATION ${runtime_output_directory} ) diff --git a/cmake/Packaging.cmake b/cmake/Packaging.cmake index 477a5f24ea..006689549b 100644 --- a/cmake/Packaging.cmake +++ b/cmake/Packaging.cmake @@ -89,37 +89,49 @@ endif() set(_cmake_package_dest ${CPACK_BINARY_DIR}/${CPACK_CMAKE_PACKAGE_FILE}) -string(REPLACE "." ";" _version_componets "${CPACK_DESIRED_CMAKE_VERSION}") -list(GET _version_componets 0 _major_version) -list(GET _version_componets 1 _minor_version) - -set(_url_version_tag "v${_major_version}.${_minor_version}") -set(_package_url "https://cmake.org/files/${_url_version_tag}/${CPACK_CMAKE_PACKAGE_FILE}") - -message(STATUS "Downloading CMake ${CPACK_DESIRED_CMAKE_VERSION} for packaging...") -download_file( - URL ${_package_url} - TARGET_FILE ${_cmake_package_dest} - EXPECTED_HASH ${CPACK_CMAKE_PACKAGE_HASH} - RESULTS _results -) -list(GET _results 0 _status_code) +if(EXISTS ${_cmake_package_dest}) + file(SHA256 ${_cmake_package_dest} hash_of_downloaded_file) + if (NOT "${hash_of_downloaded_file}" STREQUAL "${CPACK_CMAKE_PACKAGE_HASH}") + message(STATUS "CMake ${CPACK_DESIRED_CMAKE_VERSION} found at ${_cmake_package_dest} but expected hash missmatches, re-downloading...") + file(REMOVE ${_cmake_package_dest}) + else() + message(STATUS "CMake ${CPACK_DESIRED_CMAKE_VERSION} found") + endif() +endif() +if(NOT EXISTS ${_cmake_package_dest}) + # download it + string(REPLACE "." ";" _version_componets "${CPACK_DESIRED_CMAKE_VERSION}") + list(GET _version_componets 0 _major_version) + list(GET _version_componets 1 _minor_version) + + set(_url_version_tag "v${_major_version}.${_minor_version}") + set(_package_url "https://cmake.org/files/${_url_version_tag}/${CPACK_CMAKE_PACKAGE_FILE}") + + message(STATUS "Downloading CMake ${CPACK_DESIRED_CMAKE_VERSION} for packaging...") + download_file( + URL ${_package_url} + TARGET_FILE ${_cmake_package_dest} + EXPECTED_HASH ${CPACK_CMAKE_PACKAGE_HASH} + RESULTS _results + ) + list(GET _results 0 _status_code) + + if (${_status_code} EQUAL 0 AND EXISTS ${_cmake_package_dest}) + message(STATUS "CMake ${CPACK_DESIRED_CMAKE_VERSION} found") + else() + file(REMOVE ${_cmake_package_dest}) + list(REMOVE_AT _results 0) -if (${_status_code} EQUAL 0 AND EXISTS ${_cmake_package_dest}) - message(STATUS "Package found and verified!") -else() - file(REMOVE ${_cmake_package_dest}) - list(REMOVE_AT _results 0) + set(_error_message "An error occurred, code ${_status_code}. URL ${_package_url} - ${_results}") - set(_error_message "An error occurred, code ${_status_code}. URL ${_package_url} - ${_results}") + if(${_status_code} EQUAL 1) + string(APPEND _error_message + " Please double check the CPACK_CMAKE_PACKAGE_FILE and " + "CPACK_CMAKE_PACKAGE_HASH properties before trying again.") + endif() - if(${_status_code} EQUAL 1) - string(APPEND _error_message - " Please double check the CPACK_CMAKE_PACKAGE_FILE and " - "CPACK_CMAKE_PACKAGE_HASH properties before trying again.") + message(FATAL_ERROR ${_error_message}) endif() - - message(FATAL_ERROR ${_error_message}) endif() install(FILES ${_cmake_package_dest} diff --git a/cmake/Platform/Common/Install_common.cmake b/cmake/Platform/Common/Install_common.cmake index 8fb2effe29..5fa7f21939 100644 --- a/cmake/Platform/Common/Install_common.cmake +++ b/cmake/Platform/Common/Install_common.cmake @@ -430,6 +430,21 @@ function(ly_setup_cmake_install) DESTINATION . COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} ) + string(CONFIGURE [=[ +if("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Rr][Ee][Ll][Ee][Aa][Ss][Ee])$") + set(install_output_folder "${CMAKE_INSTALL_PREFIX}/@runtime_output_directory@") + file(WRITE ${install_output_folder}/engine.json +"{ + \"engine_name\": \"@LY_VERSION_ENGINE_NAME@\" +}") +endif() +]=] + install_engine_json_release + @ONLY + ) + install(CODE ${install_engine_json_release} + COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} # use the default for the time being + ) # Collect all Find files that were added with ly_add_external_target_path unset(additional_find_files) diff --git a/cmake/Platform/Windows/Packaging_windows.cmake b/cmake/Platform/Windows/Packaging_windows.cmake index ced7757852..4a03df2fd2 100644 --- a/cmake/Platform/Windows/Packaging_windows.cmake +++ b/cmake/Platform/Windows/Packaging_windows.cmake @@ -23,6 +23,7 @@ set(CPACK_WIX_ROOT ${LY_INSTALLER_WIX_ROOT}) set(CPACK_GENERATOR WIX) +set(CPACK_THREADS 0) set(_cmake_package_name "cmake-${CPACK_DESIRED_CMAKE_VERSION}-windows-x86_64") set(CPACK_CMAKE_PACKAGE_FILE "${_cmake_package_name}.zip") set(CPACK_CMAKE_PACKAGE_HASH "15a49e2ab81c1822d75b1b1a92f7863f58e31f6d6aac1c4103eef2b071be3112") diff --git a/cmake/Projects.cmake b/cmake/Projects.cmake index 61cb101909..b21704ee85 100644 --- a/cmake/Projects.cmake +++ b/cmake/Projects.cmake @@ -10,7 +10,7 @@ include_guard() -set(LY_PROJECTS "${LY_PROJECTS}" CACHE STRING "List of projects to enable, this can be a relative path to the engine root or an absolute path") +set(LY_PROJECTS "" CACHE STRING "List of projects to enable, this can be a relative path to the engine root or an absolute path") #! ly_add_target_dependencies: adds module load dependencies for this target. # @@ -143,21 +143,25 @@ foreach(project ${LY_PROJECTS}) ly_generate_project_build_path_setreg(${full_directory_path}) add_project_json_external_subdirectories(${full_directory_path}) + # Get project name + o3de_read_json_key(project_name ${full_directory_path}/project.json "project_name") + # Generate pak for project in release installs - cmake_path(RELATIVE_PATH CMAKE_RUNTIME_OUTPUT_DIRECTORY BASE_DIRECTORY ${CMAKE_BINARY_DIR} OUTPUT_VARIABLE runtime_output_directory) + cmake_path(RELATIVE_PATH CMAKE_RUNTIME_OUTPUT_DIRECTORY BASE_DIRECTORY ${CMAKE_BINARY_DIR} OUTPUT_VARIABLE install_base_runtime_output_directory) set(install_engine_pak_template [=[ if("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Rr][Ee][Ll][Ee][Aa][Ss][Ee])$") - set(install_output_folder "${CMAKE_INSTALL_PREFIX}/@runtime_output_directory@/@PAL_PLATFORM_NAME@/${CMAKE_INSTALL_CONFIG_NAME}/@LY_BUILD_PERMUTATION@") + set(install_output_folder "${CMAKE_INSTALL_PREFIX}/@install_base_runtime_output_directory@/@PAL_PLATFORM_NAME@/${CMAKE_INSTALL_CONFIG_NAME}/@LY_BUILD_PERMUTATION@") + set(install_pak_output_folder "${install_output_folder}/Cache/@LY_ASSET_DEPLOY_ASSET_TYPE@") if(NOT DEFINED LY_ASSET_DEPLOY_ASSET_TYPE) set(LY_ASSET_DEPLOY_ASSET_TYPE @LY_ASSET_DEPLOY_ASSET_TYPE@) endif() - message(STATUS "Generating ${install_output_folder}/engine.pak from @full_directory_path@/Cache/${LY_ASSET_DEPLOY_ASSET_TYPE}") - file(MAKE_DIRECTORY "${install_output_folder}") + message(STATUS "Generating ${install_pak_output_folder}/engine.pak from @full_directory_path@/Cache/${LY_ASSET_DEPLOY_ASSET_TYPE}") + file(MAKE_DIRECTORY "${install_pak_output_folder}") cmake_path(SET cache_product_path "@full_directory_path@/Cache/${LY_ASSET_DEPLOY_ASSET_TYPE}") file(GLOB product_assets "${cache_product_path}/*") if(product_assets) execute_process( - COMMAND ${CMAKE_COMMAND} -E tar "cf" "${install_output_folder}/engine.pak" --format=zip -- ${product_assets} + COMMAND ${CMAKE_COMMAND} -E tar "cf" "${install_pak_output_folder}/engine.pak" --format=zip -- ${product_assets} WORKING_DIRECTORY "${cache_product_path}" RESULT_VARIABLE archive_creation_result ) @@ -165,6 +169,10 @@ if("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Rr][Ee][Ll][Ee][Aa][Ss][Ee])$") message(STATUS "${install_output_folder}/engine.pak generated") endif() endif() + file(WRITE ${install_output_folder}/project.json +"{ + \"project_name\": \"@project_name@\" +}") endif() ]=]) string(CONFIGURE "${install_engine_pak_template}" install_engine_pak_code @ONLY)