From a1b59e5e5e5371adb2911548b2daf8539b195553 Mon Sep 17 00:00:00 2001 From: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> Date: Thu, 19 Aug 2021 08:51:29 -0700 Subject: [PATCH] install reorg/cleanup Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> --- Assets/CMakeLists.txt | 9 + CMakeLists.txt | 11 +- Code/LauncherUnified/CMakeLists.txt | 24 +++ Registry/CMakeLists.txt | 16 ++ Templates/CMakeLists.txt | 9 + Tools/CMakeLists.txt | 10 ++ Tools/LyTestTools/CMakeLists.txt | 14 ++ Tools/RemoteConsole/CMakeLists.txt | 14 ++ cmake/Install.cmake | 86 +++++++++- cmake/Platform/Common/Install_common.cmake | 156 ++---------------- python/CMakeLists.txt | 24 +++ .../Platform/Linux/install_files_linux.cmake | 13 ++ python/Platform/Mac/install_files_mac.cmake | 13 ++ .../Windows/install_files_windows.cmake | 13 ++ scripts/CMakeLists.txt | 1 + scripts/bundler/CMakeLists.txt | 13 ++ scripts/o3de/CMakeLists.txt | 13 ++ 17 files changed, 288 insertions(+), 151 deletions(-) create mode 100644 Assets/CMakeLists.txt create mode 100644 Registry/CMakeLists.txt create mode 100644 Templates/CMakeLists.txt create mode 100644 Tools/CMakeLists.txt create mode 100644 Tools/LyTestTools/CMakeLists.txt create mode 100644 Tools/RemoteConsole/CMakeLists.txt create mode 100644 python/CMakeLists.txt create mode 100644 python/Platform/Linux/install_files_linux.cmake create mode 100644 python/Platform/Mac/install_files_mac.cmake create mode 100644 python/Platform/Windows/install_files_windows.cmake create mode 100644 scripts/bundler/CMakeLists.txt diff --git a/Assets/CMakeLists.txt b/Assets/CMakeLists.txt new file mode 100644 index 0000000000..11b30db8c3 --- /dev/null +++ b/Assets/CMakeLists.txt @@ -0,0 +1,9 @@ +# +# 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 +# +# + +ly_install_directory(DIRECTORY .) diff --git a/CMakeLists.txt b/CMakeLists.txt index bd02eeb7ff..7a668af6a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,14 +64,13 @@ include(cmake/Projects.cmake) if(NOT INSTALLED_ENGINE) # Add the rest of the targets + add_subdirectory(Assets) add_subdirectory(Code) + add_subdirectory(python) + add_subdirectory(Registry) add_subdirectory(scripts) - - # SPEC-1417 will investigate and fix this - if(NOT PAL_PLATFORM_NAME STREQUAL "Mac") - add_subdirectory(Tools/LyTestTools/tests/) - add_subdirectory(Tools/RemoteConsole/ly_remote_console/tests/) - endif() + add_subdirectory(Templates) + add_subdirectory(Tools) # Add external subdirectories listed in the engine.json. LY_EXTERNAL_SUBDIRS is a cache variable so the user can add extra # external subdirectories diff --git a/Code/LauncherUnified/CMakeLists.txt b/Code/LauncherUnified/CMakeLists.txt index 079156632c..d496e4fae6 100644 --- a/Code/LauncherUnified/CMakeLists.txt +++ b/Code/LauncherUnified/CMakeLists.txt @@ -94,3 +94,27 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS) endif() +################################################################################ +# Install +################################################################################ + +ly_install_files( + FILES + ${LY_ROOT_FOLDER}/Code/LauncherUnified/launcher_generator.cmake + ${LY_ROOT_FOLDER}/Code/LauncherUnified/launcher_project_files.cmake + ${LY_ROOT_FOLDER}/Code/LauncherUnified/LauncherProject.cpp + ${LY_ROOT_FOLDER}/Code/LauncherUnified/StaticModules.in + DESTINATION LauncherGenerator +) +ly_install_directory( + DIRECTORY Platform/${PAL_PLATFORM_NAME} + DESTINATION LauncherGenerator +) +ly_install_directory( + DIRECTORY Platform/Common + DESTINATION LauncherGenerator +) +ly_install_files( + FILES FindLauncherGenerator.cmake + DESTINATION cmake +) diff --git a/Registry/CMakeLists.txt b/Registry/CMakeLists.txt new file mode 100644 index 0000000000..4e0d433496 --- /dev/null +++ b/Registry/CMakeLists.txt @@ -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 +# +# + +ly_install_directory(DIRECTORY .) + +cmake_path(RELATIVE_PATH CMAKE_RUNTIME_OUTPUT_DIRECTORY BASE_DIRECTORY ${CMAKE_BINARY_DIR} OUTPUT_VARIABLE runtime_output_directory) + +ly_install_directory(DIRECTORY + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$/Registry + DESTINATION ${runtime_output_directory}/${PAL_PLATFORM_NAME}/$ +) diff --git a/Templates/CMakeLists.txt b/Templates/CMakeLists.txt new file mode 100644 index 0000000000..11b30db8c3 --- /dev/null +++ b/Templates/CMakeLists.txt @@ -0,0 +1,9 @@ +# +# 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 +# +# + +ly_install_directory(DIRECTORY .) diff --git a/Tools/CMakeLists.txt b/Tools/CMakeLists.txt new file mode 100644 index 0000000000..08958cd97e --- /dev/null +++ b/Tools/CMakeLists.txt @@ -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 +# +# + +add_subdirectory(LyTestTools) +add_subdirectory(RemoteConsole) diff --git a/Tools/LyTestTools/CMakeLists.txt b/Tools/LyTestTools/CMakeLists.txt new file mode 100644 index 0000000000..72321a8915 --- /dev/null +++ b/Tools/LyTestTools/CMakeLists.txt @@ -0,0 +1,14 @@ +# +# 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 +# +# + +# SPEC-1417 will investigate and fix this +if(NOT PAL_PLATFORM_NAME STREQUAL "Mac") + add_subdirectory(tests) +endif() + +ly_install_directory(DIRECTORY .) diff --git a/Tools/RemoteConsole/CMakeLists.txt b/Tools/RemoteConsole/CMakeLists.txt new file mode 100644 index 0000000000..cabe27c7ea --- /dev/null +++ b/Tools/RemoteConsole/CMakeLists.txt @@ -0,0 +1,14 @@ +# +# 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 +# +# + +# SPEC-1417 will investigate and fix this +if(NOT PAL_PLATFORM_NAME STREQUAL "Mac") + add_subdirectory(ly_remote_console/tests) +endif() + +ly_install_directory(DIRECTORY .) diff --git a/cmake/Install.cmake b/cmake/Install.cmake index 816fb2a372..81f323dc95 100644 --- a/cmake/Install.cmake +++ b/cmake/Install.cmake @@ -9,4 +9,88 @@ if(NOT INSTALLED_ENGINE) 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() \ No newline at end of file +endif() + +#! ly_install_directory: specifies a directory to be copied to the install layout at install time +# +# \arg:DIRECTORY directory to install +# \arg:DESTINATION (optional) destination to install the directory to (relative to CMAKE_PREFIX_PATH) +# \arg:EXCLUDE_PATTERNS (optional) patterns to exclude +# +# \notes: refer to cmake's install(DIRECTORY documentation for more information +# +function(ly_install_directory) + + set(options) + set(oneValueArgs DIRECTORY DESTINATION) + set(multiValueArgs EXCLUDE_PATTERNS) + + cmake_parse_arguments(ly_install_directory "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(NOT ly_install_directory_DIRECTORY) + message(FATAL_ERROR "You must provide a directory to install") + endif() + + if(NOT ly_install_directory_DESTINATION) + # maintain the same structure relative to LY_ROOT_FOLDER + set(ly_install_directory_DESTINATION ${ly_install_directory_DIRECTORY}) + if(${ly_install_directory_DESTINATION} STREQUAL ".") + set(ly_install_directory_DESTINATION ${CMAKE_CURRENT_LIST_DIR}) + else() + cmake_path(ABSOLUTE_PATH ly_install_directory_DESTINATION BASE_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) + endif() + # take out the last directory since install asks for the destination of the folder, without including the fodler itself + cmake_path(GET ly_install_directory_DESTINATION PARENT_PATH ly_install_directory_DESTINATION) + cmake_path(RELATIVE_PATH ly_install_directory_DESTINATION BASE_DIRECTORY ${LY_ROOT_FOLDER}) + endif() + + unset(exclude_patterns) + if(ly_install_directory_EXCLUDE_PATTERNS) + foreach(exclude_pattern ${ly_install_directory_EXCLUDE_PATTERNS}) + list(APPEND exclude_patterns PATTERN ${exclude_pattern} EXCLUDE) + endforeach() + endif() + + install(DIRECTORY ${ly_install_directory_DIRECTORY} + DESTINATION ${ly_install_directory_DESTINATION} + COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} # use the deafult for the time being + ${exclude_patterns} + ) + +endfunction() + +#! ly_install_files: specifies files to be copied to the install layout at install time +# +# \arg:FILES files to install +# \arg:DESTINATION (optional) destination to install the directory to (relative to CMAKE_PREFIX_PATH) +# \arg:PROGRAMS (optional) indicates if the files are programs that should be installed with EXECUTE permissions +# +# \notes: refer to cmake's install(DIRECTORY documentation for more information +# +function(ly_install_files) + + set(options PROGRAMS) + set(oneValueArgs DESTINATION) + set(multiValueArgs FILES) + + cmake_parse_arguments(ly_install_files "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(NOT ly_install_files_FILES) + message(FATAL_ERROR "You must provide a list of files to install") + endif() + if(NOT ly_install_files_DESTINATION) + message(FATAL_ERROR "You must provide a destination to install filest to") + endif() + + if(ly_install_files_PROGRAMS) + set(install_type PROGRAMS) + else() + set(install_type FILES) + endif() + + install(${install_type} ${ly_install_files_FILES} + DESTINATION ${ly_install_files_DESTINATION} + COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} # use the deafult for the time being + ) + +endfunction() \ No newline at end of file diff --git a/cmake/Platform/Common/Install_common.cmake b/cmake/Platform/Common/Install_common.cmake index 2b56a1f0b4..bee2349e75 100644 --- a/cmake/Platform/Common/Install_common.cmake +++ b/cmake/Platform/Common/Install_common.cmake @@ -355,9 +355,16 @@ function(ly_setup_o3de_install) ly_setup_subdirectories() ly_setup_cmake_install() - ly_setup_target_generator() ly_setup_runtime_dependencies() - ly_setup_others() + ly_setup_assets() + + # Misc + install(FILES + ${LY_ROOT_FOLDER}/ctest_pytest.ini + ${LY_ROOT_FOLDER}/LICENSE.txt + ${LY_ROOT_FOLDER}/README.md + DESTINATION . + ) endfunction() @@ -488,75 +495,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}" - ) + install(CODE "${runtime_commands_str}") endfunction() -#! ly_setup_others: install directories required by the engine -function(ly_setup_others) - - # List of directories we want to install relative to engine root - set(DIRECTORIES_TO_INSTALL Tools/LyTestTools Tools/RemoteConsole) - foreach(dir ${DIRECTORIES_TO_INSTALL}) - - get_filename_component(install_path ${dir} DIRECTORY) - if (NOT install_path) - set(install_path .) - endif() - - install(DIRECTORY "${LY_ROOT_FOLDER}/${dir}" - DESTINATION ${install_path} - PATTERN "__pycache__" EXCLUDE - ) - - endforeach() - - # Scripts - file(GLOB o3de_scripts "${LY_ROOT_FOLDER}/scripts/o3de.*") - install(PROGRAMS - ${o3de_scripts} - DESTINATION ./scripts - ) - - install(DIRECTORY - ${LY_ROOT_FOLDER}/scripts/bundler - ${LY_ROOT_FOLDER}/scripts/o3de - DESTINATION ./scripts - PATTERN "__pycache__" EXCLUDE - PATTERN "CMakeLists.txt" EXCLUDE - PATTERN "tests" EXCLUDE - ) - - install(DIRECTORY "${LY_ROOT_FOLDER}/python" - DESTINATION . - REGEX "downloaded_packages" EXCLUDE - REGEX "runtime" EXCLUDE - REGEX ".*$\.sh" EXCLUDE - ) - - # For Mac/Linux shell scripts need to be installed as PROGRAMS to have execute permission - file(GLOB python_scripts "${LY_ROOT_FOLDER}/python/*.sh") - install(PROGRAMS - ${python_scripts} - DESTINATION ./python - ) - - # Registry - install(DIRECTORY - ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$/Registry - DESTINATION ./${runtime_output_directory}/${PAL_PLATFORM_NAME}/$ - ) - install(DIRECTORY - ${LY_ROOT_FOLDER}/Registry - DESTINATION . - ) - - # Engine Source Assets - install(DIRECTORY - ${LY_ROOT_FOLDER}/Assets - DESTINATION . - ) +#! ly_setup_assets: install asset directories required by the engine +function(ly_setup_assets) # Gem Source Assets and configuration files # Find all gem directories relative to the CMake Source Dir @@ -645,80 +589,4 @@ function(ly_setup_others) endforeach() - # Templates - install(DIRECTORY - ${LY_ROOT_FOLDER}/Templates - DESTINATION . - ) - - # Misc - install(FILES - ${LY_ROOT_FOLDER}/ctest_pytest.ini - ${LY_ROOT_FOLDER}/LICENSE.txt - ${LY_ROOT_FOLDER}/README.md - DESTINATION . - ) - -endfunction() - -#! ly_setup_target_generator: install source files needed for project launcher generation -function(ly_setup_target_generator) - - install(FILES - ${LY_ROOT_FOLDER}/Code/LauncherUnified/launcher_generator.cmake - ${LY_ROOT_FOLDER}/Code/LauncherUnified/launcher_project_files.cmake - ${LY_ROOT_FOLDER}/Code/LauncherUnified/LauncherProject.cpp - ${LY_ROOT_FOLDER}/Code/LauncherUnified/StaticModules.in - DESTINATION LauncherGenerator - ) - install(DIRECTORY ${LY_ROOT_FOLDER}/Code/LauncherUnified/Platform - DESTINATION LauncherGenerator - ) - install(FILES ${LY_ROOT_FOLDER}/Code/LauncherUnified/FindLauncherGenerator.cmake - DESTINATION cmake - ) - -endfunction() - -#! ly_add_install_paths: Adds the list of path to copy to the install layout relative to the same folder -# \arg:PATHS - Paths to copy over to the install layout. The DESTINATION sub argument is optional -# The INPUT sub-argument is required -# \arg:BASE_DIRECTORY(Optional) - Absolute path where a relative path from the each input path will be -# based off of. Defaults to LY_ROOT_FOLDER if not supplied -function(ly_add_install_paths) - set(options) - set(oneValueArgs BASE_DIRECTORY) - set(multiValueArgs PATHS) - cmake_parse_arguments(ly_add_install_paths "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - if(NOT ly_add_install_paths_PATHS) - message(FATAL_ERROR "ly_add_install_paths requires at least one input path to copy to the destination") - endif() - - # The default is the "." directory if not supplied - if(NOT ly_add_install_paths_BASE_DIRECTORY) - cmake_path(SET ly_add_install_paths_BASE_DIRECTORY ${LY_ROOT_FOLDER}) - endif() - - # Separate each path into an INPUT and DESTINATION parameter - set(options) - set(oneValueArgs INPUT DESTINATION) - set(multiValueArgs) - foreach(install_path IN LISTS ly_add_install_paths_PATHS) - string(REPLACE " " ";" install_path ${install_path}) - cmake_parse_arguments(install "${options}" "${oneValueArgs}" "${multiValueArgs}" ${install_path}) - if(NOT install_DESTINATION) - ly_get_engine_relative_source_dir(${install_INPUT} rel_to_root_input_path - BASE_DIRECTORY ${ly_add_install_paths_BASE_DIRECTORY}) - cmake_path(GET rel_to_root_input_path PARENT_PATH install_DESTINATION) - endif() - if(NOT install_DESTINATION) - cmake_path(SET install_DESTINATION .) - endif() - if(IS_DIRECTORY ${install_INPUT}) - install(DIRECTORY ${install_INPUT} DESTINATION ${install_DESTINATION}) - elseif(EXISTS ${install_INPUT}) - install(FILES ${install_INPUT} DESTINATION ${install_DESTINATION}) - endif() - endforeach() - endfunction() diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt new file mode 100644 index 0000000000..4e49c6396a --- /dev/null +++ b/python/CMakeLists.txt @@ -0,0 +1,24 @@ +# +# 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 +# +# + +# common files to all platforms +ly_install_files( + FILES + get_python.cmake + readme.md + requirements.txt + DESTINATION python +) + +# platform specific files (they are PROGRAMS) +include(Platform/${PAL_PLATFORM_NAME}/install_files_${PAL_PLATFORM_NAME_LOWERCASE}.cmake) +ly_install_files( + FILES ${install_files} + PROGRAMS + DESTINATION python +) diff --git a/python/Platform/Linux/install_files_linux.cmake b/python/Platform/Linux/install_files_linux.cmake new file mode 100644 index 0000000000..e6ce1f2701 --- /dev/null +++ b/python/Platform/Linux/install_files_linux.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 +# +# + +set(install_files + get_python.sh + pip.sh + python.sh +) diff --git a/python/Platform/Mac/install_files_mac.cmake b/python/Platform/Mac/install_files_mac.cmake new file mode 100644 index 0000000000..e6ce1f2701 --- /dev/null +++ b/python/Platform/Mac/install_files_mac.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 +# +# + +set(install_files + get_python.sh + pip.sh + python.sh +) diff --git a/python/Platform/Windows/install_files_windows.cmake b/python/Platform/Windows/install_files_windows.cmake new file mode 100644 index 0000000000..df9a88ba1c --- /dev/null +++ b/python/Platform/Windows/install_files_windows.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 +# +# + +set(install_files + get_python.bat + pip.cmd + python.cmd +) diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 14cc7f0be1..5dcd739fb4 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -6,6 +6,7 @@ # # +add_subdirectory(bundler) add_subdirectory(detect_file_changes) add_subdirectory(commit_validation) add_subdirectory(o3de) diff --git a/scripts/bundler/CMakeLists.txt b/scripts/bundler/CMakeLists.txt new file mode 100644 index 0000000000..3642b34cbc --- /dev/null +++ b/scripts/bundler/CMakeLists.txt @@ -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 +# +# + +ly_install_directory(DIRECTORY . + EXCLUDE_PATTERNS + __pycache__ + CMakeLists.txt +) diff --git a/scripts/o3de/CMakeLists.txt b/scripts/o3de/CMakeLists.txt index 48b8a1e801..3c60fa4b16 100644 --- a/scripts/o3de/CMakeLists.txt +++ b/scripts/o3de/CMakeLists.txt @@ -7,3 +7,16 @@ # add_subdirectory(tests) + +file(GLOB o3de_scripts "${LY_ROOT_FOLDER}/scripts/o3de.*") +ly_install_files(FILES ${o3de_scripts} +PROGRAMS + DESTINATION ./scripts +) + +ly_install_directory(DIRECTORY . + EXCLUDE_PATTERNS + __pycache__ + CMakeLists.txt + tests +)