SPEC-6663 add file(READ files to tracking (#1416)

* adding property to track files read by file(READ

* code review comments

* adding newline
main
Esteban Papp 5 years ago committed by GitHub
parent 8fb0007201
commit 2fa6883455
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -15,6 +15,8 @@ include_guard()
# Read the engine name from the project_json file # Read the engine name from the project_json file
file(READ ${CMAKE_CURRENT_LIST_DIR}/project.json project_json) file(READ ${CMAKE_CURRENT_LIST_DIR}/project.json project_json)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_CURRENT_LIST_DIR}/project.json)
string(JSON LY_ENGINE_NAME_TO_USE ERROR_VARIABLE json_error GET ${project_json} engine) string(JSON LY_ENGINE_NAME_TO_USE ERROR_VARIABLE json_error GET ${project_json} engine)
if(json_error) if(json_error)
message(FATAL_ERROR "Unable to read key 'engine' from 'project.json', error: ${json_error}") message(FATAL_ERROR "Unable to read key 'engine' from 'project.json', error: ${json_error}")
@ -30,6 +32,7 @@ endif()
# Find a key that matches LY_ENGINE_NAME_TO_USE and use that as the engine path. # Find a key that matches LY_ENGINE_NAME_TO_USE and use that as the engine path.
if(EXISTS ${manifest_path}) if(EXISTS ${manifest_path})
file(READ ${manifest_path} manifest_json) file(READ ${manifest_path} manifest_json)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${manifest_path})
string(JSON engines_path_count ERROR_VARIABLE json_error LENGTH ${manifest_json} engines_path) string(JSON engines_path_count ERROR_VARIABLE json_error LENGTH ${manifest_json} engines_path)
if(json_error) if(json_error)

@ -26,7 +26,7 @@ foreach(project_name project_path IN ZIP_LISTS LY_PROJECTS_TARGET_NAME LY_PROJEC
message(FATAL_ERROR "The specified project path of ${project_real_path} does not contain a project.json file") message(FATAL_ERROR "The specified project path of ${project_real_path} does not contain a project.json file")
else() else()
# Add the project_name to global LY_PROJECTS_TARGET_NAME property # Add the project_name to global LY_PROJECTS_TARGET_NAME property
file(READ "${project_real_path}/project.json" project_json) ly_file_read("${project_real_path}/project.json" project_json)
string(JSON project_name ERROR_VARIABLE json_error GET ${project_json} "project_name") string(JSON project_name ERROR_VARIABLE json_error GET ${project_json} "project_name")
if(json_error) if(json_error)
message(FATAL_ERROR "There is an error reading the \"project_name\" key from the '${project_real_path}/project.json' file: ${json_error}") message(FATAL_ERROR "There is an error reading the \"project_name\" key from the '${project_real_path}/project.json' file: ${json_error}")

@ -17,6 +17,8 @@ include_guard()
# Read the engine name from the project_json file # Read the engine name from the project_json file
file(READ ${CMAKE_CURRENT_LIST_DIR}/project.json project_json) file(READ ${CMAKE_CURRENT_LIST_DIR}/project.json project_json)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_CURRENT_LIST_DIR}/project.json)
string(JSON LY_ENGINE_NAME_TO_USE ERROR_VARIABLE json_error GET ${project_json} engine) string(JSON LY_ENGINE_NAME_TO_USE ERROR_VARIABLE json_error GET ${project_json} engine)
if(json_error) if(json_error)
message(FATAL_ERROR "Unable to read key 'engine' from 'project.json', error: ${json_error}") message(FATAL_ERROR "Unable to read key 'engine' from 'project.json', error: ${json_error}")
@ -32,6 +34,7 @@ endif()
# Find a key that matches LY_ENGINE_NAME_TO_USE and use that as the engine path. # Find a key that matches LY_ENGINE_NAME_TO_USE and use that as the engine path.
if(EXISTS ${manifest_path}) if(EXISTS ${manifest_path})
file(READ ${manifest_path} manifest_json) file(READ ${manifest_path} manifest_json)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${manifest_path})
string(JSON engines_path_count ERROR_VARIABLE json_error LENGTH ${manifest_json} engines_path) string(JSON engines_path_count ERROR_VARIABLE json_error LENGTH ${manifest_json} engines_path)
if(json_error) if(json_error)

@ -17,6 +17,8 @@ include_guard()
# Read the engine name from the project_json file # Read the engine name from the project_json file
file(READ ${CMAKE_CURRENT_LIST_DIR}/project.json project_json) file(READ ${CMAKE_CURRENT_LIST_DIR}/project.json project_json)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_CURRENT_LIST_DIR}/project.json)
string(JSON LY_ENGINE_NAME_TO_USE ERROR_VARIABLE json_error GET ${project_json} engine) string(JSON LY_ENGINE_NAME_TO_USE ERROR_VARIABLE json_error GET ${project_json} engine)
if(json_error) if(json_error)
message(FATAL_ERROR "Unable to read key 'engine' from 'project.json', error: ${json_error}") message(FATAL_ERROR "Unable to read key 'engine' from 'project.json', error: ${json_error}")
@ -32,6 +34,7 @@ endif()
# Find a key that matches LY_ENGINE_NAME_TO_USE and use that as the engine path. # Find a key that matches LY_ENGINE_NAME_TO_USE and use that as the engine path.
if(EXISTS ${manifest_path}) if(EXISTS ${manifest_path})
file(READ ${manifest_path} manifest_json) file(READ ${manifest_path} manifest_json)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${manifest_path})
string(JSON engines_path_count ERROR_VARIABLE json_error LENGTH ${manifest_json} engines_path) string(JSON engines_path_count ERROR_VARIABLE json_error LENGTH ${manifest_json} engines_path)
if(json_error) if(json_error)

@ -22,7 +22,7 @@ set(LY_EXTERNAL_SUBDIRS "" CACHE STRING "List of subdirectories to recurse into
# Restricted folders(contains an additional restricted.json), etc... # Restricted folders(contains an additional restricted.json), etc...
# \arg:output_external_subdirs name of output variable to store external subdirectories into # \arg:output_external_subdirs name of output variable to store external subdirectories into
function(read_engine_external_subdirs output_external_subdirs) function(read_engine_external_subdirs output_external_subdirs)
file(READ ${LY_ROOT_FOLDER}/engine.json engine_json_data) ly_file_read(${LY_ROOT_FOLDER}/engine.json engine_json_data)
string(JSON external_subdirs_count ERROR_VARIABLE engine_json_error string(JSON external_subdirs_count ERROR_VARIABLE engine_json_error
LENGTH ${engine_json_data} "external_subdirectories") LENGTH ${engine_json_data} "external_subdirectories")
if(engine_json_error) if(engine_json_error)

@ -118,4 +118,13 @@ override_pak_root=${LY_OVERRIDE_PAK_FOLDER_ROOT}
endfunction() endfunction()
#! ly_file_read: wrap to file(READ) that adds the file to configuration tracking
#
# file(READ) does not add file tracking. So changes to the file being read will not cause a cmake regeneration
#
function(ly_file_read path content)
unset(file_content)
file(READ ${path} file_content)
set(${content} ${file_content} PARENT_SCOPE)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${path})
endfunction()

@ -22,6 +22,8 @@ o3de_current_file_path(current_path)
# Make sure we are matching LY_ENGINE_NAME_TO_USE with the current engine # Make sure we are matching LY_ENGINE_NAME_TO_USE with the current engine
file(READ ${current_path}/../engine.json engine_json) file(READ ${current_path}/../engine.json engine_json)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${current_path}/../engine.json)
string(JSON this_engine_name ERROR_VARIABLE json_error GET ${engine_json} engine_name) string(JSON this_engine_name ERROR_VARIABLE json_error GET ${engine_json} engine_name)
if(json_error) if(json_error)
message(FATAL_ERROR "Unable to read key 'engine_name' from '${current_path}/../engine.json', error: ${json_error}") message(FATAL_ERROR "Unable to read key 'engine_name' from '${current_path}/../engine.json', error: ${json_error}")

@ -30,7 +30,7 @@ endfunction()
#! read_json_array #! read_json_array
# Reads the a json array field into a cmake list variable # Reads the a json array field into a cmake list variable
function(o3de_read_json_array read_output_array input_json_path array_key) function(o3de_read_json_array read_output_array input_json_path array_key)
file(READ ${input_json_path} manifest_json_data) ly_file_read(${input_json_path} manifest_json_data)
string(JSON array_count ERROR_VARIABLE manifest_json_error string(JSON array_count ERROR_VARIABLE manifest_json_error
LENGTH ${manifest_json_data} ${array_key}) LENGTH ${manifest_json_data} ${array_key})
if(manifest_json_error) if(manifest_json_error)
@ -53,7 +53,7 @@ function(o3de_read_json_array read_output_array input_json_path array_key)
endfunction() endfunction()
function(o3de_read_json_key output_value input_json_path key) function(o3de_read_json_key output_value input_json_path key)
file(READ ${input_json_path} manifest_json_data) ly_file_read(${input_json_path} manifest_json_data)
string(JSON value ERROR_VARIABLE manifest_json_error GET ${manifest_json_data} ${key}) string(JSON value ERROR_VARIABLE manifest_json_error GET ${manifest_json_data} ${key})
if(manifest_json_error) if(manifest_json_error)
message(FATAL_ERROR "Error reading field at key ${key} in file \"${input_json_path}\" : ${manifest_json_error}") message(FATAL_ERROR "Error reading field at key ${key} in file \"${input_json_path}\" : ${manifest_json_error}")

@ -30,7 +30,7 @@ endforeach()
# \arg:restricted returns the restricted association element from an o3de json, otherwise engine 'o3de' is assumed # \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 # \arg:o3de_json_file name of the o3de json file
function(o3de_restricted_id o3de_json_file restricted) function(o3de_restricted_id o3de_json_file restricted)
file(READ ${o3de_json_file} json_data) ly_file_read(${o3de_json_file} json_data)
string(JSON restricted_entry ERROR_VARIABLE json_error GET ${json_data} "restricted_name") string(JSON restricted_entry ERROR_VARIABLE json_error GET ${json_data} "restricted_name")
if(json_error) if(json_error)
message(WARNING "Unable to read restricted from '${o3de_json_file}', error: ${json_error}") message(WARNING "Unable to read restricted from '${o3de_json_file}', error: ${json_error}")
@ -46,7 +46,7 @@ endfunction()
# \arg:restricted_name name of the restricted # \arg:restricted_name name of the restricted
function(o3de_find_restricted_folder restricted_name restricted_path) function(o3de_find_restricted_folder restricted_name restricted_path)
# Read the restricted path from engine.json if one EXISTS # Read the restricted path from engine.json if one EXISTS
file(READ ${LY_ROOT_FOLDER}/engine.json engine_json_data) ly_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") string(JSON restricted_subdirs_count ERROR_VARIABLE engine_json_error LENGTH ${engine_json_data} "restricted")
if(restricted_subdirs_count GREATER 0) if(restricted_subdirs_count GREATER 0)
string(JSON restricted_subdir ERROR_VARIABLE engine_json_error GET ${engine_json_data} "restricted" "0") string(JSON restricted_subdir ERROR_VARIABLE engine_json_error GET ${engine_json_data} "restricted" "0")
@ -66,7 +66,7 @@ function(o3de_find_restricted_folder restricted_name restricted_path)
# Examine the o3de manifest file for the list of restricted directories # Examine the o3de manifest file for the list of restricted directories
set(o3de_manifest_path ${home_directory}/.o3de/o3de_manifest.json) set(o3de_manifest_path ${home_directory}/.o3de/o3de_manifest.json)
if(EXISTS ${o3de_manifest_path}) if(EXISTS ${o3de_manifest_path})
file(READ ${o3de_manifest_path} o3de_manifest_json_data) ly_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") string(JSON restricted_subdirs_count ERROR_VARIABLE engine_json_error LENGTH ${o3de_manifest_json_data} "restricted")
if(restricted_subdirs_count GREATER 0) if(restricted_subdirs_count GREATER 0)
math(EXPR restricted_subdirs_range "${restricted_subdirs_count}-1") math(EXPR restricted_subdirs_range "${restricted_subdirs_count}-1")
@ -79,7 +79,7 @@ function(o3de_find_restricted_folder restricted_name restricted_path)
# Iterate over the restricted directories from the manifest file # Iterate over the restricted directories from the manifest file
foreach(restricted_entry ${restricted_subdirs}) foreach(restricted_entry ${restricted_subdirs})
set(restricted_json_file ${restricted_entry}/restricted.json) set(restricted_json_file ${restricted_entry}/restricted.json)
file(READ ${restricted_json_file} restricted_json) ly_file_read(${restricted_json_file} restricted_json)
string(JSON this_restricted_name ERROR_VARIABLE json_error GET ${restricted_json} "restricted_name") string(JSON this_restricted_name ERROR_VARIABLE json_error GET ${restricted_json} "restricted_name")
if(json_error) if(json_error)
message(WARNING "Unable to read restricted_name from '${restricted_json_file}', error: ${json_error}") message(WARNING "Unable to read restricted_name from '${restricted_json_file}', error: ${json_error}")

@ -240,7 +240,7 @@ set_property(TARGET ${TARGET_NAME}
) )
# Since a CMakeLists.txt could contain multiple targets, we generate it in a folder per target # Since a CMakeLists.txt could contain multiple targets, we generate it in a folder per target
file(READ ${LY_ROOT_FOLDER}/cmake/install/InstalledTarget.in target_cmakelists_template) ly_file_read(${LY_ROOT_FOLDER}/cmake/install/InstalledTarget.in target_cmakelists_template)
string(CONFIGURE ${target_cmakelists_template} output_cmakelists_data @ONLY) string(CONFIGURE ${target_cmakelists_template} output_cmakelists_data @ONLY)
set(${OUTPUT_CONFIGURED_TARGET} ${output_cmakelists_data} PARENT_SCOPE) set(${OUTPUT_CONFIGURED_TARGET} ${output_cmakelists_data} PARENT_SCOPE)
endfunction() endfunction()
@ -317,8 +317,7 @@ function(ly_setup_subdirectory absolute_target_source_dir)
string(APPEND ENABLE_GEMS_PLACEHOLDER ${enable_gems_command}) string(APPEND ENABLE_GEMS_PLACEHOLDER ${enable_gems_command})
endforeach() endforeach()
ly_file_read(${LY_ROOT_FOLDER}/cmake/install/Copyright.in cmake_copyright_comment)
file(READ ${LY_ROOT_FOLDER}/cmake/install/Copyright.in cmake_copyright_comment)
# Initialize the target install source directory to path underneath the current binary directory # Initialize the target install source directory to path underneath the current binary directory
set(target_install_source_dir ${CMAKE_CURRENT_BINARY_DIR}/install/${relative_target_source_dir}) set(target_install_source_dir ${CMAKE_CURRENT_BINARY_DIR}/install/${relative_target_source_dir})

@ -334,7 +334,7 @@ function(ly_test_impact_write_config_file CONFIG_TEMPLATE_FILE PERSISTENT_DATA_D
) )
# Substitute config file template with above vars # Substitute config file template with above vars
file(READ "${CONFIG_TEMPLATE_FILE}" config_file) ly_file_read("${CONFIG_TEMPLATE_FILE}" config_file)
string(CONFIGURE ${config_file} config_file) string(CONFIGURE ${config_file} config_file)
# Write out entire config contents to a file in the build directory of the test impact framework console target # Write out entire config contents to a file in the build directory of the test impact framework console target

Loading…
Cancel
Save