Create Deploy Script that can copy a Project Game Release Layout to a standalone location

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
Esteban Papp
2021-09-03 13:28:22 -07:00
committed by GitHub
33 changed files with 197 additions and 92 deletions
+4 -14
View File
@@ -305,21 +305,11 @@ endfunction()
# \arg:3RDPARTY_ROOT_DIRECTORY custom 3rd party directory which needs to be installed
function(ly_install_external_target 3RDPARTY_ROOT_DIRECTORY)
# Install the Find file to our <install_location>/cmake directory
install(FILES ${CMAKE_CURRENT_LIST_FILE}
DESTINATION cmake
# Install the Find file to our <install_location>/cmake/3rdParty directory
ly_install_files(FILES ${CMAKE_CURRENT_LIST_FILE}
DESTINATION cmake/3rdParty
)
# We only want to install external targets that are part of our source tree
# Checking for relative path beginning with "../" also works when the path
# given is on another drive letter on windows(i.e., RELATIVE_PATH returns an absolute path)
file(RELATIVE_PATH rel_path ${CMAKE_SOURCE_DIR} ${3RDPARTY_ROOT_DIRECTORY})
if (NOT ${rel_path} MATCHES "^../")
get_filename_component(rel_path ${rel_path} DIRECTORY)
install(DIRECTORY ${3RDPARTY_ROOT_DIRECTORY}
DESTINATION ${rel_path}
)
endif()
ly_install_directory(DIRECTORIES ${3RDPARTY_ROOT_DIRECTORY})
endfunction()
+32 -2
View File
@@ -6,7 +6,12 @@
#
#
if(NOT INSTALLED_ENGINE)
ly_set(LY_INSTALL_ENABLED TRUE)
if(INSTALLED_ENGINE)
ly_set(LY_INSTALL_ENABLED FALSE)
endif()
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()
@@ -27,6 +32,10 @@ endif()
#
function(ly_install_directory)
if(NOT LY_INSTALL_ENABLED)
return()
endif()
set(options VERBATIM)
set(oneValueArgs DESTINATION)
set(multiValueArgs DIRECTORIES EXCLUDE_PATTERNS)
@@ -91,6 +100,10 @@ endfunction()
#
function(ly_install_files)
if(NOT LY_INSTALL_ENABLED)
return()
endif()
set(options PROGRAMS)
set(oneValueArgs DESTINATION)
set(multiValueArgs FILES)
@@ -121,4 +134,21 @@ function(ly_install_files)
COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} # use the default for the time being
)
endfunction()
endfunction()
#! ly_install_run_code: specifies code to be added to the install process (will run at install time)
#
# \notes:
# - refer to cmake's install(CODE documentation for more information
#
function(ly_install_run_code CODE)
if(NOT LY_INSTALL_ENABLED)
return()
endif()
install(CODE ${CODE}
COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} # use the default for the time being
)
endfunction()
+4 -2
View File
@@ -13,5 +13,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin CACHE PATH "Build dir
# We install outside of the binary dir because our install support muliple platforms to
# be installed together. We also have an exclusion rule in the AP that filters out the
# "build" folder which is a common binary dir
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/install CACHE PATH "Installation prefix")
# "install" folder to avoid the AP picking it up
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/install CACHE PATH "Install directory" FORCE)
endif()
+36 -15
View File
@@ -38,9 +38,6 @@ function(ly_setup_target OUTPUT_CONFIGURED_TARGET ALIAS_TARGET_NAME absolute_tar
# Get the target source directory relative to the LY root folder
ly_get_engine_relative_source_dir(${absolute_target_source_dir} relative_target_source_dir)
# get the component ID. if the property isn't set for the target, it will auto fallback to use CMAKE_INSTALL_DEFAULT_COMPONENT_NAME
get_property(install_component TARGET ${TARGET_NAME} PROPERTY INSTALL_COMPONENT)
# All include directories marked PUBLIC or INTERFACE will be installed. We dont use PUBLIC_HEADER because in order to do that
# we need to set the PUBLIC_HEADER property of the target for all the headers we are exporting. After doing that, installing the
# headers end up in one folder instead of duplicating the folder structure of the public/interface include directory.
@@ -69,7 +66,7 @@ function(ly_setup_target OUTPUT_CONFIGURED_TARGET ALIAS_TARGET_NAME absolute_tar
install(DIRECTORY ${include_directory}
DESTINATION ${destination_dir}
COMPONENT ${install_component}
COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}
FILES_MATCHING
PATTERN *.h
PATTERN *.hpp
@@ -108,13 +105,13 @@ function(ly_setup_target OUTPUT_CONFIGURED_TARGET ALIAS_TARGET_NAME absolute_tar
TARGETS ${TARGET_NAME}
ARCHIVE
DESTINATION ${archive_output_directory}/${PAL_PLATFORM_NAME}/$<CONFIG>
COMPONENT ${install_component}
COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}
LIBRARY
DESTINATION ${library_output_directory}/${PAL_PLATFORM_NAME}/$<CONFIG>/${target_library_output_subdirectory}
COMPONENT ${install_component}
COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}
RUNTIME
DESTINATION ${runtime_output_directory}/${PAL_PLATFORM_NAME}/$<CONFIG>/${target_runtime_output_subdirectory}
COMPONENT ${install_component}
COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}
)
endif()
@@ -271,7 +268,7 @@ set_property(TARGET ${NAME_PLACEHOLDER}
file(GENERATE OUTPUT "${target_install_source_dir}/${NAME_PLACEHOLDER}_$<CONFIG>.cmake" CONTENT "${target_file_contents}")
install(FILES "${target_install_source_dir}/${NAME_PLACEHOLDER}_$<CONFIG>.cmake"
DESTINATION ${relative_target_source_dir}
COMPONENT ${install_component}
COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}
)
# Since a CMakeLists.txt could contain multiple targets, we generate it in a folder per target
@@ -320,12 +317,9 @@ function(ly_setup_subdirectory absolute_target_source_dir)
"${ENABLE_GEMS_PLACEHOLDER}"
)
# get the component ID. if the property isn't set for the directory, it will auto fallback to use CMAKE_INSTALL_DEFAULT_COMPONENT_NAME
get_property(install_component DIRECTORY ${absolute_target_source_dir} PROPERTY INSTALL_COMPONENT)
install(FILES "${target_install_source_dir}/CMakeLists.txt"
DESTINATION ${relative_target_source_dir}
COMPONENT ${install_component}
COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}
)
endfunction()
@@ -344,6 +338,7 @@ function(ly_setup_o3de_install)
${LY_ROOT_FOLDER}/LICENSE.txt
${LY_ROOT_FOLDER}/README.md
DESTINATION .
COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}
)
endfunction()
@@ -353,6 +348,7 @@ function(ly_setup_cmake_install)
install(DIRECTORY "${LY_ROOT_FOLDER}/cmake"
DESTINATION .
COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}
PATTERN "__pycache__" EXCLUDE
REGEX "Findo3de.cmake" EXCLUDE
REGEX "Platform\/.*\/BuiltInPackages_.*\.cmake" EXCLUDE
@@ -380,18 +376,32 @@ function(ly_setup_cmake_install)
"${LY_ROOT_FOLDER}/CMakeLists.txt"
"${CMAKE_CURRENT_BINARY_DIR}/cmake/engine.json"
DESTINATION .
COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}
)
# Collect all Find files that were added with ly_add_external_target_path
unset(additional_find_files)
unset(additional_platform_files)
get_property(additional_module_paths GLOBAL PROPERTY LY_ADDITIONAL_MODULE_PATH)
foreach(additional_module_path ${additional_module_paths})
unset(find_files)
file(GLOB find_files "${additional_module_path}/Find*.cmake")
list(APPEND additional_find_files "${find_files}")
foreach(find_file ${find_files})
# also copy the Platform/<current_platform> to the destination
cmake_path(GET find_file PARENT_PATH find_file_parent)
unset(plat_files)
file(GLOB plat_files "${find_file_parent}/Platform/${PAL_PLATFORM_NAME}/*.cmake")
list(APPEND additional_platform_files "${plat_files}")
endforeach()
endforeach()
install(FILES ${additional_find_files}
DESTINATION cmake/3rdParty
COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}
)
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.camke file than the one we have in cmake. This one is going to expose all
@@ -408,6 +418,7 @@ function(ly_setup_cmake_install)
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"
DESTINATION cmake
COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}
)
# BuiltInPackage_<platform>.cmake: since associations could happen in any cmake file across the engine. We collect
@@ -427,6 +438,7 @@ function(ly_setup_cmake_install)
)
install(FILES "${pal_builtin_file}"
DESTINATION cmake/3rdParty/Platform/${PAL_PLATFORM_NAME}
COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}
)
endfunction()
@@ -442,6 +454,7 @@ function(ly_setup_runtime_dependencies)
"function(ly_copy source_file target_directory)
file(COPY \"\${source_file}\" DESTINATION \"\${target_directory}\" FILE_PERMISSIONS ${LY_COPY_PERMISSIONS})
endfunction()"
COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}
)
endif()
@@ -476,7 +489,9 @@ 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}"
COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}
)
endfunction()
@@ -562,9 +577,15 @@ function(ly_setup_assets)
cmake_path(SET gem_install_dest_dir .)
endif()
if(IS_DIRECTORY ${gem_absolute_path})
install(DIRECTORY "${gem_absolute_path}" DESTINATION ${gem_install_dest_dir})
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} DESTINATION ${gem_install_dest_dir})
install(FILES ${gem_absolute_path}
DESTINATION ${gem_install_dest_dir}
COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}
)
endif()
endforeach()
+3 -1
View File
@@ -22,7 +22,9 @@ endfunction()]])
function(ly_install_code_function_override)
string(CONFIGURE "${ly_copy_template}" ly_copy_function_linux @ONLY)
install(CODE "${ly_copy_function_linux}")
install(CODE "${ly_copy_function_linux}"
COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}
)
endfunction()
include(cmake/Platform/Common/Install_common.cmake)
+8 -8
View File
@@ -42,8 +42,6 @@ function(ly_install_target_override)
set(multiValueArgs)
cmake_parse_arguments(ly_platform_install_target "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
get_property(install_component TARGET ${ly_platform_install_target_TARGET} PROPERTY INSTALL_COMPONENT)
# For bundles on Mac, we set the icons by passing in a path to the Images.xcassets directory.
# However, the CMake install command expects paths to files for the the RESOURCE property.
# More details can be found in the CMake issue: https://gitlab.kitware.com/cmake/cmake/-/issues/22409
@@ -57,19 +55,19 @@ function(ly_install_target_override)
TARGETS ${ly_platform_install_target_TARGET}
ARCHIVE
DESTINATION ${ly_platform_install_target_ARCHIVE_DIR}/${PAL_PLATFORM_NAME}/$<CONFIG>
COMPONENT ${install_component}
COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}
LIBRARY
DESTINATION ${ly_platform_install_target_LIBRARY_DIR}/${PAL_PLATFORM_NAME}/$<CONFIG>/${ly_platform_install_target_LIBRARY_SUBDIR}
COMPONENT ${install_component}
COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}
RUNTIME
DESTINATION ${ly_platform_install_target_RUNTIME_DIR}/${PAL_PLATFORM_NAME}/$<CONFIG>/${ly_platform_install_target_RUNTIME_SUBDIR}
COMPONENT ${install_component}
COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}
BUNDLE
DESTINATION ${ly_platform_install_target_RUNTIME_DIR}/${PAL_PLATFORM_NAME}/$<CONFIG>/${ly_platform_install_target_RUNTIME_SUBDIR}
COMPONENT ${install_component}
COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}
RESOURCE
DESTINATION ${ly_platform_install_target_RUNTIME_DIR}/${PAL_PLATFORM_NAME}/$<CONFIG>/${ly_platform_install_target_RUNTIME_SUBDIR}/
COMPONENT ${install_component}
COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}
)
if (${is_bundle})
@@ -95,7 +93,9 @@ function(ly_install_code_function_override)
endif()
file(COPY \"\${source_file}\" DESTINATION \"\${target_directory}\" FILE_PERMISSIONS ${LY_COPY_PERMISSIONS})
endfunction()")
endfunction()"
COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}
)
endfunction()
+17
View File
@@ -142,6 +142,23 @@ foreach(project ${LY_PROJECTS})
add_subdirectory(${project} "${project_folder_name}-${full_directory_hash}")
ly_generate_project_build_path_setreg(${full_directory_path})
add_project_json_external_subdirectories(${full_directory_path})
# Generate pak for project in release installs
cmake_path(RELATIVE_PATH CMAKE_RUNTIME_OUTPUT_DIRECTORY BASE_DIRECTORY ${CMAKE_BINARY_DIR} OUTPUT_VARIABLE runtime_output_directory)
set(install_engine_pak_template [=[
if("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Rr][Ee][Ll][Ee][Aa][Ss][Ee])$")
set(install_output_folder "${CMAKE_INSTALL_PREFIX}/@runtime_output_directory@/@PAL_PLATFORM_NAME@/${CMAKE_INSTALL_CONFIG_NAME}")
message(STATUS "Generating ${install_output_folder}/Engine.pak from @full_directory_path@/Cache")
file(ARCHIVE_CREATE OUTPUT ${install_output_folder}/Engine.pak
PATHS @full_directory_path@/Cache
FORMAT zip
)
message(STATUS "${install_output_folder}/Engine.pak generated")
endif()
]=])
string(CONFIGURE "${install_engine_pak_template}" install_engine_pak_code @ONLY)
ly_install_run_code("${install_engine_pak_code}")
endforeach()
# If just one project is defined we pass it as a parameter to the applications
+7 -1
View File
@@ -118,6 +118,12 @@ endfunction()
# The generated file contains the file to the each dependent targets
# This can be used for example to determine which list of gems to load with an application
function(ly_delayed_generate_settings_registry)
if(LY_MONOLITHIC_GAME) # No need to generate setregs for monolithic builds
set_property(GLOBAL PROPERTY LY_DELAYED_LOAD_DEPENDENCIES) # Clear out the load targets from the global load dependencies list
return()
endif()
get_property(ly_delayed_load_targets GLOBAL PROPERTY LY_DELAYED_LOAD_DEPENDENCIES)
foreach(prefix_target ${ly_delayed_load_targets})
string(REPLACE "," ";" prefix_target_list "${prefix_target}")
@@ -201,7 +207,7 @@ function(ly_delayed_generate_settings_registry)
set_property(GLOBAL PROPERTY LY_DELAYED_LOAD_"${prefix_target}")
endforeach()
# Clear out the load targets from the glboal load dependencies list
# Clear out the load targets from the global load dependencies list
set_property(GLOBAL PROPERTY LY_DELAYED_LOAD_DEPENDENCIES)
endfunction()