From dbc5d7a8bc5404b80fbc38b6b004aaa1f9e06df9 Mon Sep 17 00:00:00 2001 From: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> Date: Fri, 19 Nov 2021 14:07:25 -0800 Subject: [PATCH] Cherry-pick of Linux deb package to stabilization (#5778) * Cherry-pick 49e8f358581dad7ca0e8127905a9d5e864c41cee Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> * Merging differences from development of other changes that need to be there for deb packaging Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> * Picks a needed change for the installer Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> * Fixes warning in mac Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> * Takes version from environment if defined Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> * Do not pick up version if it is empty string since that will also break version comparison Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> * creating temp directories if they dont exist Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> * removing a dependency to itself (Multiplayer.Builders is an alias of Multiplayer.Editor) Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> * Filters which runtime dependencies are passed from private build dependencies to only those that are actual targets. This avoids something like a "d3d12" private build dependency from being passed to the runtime dependencies Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> --- AutomatedTesting/CMakeLists.txt | 3 +- AutomatedTesting/cmake/CompilerSettings.cmake | 13 + .../{ => cmake}/EngineFinder.cmake | 42 ++- .../Linux/CompilerSettings_linux.cmake | 0 .../AzCore/Serialization/AZStdContainers.inl | 2 +- .../AzToolsFramework/API/PythonLoader.h | 2 +- .../Prefab/PrefabFocusHandler.cpp | 6 +- Gems/Multiplayer/Code/CMakeLists.txt | 1 - Registry/CMakeLists.txt | 11 +- .../Template/cmake/CompilerSettings.cmake | 2 +- .../Linux/CompilerSettings_linux.cmake} | 0 Templates/DefaultProject/template.json | 4 +- .../Template/cmake/CompilerSettings.cmake | 2 +- .../Linux/CompilerSettings_linux.cmake | 0 Templates/MinimalProject/template.json | 4 +- cmake/3rdPartyPackages.cmake | 11 +- cmake/CompilerSettings.cmake | 2 +- cmake/Install.cmake | 54 +++- cmake/LYWrappers.cmake | 4 +- cmake/Packaging.cmake | 250 +++++++----------- cmake/Packaging/CMakeDownload.cmake.in | 54 ++++ cmake/Platform/Common/Install_common.cmake | 204 +++++++++----- .../Common/PackagingPostBuild_common.cmake | 114 ++++++++ .../Common/PackagingPreBuild_common.cmake | 5 + .../Common/RuntimeDependencies_common.cmake | 2 +- .../runtime_dependencies_common.cmake.in | 18 +- .../Linux/CompilerSettings_linux.cmake | 34 +++ cmake/Platform/Linux/Install_linux.cmake | 42 ++- cmake/Platform/Linux/PAL_linux.cmake | 2 +- cmake/Platform/Linux/Packaging/postinst.in | 21 ++ cmake/Platform/Linux/Packaging/postrm.in | 15 ++ cmake/Platform/Linux/Packaging/prerm.in | 23 ++ .../Linux/PackagingPostBuild_linux.cmake | 62 +++++ .../Linux/PackagingPreBuild_linux.cmake | 16 ++ cmake/Platform/Linux/Packaging_linux.cmake | 56 ++++ .../Platform/Linux/platform_linux_files.cmake | 8 + .../Linux/runtime_dependencies_linux.cmake.in | 26 +- cmake/Platform/Mac/InstallUtils_mac.cmake.in | 39 +-- cmake/Platform/Mac/Install_mac.cmake | 61 +++-- .../Platform/Mac/PackagingPostBuild_mac.cmake | 10 + .../Platform/Mac/PackagingPreBuild_mac.cmake | 10 + .../Mac/runtime_dependencies_mac.cmake.in | 35 ++- .../Platform/Windows/PackagingPostBuild.cmake | 237 ----------------- .../Windows/PackagingPostBuild_windows.cmake | 166 ++++++++++++ .../Platform/Windows/PackagingPreBuild.cmake | 37 --- .../Windows/PackagingPreBuild_windows.cmake | 60 +++++ .../Platform/Windows/Packaging_windows.cmake | 62 ++--- .../Windows/platform_windows_files.cmake | 5 +- cmake/Version.cmake | 5 + .../install/ConfigurationType_config.cmake.in | 2 +- .../build/Platform/Android/build_config.json | 10 +- .../build/Platform/Linux/build_config.json | 82 +++++- .../Platform/Linux/build_installer_linux.sh | 15 ++ scripts/build/Platform/Linux/build_linux.sh | 13 +- scripts/build/Platform/Linux/env_linux.sh | 5 + .../build/Platform/Linux/installer_linux.sh | 30 +++ scripts/build/Platform/Mac/build_config.json | 59 ++++- scripts/build/Platform/Mac/build_mac.sh | 5 +- scripts/build/Platform/Mac/env_mac.sh | 5 + .../build/Platform/Windows/build_config.json | 72 +++-- .../build/Platform/Windows/build_windows.cmd | 12 +- .../build/Platform/Windows/env_windows.cmd | 23 ++ .../Platform/Windows/installer_windows.cmd | 14 +- .../Windows/package_build_config.json | 2 +- scripts/build/Platform/iOS/build_config.json | 10 +- .../Linux/package-list.ubuntu-bionic.txt | 9 +- .../Linux/package-list.ubuntu-focal.txt | 4 +- 67 files changed, 1473 insertions(+), 741 deletions(-) create mode 100644 AutomatedTesting/cmake/CompilerSettings.cmake rename AutomatedTesting/{ => cmake}/EngineFinder.cmake (63%) rename Templates/DefaultProject/Template/cmake/Platform/Linux/CompilerSettings.cmake => AutomatedTesting/cmake/Platform/Linux/CompilerSettings_linux.cmake (100%) rename Templates/{MinimalProject/Template/cmake/Platform/Linux/CompilerSettings.cmake => DefaultProject/Template/cmake/Platform/Linux/CompilerSettings_linux.cmake} (100%) rename cmake/Platform/Linux/CompilerSettings.cmake => Templates/MinimalProject/Template/cmake/Platform/Linux/CompilerSettings_linux.cmake (100%) create mode 100644 cmake/Packaging/CMakeDownload.cmake.in create mode 100644 cmake/Platform/Common/PackagingPostBuild_common.cmake create mode 100644 cmake/Platform/Common/PackagingPreBuild_common.cmake create mode 100644 cmake/Platform/Linux/CompilerSettings_linux.cmake create mode 100644 cmake/Platform/Linux/Packaging/postinst.in create mode 100644 cmake/Platform/Linux/Packaging/postrm.in create mode 100644 cmake/Platform/Linux/Packaging/prerm.in create mode 100644 cmake/Platform/Linux/PackagingPostBuild_linux.cmake create mode 100644 cmake/Platform/Linux/PackagingPreBuild_linux.cmake create mode 100644 cmake/Platform/Linux/Packaging_linux.cmake create mode 100644 cmake/Platform/Mac/PackagingPostBuild_mac.cmake create mode 100644 cmake/Platform/Mac/PackagingPreBuild_mac.cmake delete mode 100644 cmake/Platform/Windows/PackagingPostBuild.cmake create mode 100644 cmake/Platform/Windows/PackagingPostBuild_windows.cmake delete mode 100644 cmake/Platform/Windows/PackagingPreBuild.cmake create mode 100644 cmake/Platform/Windows/PackagingPreBuild_windows.cmake create mode 100755 scripts/build/Platform/Linux/build_installer_linux.sh create mode 100755 scripts/build/Platform/Linux/installer_linux.sh diff --git a/AutomatedTesting/CMakeLists.txt b/AutomatedTesting/CMakeLists.txt index dee9d73aea..1c5382ba4b 100644 --- a/AutomatedTesting/CMakeLists.txt +++ b/AutomatedTesting/CMakeLists.txt @@ -8,11 +8,12 @@ if(NOT PROJECT_NAME) cmake_minimum_required(VERSION 3.20) + include(cmake/CompilerSettings.cmake) project(AutomatedTesting LANGUAGES C CXX VERSION 1.0.0.0 ) - include(EngineFinder.cmake OPTIONAL) + include(cmake/EngineFinder.cmake OPTIONAL) find_package(o3de REQUIRED) o3de_initialize() else() diff --git a/AutomatedTesting/cmake/CompilerSettings.cmake b/AutomatedTesting/cmake/CompilerSettings.cmake new file mode 100644 index 0000000000..60bda1d45b --- /dev/null +++ b/AutomatedTesting/cmake/CompilerSettings.cmake @@ -0,0 +1,13 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +# File to tweak compiler settings before compiler detection happens (before project() is called) +# We dont have PAL enabled at this point, so we can only use pure-CMake variables +if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux") + include(cmake/Platform/Linux/CompilerSettings_linux.cmake) +endif() diff --git a/AutomatedTesting/EngineFinder.cmake b/AutomatedTesting/cmake/EngineFinder.cmake similarity index 63% rename from AutomatedTesting/EngineFinder.cmake rename to AutomatedTesting/cmake/EngineFinder.cmake index 0a34a43b77..15b96eb8a9 100644 --- a/AutomatedTesting/EngineFinder.cmake +++ b/AutomatedTesting/cmake/EngineFinder.cmake @@ -1,3 +1,4 @@ +# {BEGIN_LICENSE} # # Copyright (c) Contributors to the Open 3D Engine Project. # For complete copyright and license terms please see the LICENSE at the root of this distribution. @@ -5,18 +6,34 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # # +# {END_LICENSE} # This file is copied during engine registration. Edits to this file will be lost next # time a registration happens. include_guard() # Read the engine name from the project_json file -file(READ ${CMAKE_CURRENT_LIST_DIR}/project.json project_json) -set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_CURRENT_LIST_DIR}/project.json) +file(READ ${CMAKE_CURRENT_SOURCE_DIR}/project.json project_json) +set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/project.json) string(JSON LY_ENGINE_NAME_TO_USE ERROR_VARIABLE json_error GET ${project_json} engine) if(json_error) - message(FATAL_ERROR "Unable to read key 'engine' from 'project.json', error: ${json_error}") + message(FATAL_ERROR "Unable to read key 'engine' from 'project.json'\nError: ${json_error}") +endif() + +if(CMAKE_MODULE_PATH) + foreach(module_path ${CMAKE_MODULE_PATH}) + if(EXISTS ${module_path}/Findo3de.cmake) + file(READ ${module_path}/../engine.json engine_json) + string(JSON engine_name ERROR_VARIABLE json_error GET ${engine_json} engine_name) + if(json_error) + message(FATAL_ERROR "Unable to read key 'engine_name' from 'engine.json'\nError: ${json_error}") + endif() + if(LY_ENGINE_NAME_TO_USE STREQUAL engine_name) + return() # Engine being forced through CMAKE_MODULE_PATH + endif() + endif() + endforeach() endif() if(DEFINED ENV{USERPROFILE} AND EXISTS $ENV{USERPROFILE}) @@ -25,6 +42,11 @@ else() set(manifest_path $ENV{HOME}/.o3de/o3de_manifest.json) # Unix endif() +set(registration_error [=[ +Engine registration is required before configuring a project. +Run 'scripts/o3de register --this-engine' from the engine root. +]=]) + # Read the ~/.o3de/o3de_manifest.json file and look through the 'engines_path' object. # Find a key that matches LY_ENGINE_NAME_TO_USE and use that as the engine path. if(EXISTS ${manifest_path}) @@ -33,36 +55,38 @@ if(EXISTS ${manifest_path}) string(JSON engines_path_count ERROR_VARIABLE json_error LENGTH ${manifest_json} engines_path) if(json_error) - message(FATAL_ERROR "Unable to read key 'engines_path' from '${manifest_path}', error: ${json_error}") + message(FATAL_ERROR "Unable to read key 'engines_path' from '${manifest_path}'\nError: ${json_error}\n${registration_error}") endif() string(JSON engines_path_type ERROR_VARIABLE json_error TYPE ${manifest_json} engines_path) if(json_error OR NOT ${engines_path_type} STREQUAL "OBJECT") - message(FATAL_ERROR "Type of 'engines_path' in '${manifest_path}' is not a JSON Object, error: ${json_error}") + message(FATAL_ERROR "Type of 'engines_path' in '${manifest_path}' is not a JSON Object\nError: ${json_error}") endif() math(EXPR engines_path_count "${engines_path_count}-1") foreach(engine_path_index RANGE ${engines_path_count}) string(JSON engine_name ERROR_VARIABLE json_error MEMBER ${manifest_json} engines_path ${engine_path_index}) if(json_error) - message(FATAL_ERROR "Unable to read 'engines_path/${engine_path_index}' from '${manifest_path}', error: ${json_error}") + message(FATAL_ERROR "Unable to read 'engines_path/${engine_path_index}' from '${manifest_path}'\nError: ${json_error}") endif() if(LY_ENGINE_NAME_TO_USE STREQUAL engine_name) string(JSON engine_path ERROR_VARIABLE json_error GET ${manifest_json} engines_path ${engine_name}) if(json_error) - message(FATAL_ERROR "Unable to read value from 'engines_path/${engine_name}', error: ${json_error}") + message(FATAL_ERROR "Unable to read value from 'engines_path/${engine_name}'\nError: ${json_error}") endif() if(engine_path) list(APPEND CMAKE_MODULE_PATH "${engine_path}/cmake") - break() + return() endif() endif() endforeach() + + message(FATAL_ERROR "The project.json uses engine name '${LY_ENGINE_NAME_TO_USE}' but no engine with that name has been registered.\n${registration_error}") else() # If the user is passing CMAKE_MODULE_PATH we assume thats where we will find the engine if(NOT CMAKE_MODULE_PATH) - message(FATAL_ERROR "Engine registration is required before configuring a project. Please register an engine by running 'scripts/o3de register --this-engine'") + message(FATAL_ERROR "O3DE Manifest file not found.\n${registration_error}") endif() endif() diff --git a/Templates/DefaultProject/Template/cmake/Platform/Linux/CompilerSettings.cmake b/AutomatedTesting/cmake/Platform/Linux/CompilerSettings_linux.cmake similarity index 100% rename from Templates/DefaultProject/Template/cmake/Platform/Linux/CompilerSettings.cmake rename to AutomatedTesting/cmake/Platform/Linux/CompilerSettings_linux.cmake diff --git a/Code/Framework/AzCore/AzCore/Serialization/AZStdContainers.inl b/Code/Framework/AzCore/AzCore/Serialization/AZStdContainers.inl index bae79a6fe7..2a00652488 100644 --- a/Code/Framework/AzCore/AzCore/Serialization/AZStdContainers.inl +++ b/Code/Framework/AzCore/AzCore/Serialization/AZStdContainers.inl @@ -94,7 +94,7 @@ namespace AZ template AZStd::enable_if_t::value> InitializeDefaultIfPodType(T& t) { - t = {}; + t = T{}; } template diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/API/PythonLoader.h b/Code/Framework/AzToolsFramework/AzToolsFramework/API/PythonLoader.h index 29125667d6..6acc160ddc 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/API/PythonLoader.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/API/PythonLoader.h @@ -19,7 +19,7 @@ namespace AzToolsFramework::EmbeddedPython ~PythonLoader(); private: - void* m_embeddedLibPythonHandle{ nullptr }; + [[maybe_unused]] void* m_embeddedLibPythonHandle{ nullptr }; }; } // namespace AzToolsFramework::EmbeddedPython diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.cpp index 3d764554ef..f20c11a1d8 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.cpp @@ -376,7 +376,7 @@ namespace AzToolsFramework::Prefab size_t index = 0; size_t maxIndex = m_instanceFocusHierarchy.size() - 1; - for (const AZ::EntityId containerEntityId : m_instanceFocusHierarchy) + for (const AZ::EntityId& containerEntityId : m_instanceFocusHierarchy) { InstanceOptionalReference instance = GetReferenceFromContainerEntityId(containerEntityId); if (instance.has_value()) @@ -414,7 +414,7 @@ namespace AzToolsFramework::Prefab return; } - for (const AZ::EntityId containerEntityId : instances) + for (const AZ::EntityId& containerEntityId : instances) { InstanceOptionalReference instance = GetReferenceFromContainerEntityId(containerEntityId); @@ -433,7 +433,7 @@ namespace AzToolsFramework::Prefab return; } - for (const AZ::EntityId containerEntityId : instances) + for (const AZ::EntityId& containerEntityId : instances) { InstanceOptionalReference instance = GetReferenceFromContainerEntityId(containerEntityId); diff --git a/Gems/Multiplayer/Code/CMakeLists.txt b/Gems/Multiplayer/Code/CMakeLists.txt index dee68fa969..cc9988fe57 100644 --- a/Gems/Multiplayer/Code/CMakeLists.txt +++ b/Gems/Multiplayer/Code/CMakeLists.txt @@ -131,7 +131,6 @@ if (PAL_TRAIT_BUILD_HOST_TOOLS) AZ::AzToolsFramework Gem::Multiplayer.Static Gem::Multiplayer.Tools.Static - Gem::Multiplayer.Builders ) ly_create_alias(NAME Multiplayer.Builders NAMESPACE Gem TARGETS Gem::Multiplayer.Editor) diff --git a/Registry/CMakeLists.txt b/Registry/CMakeLists.txt index 773adac07f..df309ba657 100644 --- a/Registry/CMakeLists.txt +++ b/Registry/CMakeLists.txt @@ -12,6 +12,11 @@ endif() ly_install_directory(DIRECTORIES .) -ly_install_directory(DIRECTORIES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$/Registry - DESTINATION ${runtime_output_directory} -) +foreach(conf IN LISTS CMAKE_CONFIGURATION_TYPES) + string(TOUPPER ${conf} UCONF) + string(REPLACE "$" "${conf}" output ${runtime_output_directory}) + ly_install_directory(DIRECTORIES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${conf}/Registry + DESTINATION ${output} + COMPONENT ${LY_INSTALL_PERMUTATION_COMPONENT}_${UCONF} + ) +endforeach() diff --git a/Templates/DefaultProject/Template/cmake/CompilerSettings.cmake b/Templates/DefaultProject/Template/cmake/CompilerSettings.cmake index cf6614e4a5..60bda1d45b 100644 --- a/Templates/DefaultProject/Template/cmake/CompilerSettings.cmake +++ b/Templates/DefaultProject/Template/cmake/CompilerSettings.cmake @@ -9,5 +9,5 @@ # File to tweak compiler settings before compiler detection happens (before project() is called) # We dont have PAL enabled at this point, so we can only use pure-CMake variables if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux") - include(cmake/Platform/${CMAKE_HOST_SYSTEM_NAME}/CompilerSettings.cmake) + include(cmake/Platform/Linux/CompilerSettings_linux.cmake) endif() diff --git a/Templates/MinimalProject/Template/cmake/Platform/Linux/CompilerSettings.cmake b/Templates/DefaultProject/Template/cmake/Platform/Linux/CompilerSettings_linux.cmake similarity index 100% rename from Templates/MinimalProject/Template/cmake/Platform/Linux/CompilerSettings.cmake rename to Templates/DefaultProject/Template/cmake/Platform/Linux/CompilerSettings_linux.cmake diff --git a/Templates/DefaultProject/template.json b/Templates/DefaultProject/template.json index a36926f632..fcffafcb34 100644 --- a/Templates/DefaultProject/template.json +++ b/Templates/DefaultProject/template.json @@ -193,8 +193,8 @@ "isOptional": false }, { - "file": "cmake/Platform/Linux/CompilerSettings.cmake", - "origin": "cmake/Platform/Linux/CompilerSettings.cmake", + "file": "cmake/Platform/Linux/CompilerSettings_linux.cmake", + "origin": "cmake/Platform/Linux/CompilerSettings_linux.cmake", "isTemplated": false, "isOptional": false }, diff --git a/Templates/MinimalProject/Template/cmake/CompilerSettings.cmake b/Templates/MinimalProject/Template/cmake/CompilerSettings.cmake index cf6614e4a5..60bda1d45b 100644 --- a/Templates/MinimalProject/Template/cmake/CompilerSettings.cmake +++ b/Templates/MinimalProject/Template/cmake/CompilerSettings.cmake @@ -9,5 +9,5 @@ # File to tweak compiler settings before compiler detection happens (before project() is called) # We dont have PAL enabled at this point, so we can only use pure-CMake variables if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux") - include(cmake/Platform/${CMAKE_HOST_SYSTEM_NAME}/CompilerSettings.cmake) + include(cmake/Platform/Linux/CompilerSettings_linux.cmake) endif() diff --git a/cmake/Platform/Linux/CompilerSettings.cmake b/Templates/MinimalProject/Template/cmake/Platform/Linux/CompilerSettings_linux.cmake similarity index 100% rename from cmake/Platform/Linux/CompilerSettings.cmake rename to Templates/MinimalProject/Template/cmake/Platform/Linux/CompilerSettings_linux.cmake diff --git a/Templates/MinimalProject/template.json b/Templates/MinimalProject/template.json index 4260e71527..7d6a4f9b94 100644 --- a/Templates/MinimalProject/template.json +++ b/Templates/MinimalProject/template.json @@ -185,8 +185,8 @@ "isOptional": false }, { - "file": "cmake/Platform/Linux/CompilerSettings.cmake", - "origin": "cmake/Platform/Linux/CompilerSettings.cmake", + "file": "cmake/Platform/Linux/CompilerSettings_linux.cmake", + "origin": "cmake/Platform/Linux/CompilerSettings_linux.cmake", "isTemplated": false, "isOptional": false }, diff --git a/cmake/3rdPartyPackages.cmake b/cmake/3rdPartyPackages.cmake index efe67b4d24..a3f15bdb22 100644 --- a/cmake/3rdPartyPackages.cmake +++ b/cmake/3rdPartyPackages.cmake @@ -7,7 +7,7 @@ include_guard() -include(cmake/LySet.cmake) +include(${LY_ROOT_FOLDER}/cmake/LySet.cmake) # OVERVIEW: # this is the Open 3D Engine Package system. @@ -80,10 +80,7 @@ macro(ly_package_message) endif() endmacro() -file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/packages) - -include(cmake/LYPackage_S3Downloader.cmake) - +include(${LY_ROOT_FOLDER}/cmake/LYPackage_S3Downloader.cmake) # Attempts one time to download a file. # sets should_retry to true if the caller should retry due to an intermittent problem @@ -711,11 +708,11 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) # include the built in 3rd party packages that are for every platform. # you can put your package associations anywhere, but this provides # a good starting point. - include(cmake/3rdParty/BuiltInPackages.cmake) + include(${LY_ROOT_FOLDER}/cmake/3rdParty/BuiltInPackages.cmake) endif() if(PAL_TRAIT_BUILD_HOST_TOOLS) - include(cmake/LYWrappers.cmake) + include(${LY_ROOT_FOLDER}/cmake/LYWrappers.cmake) # Importing this globally to handle AUTOMOC, AUTOUIC, AUTORCC ly_parse_third_party_dependencies(3rdParty::Qt) endif() diff --git a/cmake/CompilerSettings.cmake b/cmake/CompilerSettings.cmake index cf6614e4a5..60bda1d45b 100644 --- a/cmake/CompilerSettings.cmake +++ b/cmake/CompilerSettings.cmake @@ -9,5 +9,5 @@ # File to tweak compiler settings before compiler detection happens (before project() is called) # We dont have PAL enabled at this point, so we can only use pure-CMake variables if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux") - include(cmake/Platform/${CMAKE_HOST_SYSTEM_NAME}/CompilerSettings.cmake) + include(cmake/Platform/Linux/CompilerSettings_linux.cmake) endif() diff --git a/cmake/Install.cmake b/cmake/Install.cmake index 3b74e6c654..b558590b9e 100644 --- a/cmake/Install.cmake +++ b/cmake/Install.cmake @@ -8,16 +8,38 @@ set(LY_INSTALL_ENABLED TRUE CACHE BOOL "Indicates if the install process is enabled") -if(LY_INSTALL_ENABLED) - ly_get_absolute_pal_filename(pal_dir ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Platform/${PAL_PLATFORM_NAME}) - include(${pal_dir}/Install_${PAL_PLATFORM_NAME_LOWERCASE}.cmake) -endif() +#! ly_install: wrapper to install that handles common functionality +# +# \notes: +# - this wrapper handles the case where common installs are called multiple times from different +# build folders (when using LY_INSTALL_EXTERNAL_BUILD_DIRS) to generate install layouts that +# have multiple build permutations +# +function(ly_install) + + if(NOT LY_INSTALL_ENABLED) + return() + endif() + + cmake_parse_arguments(ly_install "" "COMPONENT" "" ${ARGN}) + if (NOT ly_install_COMPONENT OR "${ly_install_COMPONENT}" STREQUAL "${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}") + # if it is installing under the default component, we need to de-duplicate since we can have + # cases coming from different build directories (when using LY_INSTALL_EXTERNAL_BUILD_DIRS) + install(CODE "if(NOT LY_CORE_COMPONENT_ALREADY_INCLUDED)" ALL_COMPONENTS) + install(${ARGN}) + install(CODE "endif()\n" ALL_COMPONENTS) + else() + install(${ARGN}) + endif() + +endfunction() #! ly_install_directory: specifies a directory to be copied to the install layout at install time # # \arg:DIRECTORIES directories to install # \arg:DESTINATION (optional) destination to install the directory to (relative to CMAKE_PREFIX_PATH) # \arg:EXCLUDE_PATTERNS (optional) patterns to exclude +# \arg:COMPONENT (optional) component to use (defaults to CMAKE_INSTALL_DEFAULT_COMPONENT_NAME) # \arg:VERBATIM (optional) copies the directories as they are, this excludes the default exclude patterns # # \notes: @@ -34,7 +56,7 @@ function(ly_install_directory) endif() set(options VERBATIM) - set(oneValueArgs DESTINATION) + set(oneValueArgs DESTINATION COMPONENT) set(multiValueArgs DIRECTORIES EXCLUDE_PATTERNS) cmake_parse_arguments(ly_install_directory "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) @@ -42,6 +64,10 @@ function(ly_install_directory) if(NOT ly_install_directory_DIRECTORIES) message(FATAL_ERROR "You must provide at least a directory to install") endif() + + if(NOT ly_install_directory_COMPONENT) + set(ly_install_directory_COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}) + endif() foreach(directory ${ly_install_directory_DIRECTORIES}) @@ -77,11 +103,12 @@ function(ly_install_directory) list(APPEND exclude_patterns PATTERN *.egg-info EXCLUDE) endif() - install(DIRECTORY ${directory} + ly_install(DIRECTORY ${directory} DESTINATION ${ly_install_directory_DESTINATION} - COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} # use the deafult for the time being + COMPONENT ${ly_install_directory_COMPONENT} ${exclude_patterns} ) + endforeach() endfunction() @@ -126,7 +153,7 @@ function(ly_install_files) set(install_type FILES) endif() - install(${install_type} ${files} + ly_install(${install_type} ${files} DESTINATION ${ly_install_files_DESTINATION} COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} # use the default for the time being ) @@ -144,7 +171,7 @@ function(ly_install_run_code CODE) return() endif() - install(CODE ${CODE} + ly_install(CODE ${CODE} COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} # use the default for the time being ) @@ -161,8 +188,13 @@ function(ly_install_run_script SCRIPT) return() endif() - install(SCRIPT ${SCRIPT} + ly_install(SCRIPT ${SCRIPT} COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} # use the default for the time being ) -endfunction() \ No newline at end of file +endfunction() + +if(LY_INSTALL_ENABLED) + ly_get_absolute_pal_filename(pal_dir ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Platform/${PAL_PLATFORM_NAME}) + include(${pal_dir}/Install_${PAL_PLATFORM_NAME_LOWERCASE}.cmake) +endif() diff --git a/cmake/LYWrappers.cmake b/cmake/LYWrappers.cmake index 0416d41ece..ae097c9bb7 100644 --- a/cmake/LYWrappers.cmake +++ b/cmake/LYWrappers.cmake @@ -354,7 +354,7 @@ function(ly_add_target) # of running the copy of runtime dependencies, the stamp file is touched so the timestamp is updated. # Adding a config as part of the name since the stamp file is added to the VS project. # Note the STAMP_OUTPUT_FILE need to match with the one used in runtime dependencies (e.g. RuntimeDependencies_common.cmake) - set(STAMP_OUTPUT_FILE ${CMAKE_BINARY_DIR}/runtime_dependencies/$/${ly_add_target_NAME}_$.stamp) + set(STAMP_OUTPUT_FILE ${CMAKE_BINARY_DIR}/runtime_dependencies/$/${ly_add_target_NAME}.stamp) add_custom_command( OUTPUT ${STAMP_OUTPUT_FILE} DEPENDS "$>" @@ -367,7 +367,7 @@ function(ly_add_target) # stamp file on each configuration so it gets properly excluded by the generator unset(stamp_files_per_config) foreach(conf IN LISTS CMAKE_CONFIGURATION_TYPES) - set(stamp_file_conf ${CMAKE_BINARY_DIR}/runtime_dependencies/${conf}/${ly_add_target_NAME}_${conf}.stamp) + set(stamp_file_conf ${CMAKE_BINARY_DIR}/runtime_dependencies/${conf}/${ly_add_target_NAME}.stamp) set_source_files_properties(${stamp_file_conf} PROPERTIES GENERATED TRUE SKIP_AUTOGEN TRUE) list(APPEND stamp_files_per_config $<$:${stamp_file_conf}>) endforeach() diff --git a/cmake/Packaging.cmake b/cmake/Packaging.cmake index 006689549b..d716efb225 100644 --- a/cmake/Packaging.cmake +++ b/cmake/Packaging.cmake @@ -24,18 +24,23 @@ number will automatically appended as '/'. If LY_INSTALLER_AUTO_ full URL format will be: //" ) -set(LY_INSTALLER_UPLOAD_URL "" CACHE STRING -"Base URL used to upload the installer artifacts after generation, the host target and version number \ -will automatically appended as '/'. If LY_INSTALLER_AUTO_GEN_TAG is set, the full URL \ -format will be: //. Can also be set via LY_INSTALLER_UPLOAD_URL environment \ -variable. Currently only accepts S3 URLs e.g. s3:///" +set(CPACK_UPLOAD_URL "" CACHE STRING +"URL used to upload the installer artifacts after generation, the host target and version number \ +will automatically appended as '/'. If LY_INSTALLER_AUTO_GEN_TAG is set, the full URL \ +format will be: //. Currently only accepts S3 URLs e.g. s3:///" ) -set(LY_INSTALLER_AWS_PROFILE "" CACHE STRING -"AWS CLI profile for uploading artifacts. Can also be set via LY_INSTALLER_AWS_PROFILE environment variable." +set(CPACK_AWS_PROFILE "" CACHE STRING +"AWS CLI profile for uploading artifacts." ) +set(CPACK_THREADS 0) set(CPACK_DESIRED_CMAKE_VERSION 3.20.2) +if(${CPACK_DESIRED_CMAKE_VERSION} VERSION_LESS ${CMAKE_MINIMUM_REQUIRED_VERSION}) + message(FATAL_ERROR + "The desired version of CMake to be included in the package is " + "below the minimum required version of CMake to run") +endif() # set all common cpack variable overrides first so they can be accessible via configure_file # when the platform specific settings are applied below. additionally, any variable with @@ -44,15 +49,16 @@ set(CPACK_DESIRED_CMAKE_VERSION 3.20.2) set(CPACK_PACKAGE_NAME "${PROJECT_NAME}") set(CPACK_PACKAGE_FULL_NAME "Open3D Engine") set(CPACK_PACKAGE_VENDOR "O3DE Binary Project a Series of LF Projects, LLC") +set(CPACK_PACKAGE_CONTACT "info@o3debinaries.org") set(CPACK_PACKAGE_VERSION "${LY_VERSION_STRING}") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Installation Tool") string(TOLOWER "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}" CPACK_PACKAGE_FILE_NAME) set(DEFAULT_LICENSE_NAME "Apache-2.0") -set(DEFAULT_LICENSE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt") -set(CPACK_RESOURCE_FILE_LICENSE ${DEFAULT_LICENSE_FILE}) +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt") +set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md") set(CPACK_LICENSE_URL ${LY_INSTALLER_LICENSE_URL}) set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}/${CPACK_PACKAGE_VERSION}") @@ -60,6 +66,7 @@ set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}/${CPACK_PACKAGE_VERSI # neither of the SOURCE_DIR variables equate to anything during execution of pre/post build scripts set(CPACK_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/cmake) set(CPACK_BINARY_DIR ${CMAKE_BINARY_DIR}/_CPack) # to match other CPack out dirs +set(CPACK_OUTPUT_FILE_PREFIX CPackUploads) # this config file allows the dynamic setting of cpack variables at cpack-time instead of cmake configure set(CPACK_PROJECT_CONFIG_FILE ${CPACK_SOURCE_DIR}/PackagingConfig.cmake) @@ -74,97 +81,104 @@ if(NOT CPACK_GENERATOR) return() endif() -if(${CPACK_DESIRED_CMAKE_VERSION} VERSION_LESS ${CMAKE_MINIMUM_REQUIRED_VERSION}) - message(FATAL_ERROR - "The desired version of CMake to be included in the package is " - "below the minimum required version of CMake to run") -endif() - -# pull down the desired copy of CMake so it can be included in the package +# We will download the desired copy of CMake so it can be included in the package, we defer the downloading +# to the install process, to do so we generate a script that will perform the download and execute such script +# during the install process (before packaging) if(NOT (CPACK_CMAKE_PACKAGE_FILE AND CPACK_CMAKE_PACKAGE_HASH)) message(FATAL_ERROR "Packaging is missing one or more following properties required to include CMake: " " CPACK_CMAKE_PACKAGE_FILE, CPACK_CMAKE_PACKAGE_HASH") endif() -set(_cmake_package_dest ${CPACK_BINARY_DIR}/${CPACK_CMAKE_PACKAGE_FILE}) +# We download it to a different location because CPACK_PACKAGING_INSTALL_PREFIX will be removed during +# cpack generation. CPACK_BINARY_DIR persists across cpack invocations +set(LY_CMAKE_PACKAGE_DOWNLOAD_PATH ${CPACK_BINARY_DIR}/${CPACK_CMAKE_PACKAGE_FILE}) -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) +configure_file(${LY_ROOT_FOLDER}/cmake/Packaging/CMakeDownload.cmake.in + ${CPACK_BINARY_DIR}/CMakeDownload.cmake + @ONLY +) +ly_install(SCRIPT ${CPACK_BINARY_DIR}/CMakeDownload.cmake + COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} +) +ly_install(FILES ${LY_CMAKE_PACKAGE_DOWNLOAD_PATH} + DESTINATION Tools/Redistributables/CMake + COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} +) - set(_error_message "An error occurred, code ${_status_code}. URL ${_package_url} - ${_results}") +# Set common CPACK variables to all platforms/generators +set(CPACK_STRIP_FILES TRUE) # always strip symbols on packaging +set(CPACK_PACKAGE_CHECKSUM SHA256) # Generate checksum file +set(CPACK_PRE_BUILD_SCRIPTS ${pal_dir}/PackagingPreBuild_${PAL_HOST_PLATFORM_NAME_LOWERCASE}.cmake) +set(CPACK_POST_BUILD_SCRIPTS ${pal_dir}/PackagingPostBuild_${PAL_HOST_PLATFORM_NAME_LOWERCASE}.cmake) +set(CPACK_LY_PYTHON_CMD ${LY_PYTHON_CMD}) - 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() +# IMPORTANT: required to be included AFTER setting all property overrides +include(CPack REQUIRED) - message(FATAL_ERROR ${_error_message}) - endif() +# configure ALL components here +file(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" " +set(CPACK_COMPONENTS_ALL ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}) +set(CPACK_COMPONENT_${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}_DISPLAY_NAME \"Common files\") +set(CPACK_COMPONENT_${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}_DESCRIPTION \"${PROJECT_NAME} Headers, scripts and common files\") +set(CPACK_COMPONENT_${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}_REQUIRED TRUE) +set(CPACK_COMPONENT_${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}_DISABLED FALSE) + +include(CPackComponents.cmake) +") + +# Generate a file (CPackComponents.config) that we will include that defines the components +# for this build permutation. This way we can get components for other permutations being passed +# through LY_INSTALL_EXTERNAL_BUILD_DIRS +unset(cpack_components_contents) + +set(required "FALSE") +set(disabled "FALSE") +if(${LY_INSTALL_PERMUTATION_COMPONENT} STREQUAL DEFAULT) + set(required "TRUE") +else() + set(disabled "TRUE") endif() - -install(FILES ${_cmake_package_dest} - DESTINATION ./Tools/Redistributables/CMake -) - -# the version string and git tags are intended to be synchronized so it should be safe to use that instead -# of directly calling into git which could get messy in certain scenarios -if(${CPACK_PACKAGE_VERSION} VERSION_GREATER "0.0.0.0") - set(_3rd_party_license_filename NOTICES.txt) - - set(_3rd_party_license_url "https://raw.githubusercontent.com/o3de/3p-package-source/${CPACK_PACKAGE_VERSION}/${_3rd_party_license_filename}") - set(_3rd_party_license_dest ${CPACK_BINARY_DIR}/${_3rd_party_license_filename}) - - # use the plain file downloader as we don't have the file hash available and using a dummy will - # delete the file once it fails hash verification - file(DOWNLOAD - ${_3rd_party_license_url} - ${_3rd_party_license_dest} - STATUS _status - TLS_VERIFY ON - ) - list(POP_FRONT _status _status_code) - - if (${_status_code} EQUAL 0 AND EXISTS ${_3rd_party_license_dest}) - install(FILES ${_3rd_party_license_dest} - DESTINATION . - ) +string(APPEND cpack_components_contents " +list(APPEND CPACK_COMPONENTS_ALL ${LY_INSTALL_PERMUTATION_COMPONENT}) +set(CPACK_COMPONENT_${LY_INSTALL_PERMUTATION_COMPONENT}_DISPLAY_NAME \"${LY_BUILD_PERMUTATION} common files\") +set(CPACK_COMPONENT_${LY_INSTALL_PERMUTATION_COMPONENT}_DESCRIPTION \"${PROJECT_NAME} scripts and common files for ${LY_BUILD_PERMUTATION}\") +set(CPACK_COMPONENT_${LY_INSTALL_PERMUTATION_COMPONENT}_DEPENDS ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}) +set(CPACK_COMPONENT_${LY_INSTALL_PERMUTATION_COMPONENT}_REQUIRED ${required}) +set(CPACK_COMPONENT_${LY_INSTALL_PERMUTATION_COMPONENT}_DISABLED ${disabled}) +") + +foreach(conf IN LISTS CMAKE_CONFIGURATION_TYPES) + string(TOUPPER ${conf} UCONF) + set(required "FALSE") + set(disabled "FALSE") + if(${conf} STREQUAL profile AND ${LY_INSTALL_PERMUTATION_COMPONENT} STREQUAL DEFAULT) + set(required "TRUE") else() - file(REMOVE ${_3rd_party_license_dest}) - message(FATAL_ERROR "Failed to acquire the 3rd Party license manifest file at ${_3rd_party_license_url}. Error: ${_status}") + set(disabled "TRUE") endif() + + # Inject a check to not declare components that have not been built. We are using AzCore since that is a + # common target that will always be build, in every permutation and configuration + string(APPEND cpack_components_contents " +if(EXISTS \"${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${conf}/${CMAKE_STATIC_LIBRARY_PREFIX}AzCore${CMAKE_STATIC_LIBRARY_SUFFIX}\") + list(APPEND CPACK_COMPONENTS_ALL ${LY_INSTALL_PERMUTATION_COMPONENT}_${UCONF}) + set(CPACK_COMPONENT_${LY_INSTALL_PERMUTATION_COMPONENT}_${UCONF}_DISPLAY_NAME \"Binaries for ${LY_BUILD_PERMUTATION} ${conf}\") + set(CPACK_COMPONENT_${LY_INSTALL_PERMUTATION_COMPONENT}_${UCONF}_DESCRIPTION \"${PROJECT_NAME} libraries and applications for ${LY_BUILD_PERMUTATION} ${conf}\") + set(CPACK_COMPONENT_${LY_INSTALL_PERMUTATION_COMPONENT}_${UCONF}_DEPENDS ${LY_INSTALL_PERMUTATION_COMPONENT}) + set(CPACK_COMPONENT_${LY_INSTALL_PERMUTATION_COMPONENT}_${UCONF}_REQUIRED ${required}) + set(CPACK_COMPONENT_${LY_INSTALL_PERMUTATION_COMPONENT}_${UCONF}_DISABLED ${disabled}) endif() +") +endforeach() +file(WRITE "${CMAKE_BINARY_DIR}/CPackComponents.cmake" ${cpack_components_contents}) + +# Inject other build directories +foreach(external_dir ${LY_INSTALL_EXTERNAL_BUILD_DIRS}) + file(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" + "include(${external_dir}/CPackComponents.cmake)\n" + ) +endforeach() # checks for and removes trailing slash function(strip_trailing_slash in_url out_url) @@ -179,75 +193,13 @@ function(strip_trailing_slash in_url out_url) endif() endfunction() -if(NOT LY_INSTALLER_UPLOAD_URL AND DEFINED ENV{LY_INSTALLER_UPLOAD_URL}) - set(LY_INSTALLER_UPLOAD_URL $ENV{LY_INSTALLER_UPLOAD_URL}) -endif() - -if(LY_INSTALLER_UPLOAD_URL) - ly_is_s3_url(${LY_INSTALLER_UPLOAD_URL} _is_s3_bucket) - if(NOT _is_s3_bucket) - message(FATAL_ERROR "Only S3 installer uploading is supported at this time") - endif() - - if (LY_INSTALLER_AWS_PROFILE) - set(CPACK_AWS_PROFILE ${LY_INSTALLER_AWS_PROFILE}) - elseif (DEFINED ENV{LY_INSTALLER_AWS_PROFILE}) - set(CPACK_AWS_PROFILE $ENV{LY_INSTALLER_AWS_PROFILE}) - endif() - - strip_trailing_slash(${LY_INSTALLER_UPLOAD_URL} LY_INSTALLER_UPLOAD_URL) - set(CPACK_UPLOAD_URL ${LY_INSTALLER_UPLOAD_URL}) -endif() - -# IMPORTANT: required to be included AFTER setting all property overrides -include(CPack REQUIRED) - -function(ly_configure_cpack_component ly_configure_cpack_component_NAME) - - set(options REQUIRED) - set(oneValueArgs DISPLAY_NAME DESCRIPTION LICENSE_NAME LICENSE_FILE) - set(multiValueArgs) - - cmake_parse_arguments(ly_configure_cpack_component "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - # default to optional - set(component_type DISABLED) - - if(ly_configure_cpack_component_REQUIRED) - set(component_type REQUIRED) - endif() - - set(license_name ${DEFAULT_LICENSE_NAME}) - set(license_file ${DEFAULT_LICENSE_FILE}) - - if(ly_configure_cpack_component_LICENSE_NAME AND ly_configure_cpack_component_LICENSE_FILE) - set(license_name ${ly_configure_cpack_component_LICENSE_NAME}) - set(license_file ${ly_configure_cpack_component_LICENSE_FILE}) - elseif(ly_configure_cpack_component_LICENSE_NAME OR ly_configure_cpack_component_LICENSE_FILE) - message(FATAL_ERROR "Invalid argument configuration. Both LICENSE_NAME and LICENSE_FILE must be set for ly_configure_cpack_component") - endif() - - cpack_add_component( - ${ly_configure_cpack_component_NAME} ${component_type} - DISPLAY_NAME ${ly_configure_cpack_component_DISPLAY_NAME} - DESCRIPTION ${ly_configure_cpack_component_DESCRIPTION} - ) -endfunction() - -# configure ALL components here -ly_configure_cpack_component( - ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} REQUIRED - DISPLAY_NAME "${PROJECT_NAME} Core" - DESCRIPTION "${PROJECT_NAME} Headers, Libraries and Tools" -) - if(LY_INSTALLER_DOWNLOAD_URL) strip_trailing_slash(${LY_INSTALLER_DOWNLOAD_URL} LY_INSTALLER_DOWNLOAD_URL) # this will set the following variables: CPACK_DOWNLOAD_SITE, CPACK_DOWNLOAD_ALL, and CPACK_UPLOAD_DIRECTORY (local) cpack_configure_downloads( ${LY_INSTALLER_DOWNLOAD_URL} - UPLOAD_DIRECTORY ${CMAKE_BINARY_DIR}/_CPack_Uploads # to match the _CPack_Packages directory + UPLOAD_DIRECTORY ${CMAKE_BINARY_DIR}/CPackUploads # to match the _CPack_Packages directory ALL ) endif() diff --git a/cmake/Packaging/CMakeDownload.cmake.in b/cmake/Packaging/CMakeDownload.cmake.in new file mode 100644 index 0000000000..e84611b354 --- /dev/null +++ b/cmake/Packaging/CMakeDownload.cmake.in @@ -0,0 +1,54 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +set(LY_ROOT_FOLDER "@LY_ROOT_FOLDER@") +set(CMAKE_SCRIPT_MODE_FILE TRUE) +include(@LY_ROOT_FOLDER@/cmake/3rdPartyPackages.cmake) + +if(EXISTS "@LY_CMAKE_PACKAGE_DOWNLOAD_PATH@") + file(SHA256 "@LY_CMAKE_PACKAGE_DOWNLOAD_PATH@" hash_of_downloaded_file) + if (NOT "${hash_of_downloaded_file}" STREQUAL "@CPACK_CMAKE_PACKAGE_HASH@") + message(STATUS "CMake @CPACK_DESIRED_CMAKE_VERSION@ found at @LY_CMAKE_PACKAGE_DOWNLOAD_PATH@ but expected hash missmatches, re-downloading...") + file(REMOVE "@LY_CMAKE_PACKAGE_DOWNLOAD_PATH@") + else() + message(STATUS "CMake @CPACK_DESIRED_CMAKE_VERSION@ found") + endif() +endif() +if(NOT EXISTS "@LY_CMAKE_PACKAGE_DOWNLOAD_PATH@") + # download it + string(REPLACE "." ";" _version_components "@CPACK_DESIRED_CMAKE_VERSION@") + list(GET _version_components 0 _major_version) + list(GET _version_components 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 @LY_CMAKE_PACKAGE_DOWNLOAD_PATH@ + EXPECTED_HASH @CPACK_CMAKE_PACKAGE_HASH@ + RESULTS _results + ) + list(GET _results 0 _status_code) + + if (${_status_code} EQUAL 0 AND EXISTS "@LY_CMAKE_PACKAGE_DOWNLOAD_PATH@") + message(STATUS "CMake @CPACK_DESIRED_CMAKE_VERSION@ found") + else() + file(REMOVE "@LY_CMAKE_PACKAGE_DOWNLOAD_PATH@") + list(REMOVE_AT _results 0) + + 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() + message(FATAL_ERROR ${_error_message}) + endif() +endif() diff --git a/cmake/Platform/Common/Install_common.cmake b/cmake/Platform/Common/Install_common.cmake index f844b1bec9..46130f1345 100644 --- a/cmake/Platform/Common/Install_common.cmake +++ b/cmake/Platform/Common/Install_common.cmake @@ -8,6 +8,14 @@ include(cmake/FileUtil.cmake) +set(LY_INSTALL_EXTERNAL_BUILD_DIRS "" CACHE PATH "External build directories to be included in the install process. This allows to package non-monolithic and monolithic.") +unset(normalized_external_build_dirs) +foreach(external_dir ${LY_INSTALL_EXTERNAL_BUILD_DIRS}) + cmake_path(ABSOLUTE_PATH external_dir BASE_DIRECTORY ${LY_ROOT_FOLDER} NORMALIZE) + list(APPEND normalized_external_build_dirs ${external_dir}) +endforeach() +set(LY_INSTALL_EXTERNAL_BUILD_DIRS ${normalized_external_build_dirs}) + set(CMAKE_INSTALL_MESSAGE NEVER) # Simplify messages to reduce output noise define_property(TARGET PROPERTY LY_INSTALL_GENERATE_RUN_TARGET @@ -19,13 +27,25 @@ define_property(TARGET PROPERTY LY_INSTALL_GENERATE_RUN_TARGET ]] ) -ly_set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME Core) - +# We can have elements being installed under the following components: +# - Core (required for all) (default) +# - Default +# - Default_$ +# - Monolithic +# - Monolithic_$ +# Debug/Monolithic are build permutations, so for a CMake run, it can only generate +# one of the permutations. Each build permutation can generate only one cmake_install.cmake. +# Each build permutation will generate the same elements in Core. +# CPack is able to put the two together by taking Core from one permutation and then taking +# each permutation. + +ly_set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME CORE) if(LY_MONOLITHIC_GAME) set(LY_BUILD_PERMUTATION Monolithic) else() set(LY_BUILD_PERMUTATION Default) endif() +string(TOUPPER ${LY_BUILD_PERMUTATION} LY_INSTALL_PERMUTATION_COMPONENT) cmake_path(RELATIVE_PATH CMAKE_RUNTIME_OUTPUT_DIRECTORY BASE_DIRECTORY ${CMAKE_BINARY_DIR} OUTPUT_VARIABLE runtime_output_directory) cmake_path(RELATIVE_PATH CMAKE_LIBRARY_OUTPUT_DIRECTORY BASE_DIRECTORY ${CMAKE_BINARY_DIR} OUTPUT_VARIABLE library_output_directory) @@ -65,14 +85,24 @@ function(ly_setup_target OUTPUT_CONFIGURED_TARGET ALIAS_TARGET_NAME absolute_tar continue() endif() + # For some cases (e.g. codegen) we generate headers that end up in the BUILD_DIR. Since the BUILD_DIR + # is per-permutation, we need to install such headers per permutation. For the other cases, we can install + # under the default component since they are shared across permutations/configs. + cmake_path(IS_PREFIX CMAKE_BINARY_DIR ${include_directory} NORMALIZE include_directory_child_of_build) + if(NOT include_directory_child_of_build) + set(include_directory_component ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}) + else() + set(include_directory_component ${LY_INSTALL_PERMUTATION_COMPONENT}) + endif() + unset(rel_include_dir) cmake_path(RELATIVE_PATH include_directory BASE_DIRECTORY ${LY_ROOT_FOLDER} OUTPUT_VARIABLE rel_include_dir) cmake_path(APPEND rel_include_dir "..") cmake_path(NORMAL_PATH rel_include_dir OUTPUT_VARIABLE destination_dir) - - install(DIRECTORY ${include_directory} + + ly_install(DIRECTORY ${include_directory} DESTINATION ${destination_dir} - COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} + COMPONENT ${include_directory_component} FILES_MATCHING PATTERN *.h PATTERN *.hpp @@ -94,9 +124,9 @@ function(ly_setup_target OUTPUT_CONFIGURED_TARGET ALIAS_TARGET_NAME absolute_tar cmake_path(RELATIVE_PATH target_library_output_directory BASE_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} OUTPUT_VARIABLE target_library_output_subdirectory) endif() - if(COMMAND ly_install_target_override) + if(COMMAND ly_setup_target_install_targets_override) # Mac needs special handling because of a cmake issue - ly_install_target_override(TARGET ${TARGET_NAME} + ly_setup_target_install_targets_override(TARGET ${TARGET_NAME} ARCHIVE_DIR ${archive_output_directory} LIBRARY_DIR ${library_output_directory} RUNTIME_DIR ${runtime_output_directory} @@ -104,18 +134,23 @@ function(ly_setup_target OUTPUT_CONFIGURED_TARGET ALIAS_TARGET_NAME absolute_tar RUNTIME_SUBDIR ${target_runtime_output_subdirectory} ) else() - install( - TARGETS ${TARGET_NAME} - ARCHIVE - DESTINATION ${archive_output_directory} - COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} - LIBRARY - DESTINATION ${library_output_directory}/${target_library_output_subdirectory} - COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} - RUNTIME - DESTINATION ${runtime_output_directory}/${target_runtime_output_subdirectory} - COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} - ) + foreach(conf IN LISTS CMAKE_CONFIGURATION_TYPES) + string(TOUPPER ${conf} UCONF) + ly_install(TARGETS ${TARGET_NAME} + ARCHIVE + DESTINATION ${archive_output_directory} + COMPONENT ${LY_INSTALL_PERMUTATION_COMPONENT}_${UCONF} + CONFIGURATIONS ${conf} + LIBRARY + DESTINATION ${library_output_directory}/${target_library_output_subdirectory} + COMPONENT ${LY_INSTALL_PERMUTATION_COMPONENT}_${UCONF} + CONFIGURATIONS ${conf} + RUNTIME + DESTINATION ${runtime_output_directory}/${target_runtime_output_subdirectory} + COMPONENT ${LY_INSTALL_PERMUTATION_COMPONENT}_${UCONF} + CONFIGURATIONS ${conf} + ) + endforeach() endif() # CMakeLists.txt related files @@ -189,8 +224,14 @@ function(ly_setup_target OUTPUT_CONFIGURED_TARGET ALIAS_TARGET_NAME absolute_tar if("${target_type}" STREQUAL "STATIC_LIBRARY") set(build_deps_target "${build_deps_target};${build_deps_PRIVATE}") endif() - # But we will also pass the private dependencies as runtime dependencies (note the comment above) - set(RUNTIME_DEPENDENCIES_PLACEHOLDER ${build_deps_PRIVATE}) + + # But we will also pass the private dependencies as runtime dependencies (as long as they are targets, note the comment above) + foreach(build_dep_private IN LISTS build_deps_PRIVATE) + if(TARGET ${build_dep_private}) + list(APPEND RUNTIME_DEPENDENCIES_PLACEHOLDER "${build_dep_private}") + endif() + endforeach() + foreach(build_dependency IN LISTS build_deps_target) # Skip wrapping produced when targets are not created in the same directory if(build_dependency) @@ -280,10 +321,15 @@ set_property(TARGET ${NAME_PLACEHOLDER} set(target_install_source_dir ${CMAKE_CURRENT_BINARY_DIR}/install/${relative_target_source_dir}) file(GENERATE OUTPUT "${target_install_source_dir}/Platform/${PAL_PLATFORM_NAME}/${LY_BUILD_PERMUTATION}/${NAME_PLACEHOLDER}_$.cmake" CONTENT "${target_file_contents}") - install(FILES "${target_install_source_dir}/Platform/${PAL_PLATFORM_NAME}/${LY_BUILD_PERMUTATION}/${NAME_PLACEHOLDER}_$.cmake" - DESTINATION ${relative_target_source_dir}/Platform/${PAL_PLATFORM_NAME}/${LY_BUILD_PERMUTATION} - COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} - ) + + foreach(conf IN LISTS CMAKE_CONFIGURATION_TYPES) + string(TOUPPER ${conf} UCONF) + ly_install(FILES "${target_install_source_dir}/Platform/${PAL_PLATFORM_NAME}/${LY_BUILD_PERMUTATION}/${NAME_PLACEHOLDER}_${conf}.cmake" + DESTINATION ${relative_target_source_dir}/Platform/${PAL_PLATFORM_NAME}/${LY_BUILD_PERMUTATION} + COMPONENT ${LY_INSTALL_PERMUTATION_COMPONENT}_${UCONF} + CONFIGURATIONS ${conf} + ) + endforeach() # Since a CMakeLists.txt could contain multiple targets, we generate it in a folder per target ly_file_read(${LY_ROOT_FOLDER}/cmake/install/InstalledTarget.in target_cmakelists_template) @@ -323,7 +369,8 @@ function(ly_setup_subdirectory absolute_target_source_dir) @cmake_copyright_comment@ include(Platform/${PAL_PLATFORM_NAME}/platform_${PAL_PLATFORM_NAME_LOWERCASE}.cmake) ]] @ONLY) - install(FILES "${target_install_source_dir}/CMakeLists.txt" + + ly_install(FILES "${target_install_source_dir}/CMakeLists.txt" DESTINATION ${relative_target_source_dir} COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} ) @@ -338,7 +385,7 @@ else() include(Platform/${PAL_PLATFORM_NAME}/Default/permutation.cmake) endif() ]]) - install(FILES "${target_install_source_dir}/Platform/${PAL_PLATFORM_NAME}/platform_${PAL_PLATFORM_NAME_LOWERCASE}.cmake" + ly_install(FILES "${target_install_source_dir}/Platform/${PAL_PLATFORM_NAME}/platform_${PAL_PLATFORM_NAME_LOWERCASE}.cmake" DESTINATION ${relative_target_source_dir}/Platform/${PAL_PLATFORM_NAME} COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} ) @@ -358,9 +405,10 @@ endif() "${GEM_VARIANT_TO_LOAD_PLACEHOLDER}" "${ENABLE_GEMS_PLACEHOLDER}" ) - install(FILES "${target_install_source_dir}/Platform/${PAL_PLATFORM_NAME}/${LY_BUILD_PERMUTATION}/permutation.cmake" - DESTINATION ${relative_target_source_dir}//Platform/${PAL_PLATFORM_NAME}/${LY_BUILD_PERMUTATION} - COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} + + ly_install(FILES "${target_install_source_dir}/Platform/${PAL_PLATFORM_NAME}/${LY_BUILD_PERMUTATION}/permutation.cmake" + DESTINATION ${relative_target_source_dir}/Platform/${PAL_PLATFORM_NAME}/${LY_BUILD_PERMUTATION} + COMPONENT ${LY_INSTALL_PERMUTATION_COMPONENT} ) endfunction() @@ -368,7 +416,7 @@ endfunction() #! ly_setup_cmake_install: install the "cmake" folder function(ly_setup_cmake_install) - install(DIRECTORY "${LY_ROOT_FOLDER}/cmake" + ly_install(DIRECTORY "${LY_ROOT_FOLDER}/cmake" DESTINATION . COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} PATTERN "__pycache__" EXCLUDE @@ -378,22 +426,24 @@ function(ly_setup_cmake_install) ) # Connect configuration types - install(FILES "${LY_ROOT_FOLDER}/cmake/install/ConfigurationTypes.cmake" + ly_install(FILES "${LY_ROOT_FOLDER}/cmake/install/ConfigurationTypes.cmake" DESTINATION cmake COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} ) - # Inject code that will generate each ConfigurationType_.cmake file - set(install_configuration_type_template [=[ - configure_file(@LY_ROOT_FOLDER@/cmake/install/ConfigurationType_config.cmake.in - ${CMAKE_INSTALL_PREFIX}/cmake/Platform/@PAL_PLATFORM_NAME@/@LY_BUILD_PERMUTATION@/ConfigurationTypes_${CMAKE_INSTALL_CONFIG_NAME}.cmake + + # generate each ConfigurationType_.cmake file and install it under that configuration + foreach(conf IN LISTS CMAKE_CONFIGURATION_TYPES) + string(TOUPPER ${conf} UCONF) + configure_file("${LY_ROOT_FOLDER}/cmake/install/ConfigurationType_config.cmake.in" + "${CMAKE_BINARY_DIR}/cmake/Platform/${PAL_PLATFORM_NAME}/${LY_BUILD_PERMUTATION}/ConfigurationTypes_${conf}.cmake" @ONLY ) - message(STATUS "Generated ${CMAKE_INSTALL_PREFIX}/cmake/Platform/@PAL_PLATFORM_NAME@/@LY_BUILD_PERMUTATION@/ConfigurationTypes_${CMAKE_INSTALL_CONFIG_NAME}.cmake") - ]=]) - string(CONFIGURE "${install_configuration_type_template}" install_configuration_type @ONLY) - install(CODE "${install_configuration_type}" - COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} - ) + ly_install(FILES "${CMAKE_BINARY_DIR}/cmake/Platform/${PAL_PLATFORM_NAME}/${LY_BUILD_PERMUTATION}/ConfigurationTypes_${conf}.cmake" + DESTINATION cmake/Platform/${PAL_PLATFORM_NAME}/${LY_BUILD_PERMUTATION} + COMPONENT ${LY_INSTALL_PERMUTATION_COMPONENT}_${UCONF} + CONFIGURATIONS ${conf} + ) + endforeach() # Transform the LY_EXTERNAL_SUBDIRS list into a json array set(indent " ") @@ -412,8 +462,7 @@ function(ly_setup_cmake_install) configure_file(${LY_ROOT_FOLDER}/cmake/install/engine.json.in ${CMAKE_CURRENT_BINARY_DIR}/cmake/engine.json @ONLY) - install( - FILES + ly_install(FILES "${LY_ROOT_FOLDER}/CMakeLists.txt" "${CMAKE_CURRENT_BINARY_DIR}/cmake/engine.json" DESTINATION . @@ -437,18 +486,18 @@ function(ly_setup_cmake_install) endforeach() endforeach() - install(FILES ${additional_find_files} + ly_install(FILES ${additional_find_files} DESTINATION cmake/3rdParty COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} ) - install(FILES ${additional_platform_files} + ly_install(FILES ${additional_platform_files} DESTINATION cmake/3rdParty/Platform/${PAL_PLATFORM_NAME} COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} ) # Findo3de.cmake file: we generate a different Findo3de.cmake file than the one we have in the source dir. configure_file(${LY_ROOT_FOLDER}/cmake/install/Findo3de.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/cmake/Findo3de.cmake @ONLY) - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/Findo3de.cmake" + ly_install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/Findo3de.cmake" DESTINATION cmake COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} ) @@ -467,9 +516,9 @@ function(ly_setup_cmake_install) ${find_subdirectories} " ) - install(FILES "${permutation_find_subdirectories}" + ly_install(FILES "${permutation_find_subdirectories}" DESTINATION cmake/Platform/${PAL_PLATFORM_NAME}/${LY_BUILD_PERMUTATION} - COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} + COMPONENT ${LY_INSTALL_PERMUTATION_COMPONENT} ) set(pal_builtin_file ${CMAKE_CURRENT_BINARY_DIR}/cmake/3rdParty/Platform/${PAL_PLATFORM_NAME}/BuiltInPackages_${PAL_PLATFORM_NAME_LOWERCASE}.cmake) @@ -483,7 +532,7 @@ else() endif() " ) - install(FILES "${pal_builtin_file}" + ly_install(FILES "${pal_builtin_file}" DESTINATION cmake/3rdParty/Platform/${PAL_PLATFORM_NAME} COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} ) @@ -506,9 +555,9 @@ endif() file(GENERATE OUTPUT ${permutation_builtin_file} CONTENT ${builtinpackages} ) - install(FILES "${permutation_builtin_file}" + ly_install(FILES "${permutation_builtin_file}" DESTINATION cmake/3rdParty/Platform/${PAL_PLATFORM_NAME}/${LY_BUILD_PERMUTATION} - COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} + COMPONENT ${LY_INSTALL_PERMUTATION_COMPONENT} ) endfunction() @@ -517,15 +566,27 @@ endfunction() function(ly_setup_runtime_dependencies) # Common functions used by the bellow code - if(COMMAND ly_install_code_function_override) - ly_install_code_function_override() + if(COMMAND ly_setup_runtime_dependencies_copy_function_override) + ly_setup_runtime_dependencies_copy_function_override() else() - install(CODE + # despite this copy function being the same, we need to install it per component that uses it + # (which is per-configuration per-permutation component) + foreach(conf IN LISTS CMAKE_CONFIGURATION_TYPES) + string(TOUPPER ${conf} UCONF) + ly_install(CODE "function(ly_copy source_file target_directory) - file(COPY \"\${source_file}\" DESTINATION \"\${target_directory}\" FILE_PERMISSIONS ${LY_COPY_PERMISSIONS}) + cmake_path(GET source_file FILENAME target_filename) + cmake_path(APPEND full_target_directory \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}\" \"\${target_directory}\") + cmake_path(APPEND target_file \"\${full_target_directory}\" \"\${target_filename}\") + if(\"\${source_file}\" IS_NEWER_THAN \"\${target_file}\") + message(STATUS \"Copying \${source_file} to \${full_target_directory}...\") + file(COPY \"\${source_file}\" DESTINATION \"\${full_target_directory}\" FILE_PERMISSIONS ${LY_COPY_PERMISSIONS} FOLLOW_SYMLINK_CHAIN) + file(TOUCH_NOCREATE \"${target_file}\") + endif() endfunction()" - COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} - ) + COMPONENT ${LY_INSTALL_PERMUTATION_COMPONENT}_${UCONF} + ) + endforeach() endif() unset(runtime_commands) @@ -545,12 +606,7 @@ endfunction()" endif() # runtime dependencies that need to be copied to the output - # Anywhere CMAKE_INSTALL_PREFIX is used, it has to be escaped so it is baked into the cmake_install.cmake script instead - # of baking the path. This is needed so `cmake --install --prefix ` works regardless of the CMAKE_INSTALL_PREFIX - # used to generate the solution. - # CMAKE_INSTALL_PREFIX is still used when building the INSTALL target - set(install_output_folder "\${CMAKE_INSTALL_PREFIX}/${runtime_output_directory}") - set(target_file_dir "${install_output_folder}/${target_runtime_output_subdirectory}") + set(target_file_dir "${runtime_output_directory}/${target_runtime_output_subdirectory}") ly_get_runtime_dependencies(runtime_dependencies ${target}) foreach(runtime_dependency ${runtime_dependencies}) unset(runtime_command) @@ -564,9 +620,12 @@ endfunction()" list(REMOVE_DUPLICATES runtime_commands) list(JOIN runtime_commands " " runtime_commands_str) # the spaces are just to see the right identation in the cmake_install.cmake file - install(CODE "${runtime_commands_str}" - COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} - ) + foreach(conf IN LISTS CMAKE_CONFIGURATION_TYPES) + string(TOUPPER ${conf} UCONF) + ly_install(CODE "${runtime_commands_str}" + COMPONENT ${LY_INSTALL_PERMUTATION_COMPONENT}_${UCONF} + ) + endforeach() endfunction() @@ -653,16 +712,17 @@ function(ly_setup_assets) endif() if(IS_DIRECTORY ${gem_absolute_path}) - install(DIRECTORY "${gem_absolute_path}" + ly_install(DIRECTORY "${gem_absolute_path}" DESTINATION ${gem_install_dest_dir} COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} ) elseif (EXISTS ${gem_absolute_path}) - install(FILES ${gem_absolute_path} + ly_install(FILES ${gem_absolute_path} DESTINATION ${gem_install_dest_dir} COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} ) endif() + endforeach() endforeach() @@ -733,7 +793,7 @@ function(ly_setup_o3de_install) ly_setup_assets() # Misc - install(FILES + ly_install(FILES ${LY_ROOT_FOLDER}/pytest.ini ${LY_ROOT_FOLDER}/LICENSE.txt ${LY_ROOT_FOLDER}/README.md @@ -743,7 +803,7 @@ function(ly_setup_o3de_install) # Inject other build directories foreach(external_dir ${LY_INSTALL_EXTERNAL_BUILD_DIRS}) - install(CODE + ly_install(CODE "set(LY_CORE_COMPONENT_ALREADY_INCLUDED TRUE) include(${external_dir}/cmake_install.cmake) set(LY_CORE_COMPONENT_ALREADY_INCLUDED FALSE)" @@ -755,4 +815,4 @@ set(LY_CORE_COMPONENT_ALREADY_INCLUDED FALSE)" ly_post_install_steps() endif() -endfunction() \ No newline at end of file +endfunction() diff --git a/cmake/Platform/Common/PackagingPostBuild_common.cmake b/cmake/Platform/Common/PackagingPostBuild_common.cmake new file mode 100644 index 0000000000..6e3c7ddf0b --- /dev/null +++ b/cmake/Platform/Common/PackagingPostBuild_common.cmake @@ -0,0 +1,114 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +message(STATUS "Executing packaging postbuild...") + +# ly_is_s3_url +# if the given URL is a s3 url of thr form "s3://(stuff)" then sets +# the output_variable_name to TRUE otherwise unsets it. +function (ly_is_s3_url download_url output_variable_name) + if ("${download_url}" MATCHES "s3://.*") + set(${output_variable_name} TRUE PARENT_SCOPE) + else() + unset(${output_variable_name} PARENT_SCOPE) + endif() +endfunction() + +function(ly_upload_to_url in_url in_local_path in_file_regex) + + message(STATUS "Uploading ${in_local_path}/${in_file_regex} artifacts to ${CPACK_UPLOAD_URL}") + ly_is_s3_url(${in_url} _is_s3_bucket) + if(NOT _is_s3_bucket) + message(FATAL_ERROR "Only S3 installer uploading is supported at this time") + endif() + + # strip the scheme and extract the bucket/key prefix from the URL + string(REPLACE "s3://" "" _stripped_url ${in_url}) + string(REPLACE "/" ";" _tokens ${_stripped_url}) + + list(POP_FRONT _tokens _bucket) + string(JOIN "/" _prefix ${_tokens}) + + set(_extra_args [[{"ACL":"bucket-owner-full-control"}]]) + + file(TO_NATIVE_PATH "${LY_ROOT_FOLDER}/scripts/build/tools/upload_to_s3.py" _upload_script) + + set(_upload_command + ${CPACK_LY_PYTHON_CMD} -s + -u ${_upload_script} + --base_dir ${in_local_path} + --file_regex="${in_file_regex}" + --bucket ${_bucket} + --key_prefix ${_prefix} + --extra_args ${_extra_args} + ) + + if(CPACK_AWS_PROFILE) + list(APPEND _upload_command --profile ${CPACK_AWS_PROFILE}) + endif() + + execute_process( + COMMAND ${_upload_command} + RESULT_VARIABLE _upload_result + OUTPUT_VARIABLE _upload_output + ERROR_VARIABLE _upload_error + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + if (${_upload_result} EQUAL 0) + message(STATUS "Artifact uploading complete!") + else() + message(FATAL_ERROR "An error occurred uploading to s3.\n Output: ${_upload_output}\n\ Error: ${_upload_error}") + endif() +endfunction() + +function(ly_upload_to_latest in_url in_path) + + message(STATUS "Updating latest tagged build") + + # make sure we can extra the commit info from the URL first + string(REGEX MATCH "([0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]-[0-9a-zA-Z]+)" + commit_info ${in_url} + ) + if(NOT commit_info) + message(FATAL_ERROR "Failed to extract the build tag") + endif() + + # Create a temp directory where we are going to rename the file to take out the version + # and then upload it + set(temp_dir ${CPACK_BINARY_DIR}/temp) + if(NOT EXISTS ${temp_dir}) + file(MAKE_DIRECTORY ${temp_dir}) + endif() + file(COPY ${in_path} DESTINATION ${temp_dir}) + + cmake_path(GET in_path FILENAME in_path_filename) + string(REPLACE "_${CPACK_PACKAGE_VERSION}" "" non_versioned_in_path_filename ${in_path_filename}) + file(RENAME "${temp_dir}/${in_path_filename}" "${temp_dir}/${non_versioned_in_path_filename}") + + # include the commit info in a text file that will live next to the exe + set(_temp_info_file ${temp_dir}/build_tag.txt) + file(WRITE ${_temp_info_file} ${commit_info}) + + # update the URL and upload + string(REPLACE + ${commit_info} "Latest" + latest_upload_url ${in_url} + ) + + ly_upload_to_url( + ${latest_upload_url} + ${temp_dir} + ".*(${non_versioned_in_path_filename}|build_tag.txt)$" + ) + + # cleanup the temp files + file(REMOVE_RECURSE ${temp_dir}) + message(STATUS "Latest build update complete!") + +endfunction() \ No newline at end of file diff --git a/cmake/Platform/Common/PackagingPreBuild_common.cmake b/cmake/Platform/Common/PackagingPreBuild_common.cmake new file mode 100644 index 0000000000..e6b8a7796e --- /dev/null +++ b/cmake/Platform/Common/PackagingPreBuild_common.cmake @@ -0,0 +1,5 @@ +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# diff --git a/cmake/Platform/Common/RuntimeDependencies_common.cmake b/cmake/Platform/Common/RuntimeDependencies_common.cmake index 60e55453f8..a03f7f667b 100644 --- a/cmake/Platform/Common/RuntimeDependencies_common.cmake +++ b/cmake/Platform/Common/RuntimeDependencies_common.cmake @@ -272,7 +272,7 @@ function(ly_delayed_generate_runtime_dependencies) endforeach() # Generate the output file, note the STAMP_OUTPUT_FILE need to match with the one defined in LYWrappers.cmake - set(STAMP_OUTPUT_FILE ${CMAKE_BINARY_DIR}/runtime_dependencies/$/${target}_$.stamp) + set(STAMP_OUTPUT_FILE ${CMAKE_BINARY_DIR}/runtime_dependencies/$/${target}.stamp) set(target_file_dir "$") set(target_file "$") ly_file_read(${LY_RUNTIME_DEPENDENCIES_TEMPLATE} template_file) diff --git a/cmake/Platform/Common/runtime_dependencies_common.cmake.in b/cmake/Platform/Common/runtime_dependencies_common.cmake.in index 6e41dbaad1..8717710a3b 100644 --- a/cmake/Platform/Common/runtime_dependencies_common.cmake.in +++ b/cmake/Platform/Common/runtime_dependencies_common.cmake.in @@ -9,14 +9,22 @@ cmake_policy(SET CMP0012 NEW) # new policy for the if that evaluates a boolean out of "if(NOT ${same_location})" function(ly_copy source_file target_directory) - get_filename_component(target_filename "${source_file}" NAME) - cmake_path(COMPARE "${source_file}" EQUAL "${target_directory}/${target_filename}" same_location) + cmake_path(GET source_file FILENAME target_filename) + cmake_path(APPEND target_file "${target_directory}" "${target_filename}") + cmake_path(COMPARE "${source_file}" EQUAL "${target_file}" same_location) if(NOT ${same_location}) - file(LOCK ${target_directory}/${target_filename}.lock GUARD FUNCTION TIMEOUT 300) - if("${source_file}" IS_NEWER_THAN "${target_directory}/${target_filename}") + file(LOCK ${target_file}.lock GUARD FUNCTION TIMEOUT 300) + file(SIZE "${source_file}" source_file_size) + if(EXISTS "${target_file}") + file(SIZE "${target_file}" target_file_size) + else() + set(target_file_size 0) + endif() + if((NOT source_file_size EQUAL target_file_size) OR "${source_file}" IS_NEWER_THAN "${target_file}") message(STATUS "Copying \"${source_file}\" to \"${target_directory}\"...") + file(MAKE_DIRECTORY "${full_target_directory}") file(COPY "${source_file}" DESTINATION "${target_directory}" FILE_PERMISSIONS @LY_COPY_PERMISSIONS@ FOLLOW_SYMLINK_CHAIN) - file(TOUCH_NOCREATE ${target_directory}/${target_filename}) + file(TOUCH_NOCREATE ${target_file}) endif() endif() endfunction() diff --git a/cmake/Platform/Linux/CompilerSettings_linux.cmake b/cmake/Platform/Linux/CompilerSettings_linux.cmake new file mode 100644 index 0000000000..9bb629c53b --- /dev/null +++ b/cmake/Platform/Linux/CompilerSettings_linux.cmake @@ -0,0 +1,34 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +if(NOT CMAKE_C_COMPILER AND NOT CMAKE_CXX_COMPILER AND NOT "$ENV{CC}" AND NOT "$ENV{CXX}") + set(path_search + /bin + /usr/bin + /usr/local/bin + /sbin + /usr/sbin + /usr/local/sbin + ) + list(TRANSFORM path_search APPEND "/clang-[0-9]*") + file(GLOB clang_versions ${path_search}) + if(clang_versions) + # Find and pick the highest installed version + list(SORT clang_versions COMPARE NATURAL) + list(GET clang_versions 0 clang_higher_version_path) + string(REGEX MATCH "clang-([0-9.]*)" clang_higher_version ${clang_higher_version_path}) + if(CMAKE_MATCH_1) + set(CMAKE_C_COMPILER clang-${CMAKE_MATCH_1}) + set(CMAKE_CXX_COMPILER clang++-${CMAKE_MATCH_1}) + else() + message(FATAL_ERROR "Clang not found, please install clang") + endif() + else() + message(FATAL_ERROR "Clang not found, please install clang") + endif() +endif() diff --git a/cmake/Platform/Linux/Install_linux.cmake b/cmake/Platform/Linux/Install_linux.cmake index dea26e5872..0f5494131a 100644 --- a/cmake/Platform/Linux/Install_linux.cmake +++ b/cmake/Platform/Linux/Install_linux.cmake @@ -6,25 +6,41 @@ # # -#! ly_install_code_function_override: Linux-specific copy function to handle RPATH fixes +#! ly_setup_runtime_dependencies_copy_function_override: Linux-specific copy function to handle RPATH fixes set(ly_copy_template [[ function(ly_copy source_file target_directory) - file(COPY "${source_file}" DESTINATION "${target_directory}" FILE_PERMISSIONS @LY_COPY_PERMISSIONS@ FOLLOW_SYMLINK_CHAIN) - get_filename_component(target_filename_ext "${source_file}" LAST_EXT) - if("${source_file}" MATCHES "qt/plugins" AND "${target_filename_ext}" STREQUAL ".so") - get_filename_component(target_filename "${source_file}" NAME) - file(RPATH_CHANGE FILE "${target_directory}/${target_filename}" OLD_RPATH "\$ORIGIN/../../lib" NEW_RPATH "\$ORIGIN/..") - elseif("${source_file}" MATCHES "lrelease") - get_filename_component(target_filename "${source_file}" NAME) - file(RPATH_CHANGE FILE "${target_directory}/${target_filename}" OLD_RPATH "\$ORIGIN/../lib" NEW_RPATH "\$ORIGIN") + cmake_path(GET source_file FILENAME target_filename) + cmake_path(APPEND full_target_directory "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}" "${target_directory}") + cmake_path(APPEND target_file "${full_target_directory}" "${target_filename}") + if("${source_file}" IS_NEWER_THAN "${target_file}") + message(STATUS "Copying ${source_file} to ${full_target_directory}...") + file(MAKE_DIRECTORY "${full_target_directory}") + file(COPY "${source_file}" DESTINATION "${full_target_directory}" FILE_PERMISSIONS @LY_COPY_PERMISSIONS@ FOLLOW_SYMLINK_CHAIN) + file(TOUCH_NOCREATE "${target_file}") + + # Special case for install + cmake_PATH(GET source_file EXTENSION target_filename_ext) + if("${target_filename_ext}" STREQUAL ".so") + if("${source_file}" MATCHES "qt/plugins") + file(RPATH_CHANGE FILE "${target_file}" OLD_RPATH "\$ORIGIN/../../lib" NEW_RPATH "\$ORIGIN/..") + endif() + if(CMAKE_INSTALL_DO_STRIP) + execute_process(COMMAND @CMAKE_STRIP@ "${target_file}") + endif() + elseif("${source_file}" MATCHES "lrelease") + file(RPATH_CHANGE FILE "${target_file}" OLD_RPATH "\$ORIGIN/../lib" NEW_RPATH "\$ORIGIN") + endif() endif() endfunction()]]) -function(ly_install_code_function_override) +function(ly_setup_runtime_dependencies_copy_function_override) string(CONFIGURE "${ly_copy_template}" ly_copy_function_linux @ONLY) - install(CODE "${ly_copy_function_linux}" - COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} - ) + foreach(conf IN LISTS CMAKE_CONFIGURATION_TYPES) + string(TOUPPER ${conf} UCONF) + ly_install(CODE "${ly_copy_function_linux}" + COMPONENT ${LY_INSTALL_PERMUTATION_COMPONENT}_${UCONF} + ) + endforeach() endfunction() include(cmake/Platform/Common/Install_common.cmake) diff --git a/cmake/Platform/Linux/PAL_linux.cmake b/cmake/Platform/Linux/PAL_linux.cmake index e74adb287e..9383b8fcf6 100644 --- a/cmake/Platform/Linux/PAL_linux.cmake +++ b/cmake/Platform/Linux/PAL_linux.cmake @@ -16,7 +16,7 @@ ly_set(PAL_TRAIT_BUILD_TESTS_SUPPORTED TRUE) ly_set(PAL_TRAIT_BUILD_UNITY_SUPPORTED TRUE) ly_set(PAL_TRAIT_BUILD_UNITY_EXCLUDE_EXTENSIONS) ly_set(PAL_TRAIT_BUILD_EXCLUDE_ALL_TEST_RUNS_FROM_IDE FALSE) -ly_set(PAL_TRAIT_BUILD_CPACK_SUPPORTED FALSE) +ly_set(PAL_TRAIT_BUILD_CPACK_SUPPORTED TRUE) ly_set(PAL_TRAIT_PROF_PIX_SUPPORTED FALSE) diff --git a/cmake/Platform/Linux/Packaging/postinst.in b/cmake/Platform/Linux/Packaging/postinst.in new file mode 100644 index 0000000000..c6c0ba228d --- /dev/null +++ b/cmake/Platform/Linux/Packaging/postinst.in @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +set -o errexit # exit on the first failure encountered + +{ + if [[ ! -f "/usr/lib/x86_64-linux-gnu/libffi.so.6" ]]; then + sudo ln -s /usr/lib/x86_64-linux-gnu/libffi.so.7 /usr/lib/x86_64-linux-gnu/libffi.so.6 + fi + + pushd @CPACK_PACKAGING_INSTALL_PREFIX@ + python/get_python.sh + chown -R $SUDO_USER . + popd +} &> /dev/null # hide output diff --git a/cmake/Platform/Linux/Packaging/postrm.in b/cmake/Platform/Linux/Packaging/postrm.in new file mode 100644 index 0000000000..acda38bf1e --- /dev/null +++ b/cmake/Platform/Linux/Packaging/postrm.in @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +set -o errexit # exit on the first failure encountered + +{ + pushd @CPACK_PACKAGING_INSTALL_PREFIX@ + popd +} &> /dev/null # hide output diff --git a/cmake/Platform/Linux/Packaging/prerm.in b/cmake/Platform/Linux/Packaging/prerm.in new file mode 100644 index 0000000000..5595d7010f --- /dev/null +++ b/cmake/Platform/Linux/Packaging/prerm.in @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +set -o errexit # exit on the first failure encountered + +{ + # We dont remove this symlink that we potentially created because the user could have + # installed themselves. + #if [[ -L "/usr/lib/x86_64-linux-gnu/libffi.so.6" ]]; then + # sudo rm /usr/lib/x86_64-linux-gnu/libffi.so.6 + #fi + + pushd @CPACK_PACKAGING_INSTALL_PREFIX@ + # delete python downloads + rm -rf python/downloaded_packages python/runtime + popd +} &> /dev/null # hide output diff --git a/cmake/Platform/Linux/PackagingPostBuild_linux.cmake b/cmake/Platform/Linux/PackagingPostBuild_linux.cmake new file mode 100644 index 0000000000..d92ee908fd --- /dev/null +++ b/cmake/Platform/Linux/PackagingPostBuild_linux.cmake @@ -0,0 +1,62 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +file(REAL_PATH "${CPACK_SOURCE_DIR}/.." LY_ROOT_FOLDER) +include(${LY_ROOT_FOLDER}/cmake/Platform/Common/PackagingPostBuild_common.cmake) + +file(${CPACK_PACKAGE_CHECKSUM} ${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}.deb file_checksum) +file(WRITE ${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}.deb.sha256 "${file_checksum} ${CPACK_PACKAGE_FILE_NAME}.deb") + +if(CPACK_UPLOAD_URL) + + # use the internal default path if somehow not specified from cpack_configure_downloads + if(NOT CPACK_UPLOAD_DIRECTORY) + set(CPACK_UPLOAD_DIRECTORY ${CPACK_PACKAGE_DIRECTORY}/CPackUploads) + endif() + + # Copy the artifacts intended to be uploaded to a remote server into the folder specified + # through CPACK_UPLOAD_DIRECTORY. This mimics the same process cpack does natively for + # some other frameworks that have built-in online installer support. + message(STATUS "Copying packaging artifacts to upload directory...") + file(REMOVE_RECURSE ${CPACK_UPLOAD_DIRECTORY}) + file(GLOB _artifacts + "${CPACK_TOPLEVEL_DIRECTORY}/*.deb" + "${CPACK_TOPLEVEL_DIRECTORY}/*.sha256" + ) + file(COPY ${_artifacts} + DESTINATION ${CPACK_UPLOAD_DIRECTORY} + ) + message(STATUS "Artifacts copied to ${CPACK_UPLOAD_DIRECTORY}") + + # TODO: copy gpg file to CPACK_UPLOAD_DIRECTORY + + ly_upload_to_url( + ${CPACK_UPLOAD_URL} + ${CPACK_UPLOAD_DIRECTORY} + ".*(.deb|.gpg|.sha256)$" + ) + + # for auto tagged builds, we will also upload a second copy of just the boostrapper + # to a special "Latest" folder under the branch in place of the commit date/hash + if(CPACK_AUTO_GEN_TAG) + + set(latest_deb_package "${CPACK_UPLOAD_DIRECTORY}/${CPACK_PACKAGE_NAME}_latest.deb") + file(COPY_FILE + ${CPACK_UPLOAD_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}.deb + ${latest_deb_package} + ) + ly_upload_to_latest(${CPACK_UPLOAD_URL} ${latest_deb_package}) + + # TODO: upload gpg file to latest + + # Generate a checksum file for latest and upload it + set(latest_hash_file "${CPACK_UPLOAD_DIRECTORY}/${CPACK_PACKAGE_NAME}_latest.deb.sha256") + file(WRITE "${latest_hash_file}" "${file_checksum} ${CPACK_PACKAGE_NAME}_latest.deb") + ly_upload_to_latest(${CPACK_UPLOAD_URL} "${latest_hash_file}") + endif() +endif() diff --git a/cmake/Platform/Linux/PackagingPreBuild_linux.cmake b/cmake/Platform/Linux/PackagingPreBuild_linux.cmake new file mode 100644 index 0000000000..31dc393307 --- /dev/null +++ b/cmake/Platform/Linux/PackagingPreBuild_linux.cmake @@ -0,0 +1,16 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +file(REAL_PATH "${CPACK_SOURCE_DIR}/.." LY_ROOT_FOLDER) +include(${LY_ROOT_FOLDER}/cmake/Platform/Common/PackagingPreBuild_common.cmake) + +if(NOT CPACK_UPLOAD_URL) # Skip signing if we are not uploading the package + return() +endif() + +# TODO: do signing diff --git a/cmake/Platform/Linux/Packaging_linux.cmake b/cmake/Platform/Linux/Packaging_linux.cmake new file mode 100644 index 0000000000..2e178429c3 --- /dev/null +++ b/cmake/Platform/Linux/Packaging_linux.cmake @@ -0,0 +1,56 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +set(CPACK_GENERATOR DEB) + +set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/${CPACK_PACKAGE_NAME}/${LY_VERSION_STRING}") + +set(_cmake_package_name "cmake-${CPACK_DESIRED_CMAKE_VERSION}-linux-x86_64") +set(CPACK_CMAKE_PACKAGE_FILE "${_cmake_package_name}.tar.gz") +set(CPACK_CMAKE_PACKAGE_HASH "3f827544f9c82e74ddf5016461fdfcfea4ede58a26f82612f473bf6bfad8bfc2") + +# get all the package dependencies, extracted from scripts\build\build_node\Platform\Linux\package-list.ubuntu-focal.txt +set(package_dependencies + libffi7 + clang-12 + ninja-build + # Build Libraries + libglu1-mesa-dev # For Qt (GL dependency) + libxcb-xinerama0 # For Qt plugins at runtime + libxcb-xinput0 # For Qt plugins at runtime + libfontconfig1-dev # For Qt plugins at runtime + libcurl4-openssl-dev # For HttpRequestor + # libsdl2-dev # for WWise/Audio + libxcb-xkb-dev # For xcb keyboard input + libxkbcommon-x11-dev # For xcb keyboard input + libxkbcommon-dev # For xcb keyboard input + libxcb-xfixes0-dev # For mouse input + libxcb-xinput-dev # For mouse input + zlib1g-dev + mesa-common-dev +) +list(JOIN package_dependencies "," CPACK_DEBIAN_PACKAGE_DEPENDS) + +# Post-installation and pre/post removal scripts +configure_file("${LY_ROOT_FOLDER}/cmake/Platform/${PAL_PLATFORM_NAME}/Packaging/postinst.in" + "${CMAKE_BINARY_DIR}/cmake/Platform/${PAL_PLATFORM_NAME}/Packaging/postinst" + @ONLY +) +configure_file("${LY_ROOT_FOLDER}/cmake/Platform/${PAL_PLATFORM_NAME}/Packaging/prerm.in" + "${CMAKE_BINARY_DIR}/cmake/Platform/${PAL_PLATFORM_NAME}/Packaging/prerm" + @ONLY +) +configure_file("${LY_ROOT_FOLDER}/cmake/Platform/${PAL_PLATFORM_NAME}/Packaging/postrm.in" + "${CMAKE_BINARY_DIR}/cmake/Platform/${PAL_PLATFORM_NAME}/Packaging/postrm" + @ONLY +) +set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA + ${CMAKE_BINARY_DIR}/cmake/Platform/Linux/Packaging/postinst + ${CMAKE_BINARY_DIR}/cmake/Platform/Linux/Packaging/prerm + ${CMAKE_BINARY_DIR}/cmake/Platform/Linux/Packaging/postrm +) diff --git a/cmake/Platform/Linux/platform_linux_files.cmake b/cmake/Platform/Linux/platform_linux_files.cmake index fa5545cd26..d30959b8d2 100644 --- a/cmake/Platform/Linux/platform_linux_files.cmake +++ b/cmake/Platform/Linux/platform_linux_files.cmake @@ -10,11 +10,19 @@ set(FILES ../Common/Configurations_common.cmake ../Common/Clang/Configurations_clang.cmake ../Common/Install_common.cmake + ../Common/PackagingPostBuild_common.cmake + ../Common/PackagingPreBuild_common.cmake + CompilerSettings_linux.cmake Configurations_linux.cmake Install_linux.cmake LYTestWrappers_linux.cmake LYWrappers_linux.cmake + Packaging_linux.cmake + PackagingPostBuild_linux.cmake + PackagingPreBuild_linux.cmake PAL_linux.cmake PALDetection_linux.cmake RPathChange.cmake + runtime_dependencies_linux.cmake.in + RuntimeDependencies_linux.cmake ) diff --git a/cmake/Platform/Linux/runtime_dependencies_linux.cmake.in b/cmake/Platform/Linux/runtime_dependencies_linux.cmake.in index 394252e284..4ccf123e27 100644 --- a/cmake/Platform/Linux/runtime_dependencies_linux.cmake.in +++ b/cmake/Platform/Linux/runtime_dependencies_linux.cmake.in @@ -9,23 +9,33 @@ cmake_policy(SET CMP0012 NEW) # new policy for the if that evaluates a boolean out of "if(NOT ${same_location})" function(ly_copy source_file target_directory) - get_filename_component(target_filename "${source_file}" NAME) - get_filename_component(target_filename_ext "${source_file}" LAST_EXT) - cmake_path(COMPARE "${source_file}" EQUAL "${target_directory}/${target_filename}" same_location) + cmake_path(GET source_file FILENAME target_filename) + cmake_path(APPEND target_file "${target_directory}" "${target_filename}") + cmake_path(COMPARE "${source_file}" EQUAL "${target_file}" same_location) if(NOT ${same_location}) - file(LOCK ${target_directory}/${target_filename}.lock GUARD FUNCTION TIMEOUT 300) - if("${source_file}" IS_NEWER_THAN "${target_directory}/${target_filename}") + file(LOCK ${target_file}.lock GUARD FUNCTION TIMEOUT 300) + file(SIZE "${source_file}" source_file_size) + if(EXISTS "${target_file}") + file(SIZE "${target_file}" target_file_size) + else() + set(target_file_size 0) + endif() + if((NOT source_file_size EQUAL target_file_size) OR "${source_file}" IS_NEWER_THAN "${target_file}") + message(STATUS "Copying \"${source_file}\" to \"${target_directory}\"...") + file(MAKE_DIRECTORY "${full_target_directory}") file(COPY "${source_file}" DESTINATION "${target_directory}" FILE_PERMISSIONS @LY_COPY_PERMISSIONS@ FOLLOW_SYMLINK_CHAIN) - + file(TOUCH_NOCREATE "${target_file}") + # Special case, shared libraries that are copied from qt/plugins have their RPATH set to \$ORIGIN/../../lib # which is the correct relative path based on the source location. But when we copy it to their subfolder, # the rpath needs to be adjusted to the parent ($ORIGIN/..) if("${source_file}" MATCHES "qt/plugins" AND "${target_filename_ext}" STREQUAL ".so") - file(RPATH_CHANGE FILE "${target_directory}/${target_filename}" OLD_RPATH "\$ORIGIN/../../lib" NEW_RPATH "\$ORIGIN/..") + file(RPATH_CHANGE FILE "${target_file}" OLD_RPATH "\$ORIGIN/../../lib" NEW_RPATH "\$ORIGIN/..") endif() - endif() endif() endfunction() @LY_COPY_COMMANDS@ + +file(TOUCH @STAMP_OUTPUT_FILE@) diff --git a/cmake/Platform/Mac/InstallUtils_mac.cmake.in b/cmake/Platform/Mac/InstallUtils_mac.cmake.in index d73c4db459..89ce4a59f2 100644 --- a/cmake/Platform/Mac/InstallUtils_mac.cmake.in +++ b/cmake/Platform/Mac/InstallUtils_mac.cmake.in @@ -130,27 +130,36 @@ endfunction() function(ly_copy source_file target_directory) - if("${source_file}" MATCHES "\\.[Ff]ramework[^\\.]") + if("${source_file}" MATCHES "\\.[Ff]ramework") # fixup origin to copy the whole Framework folder string(REGEX REPLACE "(.*\\.[Ff]ramework).*" "\\1" source_file "${source_file}") endif() - get_filename_component(target_filename "${source_file}" NAME) - file(COPY "${source_file}" DESTINATION "${target_directory}" FILE_PERMISSIONS @LY_COPY_PERMISSIONS@ FOLLOW_SYMLINK_CHAIN) - - # Our Qt and Python frameworks aren't in the correct bundle format to be codesigned. - if("${target_filename}" MATCHES "(Qt[^.]+)\\.[Ff]ramework") - fixup_qt_framework(${CMAKE_MATCH_1} "${target_directory}/${target_filename}") - # For some Qt frameworks(QtCore), signing the bundle doesn't work because of bundle - # format issues(despite the fixes above). But once we've patched the framework above, there's - # only one executable that we need to sign so we can do it directly. - set(target_filename "${target_filename}/Versions/5/${CMAKE_MATCH_1}") - elseif("${target_filename}" MATCHES "Python.framework") - fixup_python_framework("${target_directory}/${target_filename}") - codesign_python_framework_binaries("${target_directory}/${target_filename}") + + cmake_path(GET source_file FILENAME target_filename) + cmake_path(APPEND full_target_directory "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}" "${target_directory}") + cmake_path(APPEND target_file "${full_target_directory}" "${target_filename}") + + if("${source_file}" IS_NEWER_THAN "${target_file}") + message(STATUS "Copying ${source_file} to ${full_target_directory}...") + file(MAKE_DIRECTORY "${full_target_directory}") + file(COPY "${source_file}" DESTINATION "${full_target_directory}" FILE_PERMISSIONS @LY_COPY_PERMISSIONS@ FOLLOW_SYMLINK_CHAIN) + file(TOUCH_NOCREATE "${target_file}") + + # Our Qt and Python frameworks aren't in the correct bundle format to be codesigned. + if("${target_filename}" MATCHES "(Qt[^.]+)\\.[Ff]ramework") + fixup_qt_framework(${CMAKE_MATCH_1} "${target_file}") + # For some Qt frameworks(QtCore), signing the bundle doesn't work because of bundle + # format issues(despite the fixes above). But once we've patched the framework above, there's + # only one executable that we need to sign so we can do it directly. + set(target_filename "${target_filename}/Versions/5/${CMAKE_MATCH_1}") + elseif("${target_filename}" MATCHES "Python.framework") + fixup_python_framework("${target_file}") + codesign_python_framework_binaries("${target_file}") + endif() + codesign_file("${target_file}" "none") endif() - codesign_file("${target_directory}/${target_filename}" "none") endfunction() diff --git a/cmake/Platform/Mac/Install_mac.cmake b/cmake/Platform/Mac/Install_mac.cmake index bdc2300131..d5ab5d0fed 100644 --- a/cmake/Platform/Mac/Install_mac.cmake +++ b/cmake/Platform/Mac/Install_mac.cmake @@ -39,10 +39,10 @@ file(GENERATE # This needs to be done here because it needs to update the install prefix # before cmake does anything else in the install process. configure_file(${LY_ROOT_FOLDER}/cmake/Platform/Mac/PreInstallSteps_mac.cmake.in ${CMAKE_BINARY_DIR}/runtime_install/PreInstallSteps_mac.cmake @ONLY) -install(SCRIPT ${CMAKE_BINARY_DIR}/runtime_install/PreInstallSteps_mac.cmake COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}) +ly_install(SCRIPT ${CMAKE_BINARY_DIR}/runtime_install/PreInstallSteps_mac.cmake COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}) -#! ly_install_target_override: Mac specific target installation -function(ly_install_target_override) +#! ly_setup_target_install_targets_override: Mac specific target installation +function(ly_setup_target_install_targets_override) set(options) set(oneValueArgs TARGET ARCHIVE_DIR LIBRARY_DIR RUNTIME_DIR LIBRARY_SUBDIR RUNTIME_SUBDIR) @@ -58,24 +58,31 @@ function(ly_install_target_override) set_property(TARGET ${ly_platform_install_target_TARGET} PROPERTY RESOURCE "") endif() - install( - TARGETS ${ly_platform_install_target_TARGET} - ARCHIVE - DESTINATION ${ly_platform_install_target_ARCHIVE_DIR} - COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} - LIBRARY - DESTINATION ${ly_platform_install_target_LIBRARY_DIR}/${ly_platform_install_target_LIBRARY_SUBDIR} - COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} - RUNTIME - DESTINATION ${ly_platform_install_target_RUNTIME_DIR}/${ly_platform_install_target_RUNTIME_SUBDIR} - COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} - BUNDLE - DESTINATION ${ly_platform_install_target_RUNTIME_DIR}/${ly_platform_install_target_RUNTIME_SUBDIR} - COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} - RESOURCE - DESTINATION ${ly_platform_install_target_RUNTIME_DIR}/${ly_platform_install_target_RUNTIME_SUBDIR} - COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} - ) + foreach(conf IN LISTS CMAKE_CONFIGURATION_TYPES) + string(TOUPPER ${conf} UCONF) + ly_install(TARGETS ${TARGET_NAME} + ARCHIVE + DESTINATION ${ly_platform_install_target_ARCHIVE_DIR} + COMPONENT ${LY_INSTALL_PERMUTATION_COMPONENT}_${UCONF} + CONFIGURATIONS ${conf} + LIBRARY + DESTINATION ${ly_platform_install_target_LIBRARY_DIR}/${ly_platform_install_target_LIBRARY_SUBDIR} + COMPONENT ${LY_INSTALL_PERMUTATION_COMPONENT}_${UCONF} + CONFIGURATIONS ${conf} + RUNTIME + DESTINATION ${ly_platform_install_target_RUNTIME_DIR}/${ly_platform_install_target_RUNTIME_SUBDIR} + COMPONENT ${LY_INSTALL_PERMUTATION_COMPONENT}_${UCONF} + CONFIGURATIONS ${conf} + BUNDLE + DESTINATION ${ly_platform_install_target_RUNTIME_DIR}/${ly_platform_install_target_RUNTIME_SUBDIR} + COMPONENT ${LY_INSTALL_PERMUTATION_COMPONENT}_${UCONF} + CONFIGURATIONS ${conf} + RESOURCE + DESTINATION ${ly_platform_install_target_RUNTIME_DIR}/${ly_platform_install_target_RUNTIME_SUBDIR} + COMPONENT ${LY_INSTALL_PERMUTATION_COMPONENT}_${UCONF} + CONFIGURATIONS ${conf} + ) + endforeach() set(install_relative_binaries_path "${ly_platform_install_target_RUNTIME_DIR}/${ly_platform_install_target_RUNTIME_SUBDIR}") @@ -102,11 +109,16 @@ function(ly_install_target_override) endif() endfunction() -#! ly_install_code_function_override: Mac specific copy function to handle frameworks -function(ly_install_code_function_override) +#! ly_setup_runtime_dependencies_copy_function_override: Mac specific copy function to handle frameworks +function(ly_setup_runtime_dependencies_copy_function_override) configure_file(${LY_ROOT_FOLDER}/cmake/Platform/Mac/InstallUtils_mac.cmake.in ${CMAKE_BINARY_DIR}/runtime_install/InstallUtils_mac.cmake @ONLY) - ly_install_run_script(${CMAKE_BINARY_DIR}/runtime_install/InstallUtils_mac.cmake) + foreach(conf IN LISTS CMAKE_CONFIGURATION_TYPES) + string(TOUPPER ${conf} UCONF) + ly_install(SCRIPT "${CMAKE_BINARY_DIR}/runtime_install/InstallUtils_mac.cmake" + COMPONENT ${LY_INSTALL_PERMUTATION_COMPONENT}_${UCONF} + ) + endforeach() endfunction() @@ -135,4 +147,3 @@ function(ly_post_install_steps) ") endfunction() - diff --git a/cmake/Platform/Mac/PackagingPostBuild_mac.cmake b/cmake/Platform/Mac/PackagingPostBuild_mac.cmake new file mode 100644 index 0000000000..5fa3787c21 --- /dev/null +++ b/cmake/Platform/Mac/PackagingPostBuild_mac.cmake @@ -0,0 +1,10 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +file(REAL_PATH "${CPACK_SOURCE_DIR}/.." LY_ROOT_FOLDER) +include(${LY_ROOT_FOLDER}/cmake/Platform/Common/PackagingPostBuild_common.cmake) diff --git a/cmake/Platform/Mac/PackagingPreBuild_mac.cmake b/cmake/Platform/Mac/PackagingPreBuild_mac.cmake new file mode 100644 index 0000000000..1d30e21767 --- /dev/null +++ b/cmake/Platform/Mac/PackagingPreBuild_mac.cmake @@ -0,0 +1,10 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +file(REAL_PATH "${CPACK_SOURCE_DIR}/.." LY_ROOT_FOLDER) +include(${LY_ROOT_FOLDER}/cmake/Platform/Common/PackagingPreBuild_common.cmake) diff --git a/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in b/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in index 11551f608f..892a90640f 100644 --- a/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in +++ b/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in @@ -34,7 +34,7 @@ endif() function(ly_copy source_file target_directory) - get_filename_component(target_filename "${source_file}" NAME) + cmake_path(GET source_file FILENAME target_filename) # If target_directory is a bundle if("${target_directory}" MATCHES "\\.app/Contents/MacOS") @@ -113,20 +113,37 @@ function(ly_copy source_file target_directory) endif() - cmake_path(COMPARE "${source_file}" EQUAL "${target_directory}/${target_filename}" same_location) + cmake_path(APPEND target_file "${target_directory}" "${target_filename}") + cmake_path(COMPARE "${source_file}" EQUAL "${target_file}" same_location) if(NOT ${same_location}) if(NOT EXISTS "${target_directory}") file(MAKE_DIRECTORY "${target_directory}") endif() - if(NOT EXISTS "${target_directory}/${target_filename}" OR "${source_file}" IS_NEWER_THAN "${target_directory}/${target_filename}") - message(STATUS "Copying \"${source_file}\" to \"${target_directory}\"...") - if(NOT target_is_bundle) - # if it is a bundle, there is no contention about the files in the destination, each bundle target will copy everything - # we dont want these files to invalidate the bundle and cause a new signature - file(LOCK ${target_directory}/${target_filename}.lock GUARD FUNCTION TIMEOUT 300) + + set(is_framework FALSE) + if("${source_file}" MATCHES "\\.[Ff]ramework") + set(is_framework TRUE) + endif() + if(NOT is_framework) + # if it is a bundle, there is no contention about the files in the destination, each bundle target will copy everything + # we dont want these files to invalidate the bundle and cause a new signature + file(LOCK ${target_file}.lock GUARD FUNCTION TIMEOUT 300) + file(SIZE "${source_file}" source_file_size) + if(EXISTS "${target_file}") + file(SIZE "${target_file}" target_file_size) + else() + set(target_file_size 0) endif() + else() + set(source_file_size 0) + set(target_file_size 0) + endif() + + if((NOT source_file_size EQUAL target_file_size) OR "${source_file}" IS_NEWER_THAN "${target_file}") + message(STATUS "Copying \"${source_file}\" to \"${target_directory}\"...") + file(MAKE_DIRECTORY "${target_directory}") file(COPY "${source_file}" DESTINATION "${target_directory}" FILE_PERMISSIONS @LY_COPY_PERMISSIONS@ FOLLOW_SYMLINK_CHAIN) - file(TOUCH_NOCREATE ${target_directory}/${target_filename}) + file(TOUCH_NOCREATE "${target_file}") set(anything_new TRUE PARENT_SCOPE) endif() endif() diff --git a/cmake/Platform/Windows/PackagingPostBuild.cmake b/cmake/Platform/Windows/PackagingPostBuild.cmake deleted file mode 100644 index 377a9fb221..0000000000 --- a/cmake/Platform/Windows/PackagingPostBuild.cmake +++ /dev/null @@ -1,237 +0,0 @@ -# -# Copyright (c) Contributors to the Open 3D Engine Project. -# For complete copyright and license terms please see the LICENSE at the root of this distribution. -# -# SPDX-License-Identifier: Apache-2.0 OR MIT -# -# - -# convert the path to a windows style path using string replace because TO_NATIVE_PATH -# only works on real paths -string(REPLACE "/" "\\" _fixed_package_install_dir ${CPACK_PACKAGE_INSTALL_DIRECTORY}) - -# directory where the auto generated files live e.g /_CPack_Package/win64/WIX -set(_cpack_wix_out_dir ${CPACK_TOPLEVEL_DIRECTORY}) -set(_bootstrap_out_dir "${CPACK_TOPLEVEL_DIRECTORY}/bootstrap") - -set(_bootstrap_filename "${CPACK_PACKAGE_FILE_NAME}_installer.exe") -set(_bootstrap_output_file ${_cpack_wix_out_dir}/${_bootstrap_filename}) - -set(_ext_flags - -ext WixBalExtension -) - -set(_addtional_defines - -dCPACK_BOOTSTRAP_THEME_FILE=${CPACK_BINARY_DIR}/BootstrapperTheme - -dCPACK_BOOTSTRAP_UPGRADE_GUID=${CPACK_WIX_BOOTSTRAP_UPGRADE_GUID} - -dCPACK_DOWNLOAD_SITE=${CPACK_DOWNLOAD_SITE} - -dCPACK_LOCAL_INSTALLER_DIR=${_cpack_wix_out_dir} - -dCPACK_PACKAGE_FILE_NAME=${CPACK_PACKAGE_FILE_NAME} - -dCPACK_PACKAGE_INSTALL_DIRECTORY=${_fixed_package_install_dir} - -dCPACK_WIX_PRODUCT_LOGO=${CPACK_WIX_PRODUCT_LOGO} - -dCPACK_RESOURCE_PATH=${CPACK_SOURCE_DIR}/Platform/Windows/Packaging -) - -file(REAL_PATH "${CPACK_SOURCE_DIR}/.." _root_path) -file(TO_NATIVE_PATH "${_root_path}/scripts/signer/Platform/Windows/signer.ps1" _sign_script) - -if(CPACK_LICENSE_URL) - list(APPEND _addtional_defines -dCPACK_LICENSE_URL=${CPACK_LICENSE_URL}) -endif() - -set(_candle_command - ${CPACK_WIX_CANDLE_EXECUTABLE} - -nologo - -arch x64 - "-I${_cpack_wix_out_dir}" # to include cpack_variables.wxi - ${_addtional_defines} - ${_ext_flags} - "${CPACK_SOURCE_DIR}/Platform/Windows/Packaging/Bootstrapper.wxs" - -o "${_bootstrap_out_dir}/" -) - -set(_light_command - ${CPACK_WIX_LIGHT_EXECUTABLE} - -nologo - ${_ext_flags} - ${_bootstrap_out_dir}/*.wixobj - -o "${_bootstrap_output_file}" -) - -set(_signing_command - psexec.exe - -accepteula - -nobanner - -s - powershell.exe - -NoLogo - -ExecutionPolicy Bypass - -File ${_sign_script} -) - -message(STATUS "Signing package files in ${_cpack_wix_out_dir}") -execute_process( - COMMAND ${_signing_command} -packagePath ${_cpack_wix_out_dir} - RESULT_VARIABLE _signing_result - ERROR_VARIABLE _signing_errors - OUTPUT_VARIABLE _signing_output - ECHO_OUTPUT_VARIABLE -) - -if(NOT ${_signing_result} EQUAL 0) - message(FATAL_ERROR "An error occurred during signing package files. ${_signing_errors}") -endif() - -message(STATUS "Creating Bootstrap Installer...") -execute_process( - COMMAND ${_candle_command} - RESULT_VARIABLE _candle_result - ERROR_VARIABLE _candle_errors -) -if(NOT ${_candle_result} EQUAL 0) - message(FATAL_ERROR "An error occurred invoking candle.exe. ${_candle_errors}") -endif() - -execute_process( - COMMAND ${_light_command} - RESULT_VARIABLE _light_result - ERROR_VARIABLE _light_errors -) -if(NOT ${_light_result} EQUAL 0) - message(FATAL_ERROR "An error occurred invoking light.exe. ${_light_errors}") -endif() - -file(COPY ${_bootstrap_output_file} - DESTINATION ${CPACK_PACKAGE_DIRECTORY} -) - -message(STATUS "Bootstrap installer generated to ${CPACK_PACKAGE_DIRECTORY}/${_bootstrap_filename}") - -message(STATUS "Signing bootstrap installer in ${CPACK_PACKAGE_DIRECTORY}") -execute_process( - COMMAND ${_signing_command} -bootstrapPath ${CPACK_PACKAGE_DIRECTORY}/${_bootstrap_filename} - RESULT_VARIABLE _signing_result - ERROR_VARIABLE _signing_errors - OUTPUT_VARIABLE _signing_output - ECHO_OUTPUT_VARIABLE -) - -if(NOT ${_signing_result} EQUAL 0) - message(FATAL_ERROR "An error occurred during signing bootstrap installer. ${_signing_errors}") -endif() - -# use the internal default path if somehow not specified from cpack_configure_downloads -if(NOT CPACK_UPLOAD_DIRECTORY) - set(CPACK_UPLOAD_DIRECTORY ${CPACK_PACKAGE_DIRECTORY}/CPackUploads) -endif() - -# copy the artifacts intended to be uploaded to a remote server into the folder specified -# through cpack_configure_downloads. this mimics the same process cpack does natively for -# some other frameworks that have built-in online installer support. -message(STATUS "Copying installer artifacts to upload directory...") -file(REMOVE_RECURSE ${CPACK_UPLOAD_DIRECTORY}) -file(GLOB _artifacts "${_cpack_wix_out_dir}/*.msi" "${_cpack_wix_out_dir}/*.cab") -file(COPY ${_artifacts} - DESTINATION ${CPACK_UPLOAD_DIRECTORY} -) -message(STATUS "Artifacts copied to ${CPACK_UPLOAD_DIRECTORY}") - -if(NOT CPACK_UPLOAD_URL) - return() -endif() - -file(TO_NATIVE_PATH "${_cpack_wix_out_dir}" _cpack_wix_out_dir) -file(TO_NATIVE_PATH "${_root_path}/python/python.cmd" _python_cmd) -file(TO_NATIVE_PATH "${_root_path}/scripts/build/tools/upload_to_s3.py" _upload_script) - -function(upload_to_s3 in_url in_local_path in_file_regex) - - # strip the scheme and extract the bucket/key prefix from the URL - string(REPLACE "s3://" "" _stripped_url ${in_url}) - string(REPLACE "/" ";" _tokens ${_stripped_url}) - - list(POP_FRONT _tokens _bucket) - string(JOIN "/" _prefix ${_tokens}) - - set(_extra_args [[{"ACL":"bucket-owner-full-control"}]]) - - set(_upload_command - ${_python_cmd} -s - -u ${_upload_script} - --base_dir ${in_local_path} - --file_regex="${in_file_regex}" - --bucket ${_bucket} - --key_prefix ${_prefix} - --extra_args ${_extra_args} - ) - - if(CPACK_AWS_PROFILE) - list(APPEND _upload_command --profile ${CPACK_AWS_PROFILE}) - endif() - - execute_process( - COMMAND ${_upload_command} - RESULT_VARIABLE _upload_result - OUTPUT_VARIABLE _upload_output - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - - if (NOT ${_upload_result} EQUAL 0) - message(FATAL_ERROR "An error occurred uploading to s3.\nOutput:\n${_upload_output}") - endif() -endfunction() - -message(STATUS "Uploading artifacts to ${CPACK_UPLOAD_URL}") -upload_to_s3( - ${CPACK_UPLOAD_URL} - ${_cpack_wix_out_dir} - ".*(cab|exe|msi)$" -) -message(STATUS "Artifact uploading complete!") - -# for auto tagged builds, we will also upload a second copy of just the boostrapper -# to a special "Latest" folder under the branch in place of the commit date/hash -if(CPACK_AUTO_GEN_TAG) - message(STATUS "Updating latest tagged build") - - # make sure we can extra the commit info from the URL first - string(REGEX MATCH "([0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]-[0-9a-zA-Z]+)" - _commit_info ${CPACK_UPLOAD_URL} - ) - if(NOT _commit_info) - message(FATAL_ERROR "Failed to extract the build tag") - endif() - - set(_temp_dir ${_cpack_wix_out_dir}/temp) - if(NOT EXISTS ${_temp_dir}) - file(MAKE_DIRECTORY ${_temp_dir}) - endif() - - # strip the version number form the exe name in the one uploaded to latest - string(TOLOWER "${CPACK_PACKAGE_NAME}_installer.exe" _non_versioned_exe) - set(_temp_exe_copy ${_temp_dir}/${_non_versioned_exe}) - - file(COPY ${_bootstrap_output_file} DESTINATION ${_temp_dir}) - file(RENAME "${_temp_dir}/${_bootstrap_filename}" ${_temp_exe_copy}) - - # include the commit info in a text file that will live next to the exe - set(_temp_info_file ${_temp_dir}/build_tag.txt) - file(WRITE ${_temp_info_file} ${_commit_info}) - - # update the URL and upload - string(REPLACE - ${_commit_info} "Latest" - _latest_upload_url ${CPACK_UPLOAD_URL} - ) - - upload_to_s3( - ${_latest_upload_url} - ${_temp_dir} - ".*(${_non_versioned_exe}|build_tag.txt)$" - ) - - # cleanup the temp files - file(REMOVE_RECURSE ${_temp_dir}) - - message(STATUS "Latest build update complete!") -endif() diff --git a/cmake/Platform/Windows/PackagingPostBuild_windows.cmake b/cmake/Platform/Windows/PackagingPostBuild_windows.cmake new file mode 100644 index 0000000000..0993135c23 --- /dev/null +++ b/cmake/Platform/Windows/PackagingPostBuild_windows.cmake @@ -0,0 +1,166 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +file(REAL_PATH "${CPACK_SOURCE_DIR}/.." LY_ROOT_FOLDER) +include(${LY_ROOT_FOLDER}/cmake/Platform/Common/PackagingPostBuild_common.cmake) + +# convert the path to a windows style path using string replace because TO_NATIVE_PATH +# only works on real paths +string(REPLACE "/" "\\" _fixed_package_install_dir ${CPACK_PACKAGE_INSTALL_DIRECTORY}) + +# directory where the auto generated files live e.g /_CPack_Package/win64/WIX +set(_cpack_wix_out_dir ${CPACK_TOPLEVEL_DIRECTORY}) +set(_bootstrap_out_dir "${CPACK_TOPLEVEL_DIRECTORY}/bootstrap") + +set(_bootstrap_filename "${CPACK_PACKAGE_FILE_NAME}_installer.exe") +set(_bootstrap_output_file ${_cpack_wix_out_dir}/${_bootstrap_filename}) + +set(_ext_flags + -ext WixBalExtension +) + +set(_addtional_defines + -dCPACK_BOOTSTRAP_THEME_FILE=${CPACK_BINARY_DIR}/BootstrapperTheme + -dCPACK_BOOTSTRAP_UPGRADE_GUID=${CPACK_WIX_BOOTSTRAP_UPGRADE_GUID} + -dCPACK_DOWNLOAD_SITE=${CPACK_DOWNLOAD_SITE} + -dCPACK_LOCAL_INSTALLER_DIR=${_cpack_wix_out_dir} + -dCPACK_PACKAGE_FILE_NAME=${CPACK_PACKAGE_FILE_NAME} + -dCPACK_PACKAGE_INSTALL_DIRECTORY=${_fixed_package_install_dir} + -dCPACK_WIX_PRODUCT_LOGO=${CPACK_WIX_PRODUCT_LOGO} + -dCPACK_RESOURCE_PATH=${CPACK_SOURCE_DIR}/Platform/Windows/Packaging +) + +if(CPACK_LICENSE_URL) + list(APPEND _addtional_defines -dCPACK_LICENSE_URL=${CPACK_LICENSE_URL}) +endif() + +set(_candle_command + ${CPACK_WIX_CANDLE_EXECUTABLE} + -nologo + -arch x64 + "-I${_cpack_wix_out_dir}" # to include cpack_variables.wxi + ${_addtional_defines} + ${_ext_flags} + "${CPACK_SOURCE_DIR}/Platform/Windows/Packaging/Bootstrapper.wxs" + -o "${_bootstrap_out_dir}/" +) + +set(_light_command + ${CPACK_WIX_LIGHT_EXECUTABLE} + -nologo + ${_ext_flags} + ${_bootstrap_out_dir}/*.wixobj + -o "${_bootstrap_output_file}" +) + +if(CPACK_UPLOAD_URL) # Skip signing if we are not uploading the package + file(TO_NATIVE_PATH "${LY_ROOT_FOLDER}/scripts/signer/Platform/Windows/signer.ps1" _sign_script) + + unset(_signing_command) + find_program(_psiexec_path psexec.exe) + if(_psiexec_path) + list(APPEND _signing_command + ${_psiexec_path} + -accepteula + -nobanner + -s + ) + endif() + + find_program(_powershell_path powershell.exe REQUIRED) + list(APPEND _signing_command + ${_powershell_path} + -NoLogo + -ExecutionPolicy Bypass + -File ${_sign_script} + ) + + message(STATUS "Signing package files in ${_cpack_wix_out_dir}") + execute_process( + COMMAND ${_signing_command} -packagePath ${_cpack_wix_out_dir} + RESULT_VARIABLE _signing_result + ERROR_VARIABLE _signing_errors + OUTPUT_VARIABLE _signing_output + ECHO_OUTPUT_VARIABLE + ) + + if(NOT ${_signing_result} EQUAL 0) + message(FATAL_ERROR "An error occurred during signing package files. ${_signing_errors}") + endif() +endif() + +message(STATUS "Creating Bootstrap Installer...") +execute_process( + COMMAND ${_candle_command} + RESULT_VARIABLE _candle_result + ERROR_VARIABLE _candle_errors +) +if(NOT ${_candle_result} EQUAL 0) + message(FATAL_ERROR "An error occurred invoking candle.exe. ${_candle_errors}") +endif() + +execute_process( + COMMAND ${_light_command} + RESULT_VARIABLE _light_result + ERROR_VARIABLE _light_errors +) +if(NOT ${_light_result} EQUAL 0) + message(FATAL_ERROR "An error occurred invoking light.exe. ${_light_errors}") +endif() + +message(STATUS "Bootstrap installer generated to ${_bootstrap_output_file}") + +if(CPACK_UPLOAD_URL) # Skip signing if we are not uploading the package + message(STATUS "Signing bootstrap installer in ${_bootstrap_output_file}") + execute_process( + COMMAND ${_signing_command} -bootstrapPath ${_bootstrap_output_file} + RESULT_VARIABLE _signing_result + ERROR_VARIABLE _signing_errors + OUTPUT_VARIABLE _signing_output + ECHO_OUTPUT_VARIABLE + ) + + if(NOT ${_signing_result} EQUAL 0) + message(FATAL_ERROR "An error occurred during signing bootstrap installer. ${_signing_errors}") + endif() +endif() + +# use the internal default path if somehow not specified from cpack_configure_downloads +if(NOT CPACK_UPLOAD_DIRECTORY) + set(CPACK_UPLOAD_DIRECTORY ${CPACK_PACKAGE_DIRECTORY}/CPackUploads) +endif() + +# Copy the artifacts intended to be uploaded to a remote server into the folder specified +# through CPACK_UPLOAD_DIRECTORY. This mimics the same process cpack does natively for +# some other frameworks that have built-in online installer support. +message(STATUS "Copying packaging artifacts to upload directory...") +file(REMOVE_RECURSE ${CPACK_UPLOAD_DIRECTORY}) +file(GLOB _artifacts + "${_cpack_wix_out_dir}/*.msi" + "${_cpack_wix_out_dir}/*.cab" + "${_cpack_wix_out_dir}/*.exe" +) +file(COPY ${_artifacts} + DESTINATION ${CPACK_UPLOAD_DIRECTORY} +) +message(STATUS "Artifacts copied to ${CPACK_UPLOAD_DIRECTORY}") + +if(CPACK_UPLOAD_URL) + file(TO_NATIVE_PATH "${_cpack_wix_out_dir}" _cpack_wix_out_dir) + ly_upload_to_url( + ${CPACK_UPLOAD_URL} + ${_cpack_wix_out_dir} + ".*(cab|exe|msi)$" + ) + + # for auto tagged builds, we will also upload a second copy of just the boostrapper + # to a special "Latest" folder under the branch in place of the commit date/hash + if(CPACK_AUTO_GEN_TAG) + ly_upload_to_latest(${CPACK_UPLOAD_URL} ${_bootstrap_output_file}) + endif() +endif() diff --git a/cmake/Platform/Windows/PackagingPreBuild.cmake b/cmake/Platform/Windows/PackagingPreBuild.cmake deleted file mode 100644 index d3924c7a02..0000000000 --- a/cmake/Platform/Windows/PackagingPreBuild.cmake +++ /dev/null @@ -1,37 +0,0 @@ -# -# Copyright (c) Contributors to the Open 3D Engine Project. -# For complete copyright and license terms please see the LICENSE at the root of this distribution. -# -# SPDX-License-Identifier: Apache-2.0 OR MIT -# -# - -file(REAL_PATH "${CPACK_SOURCE_DIR}/.." _root_path) -set(_cpack_wix_out_dir ${CPACK_TOPLEVEL_DIRECTORY}) -file(TO_NATIVE_PATH "${_root_path}/scripts/signer/Platform/Windows/signer.ps1" _sign_script) - -set(_signing_command - psexec.exe - -accepteula - -nobanner - -s - powershell.exe - -NoLogo - -ExecutionPolicy Bypass - -File ${_sign_script} -) - -message(STATUS "Signing executable files in ${_cpack_wix_out_dir}") -execute_process( - COMMAND ${_signing_command} -exePath ${_cpack_wix_out_dir} - RESULT_VARIABLE _signing_result - ERROR_VARIABLE _signing_errors - OUTPUT_VARIABLE _signing_output - ECHO_OUTPUT_VARIABLE -) - -if(NOT ${_signing_result} EQUAL 0) - message(FATAL_ERROR "An error occurred during signing executable files. ${_signing_errors}") -endif() - -message(STATUS "Signing exes complete!") diff --git a/cmake/Platform/Windows/PackagingPreBuild_windows.cmake b/cmake/Platform/Windows/PackagingPreBuild_windows.cmake new file mode 100644 index 0000000000..29995518da --- /dev/null +++ b/cmake/Platform/Windows/PackagingPreBuild_windows.cmake @@ -0,0 +1,60 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +file(REAL_PATH "${CPACK_SOURCE_DIR}/.." LY_ROOT_FOLDER) +include(${LY_ROOT_FOLDER}/cmake/Platform/Common/PackagingPreBuild_common.cmake) + +if(NOT CPACK_UPLOAD_URL) # Skip signing if we are not uploading the package + return() +endif() + +file(REAL_PATH "${CPACK_SOURCE_DIR}/.." _root_path) +set(_cpack_wix_out_dir ${CPACK_TOPLEVEL_DIRECTORY}) +file(TO_NATIVE_PATH "${_root_path}/scripts/signer/Platform/Windows/signer.ps1" _sign_script) + +unset(_signing_command) +find_program(_psiexec_path psexec.exe) +if(_psiexec_path) + list(APPEND _signing_command + ${_psiexec_path} + -accepteula + -nobanner + -s + ) +endif() + +find_program(_powershell_path powershell.exe REQUIRED) +list(APPEND _signing_command + ${_powershell_path} + -NoLogo + -ExecutionPolicy Bypass + -File ${_sign_script} +) + +# This requires to have a valid local certificate. In continuous integration, these certificates are stored +# in the machine directly. +# You can generate a test certificate to be able to run this in a PowerShell elevated promp with: +# New-SelfSignedCertificate -DnsName foo.o3de.com -Type CodeSigning -CertStoreLocation Cert:\CurrentUser\My +# Export-Certificate -Cert (Get-ChildItem Cert:\CurrentUser\My\) -Filepath "c:\selfsigned.crt" +# Import-Certificate -FilePath "c:\selfsigned.crt" -Cert Cert:\CurrentUser\TrustedPublisher +# Import-Certificate -FilePath "c:\selfsigned.crt" -Cert Cert:\CurrentUser\Root + +message(STATUS "Signing executable files in ${_cpack_wix_out_dir}") +execute_process( + COMMAND ${_signing_command} -exePath ${_cpack_wix_out_dir} + RESULT_VARIABLE _signing_result + ERROR_VARIABLE _signing_errors + OUTPUT_VARIABLE _signing_output + ECHO_OUTPUT_VARIABLE +) + +if(NOT ${_signing_result} EQUAL 0) + message(FATAL_ERROR "An error occurred during signing executable files. ${_signing_errors}") +else() + message(STATUS "Signing exes complete!") +endif() diff --git a/cmake/Platform/Windows/Packaging_windows.cmake b/cmake/Platform/Windows/Packaging_windows.cmake index 4a03df2fd2..f24e9dee1c 100644 --- a/cmake/Platform/Windows/Packaging_windows.cmake +++ b/cmake/Platform/Windows/Packaging_windows.cmake @@ -23,16 +23,12 @@ 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") -# workaround for shortening the path cpack installs to by stripping the platform directory and forcing monolithic -# mode to strip out component folders. this unfortunately is the closest we can get to changing the install location -# as CPACK_PACKAGING_INSTALL_PREFIX/CPACK_SET_DESTDIR isn't supported for the WiX generator +# workaround for shortening the path cpack installs to by stripping the platform directory set(CPACK_TOPLEVEL_TAG "") -set(CPACK_MONOLITHIC_INSTALL ON) # CPack will generate the WiX product/upgrade GUIDs further down the chain if they weren't supplied # however, they are unique for each run. instead, let's do the auto generation here and add it to @@ -108,44 +104,34 @@ set(_raw_text_license [[ #(loc.InstallEulaAcceptance) ]]) -if(LY_INSTALLER_DOWNLOAD_URL) - set(WIX_THEME_WARNING_IMAGE ${CPACK_SOURCE_DIR}/Platform/Windows/Packaging/warning.png) +set(WIX_THEME_WARNING_IMAGE ${CPACK_SOURCE_DIR}/Platform/Windows/Packaging/warning.png) - if(LY_INSTALLER_LICENSE_URL) - set(WIX_THEME_INSTALL_LICENSE_ELEMENTS ${_hyperlink_license}) - set(WIX_THEME_EULA_ACCEPTANCE_TEXT "<a href=\"#\">Terms of Use</a>") - else() - set(WIX_THEME_INSTALL_LICENSE_ELEMENTS ${_raw_text_license}) - set(WIX_THEME_EULA_ACCEPTANCE_TEXT "Terms of Use above") - endif() - - # theme ux file - configure_file( - "${CPACK_SOURCE_DIR}/Platform/Windows/Packaging/BootstrapperTheme.xml.in" - "${CPACK_BINARY_DIR}/BootstrapperTheme.xml" - @ONLY - ) - - # theme localization file - configure_file( - "${CPACK_SOURCE_DIR}/Platform/Windows/Packaging/BootstrapperTheme.wxl.in" - "${CPACK_BINARY_DIR}/BootstrapperTheme.wxl" - @ONLY - ) +if(LY_INSTALLER_LICENSE_URL) + set(WIX_THEME_INSTALL_LICENSE_ELEMENTS ${_hyperlink_license}) + set(WIX_THEME_EULA_ACCEPTANCE_TEXT "<a href=\"#\">Terms of Use</a>") +else() + set(WIX_THEME_INSTALL_LICENSE_ELEMENTS ${_raw_text_license}) + set(WIX_THEME_EULA_ACCEPTANCE_TEXT "Terms of Use above") +endif() - set(_embed_artifacts "no") +# theme ux file +configure_file( + "${CPACK_SOURCE_DIR}/Platform/Windows/Packaging/BootstrapperTheme.xml.in" + "${CPACK_BINARY_DIR}/BootstrapperTheme.xml" + @ONLY +) - # the bootstrapper will at the very least need a different upgrade guid - generate_wix_guid(CPACK_WIX_BOOTSTRAP_UPGRADE_GUID "${_guid_seed_base}_Bootstrap_UpgradeCode") +# theme localization file +configure_file( + "${CPACK_SOURCE_DIR}/Platform/Windows/Packaging/BootstrapperTheme.wxl.in" + "${CPACK_BINARY_DIR}/BootstrapperTheme.wxl" + @ONLY +) - set(CPACK_PRE_BUILD_SCRIPTS - ${CPACK_SOURCE_DIR}/Platform/Windows/PackagingPreBuild.cmake - ) +set(_embed_artifacts "no") - set(CPACK_POST_BUILD_SCRIPTS - ${CPACK_SOURCE_DIR}/Platform/Windows/PackagingPostBuild.cmake - ) -endif() +# the bootstrapper will at the very least need a different upgrade guid +generate_wix_guid(CPACK_WIX_BOOTSTRAP_UPGRADE_GUID "${_guid_seed_base}_Bootstrap_UpgradeCode") set(CPACK_WIX_CANDLE_EXTRA_FLAGS -dCPACK_EMBED_ARTIFACTS=${_embed_artifacts} diff --git a/cmake/Platform/Windows/platform_windows_files.cmake b/cmake/Platform/Windows/platform_windows_files.cmake index fcc47ab6eb..984d985380 100644 --- a/cmake/Platform/Windows/platform_windows_files.cmake +++ b/cmake/Platform/Windows/platform_windows_files.cmake @@ -15,6 +15,8 @@ set(FILES ../Common/MSVC/VisualStudio_common.cmake ../Common/Install_common.cmake ../Common/LYWrappers_default.cmake + ../Common/PackagingPostBuild_common.cmake + ../Common/PackagingPreBuild_common.cmake ../Common/TargetIncludeSystemDirectories_unsupported.cmake Configurations_windows.cmake LYTestWrappers_windows.cmake @@ -23,7 +25,8 @@ set(FILES PALDetection_windows.cmake Install_windows.cmake Packaging_windows.cmake - PackagingPostBuild.cmake + PackagingPostBuild_windows.cmake + PackagingPreBuild_windows.cmake Packaging/Bootstrapper.wxs Packaging/BootstrapperTheme.wxl.in Packaging/BootstrapperTheme.xml.in diff --git a/cmake/Version.cmake b/cmake/Version.cmake index 662e75c3db..de93ebefef 100644 --- a/cmake/Version.cmake +++ b/cmake/Version.cmake @@ -11,3 +11,8 @@ set(LY_VERSION_COPYRIGHT_YEAR ${current_year} CACHE STRING "Open 3D Engine's cop set(LY_VERSION_STRING "0.0.0.0" CACHE STRING "Open 3D Engine's version") set(LY_VERSION_BUILD_NUMBER 0 CACHE STRING "Open 3D Engine's build number") set(LY_VERSION_ENGINE_NAME "o3de" CACHE STRING "Open 3D Engine's engine name") + +if("$ENV{O3DE_VERSION}") + # Overriding through environment + set(LY_VERSION_STRING "$ENV{O3DE_VERSION}") +endif() diff --git a/cmake/install/ConfigurationType_config.cmake.in b/cmake/install/ConfigurationType_config.cmake.in index 074e034899..0a6940d7ff 100644 --- a/cmake/install/ConfigurationType_config.cmake.in +++ b/cmake/install/ConfigurationType_config.cmake.in @@ -8,4 +8,4 @@ include_guard(GLOBAL) -list(APPEND CMAKE_CONFIGURATION_TYPES @CMAKE_INSTALL_CONFIG_NAME@) +list(APPEND CMAKE_CONFIGURATION_TYPES @conf@) diff --git a/scripts/build/Platform/Android/build_config.json b/scripts/build/Platform/Android/build_config.json index c1fbb1dd87..5e2da44a3c 100644 --- a/scripts/build/Platform/Android/build_config.json +++ b/scripts/build/Platform/Android/build_config.json @@ -35,7 +35,7 @@ "PARAMETERS": { "CONFIGURATION":"debug", "OUTPUT_DIRECTORY":"build\\android", - "CMAKE_OPTIONS":"-G \"Ninja Multi-Config\" -DCMAKE_TOOLCHAIN_FILE=cmake\\Platform\\Android\\Toolchain_android.cmake -DANDROID_ABI=arm64-v8a -DANDROID_ARM_MODE=arm -DANDROID_ARM_NEON=FALSE -DANDROID_NATIVE_API_LEVEL=21 -DLY_NDK_DIR=\"!LY_3RDPARTY_PATH!\\android-ndk\\r21d\" -DLY_UNITY_BUILD=TRUE", + "CMAKE_OPTIONS":"-G \"Ninja Multi-Config\" -DCMAKE_TOOLCHAIN_FILE=cmake\\Platform\\Android\\Toolchain_android.cmake -DANDROID_ABI=arm64-v8a -DANDROID_ARM_MODE=arm -DANDROID_ARM_NEON=FALSE -DANDROID_NATIVE_API_LEVEL=21 -DLY_NDK_DIR=\"!LY_3RDPARTY_PATH!\\android-ndk\\r21d\"", "CMAKE_LY_PROJECTS":"AutomatedTesting", "CMAKE_TARGET":"all", "CMAKE_BUILD_ARGS":"-j!NUMBER_OF_PROCESSORS!" @@ -60,7 +60,7 @@ "PARAMETERS": { "CONFIGURATION":"profile", "OUTPUT_DIRECTORY":"build\\android", - "CMAKE_OPTIONS":"-G \"Ninja Multi-Config\" -DCMAKE_TOOLCHAIN_FILE=cmake\\Platform\\Android\\Toolchain_android.cmake -DANDROID_ABI=arm64-v8a -DANDROID_ARM_MODE=arm -DANDROID_ARM_NEON=FALSE -DANDROID_NATIVE_API_LEVEL=21 -DLY_NDK_DIR=\"!LY_3RDPARTY_PATH!\\android-ndk\\r21d\" -DLY_UNITY_BUILD=TRUE", + "CMAKE_OPTIONS":"-G \"Ninja Multi-Config\" -DCMAKE_TOOLCHAIN_FILE=cmake\\Platform\\Android\\Toolchain_android.cmake -DANDROID_ABI=arm64-v8a -DANDROID_ARM_MODE=arm -DANDROID_ARM_NEON=FALSE -DANDROID_NATIVE_API_LEVEL=21 -DLY_NDK_DIR=\"!LY_3RDPARTY_PATH!\\android-ndk\\r21d\"", "CMAKE_LY_PROJECTS":"AutomatedTesting", "CMAKE_TARGET":"all", "CMAKE_BUILD_ARGS":"-j!NUMBER_OF_PROCESSORS!" @@ -93,7 +93,7 @@ "PARAMETERS": { "CONFIGURATION":"profile", "OUTPUT_DIRECTORY":"build\\windows_vs2019", - "CMAKE_OPTIONS":"-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0 -DLY_UNITY_BUILD=TRUE", + "CMAKE_OPTIONS":"-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0", "CMAKE_LY_PROJECTS":"AutomatedTesting", "CMAKE_TARGET":"AssetProcessorBatch", "CMAKE_NATIVE_BUILD_ARGS": "/m /nologo", @@ -112,7 +112,7 @@ "PARAMETERS": { "CONFIGURATION":"release", "OUTPUT_DIRECTORY":"build\\android", - "CMAKE_OPTIONS":"-G \"Ninja Multi-Config\" -DCMAKE_TOOLCHAIN_FILE=cmake\\Platform\\Android\\Toolchain_android.cmake -DANDROID_ABI=arm64-v8a -DANDROID_ARM_MODE=arm -DANDROID_ARM_NEON=FALSE -DANDROID_NATIVE_API_LEVEL=21 -DLY_NDK_DIR=\"!LY_3RDPARTY_PATH!\\android-ndk\\r21d\" -DLY_UNITY_BUILD=TRUE", + "CMAKE_OPTIONS":"-G \"Ninja Multi-Config\" -DCMAKE_TOOLCHAIN_FILE=cmake\\Platform\\Android\\Toolchain_android.cmake -DANDROID_ABI=arm64-v8a -DANDROID_ARM_MODE=arm -DANDROID_ARM_NEON=FALSE -DANDROID_NATIVE_API_LEVEL=21 -DLY_NDK_DIR=\"!LY_3RDPARTY_PATH!\\android-ndk\\r21d\"", "CMAKE_LY_PROJECTS":"AutomatedTesting", "CMAKE_TARGET":"all", "CMAKE_BUILD_ARGS":"-j!NUMBER_OF_PROCESSORS!" @@ -128,7 +128,7 @@ "PARAMETERS": { "CONFIGURATION":"release", "OUTPUT_DIRECTORY":"build\\mono_android", - "CMAKE_OPTIONS":"-G \"Ninja Multi-Config\" -DCMAKE_TOOLCHAIN_FILE=cmake\\Platform\\Android\\Toolchain_android.cmake -DANDROID_ABI=arm64-v8a -DANDROID_ARM_MODE=arm -DANDROID_ARM_NEON=FALSE -DANDROID_NATIVE_API_LEVEL=21 -DLY_NDK_DIR=\"!LY_3RDPARTY_PATH!\\android-ndk\\r21d\" -DLY_MONOLITHIC_GAME=TRUE -DLY_UNITY_BUILD=TRUE", + "CMAKE_OPTIONS":"-G \"Ninja Multi-Config\" -DCMAKE_TOOLCHAIN_FILE=cmake\\Platform\\Android\\Toolchain_android.cmake -DANDROID_ABI=arm64-v8a -DANDROID_ARM_MODE=arm -DANDROID_ARM_NEON=FALSE -DANDROID_NATIVE_API_LEVEL=21 -DLY_NDK_DIR=\"!LY_3RDPARTY_PATH!\\android-ndk\\r21d\" -DLY_MONOLITHIC_GAME=TRUE", "CMAKE_LY_PROJECTS":"AutomatedTesting", "CMAKE_TARGET":"all", "CMAKE_BUILD_ARGS":"-j!NUMBER_OF_PROCESSORS!" diff --git a/scripts/build/Platform/Linux/build_config.json b/scripts/build/Platform/Linux/build_config.json index 84c5976215..97f8cb8b7e 100644 --- a/scripts/build/Platform/Linux/build_config.json +++ b/scripts/build/Platform/Linux/build_config.json @@ -37,7 +37,7 @@ "PARAMETERS": { "CONFIGURATION": "debug", "OUTPUT_DIRECTORY": "build/linux", - "CMAKE_OPTIONS": "-G 'Ninja Multi-Config' -DCMAKE_C_COMPILER=clang-12 -DCMAKE_CXX_COMPILER=clang++-12 -DLY_UNITY_BUILD=TRUE -DLY_PARALLEL_LINK_JOBS=4", + "CMAKE_OPTIONS": "-G 'Ninja Multi-Config' -DLY_PARALLEL_LINK_JOBS=4", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "all" } @@ -53,7 +53,7 @@ "PARAMETERS": { "CONFIGURATION": "profile", "OUTPUT_DIRECTORY": "build/linux", - "CMAKE_OPTIONS": "-G 'Ninja Multi-Config' -DCMAKE_C_COMPILER=clang-12 -DCMAKE_CXX_COMPILER=clang++-12 -DLY_UNITY_BUILD=TRUE -DLY_PARALLEL_LINK_JOBS=4", + "CMAKE_OPTIONS": "-G 'Ninja Multi-Config' -DLY_PARALLEL_LINK_JOBS=4", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "all" } @@ -66,7 +66,7 @@ "PARAMETERS": { "CONFIGURATION": "profile", "OUTPUT_DIRECTORY": "build/linux", - "CMAKE_OPTIONS": "-G 'Ninja Multi-Config' -DCMAKE_C_COMPILER=clang-12 -DCMAKE_CXX_COMPILER=clang++-12 -DLY_UNITY_BUILD=FALSE -DLY_PARALLEL_LINK_JOBS=4", + "CMAKE_OPTIONS": "-G 'Ninja Multi-Config' -DLY_UNITY_BUILD=FALSE -DLY_PARALLEL_LINK_JOBS=4", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "all" } @@ -80,7 +80,7 @@ "PARAMETERS": { "CONFIGURATION": "profile", "OUTPUT_DIRECTORY": "build/linux", - "CMAKE_OPTIONS": "-G 'Ninja Multi-Config' -DCMAKE_C_COMPILER=clang-12 -DCMAKE_CXX_COMPILER=clang++-12 -DLY_UNITY_BUILD=TRUE -DLY_PARALLEL_LINK_JOBS=4", + "CMAKE_OPTIONS": "-G 'Ninja Multi-Config' -DLY_PARALLEL_LINK_JOBS=4", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "all", "CTEST_OPTIONS": "-E Gem::EMotionFX.Editor.Tests -LE (SUITE_sandbox|SUITE_awsi) -L FRAMEWORK_googletest --no-tests=error", @@ -93,7 +93,7 @@ "PARAMETERS": { "CONFIGURATION": "profile", "OUTPUT_DIRECTORY": "build/linux", - "CMAKE_OPTIONS": "-G 'Ninja Multi-Config' -DCMAKE_C_COMPILER=clang-12 -DCMAKE_CXX_COMPILER=clang++-12 -DLY_UNITY_BUILD=FALSE -DLY_PARALLEL_LINK_JOBS=4", + "CMAKE_OPTIONS": "-G 'Ninja Multi-Config' -DLY_UNITY_BUILD=FALSE -DLY_PARALLEL_LINK_JOBS=4", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "all", "CTEST_OPTIONS": "-E Gem::EMotionFX.Editor.Tests -LE (SUITE_sandbox|SUITE_awsi) -L FRAMEWORK_googletest --no-tests=error", @@ -110,7 +110,7 @@ "PARAMETERS": { "CONFIGURATION": "profile", "OUTPUT_DIRECTORY": "build/linux", - "CMAKE_OPTIONS": "-G 'Ninja Multi-Config' -DCMAKE_C_COMPILER=clang-12 -DCMAKE_CXX_COMPILER=clang++-12 -DLY_UNITY_BUILD=TRUE -DLY_PARALLEL_LINK_JOBS=4", + "CMAKE_OPTIONS": "-G 'Ninja Multi-Config' -DLY_PARALLEL_LINK_JOBS=4", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "AssetProcessorBatch", "ASSET_PROCESSOR_BINARY": "bin/profile/AssetProcessorBatch", @@ -124,7 +124,7 @@ "PARAMETERS": { "CONFIGURATION": "profile", "OUTPUT_DIRECTORY": "build/linux", - "CMAKE_OPTIONS": "-G 'Ninja Multi-Config' -DCMAKE_C_COMPILER=clang-12 -DCMAKE_CXX_COMPILER=clang++-12 -DLY_UNITY_BUILD=FALSE -DLY_PARALLEL_LINK_JOBS=4", + "CMAKE_OPTIONS": "-G 'Ninja Multi-Config' -DLY_UNITY_BUILD=FALSE -DLY_PARALLEL_LINK_JOBS=4", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "AssetProcessorBatch", "ASSET_PROCESSOR_BINARY": "bin/profile/AssetProcessorBatch", @@ -142,7 +142,7 @@ "PARAMETERS": { "CONFIGURATION": "profile", "OUTPUT_DIRECTORY": "build/linux", - "CMAKE_OPTIONS": "-G 'Ninja Multi-Config' -DCMAKE_C_COMPILER=clang-12 -DCMAKE_CXX_COMPILER=clang++-12 -DLY_UNITY_BUILD=TRUE -DLY_PARALLEL_LINK_JOBS=4", + "CMAKE_OPTIONS": "-G 'Ninja Multi-Config' -DLY_PARALLEL_LINK_JOBS=4", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "TEST_SUITE_periodic", "CTEST_OPTIONS": "-L (SUITE_periodic) --no-tests=error", @@ -162,7 +162,7 @@ "PARAMETERS": { "CONFIGURATION": "profile", "OUTPUT_DIRECTORY": "build/linux", - "CMAKE_OPTIONS": "-G 'Ninja Multi-Config' -DCMAKE_C_COMPILER=clang-12 -DCMAKE_CXX_COMPILER=clang++-12 -DLY_UNITY_BUILD=TRUE -DLY_PARALLEL_LINK_JOBS=4 -DO3DE_HOME_PATH=\"${WORKSPACE}/home\" -DO3DE_REGISTER_ENGINE_PATH=\"${WORKSPACE}/o3de\" -DO3DE_REGISTER_THIS_ENGINE=TRUE", + "CMAKE_OPTIONS": "-G 'Ninja Multi-Config' -DLY_PARALLEL_LINK_JOBS=4", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "all", "CTEST_OPTIONS": "-L (SUITE_sandbox) --no-tests=error" @@ -178,7 +178,7 @@ "PARAMETERS": { "CONFIGURATION": "profile", "OUTPUT_DIRECTORY": "build/linux", - "CMAKE_OPTIONS": "-G 'Ninja Multi-Config' -DCMAKE_C_COMPILER=clang-12 -DCMAKE_CXX_COMPILER=clang++-12 -DLY_UNITY_BUILD=TRUE -DLY_PARALLEL_LINK_JOBS=4", + "CMAKE_OPTIONS": "-G 'Ninja Multi-Config' -DLY_PARALLEL_LINK_JOBS=4", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "TEST_SUITE_benchmark", "CTEST_OPTIONS": "-L (SUITE_benchmark) --no-tests=error", @@ -195,7 +195,7 @@ "PARAMETERS": { "CONFIGURATION": "release", "OUTPUT_DIRECTORY": "build/linux", - "CMAKE_OPTIONS": "-G 'Ninja Multi-Config' -DCMAKE_C_COMPILER=clang-12 -DCMAKE_CXX_COMPILER=clang++-12 -DLY_UNITY_BUILD=TRUE -DLY_PARALLEL_LINK_JOBS=4", + "CMAKE_OPTIONS": "-G 'Ninja Multi-Config' -DLY_PARALLEL_LINK_JOBS=4", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "all" } @@ -210,9 +210,67 @@ "PARAMETERS": { "CONFIGURATION": "release", "OUTPUT_DIRECTORY": "build/mono_linux", - "CMAKE_OPTIONS": "-G 'Ninja Multi-Config' -DCMAKE_C_COMPILER=clang-12 -DCMAKE_CXX_COMPILER=clang++-12 -DLY_MONOLITHIC_GAME=TRUE -DLY_UNITY_BUILD=TRUE -DLY_PARALLEL_LINK_JOBS=4", + "CMAKE_OPTIONS": "-G 'Ninja Multi-Config' -DLY_MONOLITHIC_GAME=TRUE -DLY_PARALLEL_LINK_JOBS=4", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "all" } + }, + "install_profile": { + "TAGS": [], + "COMMAND": "build_linux.sh", + "PARAMETERS": { + "CONFIGURATION": "profile", + "OUTPUT_DIRECTORY": "build/linux", + "CMAKE_OPTIONS": "-G 'Ninja Multi-Config' -DLY_PARALLEL_LINK_JOBS=4 -DLY_DISABLE_TEST_MODULES=TRUE", + "CMAKE_TARGET": "install" + } + }, + "installer": { + "TAGS": [ + "nightly-clean", + "nightly-installer" + ], + "COMMAND": "build_installer_linux.sh", + "PARAMETERS": { + "CONFIGURATION": "profile", + "OUTPUT_DIRECTORY": "build/linux", + "CMAKE_OPTIONS": "-G 'Ninja Multi-Config' -DLY_PARALLEL_LINK_JOBS=4 -DLY_DISABLE_TEST_MODULES=TRUE -DLY_VERSION_ENGINE_NAME=o3de-sdk", + "EXTRA_CMAKE_OPTIONS": "-DLY_INSTALLER_AUTO_GEN_TAG=TRUE -DLY_INSTALLER_DOWNLOAD_URL=${INSTALLER_DOWNLOAD_URL} -DLY_INSTALLER_LICENSE_URL=${INSTALLER_DOWNLOAD_URL}/license", + "CPACK_OPTIONS": "-D CPACK_UPLOAD_URL=${CPACK_UPLOAD_URL}", + "CMAKE_TARGET": "all" + } + }, + "install_profile_pipe": { + "TAGS": [ + "nightly-incremental", + "nightly-clean" + ], + "PIPELINE_ENV": { + "PROJECT_REPOSITORY_NAME": "TestProject" + }, + "steps": [ + "install_profile", + "project_generate", + "project_engineinstall_profile" + ] + }, + "project_generate": { + "TAGS": [], + "COMMAND": "python_linux.sh", + "PARAMETERS": { + "SCRIPT_PATH": "install/scripts/o3de.py", + "SCRIPT_PARAMETERS": "create-project -pp ${WORKSPACE}/${PROJECT_REPOSITORY_NAME} --force" + } + }, + "project_engineinstall_profile": { + "TAGS": [], + "COMMAND": "build_linux.sh", + "PARAMETERS": { + "COMMAND_CWD": "${WORKSPACE}/${PROJECT_REPOSITORY_NAME}", + "CONFIGURATION": "profile", + "OUTPUT_DIRECTORY": "build/linux", + "CMAKE_OPTIONS": "-G 'Ninja Multi-Config' -DLY_PARALLEL_LINK_JOBS=4 -DCMAKE_MODULE_PATH=${WORKSPACE}/o3de/install/cmake", + "CMAKE_TARGET": "all" + } } } diff --git a/scripts/build/Platform/Linux/build_installer_linux.sh b/scripts/build/Platform/Linux/build_installer_linux.sh new file mode 100755 index 0000000000..301eb5f16d --- /dev/null +++ b/scripts/build/Platform/Linux/build_installer_linux.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +set -o errexit # exit on the first failure encountered + +BASEDIR=$(dirname "$0") +source $BASEDIR/build_linux.sh + +source $BASEDIR/installer_linux.sh diff --git a/scripts/build/Platform/Linux/build_linux.sh b/scripts/build/Platform/Linux/build_linux.sh index fd73e17a12..c14d4b5073 100755 --- a/scripts/build/Platform/Linux/build_linux.sh +++ b/scripts/build/Platform/Linux/build_linux.sh @@ -17,7 +17,10 @@ SOURCE_DIRECTORY=${PWD} pushd $OUTPUT_DIRECTORY LAST_CONFIGURE_CMD_FILE=ci_last_configure_cmd.txt -CONFIGURE_CMD="cmake ${SOURCE_DIRECTORY} ${CMAKE_OPTIONS} ${EXTRA_CMAKE_OPTIONS} -DLY_3RDPARTY_PATH=${LY_3RDPARTY_PATH} -DLY_PROJECTS='${CMAKE_LY_PROJECTS}'" +CONFIGURE_CMD="cmake ${SOURCE_DIRECTORY} ${CMAKE_OPTIONS} ${EXTRA_CMAKE_OPTIONS} -DLY_3RDPARTY_PATH=${LY_3RDPARTY_PATH}" +if [[ -n "$CMAKE_LY_PROJECTS" ]]; then + CONFIGURE_CMD="${CONFIGURE_CMD} -DLY_PROJECTS='${CMAKE_LY_PROJECTS}'" +fi if [[ ! -e "CMakeCache.txt" ]]; then echo [ci_build] First run, generating RUN_CONFIGURE=1 @@ -34,13 +37,13 @@ else fi if [[ ! -z "$RUN_CONFIGURE" ]]; then # have to use eval since $CMAKE_OPTIONS (${EXTRA_CMAKE_OPTIONS}) contains quotes that need to be processed - echo [ci_build] ${CONFIGURE_CMD} + eval echo [ci_build] ${CONFIGURE_CMD} eval ${CONFIGURE_CMD} # Save the run only if success - echo "${CONFIGURE_CMD}" > ${LAST_CONFIGURE_CMD_FILE} + eval echo "${CONFIGURE_CMD}" > ${LAST_CONFIGURE_CMD_FILE} fi -echo [ci_build] cmake --build . --target ${CMAKE_TARGET} --config ${CONFIGURATION} -j $(grep -c processor /proc/cpuinfo) -- ${CMAKE_NATIVE_BUILD_ARGS} -cmake --build . --target ${CMAKE_TARGET} --config ${CONFIGURATION} -j $(grep -c processor /proc/cpuinfo) -- ${CMAKE_NATIVE_BUILD_ARGS} +eval echo [ci_build] cmake --build . --target ${CMAKE_TARGET} --config ${CONFIGURATION} -j $(grep -c processor /proc/cpuinfo) -- ${CMAKE_NATIVE_BUILD_ARGS} +eval cmake --build . --target ${CMAKE_TARGET} --config ${CONFIGURATION} -j $(grep -c processor /proc/cpuinfo) -- ${CMAKE_NATIVE_BUILD_ARGS} popd diff --git a/scripts/build/Platform/Linux/env_linux.sh b/scripts/build/Platform/Linux/env_linux.sh index a03b9642fb..059bb119ff 100755 --- a/scripts/build/Platform/Linux/env_linux.sh +++ b/scripts/build/Platform/Linux/env_linux.sh @@ -18,3 +18,8 @@ if ! command -v ninja &> /dev/null; then echo "[ci_build] Ninja not found" exit 1 fi + +if [[ -n "${COMMAND_CWD}" ]]; then + echo $(eval echo [ci_build] Changing CWD to $COMMAND_CWD) + cd $(eval echo ${COMMAND_CWD}) +fi diff --git a/scripts/build/Platform/Linux/installer_linux.sh b/scripts/build/Platform/Linux/installer_linux.sh new file mode 100755 index 0000000000..3ded242522 --- /dev/null +++ b/scripts/build/Platform/Linux/installer_linux.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +set -o errexit # exit on the first failure encountered + +BASEDIR=$(dirname "$0") +source $BASEDIR/env_linux.sh + +mkdir -p ${OUTPUT_DIRECTORY} +SOURCE_DIRECTORY=${PWD} +pushd $OUTPUT_DIRECTORY + +if ! command -v cpack &> /dev/null; then + echo "[ci_build] CPack not found" + exit 1 +fi + +echo [ci_build] cpack --version +cpack --version + +eval echo [ci_build] cpack -C ${CONFIGURATION} ${CPACK_OPTIONS} +eval cpack -C ${CONFIGURATION} ${CPACK_OPTIONS} + +popd diff --git a/scripts/build/Platform/Mac/build_config.json b/scripts/build/Platform/Mac/build_config.json index 7eb3cb5699..34b02a1aec 100644 --- a/scripts/build/Platform/Mac/build_config.json +++ b/scripts/build/Platform/Mac/build_config.json @@ -37,7 +37,7 @@ "PARAMETERS": { "CONFIGURATION": "debug", "OUTPUT_DIRECTORY": "build/mac", - "CMAKE_OPTIONS": "-G Xcode -DLY_UNITY_BUILD=TRUE", + "CMAKE_OPTIONS": "-G Xcode", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "ALL_BUILD" } @@ -51,7 +51,7 @@ "PARAMETERS": { "CONFIGURATION": "profile", "OUTPUT_DIRECTORY": "build/mac", - "CMAKE_OPTIONS": "-G Xcode -DLY_UNITY_BUILD=TRUE", + "CMAKE_OPTIONS": "-G Xcode", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "ALL_BUILD" } @@ -81,7 +81,7 @@ "PARAMETERS": { "CONFIGURATION": "profile", "OUTPUT_DIRECTORY": "build/mac", - "CMAKE_OPTIONS": "-G Xcode -DLY_UNITY_BUILD=TRUE", + "CMAKE_OPTIONS": "-G Xcode", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "AssetProcessorBatch", "ASSET_PROCESSOR_BINARY": "bin/profile/AssetProcessorBatch", @@ -99,7 +99,7 @@ "PARAMETERS": { "CONFIGURATION": "profile", "OUTPUT_DIRECTORY": "build/mac", - "CMAKE_OPTIONS": "-G Xcode -DLY_UNITY_BUILD=TRUE", + "CMAKE_OPTIONS": "-G Xcode", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "TEST_SUITE_periodic", "CTEST_OPTIONS": "-L \"(SUITE_periodic)\"", @@ -116,7 +116,7 @@ "PARAMETERS": { "CONFIGURATION": "profile", "OUTPUT_DIRECTORY": "build/mac", - "CMAKE_OPTIONS": "-G Xcode -DLY_UNITY_BUILD=TRUE", + "CMAKE_OPTIONS": "-G Xcode", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "TEST_SUITE_benchmark", "CTEST_OPTIONS": "-L \"(SUITE_benchmark)\"", @@ -133,7 +133,7 @@ "PARAMETERS": { "CONFIGURATION": "release", "OUTPUT_DIRECTORY": "build/mac", - "CMAKE_OPTIONS": "-G Xcode -DLY_UNITY_BUILD=TRUE", + "CMAKE_OPTIONS": "-G Xcode", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "ALL_BUILD" } @@ -148,7 +148,7 @@ "PARAMETERS": { "CONFIGURATION": "release", "OUTPUT_DIRECTORY": "build/mono_mac", - "CMAKE_OPTIONS": "-G Xcode -DLY_MONOLITHIC_GAME=TRUE -DLY_UNITY_BUILD=TRUE", + "CMAKE_OPTIONS": "-G Xcode -DLY_MONOLITHIC_GAME=TRUE", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "ALL_BUILD" } @@ -162,5 +162,50 @@ "SCRIPT_PATH": "scripts/build/package/package.py", "SCRIPT_PARAMETERS": "--platform Mac --type all" } + }, + "install_profile": { + "TAGS": [], + "COMMAND": "build_mac.sh", + "PARAMETERS": { + "CONFIGURATION": "profile", + "OUTPUT_DIRECTORY": "build/mac", + "CMAKE_OPTIONS": "-G Xcode -DLY_DISABLE_TEST_MODULES=TRUE", + "CMAKE_LY_PROJECTS": "", + "CMAKE_TARGET": "install" + } + }, + "install_profile_pipe": { + "TAGS": [ + "nightly-incremental", + "nightly-clean" + ], + "PIPELINE_ENV": { + "PROJECT_REPOSITORY_NAME": "TestProject" + }, + "steps": [ + "install_profile", + "project_generate", + "project_engineinstall_profile" + ] + }, + "project_generate": { + "TAGS": [], + "COMMAND": "python_mac.sh", + "PARAMETERS": { + "SCRIPT_PATH": "install/O3DE_SDK.app/Contents/Engine/scripts/o3de.py", + "SCRIPT_PARAMETERS": "create-project -pp ${WORKSPACE}/${PROJECT_REPOSITORY_NAME} --force" + } + }, + "project_engineinstall_profile": { + "TAGS": [], + "COMMAND": "build_mac.sh", + "PARAMETERS": { + "COMMAND_CWD": "${WORKSPACE}/${PROJECT_REPOSITORY_NAME}", + "CONFIGURATION": "profile", + "OUTPUT_DIRECTORY": "build/mac", + "CMAKE_OPTIONS": "-G Xcode -DCMAKE_MODULE_PATH=${WORKSPACE}/o3de/install/O3DE_SDK.app/Contents/Engine/cmake", + "CMAKE_LY_PROJECTS": "", + "CMAKE_TARGET": "ALL_BUILD" + } } } diff --git a/scripts/build/Platform/Mac/build_mac.sh b/scripts/build/Platform/Mac/build_mac.sh index cb271212d6..169e91c24f 100755 --- a/scripts/build/Platform/Mac/build_mac.sh +++ b/scripts/build/Platform/Mac/build_mac.sh @@ -17,7 +17,10 @@ SOURCE_DIRECTORY=${PWD} pushd $OUTPUT_DIRECTORY LAST_CONFIGURE_CMD_FILE=ci_last_configure_cmd.txt -CONFIGURE_CMD="cmake ${SOURCE_DIRECTORY} ${CMAKE_OPTIONS} ${EXTRA_CMAKE_OPTIONS} -DLY_3RDPARTY_PATH=${LY_3RDPARTY_PATH} -DLY_PROJECTS='${CMAKE_LY_PROJECTS}'" +CONFIGURE_CMD="cmake ${SOURCE_DIRECTORY} ${CMAKE_OPTIONS} ${EXTRA_CMAKE_OPTIONS} -DLY_3RDPARTY_PATH=${LY_3RDPARTY_PATH}" +if [[ -n "$CMAKE_LY_PROJECTS" ]]; then + CONFIGURE_CMD="${CONFIGURE_CMD} -DLY_PROJECTS='${CMAKE_LY_PROJECTS}'" +fi if [[ ! -e "CMakeCache.txt" ]]; then echo [ci_build] First run, generating RUN_CONFIGURE=1 diff --git a/scripts/build/Platform/Mac/env_mac.sh b/scripts/build/Platform/Mac/env_mac.sh index 2c974a1efe..f5fd9f5773 100755 --- a/scripts/build/Platform/Mac/env_mac.sh +++ b/scripts/build/Platform/Mac/env_mac.sh @@ -13,3 +13,8 @@ if ! command -v cmake &> /dev/null; then echo "[ci_build] CMake not found" exit 1 fi + +if [[ -n "${COMMAND_CWD}" ]]; then + echo $(eval echo [ci_build] Changing CWD to $COMMAND_CWD) + cd $(eval echo ${COMMAND_CWD}) +fi diff --git a/scripts/build/Platform/Windows/build_config.json b/scripts/build/Platform/Windows/build_config.json index 9eb9957729..6f1aaa1570 100644 --- a/scripts/build/Platform/Windows/build_config.json +++ b/scripts/build/Platform/Windows/build_config.json @@ -56,7 +56,7 @@ "COMMAND": "python_windows.cmd", "PARAMETERS": { "SCRIPT_PATH": "scripts/build/ci_build_metrics.py", - "SCRIPT_PARAMETERS": "--platform=Windows --repository=!REPOSITORY_NAME! --jobname=!JOB_NAME! --jobnumber=!BUILD_NUMBER! --jobnode=!NODE_LABEL! --changelist=!CHANGE_ID!" + "SCRIPT_PARAMETERS": "--platform=Windows --repository=%REPOSITORY_NAME% --jobname=%JOB_NAME% --jobnumber=%BUILD_NUMBER% --jobnode=%NODE_LABEL% --changelist=%CHANGE_ID%" } }, "windows_packaging_all": { @@ -88,7 +88,7 @@ "CONFIGURATION": "profile", "SCRIPT_PATH": "scripts/build/TestImpactAnalysis/tiaf_driver.py", "SCRIPT_PARAMETERS": - "--config=\"!OUTPUT_DIRECTORY!/bin/TestImpactFramework/profile/Persistent/tiaf.json\" --src-branch=!BRANCH_NAME! --dst-branch=!CHANGE_TARGET! --commit=!CHANGE_ID! --s3-bucket=!TEST_IMPACT_S3_BUCKET! --mars-index-prefix=jonawals --s3-top-level-dir=!REPOSITORY_NAME! --build-number=!BUILD_NUMBER! --suite=main --test-failure-policy=continue" + "--config=\"%OUTPUT_DIRECTORY%/bin/TestImpactFramework/profile/Persistent/tiaf.json\" --src-branch=%BRANCH_NAME% --dst-branch=%CHANGE_TARGET% --commit=%CHANGE_ID% --s3-bucket=%TEST_IMPACT_S3_BUCKET% --mars-index-prefix=jonawals --s3-top-level-dir=%REPOSITORY_NAME% --build-number=%BUILD_NUMBER% --suite=main --test-failure-policy=continue" } }, "debug_vs2019": { @@ -99,7 +99,7 @@ "PARAMETERS": { "CONFIGURATION": "debug", "OUTPUT_DIRECTORY": "build\\windows_vs2019", - "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0 -DLY_UNITY_BUILD=TRUE", + "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "ALL_BUILD", "CMAKE_NATIVE_BUILD_ARGS": "/m /nologo" @@ -113,7 +113,7 @@ "PARAMETERS": { "CONFIGURATION": "debug", "OUTPUT_DIRECTORY": "build\\windows_vs2019", - "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0 -DLY_UNITY_BUILD=TRUE", + "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "TEST_SUITE_smoke TEST_SUITE_main", "CMAKE_NATIVE_BUILD_ARGS": "/m /nologo", @@ -131,7 +131,7 @@ "PARAMETERS": { "CONFIGURATION": "profile", "OUTPUT_DIRECTORY": "build\\windows_vs2019", - "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0 -DLY_UNITY_BUILD=TRUE -DLY_TEST_IMPACT_INSTRUMENTATION_BIN=!TEST_IMPACT_WIN_BINARY!", + "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0 -DLY_TEST_IMPACT_INSTRUMENTATION_BIN=%TEST_IMPACT_WIN_BINARY%", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "ALL_BUILD", "CMAKE_NATIVE_BUILD_ARGS": "/m /nologo" @@ -162,7 +162,7 @@ "PARAMETERS": { "CONFIGURATION": "profile", "OUTPUT_DIRECTORY": "build\\windows_vs2019", - "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0 -DLY_UNITY_BUILD=TRUE", + "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "TEST_SUITE_smoke TEST_SUITE_main", "CMAKE_NATIVE_BUILD_ARGS": "/m /nologo", @@ -183,7 +183,7 @@ "PARAMETERS": { "CONFIGURATION": "profile", "OUTPUT_DIRECTORY": "build\\windows_vs2019", - "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0 -DLY_UNITY_BUILD=TRUE", + "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "TEST_SUITE_smoke TEST_SUITE_main", "CMAKE_NATIVE_BUILD_ARGS": "/m /nologo", @@ -203,7 +203,7 @@ "PARAMETERS": { "CONFIGURATION": "profile", "OUTPUT_DIRECTORY": "build\\windows_vs2019", - "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0 -DLY_UNITY_BUILD=TRUE", + "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "AssetProcessorBatch", "CMAKE_NATIVE_BUILD_ARGS": "/m /nologo", @@ -234,7 +234,7 @@ "PARAMETERS": { "CONFIGURATION": "profile", "OUTPUT_DIRECTORY": "build\\windows_vs2019", - "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0 -DLY_UNITY_BUILD=TRUE", + "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "TEST_SUITE_awsi", "CMAKE_NATIVE_BUILD_ARGS": "/m /nologo", @@ -253,7 +253,7 @@ "PARAMETERS": { "CONFIGURATION": "profile", "OUTPUT_DIRECTORY": "build\\windows_vs2019", - "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0 -DLY_UNITY_BUILD=TRUE", + "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "TEST_SUITE_periodic", "CMAKE_NATIVE_BUILD_ARGS": "/m /nologo", @@ -275,7 +275,7 @@ "PARAMETERS": { "CONFIGURATION": "profile", "OUTPUT_DIRECTORY": "build\\windows_vs2019", - "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0 -DLY_UNITY_BUILD=TRUE", + "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "TEST_SUITE_sandbox", "CMAKE_NATIVE_BUILD_ARGS": "/m /nologo", @@ -294,7 +294,7 @@ "PARAMETERS": { "CONFIGURATION": "profile", "OUTPUT_DIRECTORY": "build\\windows_vs2019", - "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0 -DLY_UNITY_BUILD=TRUE", + "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "TEST_SUITE_benchmark", "CMAKE_NATIVE_BUILD_ARGS": "/m /nologo", @@ -314,7 +314,7 @@ "PARAMETERS": { "CONFIGURATION": "release", "OUTPUT_DIRECTORY": "build\\windows_vs2019", - "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0 -DLY_UNITY_BUILD=TRUE", + "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "ALL_BUILD", "CMAKE_NATIVE_BUILD_ARGS": "/m /nologo" @@ -330,23 +330,19 @@ "PARAMETERS": { "CONFIGURATION": "release", "OUTPUT_DIRECTORY": "build\\mono_windows_vs2019", - "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0 -DLY_MONOLITHIC_GAME=TRUE -DLY_UNITY_BUILD=TRUE", + "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0 -DLY_MONOLITHIC_GAME=TRUE", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "ALL_BUILD", "CMAKE_NATIVE_BUILD_ARGS": "/m /nologo" } }, "install_profile_vs2019": { - "TAGS": [ - "nightly-incremental", - "nightly-clean" - ], + "TAGS": [], "COMMAND": "build_windows.cmd", "PARAMETERS": { "CONFIGURATION": "profile", "OUTPUT_DIRECTORY": "build\\windows_vs2019", - "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0 -DLY_UNITY_BUILD=TRUE -DLY_DISABLE_TEST_MODULES=TRUE", - "CMAKE_LY_PROJECTS": "", + "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0 -DLY_DISABLE_TEST_MODULES=TRUE", "CMAKE_TARGET": "INSTALL", "CMAKE_NATIVE_BUILD_ARGS": "/m /nologo" } @@ -363,14 +359,35 @@ "PARAMETERS": { "CONFIGURATION": "profile", "OUTPUT_DIRECTORY": "build\\windows_vs2019", - "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0 -DLY_UNITY_BUILD=TRUE -DLY_DISABLE_TEST_MODULES=TRUE -DLY_VERSION_ENGINE_NAME=o3de-sdk -DLY_VERSION_STRING=!O3DE_VERSION! -DLY_INSTALLER_WIX_ROOT=\"!WIX! \"", - "EXTRA_CMAKE_OPTIONS": "-DLY_INSTALLER_AUTO_GEN_TAG=ON -DLY_INSTALLER_DOWNLOAD_URL=!INSTALLER_DOWNLOAD_URL! -DLY_INSTALLER_LICENSE_URL=!INSTALLER_DOWNLOAD_URL!/license", - "CPACK_BUCKET": "!INSTALLER_BUCKET!", - "CMAKE_LY_PROJECTS": "", + "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0 -DLY_DISABLE_TEST_MODULES=TRUE -DLY_VERSION_ENGINE_NAME=o3de-sdk -DLY_INSTALLER_WIX_ROOT=\"!WIX! \"", + "EXTRA_CMAKE_OPTIONS": "-DLY_INSTALLER_AUTO_GEN_TAG=TRUE -DLY_INSTALLER_DOWNLOAD_URL=!INSTALLER_DOWNLOAD_URL! -DLY_INSTALLER_LICENSE_URL=!INSTALLER_DOWNLOAD_URL!/license", "CMAKE_TARGET": "ALL_BUILD", + "CPACK_OPTIONS": "-D CPACK_UPLOAD_URL=\"!CPACK_UPLOAD_URL!\"", "CMAKE_NATIVE_BUILD_ARGS": "/m /nologo" } }, + "install_profile_vs2019_pipe": { + "TAGS": [ + "nightly-incremental", + "nightly-clean" + ], + "PIPELINE_ENV": { + "PROJECT_REPOSITORY_NAME": "TestProject" + }, + "steps": [ + "install_profile_vs2019", + "project_generate", + "project_engineinstall_profile_vs2019" + ] + }, + "project_generate": { + "TAGS": [], + "COMMAND": "python_windows.cmd", + "PARAMETERS": { + "SCRIPT_PATH": "install\\scripts\\o3de.py", + "SCRIPT_PARAMETERS": "create-project -pp %WORKSPACE%\\%PROJECT_REPOSITORY_NAME% --force" + } + }, "project_enginesource_profile_vs2019": { "TAGS": [ "project" @@ -382,8 +399,7 @@ "PARAMETERS": { "CONFIGURATION": "profile", "OUTPUT_DIRECTORY": "build\\windows_vs2019", - "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0 -DLY_UNITY_BUILD=TRUE -DCMAKE_MODULE_PATH=!WORKSPACE!/o3de/cmake", - "CMAKE_LY_PROJECTS": "", + "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0 -DCMAKE_MODULE_PATH=%WORKSPACE%/o3de/cmake", "CMAKE_TARGET": "ALL_BUILD", "CMAKE_NATIVE_BUILD_ARGS": "/m /nologo" } @@ -395,10 +411,10 @@ }, "COMMAND": "build_windows.cmd", "PARAMETERS": { + "COMMAND_CWD": "%WORKSPACE%\\%PROJECT_REPOSITORY_NAME%", "CONFIGURATION": "profile", "OUTPUT_DIRECTORY": "build\\windows_vs2019", - "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0 -DLY_UNITY_BUILD=TRUE -DCMAKE_MODULE_PATH=!WORKSPACE!/o3de/install/cmake", - "CMAKE_LY_PROJECTS": "", + "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0 -DCMAKE_MODULE_PATH=%WORKSPACE%/o3de/install/cmake", "CMAKE_TARGET": "ALL_BUILD", "CMAKE_NATIVE_BUILD_ARGS": "/m /nologo" } diff --git a/scripts/build/Platform/Windows/build_windows.cmd b/scripts/build/Platform/Windows/build_windows.cmd index b5a0245d1a..6c3ce91397 100644 --- a/scripts/build/Platform/Windows/build_windows.cmd +++ b/scripts/build/Platform/Windows/build_windows.cmd @@ -25,18 +25,14 @@ IF ERRORLEVEL 1 ( exit /b 1 ) -REM Jenkins reports MSB8029 when TMP/TEMP is not defined, define a dummy folder -SET TMP=%cd%/temp -SET TEMP=%cd%/temp -IF NOT EXIST %TMP% ( - MKDIR temp -) - REM Compute half the amount of processors so some jobs can run SET /a HALF_PROCESSORS = NUMBER_OF_PROCESSORS / 2 SET LAST_CONFIGURE_CMD_FILE=ci_last_configure_cmd.txt -SET CONFIGURE_CMD=cmake %SOURCE_DIRECTORY% %CMAKE_OPTIONS% %EXTRA_CMAKE_OPTIONS% -DLY_3RDPARTY_PATH="%LY_3RDPARTY_PATH%" -DLY_PROJECTS=%CMAKE_LY_PROJECTS% +SET CONFIGURE_CMD=cmake %SOURCE_DIRECTORY% %CMAKE_OPTIONS% %EXTRA_CMAKE_OPTIONS% -DLY_3RDPARTY_PATH="%LY_3RDPARTY_PATH%" +IF NOT "%CMAKE_LY_PROJECTS%"=="" ( + SET CONFIGURE_CMD=!CONFIGURE_CMD! -DLY_PROJECTS="%CMAKE_LY_PROJECTS%" +) IF NOT EXIST CMakeCache.txt ( ECHO [ci_build] First run, generating SET RUN_CONFIGURE=1 diff --git a/scripts/build/Platform/Windows/env_windows.cmd b/scripts/build/Platform/Windows/env_windows.cmd index 1c54e36bfc..a78946caf6 100644 --- a/scripts/build/Platform/Windows/env_windows.cmd +++ b/scripts/build/Platform/Windows/env_windows.cmd @@ -7,12 +7,35 @@ REM SPDX-License-Identifier: Apache-2.0 OR MIT REM REM +REM To get recursive folder creation +SETLOCAL EnableExtensions +SETLOCAL EnableDelayedExpansion + where /Q cmake IF NOT %ERRORLEVEL%==0 ( ECHO [ci_build] CMake not found GOTO :error ) +IF NOT "%COMMAND_CWD%"=="" ( + ECHO [ci_build] Changing CWD to %COMMAND_CWD% + CD %COMMAND_CWD% +) + +REM Jenkins reports MSB8029 when TMP/TEMP is not defined, define a dummy folder +IF NOT "%TMP%"=="" ( + IF NOT "%WORKSPACE_TMP%"=="" ( + SET TMP=%WORKSPACE_TMP% + SET TEMP=%WORKSPACE_TMP% + ) ELSE ( + SET TMP=%cd%/temp + SET TEMP=%cd%/temp + ) +) +IF NOT EXIST "!TMP!" ( + MKDIR "!TMP!" +) + EXIT /b 0 :error diff --git a/scripts/build/Platform/Windows/installer_windows.cmd b/scripts/build/Platform/Windows/installer_windows.cmd index 87f53adc7f..bbde450973 100644 --- a/scripts/build/Platform/Windows/installer_windows.cmd +++ b/scripts/build/Platform/Windows/installer_windows.cmd @@ -17,10 +17,12 @@ IF NOT EXIST %OUTPUT_DIRECTORY% ( ) PUSHD %OUTPUT_DIRECTORY% -REM Override the temporary directory used by wix to the workspace -SET "WIX_TEMP=!WORKSPACE_TMP!/wix" -IF NOT EXIST "%WIX_TEMP%" ( - MKDIR "%WIX_TEMP%" +REM Override the temporary directory used by wix to the workspace (if we have a WORKSPACE_TMP) +IF NOT "%WORKSPACE_TMP%"=="" ( + SET "WIX_TEMP=!WORKSPACE_TMP!/wix" + IF NOT EXIST "!WIX_TEMP!" ( + MKDIR "!WIX_TEMP!" + ) ) REM Make sure we are using the CMake version of CPack and not the one that comes with chocolatey @@ -47,10 +49,6 @@ IF ERRORLEVEL 1 ( GOTO :popd_error ) -IF NOT "%CPACK_BUCKET%"=="" ( - SET "CPACK_OPTIONS=-D CPACK_UPLOAD_URL=s3://%CPACK_BUCKET% %CPACK_OPTIONS%" -) - ECHO [ci_build] "!CPACK_PATH!" -C %CONFIGURATION% %CPACK_OPTIONS% "!CPACK_PATH!" -C %CONFIGURATION% %CPACK_OPTIONS% IF NOT %ERRORLEVEL%==0 ( diff --git a/scripts/build/Platform/Windows/package_build_config.json b/scripts/build/Platform/Windows/package_build_config.json index 89431ad96e..5eb96f1e38 100644 --- a/scripts/build/Platform/Windows/package_build_config.json +++ b/scripts/build/Platform/Windows/package_build_config.json @@ -4,7 +4,7 @@ "PARAMETERS": { "CONFIGURATION":"profile", "OUTPUT_DIRECTORY":"windows_vs2019", - "CMAKE_OPTIONS":"-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0 -DLY_UNITY_BUILD=TRUE", + "CMAKE_OPTIONS":"-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0", "CMAKE_LY_PROJECTS":"AtomTest;AtomSampleViewer", "CMAKE_TARGET":"ALL_BUILD", "CMAKE_NATIVE_BUILD_ARGS": "/m /nologo" diff --git a/scripts/build/Platform/iOS/build_config.json b/scripts/build/Platform/iOS/build_config.json index 01f545ffb6..ec2b763dda 100644 --- a/scripts/build/Platform/iOS/build_config.json +++ b/scripts/build/Platform/iOS/build_config.json @@ -27,7 +27,7 @@ "PARAMETERS": { "CONFIGURATION": "debug", "OUTPUT_DIRECTORY": "build/ios", - "CMAKE_OPTIONS": "-G Xcode -DCMAKE_TOOLCHAIN_FILE=cmake/Platform/iOS/Toolchain_ios.cmake -DLY_MONOLITHIC_GAME=TRUE -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED=FALSE -DLY_IOS_CODE_SIGNING_IDENTITY=\"\" -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS=\"\" -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED=FALSE -DLY_UNITY_BUILD=TRUE", + "CMAKE_OPTIONS": "-G Xcode -DCMAKE_TOOLCHAIN_FILE=cmake/Platform/iOS/Toolchain_ios.cmake -DLY_MONOLITHIC_GAME=TRUE -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED=FALSE -DLY_IOS_CODE_SIGNING_IDENTITY=\"\" -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS=\"\" -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED=FALSE", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "ALL_BUILD", "CMAKE_NATIVE_BUILD_ARGS": "-destination generic/platform=iOS" @@ -44,7 +44,7 @@ "PARAMETERS": { "CONFIGURATION": "profile", "OUTPUT_DIRECTORY": "build/ios", - "CMAKE_OPTIONS": "-G Xcode -DCMAKE_TOOLCHAIN_FILE=cmake/Platform/iOS/Toolchain_ios.cmake -DLY_MONOLITHIC_GAME=TRUE -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED=FALSE -DLY_IOS_CODE_SIGNING_IDENTITY=\"\" -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS=\"\" -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED=FALSE -DLY_UNITY_BUILD=TRUE", + "CMAKE_OPTIONS": "-G Xcode -DCMAKE_TOOLCHAIN_FILE=cmake/Platform/iOS/Toolchain_ios.cmake -DLY_MONOLITHIC_GAME=TRUE -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED=FALSE -DLY_IOS_CODE_SIGNING_IDENTITY=\"\" -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS=\"\" -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED=FALSE", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "ALL_BUILD", "CMAKE_NATIVE_BUILD_ARGS": "-destination generic/platform=iOS" @@ -76,7 +76,7 @@ "PARAMETERS": { "CONFIGURATION": "profile", "OUTPUT_DIRECTORY": "build/mac", - "CMAKE_OPTIONS": "-G Xcode -DLY_UNITY_BUILD=TRUE -DO3DE_HOME_PATH=\"${WORKSPACE}/home\" -DO3DE_REGISTER_ENGINE_PATH=\"${WORKSPACE}/o3de\" -DO3DE_REGISTER_THIS_ENGINE=TRUE", + "CMAKE_OPTIONS": "-G Xcode", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "AssetProcessorBatch", "ASSET_PROCESSOR_BINARY": "bin/profile/AssetProcessorBatch", @@ -94,7 +94,7 @@ "PARAMETERS": { "CONFIGURATION": "release", "OUTPUT_DIRECTORY": "build/ios", - "CMAKE_OPTIONS": "-G Xcode -DCMAKE_TOOLCHAIN_FILE=cmake/Platform/iOS/Toolchain_ios.cmake -DLY_MONOLITHIC_GAME=TRUE -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED=FALSE -DLY_IOS_CODE_SIGNING_IDENTITY=\"\" -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS=\"\" -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED=FALSE -DLY_UNITY_BUILD=TRUE", + "CMAKE_OPTIONS": "-G Xcode -DCMAKE_TOOLCHAIN_FILE=cmake/Platform/iOS/Toolchain_ios.cmake -DLY_MONOLITHIC_GAME=TRUE -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED=FALSE -DLY_IOS_CODE_SIGNING_IDENTITY=\"\" -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS=\"\" -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED=FALSE", "CMAKE_LY_PROJECTS": "AutomatedTesting", "CMAKE_TARGET": "ALL_BUILD", "CMAKE_NATIVE_BUILD_ARGS": "-destination generic/platform=iOS" @@ -112,7 +112,7 @@ "PARAMETERS": { "CONFIGURATION": "profile", "OUTPUT_DIRECTORY": "build/ios_test", - "CMAKE_OPTIONS": "-G Xcode -DCMAKE_TOOLCHAIN_FILE=cmake/Platform/iOS/Toolchain_ios.cmake -DLY_MONOLITHIC_GAME=FALSE -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED=TRUE -DLY_IOS_CODE_SIGNING_IDENTITY=\"\" -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS=\"\" -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED=TRUE -DLY_UNITY_BUILD=TRUE -DO3DE_HOME_PATH=\"${WORKSPACE}/home\" -DO3DE_REGISTER_ENGINE_PATH=\"${WORKSPACE}/o3de\" -DO3DE_REGISTER_THIS_ENGINE=TRUE", + "CMAKE_OPTIONS": "-G Xcode -DCMAKE_TOOLCHAIN_FILE=cmake/Platform/iOS/Toolchain_ios.cmake -DLY_MONOLITHIC_GAME=FALSE -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED=TRUE -DLY_IOS_CODE_SIGNING_IDENTITY=\"\" -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS=\"\" -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED=TRUE", "CMAKE_TARGET": "ALL_BUILD", "CMAKE_NATIVE_BUILD_ARGS": "", "TARGET_DEVICE_NAME": "Lumberyard", diff --git a/scripts/build/build_node/Platform/Linux/package-list.ubuntu-bionic.txt b/scripts/build/build_node/Platform/Linux/package-list.ubuntu-bionic.txt index 625909e214..30259a6dc7 100644 --- a/scripts/build/build_node/Platform/Linux/package-list.ubuntu-bionic.txt +++ b/scripts/build/build_node/Platform/Linux/package-list.ubuntu-bionic.txt @@ -2,7 +2,7 @@ # Build Tools Packages cmake/3.20.1-0kitware1ubuntu18.04.1 # For cmake -clang-6.0 # For Ninja Build System +clang-12 # For Ninja Build System ninja-build # For the compiler and its dependencies java-11-amazon-corretto-jdk # For Jenkins and Android @@ -12,7 +12,12 @@ libxcb-xinerama0 # For Qt plugins at runtime libxcb-xinput0 # For Qt plugins at runtime libfontconfig1-dev # For Qt plugins at runtime libcurl4-openssl-dev # For HttpRequestor -libsdl2-dev # for WWise/Audio +# libsdl2-dev # For WWise/Audio +libxcb-xkb-dev # For xcb keyboard input +libxkbcommon-x11-dev # For xcb keyboard input +libxkbcommon-dev # For xcb keyboard input +libxcb-xfixes0-dev # For mouse input +libxcb-xinput-dev # For mouse input zlib1g-dev mesa-common-dev diff --git a/scripts/build/build_node/Platform/Linux/package-list.ubuntu-focal.txt b/scripts/build/build_node/Platform/Linux/package-list.ubuntu-focal.txt index 2cbbe58b38..71958d74bd 100644 --- a/scripts/build/build_node/Platform/Linux/package-list.ubuntu-focal.txt +++ b/scripts/build/build_node/Platform/Linux/package-list.ubuntu-focal.txt @@ -12,9 +12,11 @@ libxcb-xinerama0 # For Qt plugins at runtime libxcb-xinput0 # For Qt plugins at runtime libfontconfig1-dev # For Qt plugins at runtime libcurl4-openssl-dev # For HttpRequestor -libsdl2-dev # for WWise/Audio +# libsdl2-dev # for WWise/Audio libxcb-xkb-dev # For xcb keyboard input libxkbcommon-x11-dev # For xcb keyboard input libxkbcommon-dev # For xcb keyboard input +libxcb-xfixes0-dev # For mouse input +libxcb-xinput-dev # For mouse input zlib1g-dev mesa-common-dev