Removing the o3de_manifest.cmake file

Removed the EngineFinder.cmake file from the Engine cmake directory as it is only needed in a Project
Added an EngineJson.cmake which reads the "external_subdirectories" list from the engine.json file and calls add_subdirectory on it
Re-ordered the population of the generated gem dependency list to prepend the dependencies before the dependent targets
This commit is contained in:
lumberyard-employee-dm
2021-05-21 02:49:09 -05:00
parent e818bfe905
commit c90d446735
7 changed files with 164 additions and 1080 deletions
+5 -25
View File
@@ -25,10 +25,6 @@ include(cmake/LySet.cmake)
include(cmake/Version.cmake)
include(cmake/OutputDirectory.cmake)
# Set the engine_path and engine_json
set(o3de_engine_path ${CMAKE_CURRENT_LIST_DIR})
set(o3de_engine_json ${o3de_engine_path}/engine.json)
if(NOT PROJECT_NAME)
project(O3DE
LANGUAGES C CXX
@@ -36,21 +32,6 @@ if(NOT PROJECT_NAME)
)
endif()
################################################################################
# Resolve this engines name and restricted path
################################################################################
include(cmake/o3de_manifest.cmake)
o3de_engine_name(${o3de_engine_json} o3de_engine_name)
o3de_restricted_path(${o3de_engine_json} o3de_engine_restricted_path)
message(STATUS "O3DE Engine Name: ${o3de_engine_name}")
message(STATUS "O3DE Engine Path: ${o3de_engine_path}")
if(o3de_engine_restricted_path)
message(STATUS "O3DE Engine Restricted Path: ${o3de_engine_restricted_path}")
endif()
# add the engines cmake folder to the CMAKE_MODULE_PATH
list(APPEND CMAKE_MODULE_PATH "${o3de_engine_path}/cmake")
################################################################################
# Initialize
################################################################################
@@ -92,12 +73,11 @@ if(NOT INSTALLED_ENGINE)
add_subdirectory(Tools/RemoteConsole/ly_remote_console/tests/)
endif()
# Add any engine restricted platforms as external subdirs
o3de_add_engine_restricted_platform_external_subdirs()
# Add external subdirectories listed in the manifest. LY_EXTERNAL_SUBDIRS is a cache variable so the user can add extra
include(cmake/EngineJson.cmake)
# Add external subdirectories listed in the engine.json. LY_EXTERNAL_SUBDIRS is a cache variable so the user can add extra
# external subdirectories
list(APPEND LY_EXTERNAL_SUBDIRS ${o3de_engine_external_subdirectories})
read_engine_external_subdirs(engine_external_subdirectories)
list(APPEND LY_EXTERNAL_SUBDIRS ${engine_external_subdirectories})
# Loop over the additional external subdirectories and invoke add_subdirectory on them
foreach(external_directory ${LY_EXTERNAL_SUBDIRS})
@@ -111,7 +91,7 @@ if(NOT INSTALLED_ENGINE)
string(SUBSTRING ${full_directory_hash} 0 8 full_directory_hash)
# Use the last directory as the suffix path to use for the Binary Directory
get_filename_component(directory_name ${external_directory} NAME)
add_subdirectory(${external_directory} ${CMAKE_BINARY_DIR}/${directory_name}-${full_directory_hash})
add_subdirectory(${external_directory} ${CMAKE_BINARY_DIR}/External/${directory_name}-${full_directory_hash})
endforeach()
else()
-52
View File
@@ -1,52 +0,0 @@
#
# 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.
#
# This file is copied during engine registration. Edits to this file will be lost next
# time a registration happens.
include_guard()
# Read the engine name from the project_json file
file(READ ${CMAKE_CURRENT_LIST_DIR}/project.json project_json)
string(JSON LY_ENGINE_NAME_TO_USE ERROR_VARIABLE json_error GET ${project_json} engine)
if(json_error)
message(FATAL_ERROR "Unable to read key 'engine' from 'project.json', error: ${json_error}")
endif()
# Read the list of paths from ~.o3de/o3de_manifest.json
file(TO_CMAKE_PATH "$ENV{USERPROFILE}" home_directory) # Windows
if((NOT home_directory) OR (NOT EXISTS ${home_directory}))
file(TO_CMAKE_PATH "$ENV{HOME}" home_directory)# Unix
endif()
if (NOT home_directory)
message(FATAL_ERROR "Cannot find user home directory, the o3de manifest cannot be found")
endif()
# Set manifest path to path in the user home directory
set(manifest_path ${home_directory}/.o3de/o3de_manifest.json)
if(EXISTS ${manifest_path})
file(READ ${manifest_path} manifest_json)
string(JSON engines_count ERROR_VARIABLE json_error LENGTH ${manifest_json} engines)
if(json_error)
message(FATAL_ERROR "Unable to read key 'engines' from '${manifest_path}', error: ${json_error}")
endif()
math(EXPR engines_count "${engines_count}-1")
foreach(engine_path_index RANGE ${engines_count})
string(JSON engine_path ERROR_VARIABLE json_error GET ${manifest_json} engines ${engine_path_index})
if(${json_error})
message(FATAL_ERROR "Unable to read engines[${engine_path_index}] '${manifest_path}', error: ${json_error}")
endif()
if(engine_path)
list(APPEND CMAKE_MODULE_PATH "${engine_path}/cmake")
endif()
endforeach()
endif()
+45
View File
@@ -0,0 +1,45 @@
#
# 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.
#
# This file is copied during engine registration. Edits to this file will be lost next
# time a registration happens.
include_guard()
#! read_engine_external_subdirs
# Read the external subdirectories from the engine.json file
# External subdirectories are any folders with CMakeLists.txt in them
# This could be regular subdirectories, Gems(contains an additional gem.json),
# Restricted folders(contains an additional restricted.json), etc...
# \arg:output_external_subdirs name of output variable to store external subdirectories into
function(read_engine_external_subdirs output_external_subdirs)
file(READ ${LY_ROOT_FOLDER}/engine.json engine_json_data)
string(JSON external_subdirs_count ERROR_VARIABLE engine_json_error
LENGTH ${engine_json_data} "external_subdirectories")
if(engine_json_error)
message(FATAL_ERROR "Error querying number of elements in JSON array \"external_subdirectories\": ${engine_json_error}")
endif()
if(external_subdirs_count GREATER 0)
math(EXPR external_subdir_range "${external_subdirs_count}-1")
# Convert the paths the relative paths to absolute paths using the engine root
# as the base directory
foreach(external_subdir_index RANGE ${external_subdir_range})
string(JSON external_subdir ERROR_VARIABLE engine_json_error
GET ${engine_json_data} "external_subdirectories" "${external_subdir_index}")
if(engine_json_error)
message(FATAL_ERROR "Error reading field at index ${external_subdir_index} in \"external_subdirectories\" JSON array: ${engine_json_error}")
endif()
file(REAL_PATH ${external_subdir} real_external_subdir BASE_DIRECTORY ${CMAKE_SOURCE_DIR})
list(APPEND external_subdirs ${real_external_subdir})
endforeach()
endif()
set(${output_external_subdirs} ${external_subdirs} PARENT_SCOPE)
endfunction()
+108 -30
View File
@@ -22,7 +22,107 @@ file(GLOB detection_files "cmake/Platform/*/PALDetection_*.cmake")
foreach(detection_file ${detection_files})
include(${detection_file})
endforeach()
file(GLOB detection_files ${o3de_engine_restricted_path}/*/cmake/PALDetection_*.cmake)
#! o3de_restricted_id: Reads the "restricted" key from the o3de manifest
#
# \arg:restricted returns the restricted association element from an o3de json, otherwise engine 'o3de' is assumed
# \arg:o3de_json_file name of the o3de json file
function(o3de_restricted_id o3de_json_file restricted)
file(READ ${o3de_json_file} json_data)
string(JSON restricted_entry ERROR_VARIABLE json_error GET ${json_data} "restricted_name")
if(json_error)
message(WARNING "Unable to read restricted from '${o3de_json_file}', error: ${json_error}")
message(WARNING "Setting restricted to engine default 'o3de'")
set(restricted_entry "o3de")
endif()
if(restricted_entry)
set(${restricted} ${restricted_entry} PARENT_SCOPE)
endif()
endfunction()
#! o3de_find_restricted_folder:
#
# \arg:restricted_path returns the path of the o3de restricted folder with name restricted_name
# \arg:restricted_name name of the restricted
function(o3de_find_restricted_folder restricted_name restricted_path)
# Read the restricted path from engine.json if one EXISTS
file(READ ${LY_ROOT_FOLDER}/engine.json engine_json_data)
string(JSON restricted_subdirs_count ERROR_VARIABLE engine_json_error LENGTH ${engine_json_data} "restricted")
if(restricted_subdirs_count GREATER 0)
string(JSON restricted_subdir ERROR_VARIABLE engine_json_error GET ${engine_json_data} "restricted" "0")
set(${restricted_path} ${restricted_subdir} PARENT_SCOPE)
return()
endif()
file(TO_CMAKE_PATH "$ENV{USERPROFILE}" home_directory) # Windows
if(NOT EXISTS ${home_directory})
file(TO_CMAKE_PATH "$ENV{HOME}" home_directory) # Unix
if (NOT EXISTS ${home_directory})
return()
endif()
endif()
# Examine the o3de manifest file for the list of restricted directories
set(o3de_manifest_path ${home_directory}/.o3de/o3de_manifest.json)
if(EXISTS ${o3de_manifest_path})
file(READ ${o3de_manifest_path} o3de_manifest_json_data)
string(JSON restricted_subdirs_count ERROR_VARIABLE engine_json_error LENGTH ${o3de_manifest_json_data} "restricted")
if(restricted_subdirs_count GREATER 0)
math(EXPR restricted_subdirs_range "${restricted_subdirs_count}-1")
foreach(restricted_subdir_index RANGE ${restricted_subdirs_range})
string(JSON restricted_subdir ERROR_VARIABLE engine_json_error GET ${o3de_manifest_json_data} "restricted" "${restricted_subdir_index}")
list(APPEND restricted_subdirs ${restricted_subdir})
endforeach()
endif()
endif()
# Iterate over the restricted directories from the manifest file
foreach(restricted_entry ${restricted_subdirs})
set(restricted_json_file ${restricted_entry}/restricted.json)
file(READ ${restricted_json_file} restricted_json)
string(JSON this_restricted_name ERROR_VARIABLE json_error GET ${restricted_json} "restricted_name")
if(json_error)
message(WARNING "Unable to read restricted_name from '${restricted_json_file}', error: ${json_error}")
else()
if(this_restricted_name STREQUAL restricted_name)
set(${restricted_path} ${restricted_entry} PARENT_SCOPE)
return()
endif()
endif()
endforeach()
endfunction()
#! o3de_restricted_path:
#
# \arg:restricted_path returns the path of the o3de restricted folder with name restricted_name
# \arg:restricted_name name of the restricted
function(o3de_restricted_path o3de_json_file restricted_path)
o3de_restricted_id(${o3de_json_file} restricted_name)
if(restricted_name)
o3de_find_restricted_folder(${restricted_name} restricted_folder)
if(restricted_folder)
set(${restricted_path} ${restricted_folder} PARENT_SCOPE)
endif()
endif()
endfunction()
#! read_engine_restricted_path: Locates the restricted path within the engine from a json file
#
# \arg:restricted_path returns the path of the o3de restricted folder with name restricted_name
# \arg:restricted_name name of the restricted
function(read_engine_restricted_path output_restricted_path)
# Set manifest path to path in the user home directory
set(manifest_path ${LY_ROOT_FOLDER}/engine.json)
if(EXISTS ${manifest_path})
o3de_restricted_path(${manifest_path} output_restricted_path)
endif()
endfunction()
read_engine_restricted_path(O3DE_ENGINE_RESTRICTED_PATH)
file(GLOB detection_files ${O3DE_ENGINE_RESTRICTED_PATH}/*/cmake/PALDetection_*.cmake)
foreach(detection_file ${detection_files})
include(${detection_file})
endforeach()
@@ -37,8 +137,8 @@ ly_set(PAL_HOST_PLATFORM_NAME_LOWERCASE ${PAL_HOST_PLATFORM_NAME_LOWERCASE})
set(PAL_RESTRICTED_PLATFORMS)
string(LENGTH ${o3de_engine_restricted_path} engine_restricted_length)
file(GLOB pal_restricted_files ${o3de_engine_restricted_path}/*/cmake/PAL_*.cmake)
string(LENGTH "${O3DE_ENGINE_RESTRICTED_PATH}" engine_restricted_length)
file(GLOB pal_restricted_files ${O3DE_ENGINE_RESTRICTED_PATH}/*/cmake/PAL_*.cmake)
foreach(pal_restricted_file ${pal_restricted_files})
string(FIND ${pal_restricted_file} "/cmake/PAL" end)
if(${end} GREATER -1)
@@ -109,18 +209,18 @@ function(ly_get_absolute_pal_filename out_name in_name)
else()
# The user has not supplied any path so we must assume it is the o3de engine restricted and o3de engine path
# if the file is not in the o3de engine path then we cannot determine a PAL file for it
file(RELATIVE_PATH relative_path ${o3de_engine_path} ${full_name})
file(RELATIVE_PATH relative_path ${LY_ROOT_FOLDER} ${full_name})
if (NOT (IS_ABSOLUTE relative_path OR relative_path MATCHES [[^(\.\./)+(.*)]]))
if (NOT EXISTS ${full_name})
string(REGEX MATCH "${o3de_engine_path}/(.*)/Platform/([^/]*)/?(.*)$" match ${full_name})
string(REGEX MATCH "${LY_ROOT_FOLDER}/(.*)/Platform/([^/]*)/?(.*)$" match ${full_name})
if(NOT CMAKE_MATCH_1)
string(REGEX MATCH "${o3de_engine_path}/Platform/([^/]*)/?(.*)$" match ${full_name})
set(full_name ${o3de_engine_restricted_path}/${CMAKE_MATCH_1})
string(REGEX MATCH "${LY_ROOT_FOLDER}/Platform/([^/]*)/?(.*)$" match ${full_name})
set(full_name ${O3DE_ENGINE_RESTRICTED_PATH}/${CMAKE_MATCH_1})
if(CMAKE_MATCH_2)
string(APPEND full_name "/" ${CMAKE_MATCH_2})
endif()
elseif("${CMAKE_MATCH_2}" IN_LIST PAL_RESTRICTED_PLATFORMS)
set(full_name ${o3de_engine_restricted_path}/${CMAKE_MATCH_2}/${CMAKE_MATCH_1})
set(full_name ${O3DE_ENGINE_RESTRICTED_PATH}/${CMAKE_MATCH_2}/${CMAKE_MATCH_1})
if(CMAKE_MATCH_3)
string(APPEND full_name "/" ${CMAKE_MATCH_3})
endif()
@@ -149,25 +249,3 @@ set(LY_DISABLE_TEST_MODULES FALSE CACHE BOOL "Option to forcibly disable the inc
if(LY_DISABLE_TEST_MODULES)
ly_set(PAL_TRAIT_BUILD_TESTS_SUPPORTED FALSE)
endif()
################################################################################
# Add each restricted platform in the engines restricted folder
# If the enabled restricted platform does not have a folder add one.
# If the restricted platform folder does not have a CMakeLists.txt, create one
# so the add_subdirectory on the external folder does not fail.
################################################################################
function(o3de_add_engine_restricted_platform_external_subdirs)
foreach(restricted_platform ${PAL_RESTRICTED_PLATFORMS})
if(restricted_platform IN_LIST enabled_platforms)
set(o3de_engine_restricted_platform_folder ${o3de_engine_restricted_path}/${restricted_platform})
if(NOT EXISTS ${o3de_engine_restricted_platform_folder})
file(MAKE_DIRECTORY ${o3de_engine_restricted_platform_folder})
endif()
set(o3de_engine_restricted_platform_folder_cmakelists ${o3de_engine_restricted_platform_folder}/CMakeLists.txt)
if(NOT EXISTS ${o3de_engine_restricted_platform_folder_cmakelists})
file(TOUCH ${o3de_engine_restricted_platform_folder_cmakelists})
endif()
list(APPEND LY_EXTERNAL_SUBDIRS ${o3de_engine_restricted_platform_folder})
endif()
endforeach()
endfunction()
+2 -2
View File
@@ -108,11 +108,11 @@ function(ly_delayed_generate_settings_registry)
# Get the gem dependencies for the given project and target combination
get_property(gem_dependencies GLOBAL PROPERTY LY_DELAYED_LOAD_"${prefix_target}")
list(REMOVE_DUPLICATES gem_dependencies) # Strip out any duplicate gem targets
set(all_gem_dependencies ${gem_dependencies})
unset(all_gem_dependencies)
foreach(gem_target ${gem_dependencies})
ly_get_gem_load_dependencies(gem_load_gem_dependencies ${gem_target})
list(APPEND all_gem_dependencies ${gem_load_gem_dependencies})
list(APPEND all_gem_dependencies ${gem_load_gem_dependencies} ${gem_target})
endforeach()
list(REMOVE_DUPLICATES all_gem_dependencies)
+4 -1
View File
@@ -17,16 +17,19 @@ set(FILES
Configurations.cmake
Dependencies.cmake
Deployment.cmake
EngineFinder.cmake
EngineJson.cmake
FileUtil.cmake
Findo3de.cmake
GeneralSettings.cmake
Install.cmake
LyAutoGen.cmake
LYPackage_S3Downloader.cmake
LySet.cmake
LYTestWrappers.cmake
LYPython.cmake
LYWrappers.cmake
Monolithic.cmake
OutputDirectory.cmake
Packaging.cmake
PAL.cmake
PALTools.cmake
-970
View File
@@ -1,970 +0,0 @@
#
# 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 the user home directory
set(O3DE_HOME_PATH "" CACHE PATH "Override the user home to this path")
if(O3DE_HOME_PATH)
set(home_directory ${O3DE_HOME_PATH})
elseif(CMAKE_HOST_WIN32)
file(TO_CMAKE_PATH "$ENV{USERPROFILE}" home_directory)
else()
file(TO_CMAKE_PATH "$ENV{HOME}" home_directory)
endif()
if (NOT home_directory)
message(FATAL_ERROR "Cannot find user home directory, without the user home directory the o3de manifest cannot be found")
endif()
# Optionally delete the home directory
if(O3DE_DELETE_HOME_PATH)
if(EXISTS ${home_directory}/.o3de)
message(STATUS "Deleting ${home_directory}/.o3de")
file(REMOVE_RECURSE ${home_directory}/.o3de)
else()
message(STATUS "Home path ${home_directory}/.o3de doesnt exist.")
endif()
endif()
########################################################################################################################
# If O3DE_REGISTER_ENGINE_PATH variable is set on the commandline this will allow registration of anything using
# O3DE_REGISTER_ENGINE_PATH o3de script. This is handy for situations like build servers which download the code and
# are expected to build without the need for someone to register o3de objects like this engine by manually typing it in.
# If O3DE_REGISTER_THIS_ENGINE=TRUE is set on the commandline when O3DE_REGISTER_ENGINE_PATH is also set this will call:
# O3DE_REGISTER_ENGINE_PATH/scripts>o3de register --this-engine --override-home-folder <home_directory>
# Note: register --this-engine will automatically register anything it finds in known folders, so if you put your
# o3de objects like projects/gems/templates/restricted/etc... in known folders for those types they will get registered
# automatically. Known folders for types are your .o3de/Projects and .o3de/Gems etc. So if I wanted my project to be
# registered and built by this build server I could simply put them in those known folders on the build server and they
# would get registered automatically by this call.
# OR
# I could put them on the commandline as well. This would be the way if the o3de objects we need to regiater are NOT
# in known folders or you do not intend to call with O3DE_REGISTER_THIS_ENGINE=TRUE Ex.
# -DO3DE_REGISTER_ENGINE_PATH=C:\this\engine
# -DO3DE_REGISTER_PROJECT_PATHS=C:\ThisGame;C:\ThatGame
# -DO3DE_REGISTER_GEM_PATHS=C:\ThisGem;C:\ThatGem;C:\And\Some\Other\Gem
# -DO3DE_REGISTER_RESTRICTED_PATHS=C:\this\engine\Restricted;C:\ThisGame\Restricted;C:\ThisGem\Restricted
########################################################################################################################
if(O3DE_REGISTER_ENGINE_PATH)
if(O3DE_REGISTER_THIS_ENGINE)
if(CMAKE_HOST_WIN32)
execute_process(
COMMAND cmd /c ${O3DE_REGISTER_ENGINE_PATH}/scripts/o3de.bat register --this-engine --override-home-folder ${home_directory}
RESULT_VARIABLE o3de_register_this_engine_cmd_result
)
else()
execute_process(
COMMAND sh ${O3DE_REGISTER_ENGINE_PATH}/scripts/o3de.sh register --this-engine --override-home-folder ${home_directory}
RESULT_VARIABLE o3de_register_this_engine_cmd_result
)
endif()
if(o3de_register_this_engine_cmd_result)
message(FATAL_ERROR "An error occured trying to register --this-engine: ${o3de_register_this_engine_cmd_result}")
else()
message(STATUS "Engine ${O3DE_REGISTER_ENGINE_PATH} registration successfull.")
endif()
endif()
if(O3DE_REGISTER_RESTRICTED_PATHS)
foreach(restricted_path ${O3DE_REGISTER_RESTRICTED_PATHS})
if(CMAKE_HOST_WIN32)
execute_process(
COMMAND cmd /c ${O3DE_REGISTER_ENGINE_PATH}/scripts/o3de.bat register --restricted-path ${restricted_path} --override-home-folder ${home_directory}
RESULT_VARIABLE o3de_register_restricted_cmd_result
)
else()
execute_process(
COMMAND sh ${O3DE_REGISTER_ENGINE_PATH}/scripts/o3de.sh register --restricted-path ${restricted_path} --override-home-folder ${home_directory}
RESULT_VARIABLE o3de_register_restricted_cmd_result
)
endif()
if(o3de_register_restricted_cmd_result)
message(FATAL_ERROR "An error occured trying to ${O3DE_REGISTER_ENGINE_PATH}/scripts>o3de register --restricted-path ${restricted_path} --override-home-folder ${home_directory}: ${o3de_register_restricted_cmd_result}")
else()
message(STATUS "Restricted ${restricted_path} registration successfull.")
endif()
endforeach()
endif()
if(O3DE_REGISTER_PROJECT_PATHS)
foreach(project_path ${O3DE_REGISTER_PROJECT_PATHS})
if(CMAKE_HOST_WIN32)
execute_process(
COMMAND cmd /c ${O3DE_REGISTER_ENGINE_PATH}/scripts/o3de.bat register --project-path ${project_path} --override-home-folder ${home_directory}
RESULT_VARIABLE o3de_register_project_cmd_result
)
else()
execute_process(
COMMAND sh ${O3DE_REGISTER_ENGINE_PATH}/scripts/o3de.sh register --project-path ${project_path} --override-home-folder ${home_directory}
RESULT_VARIABLE o3de_register_project_cmd_result
)
endif()
if(o3de_register_project_cmd_result)
message(FATAL_ERROR "An error occured trying to ${O3DE_REGISTER_ENGINE_PATH}/scripts>o3de register --project-path ${project_path} --override-home-folder ${home_directory}")
else()
message(STATUS "Project ${project_path} registration successfull.")
endif()
endforeach()
endif()
if(O3DE_REGISTER_GEM_PATHS)
foreach(gem_path ${O3DE_REGISTER_GEM_PATHS})
if(CMAKE_HOST_WIN32)
execute_process(
COMMAND cmd /c ${O3DE_REGISTER_ENGINE_PATH}/scripts/o3de.bat register --gem-path ${gem_path} --override-home-folder ${home_directory}
RESULT_VARIABLE o3de_register_gem_cmd_result
)
else()
execute_process(
COMMAND sh ${O3DE_REGISTER_ENGINE_PATH}/scripts/o3de.sh register --gem-path ${gem_path} --override-home-folder ${home_directory}
RESULT_VARIABLE o3de_register_gem_cmd_result
)
endif()
if(o3de_register_gem_cmd_result)
message(FATAL_ERROR "An error occured trying to ${O3DE_REGISTER_ENGINE_PATH}/scripts>o3de register --gem-path ${gem_path} --override-home-folder ${home_directory}")
else()
message(STATUS "Gem ${gem_path} registration successfull.")
endif()
endforeach()
endif()
if(O3DE_REGISTER_TEMPLATE_PATHS)
foreach(template_path ${O3DE_REGISTER_TEMPLATE_PATHS})
if(CMAKE_HOST_WIN32)
execute_process(
COMMAND cmd /c ${O3DE_REGISTER_ENGINE_PATH}/scripts/o3de.bat register --template-path ${template_path} --override-home-folder ${home_directory}
RESULT_VARIABLE o3de_register_template_cmd_result
)
else()
execute_process(
COMMAND sh ${O3DE_REGISTER_ENGINE_PATH}/scripts/o3de.sh register --template-path ${template_path} --override-home-folder ${home_directory}
RESULT_VARIABLE o3de_register_template_cmd_result
)
endif()
if(o3de_register_template_cmd_result)
message(FATAL_ERROR "An error occured trying to ${O3DE_REGISTER_ENGINE_PATH}/scripts>o3de register --template-path ${template_path} --override-home-folder ${home_directory}")
else()
message(STATUS "Template ${template_path} registration successfull.")
endif()
endforeach()
endif()
if(O3DE_REGISTER_REPO_URIS)
foreach(repo_uri ${O3DE_REGISTER_REPO_URIS})
if(CMAKE_HOST_WIN32)
execute_process(
COMMAND cmd /c ${O3DE_REGISTER_ENGINE_PATH}/scripts/o3de.bat register --repo-uri ${repo_uri} --override-home-folder ${home_directory}
RESULT_VARIABLE o3de_register_repo_cmd_result
)
else()
execute_process(
COMMAND sh ${O3DE_REGISTER_ENGINE_PATH}/scripts/o3de.sh register --repo-uri ${repo_uri} --override-home-folder ${home_directory}
RESULT_VARIABLE o3de_register_repo_cmd_result
)
endif()
if(o3de_register_repo_cmd_result)
message(FATAL_ERROR "An error occured trying to ${O3DE_REGISTER_ENGINE_PATH}/scripts>o3de register --repo-uri ${repo_uri} --override-home-folder ${home_directory}")
else()
message(STATUS "Repo ${repo_uri} registration successfull.")
endif()
endforeach()
endif()
endif()
################################################################################
# o3de manifest
################################################################################
# Set manifest json path to the <home_directory>/.o3de/o3de_manifest.json
set(o3de_manifest_json_path ${home_directory}/.o3de/o3de_manifest.json)
if(NOT EXISTS ${o3de_manifest_json_path})
message(FATAL_ERROR "${o3de_manifest_json_path} not found. You must o3de register --this-engine.")
endif()
file(READ ${o3de_manifest_json_path} manifest_json_data)
################################################################################
# o3de manifest name
################################################################################
string(JSON o3de_manifest_name ERROR_VARIABLE json_error GET ${manifest_json_data} o3de_manifest_name)
if(json_error)
message(FATAL_ERROR "Unable to read repo_name from '${o3de_manifest_json_path}', error: ${json_error}")
endif()
################################################################################
# o3de origin
################################################################################
string(JSON o3de_origin ERROR_VARIABLE json_error GET ${manifest_json_data} origin)
if(json_error)
message(FATAL_ERROR "Unable to read origin from '${o3de_manifest_json_path}', error: ${json_error}")
endif()
################################################################################
# o3de default engines folder
################################################################################
string(JSON o3de_default_engines_folder ERROR_VARIABLE json_error GET ${manifest_json_data} default_engines_folder)
if(json_error)
message(FATAL_ERROR "Unable to read default_engines_folder from '${o3de_manifest_json_path}', error: ${json_error}")
endif()
################################################################################
# o3de default projects folder
################################################################################
string(JSON o3de_default_projects_folder ERROR_VARIABLE json_error GET ${manifest_json_data} default_projects_folder)
if(json_error)
message(FATAL_ERROR "Unable to read default_projects_folder from '${o3de_manifest_json_path}', error: ${json_error}")
endif()
################################################################################
# o3de default gems folder
################################################################################
string(JSON o3de_default_gems_folder ERROR_VARIABLE json_error GET ${manifest_json_data} default_gems_folder)
if(json_error)
message(FATAL_ERROR "Unable to read default_gems_folder from '${o3de_manifest_json_path}', error: ${json_error}")
endif()
################################################################################
# o3de default templates folder
################################################################################
string(JSON o3de_default_templates_folder ERROR_VARIABLE json_error GET ${manifest_json_data} default_templates_folder)
if(json_error)
message(FATAL_ERROR "Unable to read default_templates_folder from '${o3de_manifest_json_path}', error: ${json_error}")
endif()
################################################################################
# o3de default restricted folder
################################################################################
string(JSON o3de_default_restricted_folder ERROR_VARIABLE json_error GET ${manifest_json_data} default_restricted_folder)
if(json_error)
message(FATAL_ERROR "Unable to read default_restricted_folder from '${o3de_manifest_json_path}', error: ${json_error}")
endif()
################################################################################
# o3de projects
################################################################################
string(JSON o3de_projects_count ERROR_VARIABLE json_error LENGTH ${manifest_json_data} projects)
if(json_error)
message(FATAL_ERROR "Unable to read key 'projects' from '${o3de_manifest_json_path}', error: ${json_error}")
endif()
if(${o3de_projects_count} GREATER 0)
math(EXPR o3de_projects_count "${o3de_projects_count}-1")
foreach(projects_index RANGE ${o3de_projects_count})
string(JSON projects_path ERROR_VARIABLE json_error GET ${manifest_json_data} projects ${projects_index})
if(json_error)
message(FATAL_ERROR "Unable to read projects[${projects_index}] '${o3de_manifest_json_path}', error: ${json_error}")
endif()
list(APPEND o3de_projects ${projects_path})
list(APPEND o3de_global_projects ${projects_path})
endforeach()
endif()
################################################################################
# o3de gems
################################################################################
string(JSON o3de_gems_count ERROR_VARIABLE json_error LENGTH ${manifest_json_data} gems)
if(json_error)
message(FATAL_ERROR "Unable to read key 'gems' from '${o3de_manifest_json_path}', error: ${json_error}")
endif()
if(${o3de_gems_count} GREATER 0)
math(EXPR o3de_gems_count "${o3de_gems_count}-1")
foreach(gems_index RANGE ${o3de_gems_count})
string(JSON gems_path ERROR_VARIABLE json_error GET ${manifest_json_data} gems ${gems_index})
if(json_error)
message(FATAL_ERROR "Unable to read gems[${gems_index}] '${o3de_manifest_json_path}', error: ${json_error}")
endif()
list(APPEND o3de_gems ${gems_path})
list(APPEND o3de_global_gems ${gems_path})
endforeach()
endif()
################################################################################
# o3de templates
################################################################################
string(JSON o3de_templates_count ERROR_VARIABLE json_error LENGTH ${manifest_json_data} templates)
if(json_error)
message(FATAL_ERROR "Unable to read key 'templates' from '${o3de_manifest_json_path}', error: ${json_error}")
endif()
if(${o3de_templates_count} GREATER 0)
math(EXPR o3de_templates_count "${o3de_templates_count}-1")
foreach(templates_index RANGE ${o3de_templates_count})
string(JSON templates_path ERROR_VARIABLE json_error GET ${manifest_json_data} templates ${templates_index})
if(json_error)
message(FATAL_ERROR "Unable to read templates[${templates_index}] '${o3de_manifest_json_path}', error: ${json_error}")
endif()
list(APPEND o3de_templates ${templates_path})
list(APPEND o3de_global_templates ${templates_path})
endforeach()
endif()
################################################################################
# o3de repos
################################################################################
string(JSON o3de_repos_count ERROR_VARIABLE json_error LENGTH ${manifest_json_data} repos)
if(json_error)
message(FATAL_ERROR "Unable to read key 'repos' from '${o3de_manifest_json_path}', error: ${json_error}")
endif()
if(${o3de_repos_count} GREATER 0)
math(EXPR o3de_repos_count "${o3de_repos_count}-1")
foreach(repos_index RANGE ${o3de_repos_count})
string(JSON repo_uri ERROR_VARIABLE json_error GET ${manifest_json_data} repos ${repos_index})
if(json_error)
message(FATAL_ERROR "Unable to read repos[${repos_index}] '${o3de_manifest_json_path}', error: ${json_error}")
endif()
list(APPEND o3de_repos ${repo_uri})
list(APPEND o3de_global_repos ${repo_uri})
endforeach()
endif()
################################################################################
# o3de restricted
################################################################################
string(JSON o3de_restricted_count ERROR_VARIABLE json_error LENGTH ${manifest_json_data} restricted)
if(json_error)
message(FATAL_ERROR "Unable to read key 'restricted' from '${o3de_manifest_json_path}', error: ${json_error}")
endif()
if(${o3de_restricted_count} GREATER 0)
math(EXPR o3de_restricted_count "${o3de_restricted_count}-1")
foreach(restricted_index RANGE ${o3de_restricted_count})
string(JSON restricted_path ERROR_VARIABLE json_error GET ${manifest_json_data} restricted ${restricted_index})
if(json_error)
message(FATAL_ERROR "Unable to read restricted[${restricted_index}] '${o3de_manifest_json_path}', error: ${json_error}")
endif()
list(APPEND o3de_restricted ${restricted_path})
list(APPEND o3de_global_restricted ${restricted_path})
endforeach()
endif()
################################################################################
# o3de engines
################################################################################
string(JSON o3de_engines_count ERROR_VARIABLE json_error LENGTH ${manifest_json_data} engines)
if(json_error)
message(FATAL_ERROR "Unable to read key 'engines' from '${o3de_manifest_json_path}', error: ${json_error}")
endif()
if(${o3de_engines_count} GREATER 0)
math(EXPR o3de_engines_count "${o3de_engines_count}-1")
# Either the engine_path and engine_json are set in which case the user is configuring from the engine
# or project_path and project_json are set in which case the user is configuring from the project.
# We need to know which engine_path the user is using so if the project_json is set then we need
# to read the project_json and disambiguate the engine_path.
if(NOT o3de_engine_path)
if(NOT o3de_project_json)
message(FATAL_ERROR "Neither o3de_engine_path nor o3de_project_json defined. Cannot determine engine!")
endif()
# get the name of the engine this project uses
file(READ ${o3de_project_json} project_json_data)
string(JSON project_engine_name ERROR_VARIABLE json_error GET ${project_json_data} engine)
if(json_error)
message(FATAL_ERROR "Unable to read 'engine' from '${o3de_project_json}', error: ${json_error}")
endif()
# search each engine in order from the manifest to find the matching engine name
foreach(engines_index RANGE ${o3de_engines_count})
string(JSON engine_data ERROR_VARIABLE json_error GET ${manifest_json_data} engines ${engines_index})
if(json_error)
message(FATAL_ERROR "Unable to read engines[${engines_index}] '${o3de_manifest_json_path}', error: ${json_error}")
endif()
# get this engines path
string(JSON this_engine_path ERROR_VARIABLE json_error GET ${engine_data} path)
if(json_error)
message(FATAL_ERROR "Unable to read engine path from '${o3de_manifest_json_path}', error: ${json_error}")
endif()
# add this engine to the engines list
list(APPEND o3de_engines ${this_engine_path})
# use path to get the engine.json
set(this_engine_json ${this_engine_path}/engine.json)
# read the name of this engine
file(READ ${this_engine_json} this_engine_json_data)
string(JSON this_engine_name ERROR_VARIABLE json_error GET ${this_engine_json_data} engine_name)
if(json_error)
message(FATAL_ERROR "Unable to read engine_name from '${this_engine_json}', error: ${json_error}")
endif()
# see if this engines name is the same as the one this projects should use
if(${this_engine_name} STREQUAL ${project_engine_name})
message(STATUS "Found engine: '${project_engine_name}' at ${this_engine_path}")
set(o3de_engine_path ${this_engine_path})
break()
endif()
endforeach()
endif()
endif()
#we should have an engine_path at this point
if(NOT o3de_engine_path)
message(FATAL_ERROR "o3de_engine_path not defined. Cannot determine engine!")
endif()
# now that we have an engine_path read in that engines o3de resources
if(${o3de_engines_count} GREATER -1)
foreach(engines_index RANGE ${o3de_engines_count})
string(JSON engine_data ERROR_VARIABLE json_error GET ${manifest_json_data} engines ${engines_index})
if(json_error)
message(FATAL_ERROR "Unable to read engines[${engines_index}] '${o3de_manifest_json_path}', error: ${json_error}")
endif()
# get this engines path
string(JSON this_engine_path ERROR_VARIABLE json_error GET ${engine_data} path)
if(json_error)
message(FATAL_ERROR "Unable to read engine path from '${o3de_manifest_json_path}', error: ${json_error}")
endif()
if(${o3de_engine_path} STREQUAL ${this_engine_path})
################################################################################
# o3de engine projects
################################################################################
string(JSON o3de_engine_projects_count ERROR_VARIABLE json_error LENGTH ${engine_data} projects)
if(json_error)
message(FATAL_ERROR "Unable to read key 'projects' from '${engine_data}', error: ${json_error}")
endif()
if(${o3de_engine_projects_count} GREATER 0)
math(EXPR o3de_engine_projects_count "${o3de_engine_projects_count}-1")
foreach(engine_projects_index RANGE ${o3de_engine_projects_count})
string(JSON engine_projects_path ERROR_VARIABLE json_error GET ${engine_data} projects ${engine_projects_index})
if(json_error)
message(FATAL_ERROR "Unable to read engine projects[${projects_index}] '${o3de_manifest_json_path}', error: ${json_error}")
endif()
list(APPEND o3de_projects ${engine_projects_path})
list(APPEND o3de_engine_projects ${engine_projects_path})
endforeach()
endif()
################################################################################
# o3de engine gems
################################################################################
string(JSON o3de_engine_gems_count ERROR_VARIABLE json_error LENGTH ${engine_data} gems)
if(json_error)
message(FATAL_ERROR "Unable to read key 'gems' from '${engine_data}', error: ${json_error}")
endif()
if(${o3de_engine_gems_count} GREATER 0)
math(EXPR o3de_engine_gems_count "${o3de_engine_gems_count}-1")
foreach(engine_gems_index RANGE ${o3de_engine_gems_count})
string(JSON engine_gems_path ERROR_VARIABLE json_error GET ${engine_data} gems ${engine_gems_index})
if(json_error)
message(FATAL_ERROR "Unable to read engine gems[${gems_index}] '${o3de_manifest_json_path}', error: ${json_error}")
endif()
list(APPEND o3de_gems ${engine_gems_path})
list(APPEND o3de_engine_gems ${engine_gems_path})
endforeach()
endif()
################################################################################
# o3de engine templates
################################################################################
string(JSON o3de_engine_templates_count ERROR_VARIABLE json_error LENGTH ${engine_data} templates)
if(json_error)
message(FATAL_ERROR "Unable to read key 'templates' from '${o3de_manifest_json_path}', error: ${json_error}")
endif()
if(${o3de_engine_gems_count} GREATER 0)
math(EXPR o3de_engine_templates_count "${o3de_engine_templates_count}-1")
foreach(engine_templates_index RANGE ${o3de_engine_templates_count})
string(JSON engine_templates_path ERROR_VARIABLE json_error GET ${engine_data} templates ${engine_templates_index})
if(json_error)
message(FATAL_ERROR "Unable to read engine templates[${templates_index}] '${o3de_manifest_json_path}', error: ${json_error}")
endif()
list(APPEND o3de_templates ${engine_templates_path})
list(APPEND o3de_engine_templates ${engine_templates_path})
endforeach()
endif()
################################################################################
# o3de engine restricted
################################################################################
string(JSON o3de_engine_restricted_count ERROR_VARIABLE json_error LENGTH ${engine_data} restricted)
if(json_error)
message(FATAL_ERROR "Unable to read key 'restricted' from '${o3de_manifest_json_path}', error: ${json_error}")
endif()
if(${o3de_engine_restricted_count} GREATER 0)
math(EXPR o3de_engine_restricted_count "${o3de_engine_restricted_count}-1")
foreach(engine_restricted_index RANGE ${o3de_engine_restricted_count})
string(JSON engine_restricted_path ERROR_VARIABLE json_error GET ${engine_data} restricted ${engine_restricted_index})
if(json_error)
message(FATAL_ERROR "Unable to read engine restricted[${engine_restricted_index}] '${o3de_manifest_json_path}', error: ${json_error}")
endif()
list(APPEND o3de_restricted ${engine_restricted_path})
list(APPEND o3de_engine_restricted ${engine_restricted_path})
endforeach()
endif()
################################################################################
# o3de engine external_subdirectories
################################################################################
string(JSON o3de_external_subdirectories_count ERROR_VARIABLE json_error LENGTH ${engine_data} external_subdirectories)
if(json_error)
message(FATAL_ERROR "Unable to read key 'external_subdirectories' from '${o3de_manifest_json_path}', error: ${json_error}")
endif()
if(${o3de_external_subdirectories_count} GREATER 0)
math(EXPR o3de_external_subdirectories_count "${o3de_external_subdirectories_count}-1")
foreach(external_subdirectories_index RANGE ${o3de_external_subdirectories_count})
string(JSON external_subdirectories_path ERROR_VARIABLE json_error GET ${engine_data} external_subdirectories ${external_subdirectories_index})
if(json_error)
message(FATAL_ERROR "Unable to read engine external_subdirectories[${gems_index}] '${o3de_manifest_json_path}', error: ${json_error}")
endif()
list(APPEND o3de_engine_external_subdirectories ${external_subdirectories_path})
endforeach()
endif()
break()
endif()
endforeach()
endif()
################################################################################
#! o3de_engine_id:
#
# \arg:engine returns the engine association element from an o3de json
# \arg:o3de_json_file name of the o3de json file
################################################################################
function(o3de_engine_id o3de_json_file engine)
file(READ ${o3de_json_file} json_data)
string(JSON engine_entry ERROR_VARIABLE json_error GET ${json_data} engine)
if(json_error)
message(WARNING "Unable to read engine from '${o3de_json_file}', error: ${json_error}")
message(WARNING "Setting engine to engine default 'o3de'")
set(engine_entry "o3de")
endif()
if(engine_entry)
set(${engine} ${engine_entry} PARENT_SCOPE)
endif()
endfunction()
################################################################################
#! o3de_project_id:
#
# \arg:project returns the project association element from an o3de json
# \arg:o3de_json_file name of the o3de json file
################################################################################
function(o3de_project_id o3de_json_file project)
file(READ ${o3de_json_file} json_data)
string(JSON project_entry ERROR_VARIABLE json_error GET ${json_data} project)
if(json_error)
message(FATAL_ERROR "Unable to read project from '${o3de_json_file}', error: ${json_error}")
endif()
if(project_entry)
set(${project} ${project_entry} PARENT_SCOPE)
endif()
endfunction()
################################################################################
#! o3de_gem_id:
#
# \arg:gem returns the gem association element from an o3de json
# \arg:o3de_json_file name of the o3de json file
################################################################################
function(o3de_gem_id o3de_json_file gem)
file(READ ${o3de_json_file} json_data)
string(JSON gem_entry ERROR_VARIABLE json_error GET ${json_data} gem)
if(json_error)
message(FATAL_ERROR "Unable to read gem from '${o3de_json_file}', error: ${json_error}")
endif()
if(gem_entry)
set(${gem} ${gem_entry} PARENT_SCOPE)
endif()
endfunction()
################################################################################
#! o3de_template_id:
#
# \arg:template returns the template association element from an o3de json
# \arg:o3de_json_file name of the o3de json file
################################################################################
function(o3de_template_id o3de_json_file template)
file(READ ${o3de_json_file} json_data)
string(JSON template_entry ERROR_VARIABLE json_error GET ${json_data} template)
if(json_error)
message(FATAL_ERROR "Unable to read template from '${o3de_json_file}', error: ${json_error}")
endif()
if(template_entry)
set(${template} ${template_entry} PARENT_SCOPE)
endif()
endfunction()
################################################################################
#! o3de_repo_id:
#
# \arg:repo returns the repo association element from an o3de json
# \arg:o3de_json_file name of the o3de json file
################################################################################
function(o3de_repo_id o3de_json_file repo)
file(READ ${o3de_json_file} json_data)
string(JSON repo_entry ERROR_VARIABLE json_error GET ${json_data} repo)
if(json_error)
message(FATAL_ERROR "Unable to read repo from '${o3de_json_file}', error: ${json_error}")
endif()
if(repo_entry)
set(${repo} ${repo_entry} PARENT_SCOPE)
endif()
endfunction()
################################################################################
#! o3de_restricted_id:
#
# \arg:restricted returns the restricted association element from an o3de json, otherwise engine 'o3de' is assumed
# \arg:o3de_json_file name of the o3de json file
################################################################################
function(o3de_restricted_id o3de_json_file restricted)
file(READ ${o3de_json_file} json_data)
string(JSON restricted_entry ERROR_VARIABLE json_error GET ${json_data} restricted)
if(json_error)
message(WARNING "Unable to read restricted from '${o3de_json_file}', error: ${json_error}")
message(WARNING "Setting restricted to engine default 'o3de'")
set(restricted_entry "o3de")
endif()
if(restricted_entry)
set(${restricted} ${restricted_entry} PARENT_SCOPE)
endif()
endfunction()
################################################################################
#! o3de_find_engine_folder:
#
# \arg:engine_path returns the path of the o3de engine folder with name engine_name
# \arg:engine_name name of the engine
################################################################################
function(o3de_find_engine_folder engine_name engine_path)
foreach(engine_entry ${o3de_engines})
set(engine_json_file ${engine_entry}/engine.json)
file(READ ${engine_json_file} engine_json)
string(JSON this_engine_name ERROR_VARIABLE json_error GET ${engine_json} engine_name)
if(json_error)
message(WARNING "Unable to read engine_name from '${engine_json_file}', error: ${json_error}")
else()
if(this_engine_name STREQUAL engine_name)
set(${engine_path} ${engine_entry} PARENT_SCOPE)
return()
endif()
endif()
endforeach()
message(FATAL_ERROR "Unable to find repo_name: '${engine_name}'")
endfunction()
################################################################################
#! o3de_find_project_folder:
#
# \arg:project_path returns the path of the o3de project folder with name project_name
# \arg:project_name name of the project
################################################################################
function(o3de_find_project_folder project_name project_path)
foreach(project_entry ${o3de_projects})
set(project_json_file ${project_entry}/project.json)
file(READ ${project_json_file} project_json)
string(JSON this_project_name ERROR_VARIABLE json_error GET ${project_json} project_name)
if(json_error)
message(WARNING "Unable to read project_name from '${project_json_file}', error: ${json_error}")
else()
if(this_project_name STREQUAL project_name)
set(${project_path} ${project_entry} PARENT_SCOPE)
return()
endif()
endif()
endforeach()
message(FATAL_ERROR "Unable to find project_name: '${project_name}'")
endfunction()
################################################################################
#! o3de_find_gem_folder:
#
# \arg:gem_path returns the path of the o3de gem folder with name gem_name
# \arg:gem_name name of the gem
################################################################################
function(o3de_find_gem_folder gem_name gem_path)
foreach(gem_entry ${o3de_gems})
set(gem_json_file ${gem_entry}/gem.json)
file(READ ${gem_json_file} gem_json)
string(JSON this_gem_name ERROR_VARIABLE json_error GET ${gem_json} gem_name)
if(json_error)
message(WARNING "Unable to read gem_name from '${gem_json_file}', error: ${json_error}")
else()
if(this_gem_name STREQUAL gem_name)
set(${gem_path} ${gem_entry} PARENT_SCOPE)
return()
endif()
endif()
endforeach()
message(FATAL_ERROR "Unable to find gem_name: '${gem_name}'")
endfunction()
################################################################################
#! o3de_find_template_folder:
#
# \arg:template_path returns the path of the o3de template folder with name template_name
# \arg:template_name name of the template
################################################################################
function(o3de_find_template_folder template_name template_path)
foreach(template_entry ${o3de_templates})
set(template_json_file ${template_entry}/template.json)
file(READ ${template_json_file} template_json)
string(JSON this_template_name ERROR_VARIABLE json_error GET ${template_json} template_name)
if(json_error)
message(WARNING "Unable to read template_name from '${template_json_file}', error: ${json_error}")
else()
if(this_template_name STREQUAL template_name)
set(${template_path} ${template_entry} PARENT_SCOPE)
return()
endif()
endif()
endforeach()
message(FATAL_ERROR "Unable to find template_name: '${template_name}'")
endfunction()
################################################################################
#! o3de_find_repo_folder:
#
# \arg:repo_path returns the path of the o3de repo folder with name repo_name
# \arg:repo_name name of the repo
################################################################################
function(o3de_find_repo_folder repo_name repo_path)
foreach(repo_entry ${o3de_repos})
set(repo_json_file ${repo_entry}/repo.json)
file(READ ${repo_json_file} repo_json)
string(JSON this_repo_name ERROR_VARIABLE json_error GET ${repo_json} repo_name)
if(json_error)
message(WARNING "Unable to read repo_name from '${repo_json_file}', error: ${json_error}")
else()
if(this_repo_name STREQUAL repo_name)
set(${repo_path} ${repo_entry} PARENT_SCOPE)
return()
endif()
endif()
endforeach()
message(FATAL_ERROR "Unable to find repo_name: '${repo_name}'")
endfunction()
################################################################################
#! o3de_find_restricted_folder:
#
# \arg:restricted_path returns the path of the o3de restricted folder with name restricted_name
# \arg:restricted_name name of the restricted
################################################################################
function(o3de_find_restricted_folder restricted_name restricted_path)
foreach(restricted_entry ${o3de_restricted})
set(restricted_json_file ${restricted_entry}/restricted.json)
file(READ ${restricted_json_file} restricted_json)
string(JSON this_restricted_name ERROR_VARIABLE json_error GET ${restricted_json} restricted_name)
if(json_error)
message(WARNING "Unable to read restricted_name from '${restricted_json_file}', error: ${json_error}")
else()
if(this_restricted_name STREQUAL restricted_name)
set(${restricted_path} ${restricted_entry} PARENT_SCOPE)
return()
endif()
endif()
endforeach()
message(FATAL_ERROR "Unable to find restricted_name: '${restricted_name}'")
endfunction()
################################################################################
#! o3de_engine_name:
#
# \arg:engine returns the engine_name element from an engine.json
# \arg:o3de_engine_json_file name of the o3de json file
################################################################################
function(o3de_engine_name o3de_engine_json_file engine)
file(READ ${o3de_engine_json_file} json_data)
string(JSON engine_entry ERROR_VARIABLE json_error GET ${json_data} engine_name)
if(json_error)
message(FATAL_ERROR "Unable to read engine_name from '${o3de_json_file}', error: ${json_error}")
endif()
if(engine_entry)
set(${engine} ${engine_entry} PARENT_SCOPE)
endif()
endfunction()
################################################################################
#! o3de_project_name:
#
# \arg:project returns the project_name element from an project.json
# \arg:o3de_project_json_file name of the o3de json file
################################################################################
function(o3de_project_name o3de_project_json_file project)
file(READ ${o3de_project_json_file} json_data)
string(JSON project_entry ERROR_VARIABLE json_error GET ${json_data} project_name)
if(json_error)
message(FATAL_ERROR "Unable to read project_name from '${o3de_json_file}', error: ${json_error}")
endif()
if(project_entry)
set(${project} ${project_entry} PARENT_SCOPE)
endif()
endfunction()
################################################################################
#! o3de_gem_name:
#
# \arg:gem returns the gem_name element from an gem.json
# \arg:o3de_gem_json_file name of the o3de json file
################################################################################
function(o3de_gem_name o3de_gem_json_file gem)
file(READ ${o3de_gem_json_file} json_data)
string(JSON gem_entry ERROR_VARIABLE json_error GET ${json_data} gem_name)
if(json_error)
message(FATAL_ERROR "Unable to read gem_name from '${o3de_json_file}', error: ${json_error}")
endif()
if(gem_entry)
set(${gem} ${gem_entry} PARENT_SCOPE)
endif()
endfunction()
################################################################################
#! o3de_template_name:
#
# \arg:template returns the template_name element from an template json
# \arg:o3de_template_json_file name of the o3de json file
################################################################################
function(o3de_template_name o3de_template_json_file template)
file(READ ${o3de_template_json_file} json_data)
string(JSON template_entry ERROR_VARIABLE json_error GET ${json_data} template_name)
if(json_error)
message(FATAL_ERROR "Unable to read template_name from '${o3de_json_file}', error: ${json_error}")
endif()
if(template_entry)
set(${template} ${template_entry} PARENT_SCOPE)
endif()
endfunction()
################################################################################
#! o3de_repo_name:
#
# \arg:repo returns the repo_name element from an repo.json or o3de_manifest.json
# \arg:o3de_repo_json_file name of the o3de json file
################################################################################
function(o3de_repo_name o3de_repo_json_file repo)
file(READ ${o3de_repo_json_file} json_data)
string(JSON repo_entry ERROR_VARIABLE json_error GET ${json_data} repo_name)
if(json_error)
message(FATAL_ERROR "Unable to read repo_name from '${o3de_json_file}', error: ${json_error}")
endif()
if(repo_entry)
set(${repo} ${repo_entry} PARENT_SCOPE)
endif()
endfunction()
################################################################################
#! o3de_restricted_name:
#
# \arg:restricted returns the restricted association element from an o3de json
# \arg:o3de_json_file name of the o3de json file
################################################################################
function(o3de_restricted_name o3de_json_file restricted)
file(READ ${o3de_json_file} json_data)
string(JSON restricted_entry ERROR_VARIABLE json_error GET ${json_data} restricted_name)
if(json_error)
message(WARNING "FATAL_ERROR to read restricted_name from '${o3de_json_file}', error: ${json_error}")
endif()
if(restricted_entry)
set(${restricted} ${restricted_entry} PARENT_SCOPE)
endif()
endfunction()
################################################################################
#! o3de_engine_path:
#
# \arg:engine_path returns the path of the o3de engine folder with name engine_name
# \arg:engine_name name of the engine
################################################################################
function(o3de_engine_path o3de_json_file engine_path)
o3de_engine_id(${o3de_json_file} engine_name)
if(engine_name)
o3de_find_engine_folder(${engine_name} engine_folder)
if(engine_folder)
set(${engine_path} ${engine_folder} PARENT_SCOPE)
endif()
endif()
endfunction()
################################################################################
#! o3de_project_path:
#
# \arg:project_path returns the path of the o3de project folder with name project_name
# \arg:project_name name of the project
################################################################################
function(o3de_project_path o3de_json_file project_path)
o3de_project_id(${o3de_json_file} project_name)
if(project_name)
o3de_find_project_folder(${project_name} project_folder)
if(project_folder)
set(${project_path} ${project_folder} PARENT_SCOPE)
endif()
endif()
endfunction()
################################################################################
#! o3de_template_path:
#
# \arg:template_path returns the path of the o3de template folder with name template_name
# \arg:template_name name of the template
################################################################################
function(o3de_template_path o3de_json_file template_path)
o3de_template_id(${o3de_json_file} template_name)
if(template_name)
o3de_find_template_folder(${template_name} template_folder)
if(template_folder)
set(${template_path} ${template_folder} PARENT_SCOPE)
endif()
endif()
endfunction()
################################################################################
#! o3de_repo_path:
#
# \arg:repo_path returns the path of the o3de repo folder with name repo_name
# \arg:repo_name name of the repo
################################################################################
function(o3de_repo_path o3de_json_file repo_path)
o3de_repo_id(${o3de_json_file} repo_name)
if(repo_name)
o3de_find_repo_folder(${repo_name} repo_folder)
if(repo_folder)
set(${repo_path} ${repo_folder} PARENT_SCOPE)
endif()
endif()
endfunction()
################################################################################
#! o3de_restricted_path:
#
# \arg:restricted_path returns the path of the o3de restricted folder with name restricted_name
# \arg:restricted_name name of the restricted
################################################################################
function(o3de_restricted_path o3de_json_file restricted_path)
o3de_restricted_id(${o3de_json_file} restricted_name)
if(restricted_name)
o3de_find_restricted_folder(${restricted_name} restricted_folder)
if(restricted_folder)
set(${restricted_path} ${restricted_folder} PARENT_SCOPE)
endif()
endif()
endfunction()