Updating the Install_common.cmake script to copy over the source engine.json templates array to the generated installed engine.json

main
lumberyard-employee-dm 5 years ago
parent 44c8a19bce
commit 84cf3bffde

@ -23,26 +23,33 @@ set(LY_EXTERNAL_SUBDIRS "" CACHE STRING "List of subdirectories to recurse into
# \arg:input_json_path path to the *.json file to load and read the external subdirectories from # \arg:input_json_path path to the *.json file to load and read the external subdirectories from
# \return: external subdirectories as is from the json file. # \return: external subdirectories as is from the json file.
function(read_json_external_subdirs output_external_subdirs input_json_path) function(read_json_external_subdirs output_external_subdirs input_json_path)
o3de_read_json_array(json_array ${input_json_path} "external_subdirectories")
set(${output_external_subdirs} ${json_array} PARENT_SCOPE)
endfunction()
#! read_json_array
# Reads the a json array field into a cmake list variable
function(o3de_read_json_array read_output_array input_json_path array_key)
file(READ ${input_json_path} manifest_json_data) file(READ ${input_json_path} manifest_json_data)
string(JSON external_subdirs_count ERROR_VARIABLE manifest_json_error string(JSON array_count ERROR_VARIABLE manifest_json_error
LENGTH ${manifest_json_data} "external_subdirectories") LENGTH ${manifest_json_data} ${array_key})
if(manifest_json_error) if(manifest_json_error)
# There is "external_subdirectories" key, so theire are no subdirectories to read # There is no key, return
return() return()
endif() endif()
if(external_subdirs_count GREATER 0) if(array_count GREATER 0)
math(EXPR external_subdir_range "${external_subdirs_count}-1") math(EXPR array_range "${array_count}-1")
foreach(external_subdir_index RANGE ${external_subdir_range}) foreach(array_index RANGE ${array_range})
string(JSON external_subdir ERROR_VARIABLE manifest_json_error string(JSON array_element ERROR_VARIABLE manifest_json_error
GET ${manifest_json_data} "external_subdirectories" "${external_subdir_index}") GET ${manifest_json_data} ${array_key} "${array_index}")
if(manifest_json_error) if(manifest_json_error)
message(FATAL_ERROR "Error reading field at index ${external_subdir_index} in \"external_subdirectories\" JSON array: ${manifest_json_error}") message(FATAL_ERROR "Error reading field at index ${array_index} in \"${array_key}\" JSON array: ${manifest_json_error}")
endif() endif()
list(APPEND external_subdirs ${external_subdir}) list(APPEND array_elements ${array_element})
endforeach() endforeach()
endif() endif()
set(${output_external_subdirs} ${external_subdirs} PARENT_SCOPE) set(${read_output_array} ${array_elements} PARENT_SCOPE)
endfunction() endfunction()
function(o3de_read_json_key output_value input_json_path key) function(o3de_read_json_key output_value input_json_path key)

@ -225,14 +225,19 @@ function(ly_setup_cmake_install)
) )
# Transform the LY_EXTERNAL_SUBDIRS list into a json array # Transform the LY_EXTERNAL_SUBDIRS list into a json array
set(LY_INSTALL_EXTERNAL_SUBDIRS "[]") set(indent " ")
set(external_subdir_index "0")
foreach(external_subdir ${LY_EXTERNAL_SUBDIRS}) foreach(external_subdir ${LY_EXTERNAL_SUBDIRS})
math(EXPR external_subdir_index "${external_subdir_index} + 1")
file(RELATIVE_PATH engine_rel_external_subdir ${LY_ROOT_FOLDER} ${external_subdir}) file(RELATIVE_PATH engine_rel_external_subdir ${LY_ROOT_FOLDER} ${external_subdir})
string(JSON LY_INSTALL_EXTERNAL_SUBDIRS ERROR_VARIABLE external_subdir_error SET ${LY_INSTALL_EXTERNAL_SUBDIRS} list(APPEND relative_external_subdirs "\"${engine_rel_external_subdir}\"")
${external_subdir_index} "\"${engine_rel_external_subdir}\"")
endforeach() endforeach()
list(JOIN relative_external_subdirs ",\n${indent}" LY_INSTALL_EXTERNAL_SUBDIRS)
# Read the "templates" key from the source engine.json
o3de_read_json_array(engine_templates ${LY_ROOT_FOLDER}/engine.json "templates")
foreach(template_path ${engine_templates})
list(APPEND relative_templates "\"${template_path}\"")
endforeach()
list(JOIN relative_templates ",\n${indent}" LY_INSTALL_TEMPLATES)
configure_file(${LY_ROOT_FOLDER}/cmake/install/engine.json.in ${CMAKE_CURRENT_BINARY_DIR}/cmake/engine.json @ONLY) configure_file(${LY_ROOT_FOLDER}/cmake/install/engine.json.in ${CMAKE_CURRENT_BINARY_DIR}/cmake/engine.json @ONLY)

@ -5,7 +5,7 @@
"O3DEVersion": "@LY_VERSION_STRING@", "O3DEVersion": "@LY_VERSION_STRING@",
"O3DECopyrightYear": @LY_VERSION_COPYRIGHT_YEAR@, "O3DECopyrightYear": @LY_VERSION_COPYRIGHT_YEAR@,
"O3DEBuildNumber": @LY_VERSION_BUILD_NUMBER@, "O3DEBuildNumber": @LY_VERSION_BUILD_NUMBER@,
"external_subdirectories": @LY_INSTALL_EXTERNAL_SUBDIRS@, "external_subdirectories": [@LY_INSTALL_EXTERNAL_SUBDIRS@],
"projects": [@LY_INSTALL_PROJECTS@], "projects": [@LY_INSTALL_PROJECTS@],
"templates": [@LY_INSTALL_TEMPLATES@] "templates": [@LY_INSTALL_TEMPLATES@]
} }

Loading…
Cancel
Save