Fix engine template issue (#6927)
* fix get_enabled_gem_cmake_file to work with "Dem" or "Code" or "Gem/Code" folder in a project fix o3de_restricted_path to make the past paramter optional Signed-off-by: byrcolin <byrcolin@amazon.com> * Fix resolution of variables in `cmake_path(COMPARE)` calls in PAL.cmake The documentation for `cmake_path(COMPARE)` states that parameters marked as [<input>](https://cmake.org/cmake/help/latest/command/cmake_path.html#conventions) are string literals. Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> Co-authored-by: byrcolin <byrcolin@amazon.com> Co-authored-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
This commit is contained in:
+20
-15
@@ -157,17 +157,17 @@ function(o3de_restricted_id o3de_json_file restricted parent_relative_path)
|
||||
# This object did not have a "restricted" set, now we must look at the parent
|
||||
# Stop if this is a top level object
|
||||
o3de_manifest_restricted(manifest_restricted_paths)
|
||||
get_filename_component(o3de_json_file_parent ${o3de_json_file} DIRECTORY)
|
||||
get_filename_component(relative_path ${o3de_json_file_parent} NAME)
|
||||
get_filename_component(o3de_json_file_parent ${o3de_json_file_parent} DIRECTORY)
|
||||
cmake_path(GET o3de_json_file PARENT_PATH o3de_json_file_parent)
|
||||
cmake_path(GET o3de_json_file_parent FILENAME relative_path)
|
||||
cmake_path(GET o3de_json_file_parent PARENT_PATH o3de_json_file_parent)
|
||||
if(${o3de_json_file_parent} IN_LIST manifest_restricted_paths)
|
||||
set(${parent_relative_path} "" PARENT_SCOPE)
|
||||
set(${restricted} "" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
string(LENGTH ${o3de_json_file_parent} parent_len)
|
||||
while(parent_len)
|
||||
set(is_prev_path_segment TRUE)
|
||||
while(is_prev_path_segment)
|
||||
if(EXISTS ${o3de_json_file_parent}/engine.json)
|
||||
o3de_json_restricted(${o3de_json_file_parent}/engine.json restricted_name)
|
||||
if(restricted_name)
|
||||
@@ -199,10 +199,12 @@ function(o3de_restricted_id o3de_json_file restricted parent_relative_path)
|
||||
return()
|
||||
endif()
|
||||
|
||||
get_filename_component(parent ${o3de_json_file_parent} NAME)
|
||||
string(PREPEND relative_path ${parent}/)
|
||||
get_filename_component(o3de_json_file_parent ${o3de_json_file_parent} DIRECTORY)
|
||||
string(LENGTH ${o3de_json_file_parent} parent_len)
|
||||
# Remove one path segment from the end of the o3de json candidate path
|
||||
cmake_path(GET o3de_json_file_parent PARENT_PATH parent_path)
|
||||
cmake_path(GET o3de_json_file_parent FILENAME path_segment)
|
||||
cmake_path(COMPARE "${o3de_json_file_parent}" NOT_EQUAL "${parent_path}" is_prev_path_segment)
|
||||
cmake_path(SET o3de_json_file_parent "${parent_path}")
|
||||
cmake_path(SET relative_path "${path_segment}/${relative_path}")
|
||||
endwhile()
|
||||
endfunction()
|
||||
|
||||
@@ -232,10 +234,13 @@ endfunction()
|
||||
#! o3de_restricted_path:
|
||||
#
|
||||
# \arg:o3de_json_file json file to read restricted id from
|
||||
# \arg:restricted_name name of the restricted object
|
||||
function(o3de_restricted_path o3de_json_file restricted_path parent_relative_path)
|
||||
# \arg:restricted_path output path of the restricted object
|
||||
# \arg:parent_relative_path optional output of the path relative to the parent
|
||||
function(o3de_restricted_path o3de_json_file restricted_path) #parent_relative_path
|
||||
o3de_restricted_id(${o3de_json_file} restricted_name parent_relative)
|
||||
set(${parent_relative_path} ${parent_relative} PARENT_SCOPE)
|
||||
if(${ARGC} GREATER 2)
|
||||
set(${ARGV2} ${parent_relative} PARENT_SCOPE)
|
||||
endif()
|
||||
if(restricted_name)
|
||||
o3de_find_restricted_folder(${restricted_name} restricted_folder)
|
||||
if(restricted_folder)
|
||||
@@ -254,7 +259,7 @@ foreach(detection_file ${detection_files})
|
||||
endforeach()
|
||||
|
||||
# set the O3DE_ENGINE_RESTRICTED_PATH
|
||||
o3de_restricted_path(${LY_ROOT_FOLDER}/engine.json O3DE_ENGINE_RESTRICTED_PATH engine_has_no_parent)
|
||||
o3de_restricted_path(${LY_ROOT_FOLDER}/engine.json O3DE_ENGINE_RESTRICTED_PATH)
|
||||
|
||||
# detect platforms in the restricted path
|
||||
file(GLOB detection_files ${O3DE_ENGINE_RESTRICTED_PATH}/*/cmake/PALDetection_*.cmake)
|
||||
@@ -338,7 +343,7 @@ function(o3de_pal_dir out_name in_name object_restricted_path object_path) #pare
|
||||
cmake_path(GET current_object_path PARENT_PATH parent_path)
|
||||
cmake_path(GET current_object_path FILENAME path_segment)
|
||||
list(PREPEND path_segments_visited ${path_segment})
|
||||
cmake_path(COMPARE current_object_path NOT_EQUAL parent_path is_prev_path_segment)
|
||||
cmake_path(COMPARE "${current_object_path}" NOT_EQUAL "${parent_path}" is_prev_path_segment)
|
||||
cmake_path(SET current_object_path "${parent_path}")
|
||||
|
||||
set(is_prev_path_segment TRUE)
|
||||
@@ -346,7 +351,7 @@ function(o3de_pal_dir out_name in_name object_restricted_path object_path) #pare
|
||||
# Remove one path segment from the end of the current_object_path and prepend it to the list path_segments
|
||||
cmake_path(GET current_object_path PARENT_PATH parent_path)
|
||||
cmake_path(GET current_object_path FILENAME path_segment)
|
||||
cmake_path(COMPARE current_object_path NOT_EQUAL parent_path is_prev_path_segment)
|
||||
cmake_path(COMPARE "${current_object_path}" NOT_EQUAL "${parent_path}" is_prev_path_segment)
|
||||
cmake_path(SET current_object_path "${parent_path}")
|
||||
# The Path is in a PAL structure
|
||||
# Decompose the path into sections before "Platform" and after "Platform"
|
||||
|
||||
+18
-10
@@ -235,14 +235,22 @@ def get_enabled_gem_cmake_file(project_name: str = None,
|
||||
enable_gem_filename = "enabled_gems.cmake"
|
||||
|
||||
if platform == 'Common':
|
||||
project_code_dir = project_path / 'Gem/Code'
|
||||
if project_code_dir.is_dir():
|
||||
dependencies_file_path = project_code_dir / enable_gem_filename
|
||||
return dependencies_file_path.resolve()
|
||||
return (project_path / 'Code' / enable_gem_filename).resolve()
|
||||
possible_project_enable_gem_filename_paths = [
|
||||
pathlib.Path(project_path / 'Gem' / enable_gem_filename),
|
||||
pathlib.Path(project_path / 'Gem/Code' / enable_gem_filename),
|
||||
pathlib.Path(project_path / 'Code' / enable_gem_filename)
|
||||
]
|
||||
for possible_project_enable_gem_filename_path in possible_project_enable_gem_filename_paths:
|
||||
if possible_project_enable_gem_filename_path.is_file():
|
||||
return possible_project_enable_gem_filename_path.resolve()
|
||||
return possible_project_enable_gem_filename_paths[0].resolve()
|
||||
else:
|
||||
project_code_dir = project_path / 'Gem/Code/Platform' / platform
|
||||
if project_code_dir.is_dir():
|
||||
dependencies_file_path = project_code_dir / enable_gem_filename
|
||||
return dependencies_file_path.resolve()
|
||||
return (project_path / 'Code/Platform' / platform / enable_gem_filename).resolve()
|
||||
possible_project_platform_enable_gem_filename_paths = [
|
||||
pathlib.Path(project_path / 'Gem/Platform' / platform / enable_gem_filename),
|
||||
pathlib.Path(project_path / 'Gem/Code/Platform' / platform / enable_gem_filename),
|
||||
pathlib.Path(project_path / 'Code/Platform' / platform / enable_gem_filename)
|
||||
]
|
||||
for possible_project_platform_enable_gem_filename_path in possible_project_platform_enable_gem_filename_paths:
|
||||
if possible_project_platform_enable_gem_filename_path.is_file():
|
||||
return possible_project_platform_enable_gem_filename_path.resolve()
|
||||
return possible_project_platform_enable_gem_filename_paths[0].resolve()
|
||||
|
||||
Reference in New Issue
Block a user