8b8a582f02
* Updated the DynamicModuleHandle code to search within the
SettingsRegistry for the FilePathKey_ProjectBuildPath setting in order
to determine the binary directory for the Project.
This is used to locate shared libraries and executables built by the
project when running and Engine SDK binary from within the Engine SDK
* Added a generation step within the Projects.cmake file to generate a
.setreg file containing the CMake build directory root.
The file is output to the <project-root>/user/Registry/build_path.setreg
file.
This occurs only on non-host platforms when configuring for
non-Monolithic builds, since the Build Directory is used to located the
project binary directory in order to located the project's generated
${CMAKE_BINARY_DIR}/bin/$<CONFIG>/Registry directory containing the
cmake_dependencies.<project-name>.<application-name>.setreg file
containing the list of gem modules to load for a given application
Updated the SettingsRegistryMergeUtils AddRuntimeFilePaths function to
be read in the new "/Amazon/Project/Settings/Build/project_build_path"
and use that to form an absolute path to the project build directory by
appending it to the FilePathKey_ProjectPath key.
That key is set in the 'FilePathKey_ProjectBuildPath' constant
Next updated the SettingsRegistryMergeUtils
MergeSettingsToRegistry_TargetBuildDependencyRegistry function to look
within the project build directory to locate the
cmake_dependencies.*.setreg file to load
Tweaked the Settings Registry merge order of the ComponentApplication,
GameApplication and Settings Registry builder to merge the command line
after merging the global user registry and after merging the project
user registry.
Moved the call to MergeSettingsToRegistry_TargetBuildDependencyRegistry
to occur after the above calls to make sure the properly overriden
projects' user registry was merged in order for the correct project
build path to be stored in the SettingsRegistry
* Added a ProjectConfigurationBinPath key which contains the path to the <build-dir>/bin/$<CONFIG> directory for a project which is used to load gem dlls and the Registry/cmake_dependencies.*.setreg files when using an pre-built Editor/AssetProcessor on an external project
* Fixed variable reference to fileNamePath variable
* Removing the default Project Build Path from the Settings Registry
Runtime Filepaths.
Any paths would have to be set explicitly via .setreg/.setregpatch file
or the --project-build-path parameter
Updated the setting of the project build path and project binary
directory to perform existance checks on the paths before setting the
keys of /Amazon/AzCore/Runtime/FilePaths/ProjectBuildPath and
/Amazon/AzCore/Runtime/FilePaths/ProjectConfigurationBinPath
Added a backup project binary path of
<project-build-path>/bin/$<PLATFORM>/$<CONFIG> which is used if the path
of <project-build-path>/bin/$<CONFIG> has not been found
Fixed compile error in DynamicModuleHandle_Apple.cpp
* UnixLike Platform Build fix for the DynamicModuleHandle code
168 lines
8.4 KiB
CMake
168 lines
8.4 KiB
CMake
#
|
|
# 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.
|
|
#
|
|
|
|
# Deals with projects (e.g. game gems)
|
|
|
|
include_guard()
|
|
|
|
set(LY_PROJECTS "${LY_PROJECTS}" CACHE STRING "List of projects to enable, this can be a relative path to the engine root or an absolute path")
|
|
|
|
#! ly_add_target_dependencies: adds module load dependencies for this target.
|
|
#
|
|
# Each target may have dependencies on gems. To properly define these dependencies, users provides
|
|
# this build target a list of dependencies that need to load dynamically when this target executes
|
|
# So for example, the PythonBindingExample target adds a dependency on the EditorPythonBindings gem
|
|
# via a tool dependencies file
|
|
#
|
|
# \arg:PREFIX(optional) value to prefix to the generated cmake_dependencies .setreg file for each target
|
|
# found in the DEPENDENCIES_FILES. The PREFIX and each dependent target will be joined using the <dot> symbol
|
|
# \arg:TARGETS names of the targets to associate the dependencies to
|
|
# \arg:DEPENDENCIES_FILES file(s) that contains the load-time dependencies the TARGETS will be associated to
|
|
# \arg:DEPENDENT_TARGETS additional list of targets should be added as load-time dependencies for the TARGETS list
|
|
#
|
|
function(ly_add_target_dependencies)
|
|
|
|
set(options)
|
|
set(oneValueArgs PREFIX)
|
|
set(multiValueArgs TARGETS DEPENDENCIES_FILES DEPENDENT_TARGETS)
|
|
|
|
cmake_parse_arguments(ly_add_gem_dependencies "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
|
|
# Validate input arguments
|
|
if(NOT ly_add_gem_dependencies_TARGETS)
|
|
message(FATAL_ERROR "You must provide at least one target to associate the dependencies with")
|
|
endif()
|
|
|
|
if(NOT ly_add_gem_dependencies_DEPENDENCIES_FILES AND NOT ly_add_gem_dependencies_DEPENDENT_TARGETS)
|
|
message(FATAL_ERROR "DEPENDENCIES_FILES parameter missing. It must be supplied unless the DEPENDENT_TARGETS parameter is set")
|
|
endif()
|
|
|
|
unset(ALL_GEM_DEPENDENCIES)
|
|
foreach(dependency_file ${ly_add_gem_dependencies_DEPENDENCIES_FILES})
|
|
#unset any GEM_DEPENDENCIES and include the dependencies file, that should populate GEM_DEPENDENCIES
|
|
unset(GEM_DEPENDENCIES)
|
|
include(${dependency_file})
|
|
list(APPEND ALL_GEM_DEPENDENCIES ${GEM_DEPENDENCIES})
|
|
endforeach()
|
|
|
|
# Append the DEPENDENT_TARGETS to the list of ALL_GEM_DEPENDENCIES
|
|
list(APPEND ALL_GEM_DEPENDENCIES ${ly_add_gem_dependencies_DEPENDENT_TARGETS})
|
|
|
|
# for each target, add the dependencies and generate gems json
|
|
foreach(target ${ly_add_gem_dependencies_TARGETS})
|
|
ly_add_dependencies(${target} ${ALL_GEM_DEPENDENCIES})
|
|
|
|
# Add the target to the LY_DELAYED_LOAD_DEPENDENCIES if it isn't already on the list
|
|
get_property(delayed_load_target_set GLOBAL PROPERTY LY_DELAYED_LOAD_"${ly_add_gem_dependencies_PREFIX},${target}" SET)
|
|
if(NOT delayed_load_target_set)
|
|
set_property(GLOBAL APPEND PROPERTY LY_DELAYED_LOAD_DEPENDENCIES "${ly_add_gem_dependencies_PREFIX},${target}")
|
|
endif()
|
|
foreach(gem_target ${ALL_GEM_DEPENDENCIES})
|
|
# Add the list of gem dependencies to the LY_TARGET_DELAYED_DEPENDENCIES_${ly_add_gem_dependencies_PREFIX};${target} property
|
|
set_property(GLOBAL APPEND PROPERTY LY_DELAYED_LOAD_"${ly_add_gem_dependencies_PREFIX},${target}" ${gem_target})
|
|
endforeach()
|
|
endforeach()
|
|
endfunction()
|
|
|
|
#! ly_add_project_dependencies: adds the dependencies to runtime and tools for this project.
|
|
#
|
|
# Each project may have dependencies to gems. To properly define these dependencies, we are making the project to define
|
|
# through a "files list" cmake file the dependencies to the different targets.
|
|
# So for example, the game's runtime dependencies are associated to the project's launcher; the game's tools dependencies
|
|
# are associated to the asset processor; etc
|
|
#
|
|
# \arg:PROJECT_NAME name of the game project
|
|
# \arg:TARGETS names of the targets to associate the dependencies to
|
|
# \arg:DEPENDENCIES_FILES file(s) that contains the runtime dependencies the TARGETS will be associated to
|
|
# \arg:DEPENDENT_TARGETS additional list of targets should be added as load-time dependencies for the TARGETS list
|
|
#
|
|
function(ly_add_project_dependencies)
|
|
|
|
set(options)
|
|
set(oneValueArgs PROJECT_NAME)
|
|
set(multiValueArgs TARGETS DEPENDENCIES_FILES DEPENDENT_TARGETS)
|
|
|
|
cmake_parse_arguments(ly_add_project_dependencies "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
|
|
# Validate input arguments
|
|
if(NOT ly_add_project_dependencies_PROJECT_NAME)
|
|
message(FATAL_ERROR "PROJECT_NAME parameter missing. If not project name is needed, then call ly_add_target_dependencies directly")
|
|
endif()
|
|
|
|
ly_add_target_dependencies(
|
|
PREFIX ${ly_add_project_dependencies_PROJECT_NAME}
|
|
TARGETS ${ly_add_project_dependencies_TARGETS}
|
|
DEPENDENCIES_FILES ${ly_add_project_dependencies_DEPENDENCIES_FILES}
|
|
DEPENDENT_TARGETS ${ly_add_project_dependencies_DEPENDENT_TARGETS}
|
|
)
|
|
endfunction()
|
|
|
|
#template for generating the project build_path setreg
|
|
set(project_build_path_template [[
|
|
{
|
|
"Amazon": {
|
|
"Project": {
|
|
"Settings": {
|
|
"Build": {
|
|
"project_build_path": "@project_bin_path@"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}]]
|
|
)
|
|
|
|
|
|
#! ly_generate_project_build_path_setreg: Generates a .setreg file that contains an absolute path to the ${CMAKE_BINARY_DIR}
|
|
# This allows locate the directory where the project it's binaries are built to be located within the engine.
|
|
# Which are the shared libraries and launcher executables
|
|
# When an a pre-built engine application runs from a directory other than the project build directory, it needs
|
|
# to be able to locate the project build directory to determine the list of gems that the project depends on to load
|
|
# as well the location of those gems.
|
|
# For example if the project uses an external gem not associated with the engine, that gem's dlls/so/dylib files
|
|
# would be located within the project build directory and the engine SDK binary directory would need that info
|
|
|
|
# NOTE: This only needed for non-monolithic host platforms.
|
|
# This is because there are no dynamic gems to load on monolithic builds
|
|
# Furthermore the pre-built SDK engine applications such as the Editor and AssetProcessor
|
|
# can only run on the host platform
|
|
# \arg:project_real_path Full path to the o3de project directory
|
|
function(ly_generate_project_build_path_setreg project_real_path)
|
|
# The build path isn't needed on non-monolithic platforms
|
|
# Nor on any non-host platforms
|
|
if (LY_MONOLITHIC_GAME OR NOT PAL_TRAIT_BUILD_HOST_TOOLS)
|
|
return()
|
|
endif()
|
|
|
|
# Set the project_bin_path to the ${CMAKE_BINARY_DIR} to provide the configure template
|
|
# with the project build directory
|
|
set(project_bin_path ${CMAKE_BINARY_DIR})
|
|
string(CONFIGURE ${project_build_path_template} project_build_path_setreg_content @ONLY)
|
|
set(project_user_build_path_setreg_file ${project_real_path}/user/Registry/Platform/${PAL_PLATFORM_NAME}/build_path.setreg)
|
|
file(GENERATE OUTPUT ${project_user_build_path_setreg_file} CONTENT ${project_build_path_setreg_content})
|
|
endfunction()
|
|
|
|
# Add the projects here so the above function is found
|
|
foreach(project ${LY_PROJECTS})
|
|
file(REAL_PATH ${project} full_directory_path BASE_DIRECTORY ${CMAKE_SOURCE_DIR})
|
|
string(SHA256 full_directory_hash ${full_directory_path})
|
|
|
|
# Truncate the full_directory_hash down to 8 characters to avoid hitting the Windows 260 character path limit
|
|
# when the external subdirectory contains relative paths of significant length
|
|
string(SUBSTRING ${full_directory_hash} 0 8 full_directory_hash)
|
|
|
|
get_filename_component(project_folder_name ${project} NAME)
|
|
list(APPEND LY_PROJECTS_FOLDER_NAME ${project_folder_name})
|
|
add_subdirectory(${project} "${project_folder_name}-${full_directory_hash}")
|
|
ly_generate_project_build_path_setreg(${full_directory_path})
|
|
endforeach()
|
|
ly_set(LY_PROJECTS_FOLDER_NAME ${LY_PROJECTS_FOLDER_NAME})
|