Cherry-pick of Linux deb package to stabilization (#5778)

* Cherry-pick 49e8f35858

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>
This commit is contained in:
Esteban Papp
2021-11-19 14:07:25 -08:00
committed by GitHub
parent 3cf3e45b38
commit dbc5d7a8bc
67 changed files with 1475 additions and 743 deletions
+131 -71
View File
@@ -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_$<CONFIG>
# - Monolithic
# - Monolithic_$<CONFIG>
# 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}_$<CONFIG>.cmake" CONTENT "${target_file_contents}")
install(FILES "${target_install_source_dir}/Platform/${PAL_PLATFORM_NAME}/${LY_BUILD_PERMUTATION}/${NAME_PLACEHOLDER}_$<CONFIG>.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_<CONFIG>.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_<CONFIG>.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 <someprefix>` 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()
endfunction()
@@ -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()
@@ -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
#
#
@@ -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/$<CONFIG>/${target}_$<CONFIG>.stamp)
set(STAMP_OUTPUT_FILE ${CMAKE_BINARY_DIR}/runtime_dependencies/$<CONFIG>/${target}.stamp)
set(target_file_dir "$<TARGET_FILE_DIR:${target}>")
set(target_file "$<TARGET_FILE:${target}>")
ly_file_read(${LY_RUNTIME_DEPENDENCIES_TEMPLATE} template_file)
@@ -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()