diff --git a/cmake/Packaging.cmake b/cmake/Packaging.cmake index 1656b49e88..b22b08d64b 100644 --- a/cmake/Packaging.cmake +++ b/cmake/Packaging.cmake @@ -14,11 +14,29 @@ if(NOT PAL_TRAIT_BUILD_CPACK_SUPPORTED) endif() # public facing options will be used for conversion into cpack specific ones below. -set(LY_INSTALLER_DOWNLOAD_URL "" CACHE STRING "URL embedded into the installer to download additional artifacts") set(LY_INSTALLER_LICENSE_URL "" CACHE STRING "Optionally embed a link to the license instead of raw text") + +set(LY_INSTALLER_AUTO_GEN_TAG OFF CACHE BOOL +"Automatically generate a build tag based on the git repo and append it to the download/upload URLs. \ +Format: /-" +) + +set(LY_INSTALLER_DOWNLOAD_URL "" CACHE STRING +"Base URL embedded into the installer to download additional artifacts, the host target and version \ +number will automatically appended as '/'. If LY_INSTALLER_AUTO_GEN_TAG is set, the \ +full URL format will be: //" +) + set(LY_INSTALLER_UPLOAD_URL "" CACHE STRING - "URL used to automatically upload the artifacts. Can also be set via LY_INSTALLER_UPLOAD_URL environment variable. 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.") +"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(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_DESIRED_CMAKE_VERSION 3.20.2) @@ -46,6 +64,10 @@ set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}/${CPACK_PACKAGE_VERSI set(CPACK_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/cmake) set(CPACK_BINARY_DIR ${CMAKE_BINARY_DIR}/_CPack) # to match other CPack out dirs +# 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) +set(CPACK_AUTO_GEN_TAG ${LY_INSTALLER_AUTO_GEN_TAG}) + # attempt to apply platform specific settings ly_get_absolute_pal_filename(pal_dir ${CPACK_SOURCE_DIR}/Platform/${PAL_HOST_PLATFORM_NAME}) include(${pal_dir}/Packaging_${PAL_HOST_PLATFORM_NAME_LOWERCASE}.cmake) @@ -120,8 +142,6 @@ function(strip_trailing_slash in_url out_url) endif() endfunction() -set(CPACK_VERSIONED_TARGET_TAG "${PAL_HOST_PLATFORM_NAME}-${LY_VERSION_STRING}") - if(NOT LY_INSTALLER_UPLOAD_URL AND DEFINED ENV{LY_INSTALLER_UPLOAD_URL}) set(LY_INSTALLER_UPLOAD_URL $ENV{LY_INSTALLER_UPLOAD_URL}) endif() diff --git a/cmake/PackagingConfig.cmake b/cmake/PackagingConfig.cmake new file mode 100644 index 0000000000..aaf7554115 --- /dev/null +++ b/cmake/PackagingConfig.cmake @@ -0,0 +1,52 @@ +# +# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +# its licensors. +# +# For complete copyright and license terms please see the LICENSE at the root of this +# distribution (the "License"). All use of this software is governed by the License, +# or, if provided, by the license below or the license accompanying this file. Do not +# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# + +set(_target_name ${CMAKE_HOST_SYSTEM_NAME}) +if(${_target_name} STREQUAL Darwin) + set(_target_name Mac) +endif() + +if(CPACK_AUTO_GEN_TAG) + set(_python_script python.sh) + if(${_target_name} STREQUAL WINDOWS) + set(_python_script python.cmd) + endif() + + file(REAL_PATH "${CPACK_SOURCE_DIR}/.." _root_path) + file(TO_NATIVE_PATH "${_root_path}/python/${_python_script}" _python_cmd) + file(TO_NATIVE_PATH "${_root_path}/scripts/build/tools/generate_build_tag.py" _gen_tag_script) + + execute_process( + COMMAND ${_python_cmd} -s -u ${_gen_tag_script} + RESULT_VARIABLE _gen_tag_result + OUTPUT_VARIABLE _gen_tag_output + ERROR_VARIABLE _gen_tag_errors + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_STRIP_TRAILING_WHITESPACE + ) + + if (NOT ${_gen_tag_result} EQUAL 0) + message(FATAL_ERROR "Failed to generate build tag!") + endif() + + set(_url_tag ${_gen_tag_output}) +else() + set(_url_tag ${CPACK_PACKAGE_VERSION}) +endif() + +set(_full_tag ${_url_tag}/${_target_name}) + +if(CPACK_DOWNLOAD_SITE) + set(CPACK_DOWNLOAD_SITE ${CPACK_DOWNLOAD_SITE}/${_full_tag}) +endif() +if(CPACK_UPLOAD_URL) + set(CPACK_UPLOAD_URL ${CPACK_UPLOAD_URL}/${_full_tag}) +endif() \ No newline at end of file diff --git a/cmake/Platform/Windows/PackagingPostBuild.cmake b/cmake/Platform/Windows/PackagingPostBuild.cmake index a28ce51f41..fae9e00e84 100644 --- a/cmake/Platform/Windows/PackagingPostBuild.cmake +++ b/cmake/Platform/Windows/PackagingPostBuild.cmake @@ -24,24 +24,10 @@ set(_ext_flags -ext WixBalExtension ) -set(_build_id_file ${CPACK_BINARY_DIR}/build_id.txt) -if(EXISTS ${_build_id_file}) - file(READ ${_build_id_file} _build_id) - - set(_full_download_url ${CPACK_DOWNLOAD_SITE}/${_build_id}/${CPACK_VERSIONED_TARGET_TAG}) - set(_full_upload_url ${CPACK_UPLOAD_URL}/${_build_id}/${CPACK_VERSIONED_TARGET_TAG}) -else() - # format: YYYY-MM-DD-HHmm UTC - string(TIMESTAMP _timestamp "%Y%-%m-%d-%H%m" UTC) - - set(_full_download_url ${CPACK_DOWNLOAD_SITE}/notag/${_timestamp}/${CPACK_VERSIONED_TARGET_TAG}) - set(_full_upload_url ${CPACK_UPLOAD_URL}/notag/${_timestamp}/${CPACK_VERSIONED_TARGET_TAG}) -endif() - set(_addtional_defines -dCPACK_BOOTSTRAP_THEME_FILE=${CPACK_BINARY_DIR}/BootstrapperTheme -dCPACK_BOOTSTRAP_UPGRADE_GUID=${CPACK_WIX_BOOTSTRAP_UPGRADE_GUID} - -dCPACK_DOWNLOAD_SITE=${_full_download_url} + -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} @@ -123,7 +109,7 @@ file(TO_NATIVE_PATH "${_root_path}/scripts/build/tools/upload_to_s3.py" _upload_ file(TO_NATIVE_PATH "${_cpack_wix_out_dir}" _cpack_wix_out_dir) # strip the scheme and extract the bucket/key prefix from the URL -string(REPLACE "s3://" "" _stripped_url ${_full_upload_url}) +string(REPLACE "s3://" "" _stripped_url ${CPACK_UPLOAD_URL}) string(REPLACE "/" ";" _tokens ${_stripped_url}) list(POP_FRONT _tokens _bucket) @@ -141,7 +127,7 @@ set(_upload_command --profile ${CPACK_AWS_PROFILE} ) -message(STATUS "Uploading artifacts to ${_full_upload_url}") +message(STATUS "Uploading artifacts to ${CPACK_UPLOAD_URL}") execute_process( COMMAND ${_upload_command} RESULT_VARIABLE _upload_result diff --git a/scripts/build/Platform/Windows/installer_windows.cmd b/scripts/build/Platform/Windows/installer_windows.cmd index 5deb4f931d..368658ea95 100644 --- a/scripts/build/Platform/Windows/installer_windows.cmd +++ b/scripts/build/Platform/Windows/installer_windows.cmd @@ -50,23 +50,6 @@ IF ERRORLEVEL 1 ( GOTO :popd_error ) -REM use the git info to generate an identifier used by the online installer urls -SET "BUILD_ID_FILE=_CPack\\build_id.txt" - -SET BRANCH_ID="" -REM limit branch separators to 6 -FOR /F "tokens=1-6 delims=/" %%a in ("!BRANCH_NAME!") DO ( - SET BRANCH_ID=%%a - if NOT "%%b"=="" SET BRANCH_ID=!BRANCH_ID!-%%b - if NOT "%%c"=="" SET BRANCH_ID=!BRANCH_ID!-%%c - if NOT "%%d"=="" SET BRANCH_ID=!BRANCH_ID!-%%d - if NOT "%%e"=="" SET BRANCH_ID=!BRANCH_ID!-%%e - if NOT "%%f"=="" SET BRANCH_ID=!BRANCH_ID!-%%f -) - -REM write out the build ID to disk so cpack can consume it -ECHO %BRANCH_ID%/%CHANGE_DATE%-%CHANGE_ID:~0,7% > "%BUILD_ID_FILE%" - ECHO [ci_build] "!CPACK_PATH!" -C %CONFIGURATION% "!CPACK_PATH!" -C %CONFIGURATION% IF NOT %ERRORLEVEL%==0 (