Fix PAL.cmake logic, thanks to lumberyard-employee-dm! (#3516)

* Fix PAL.cmake logic, thanks to lumberyard-employee-dm!

Signed-off-by: bosnichd <bosnichd@amazon.com>

* Lowercase the platform name to address review feedback.

Signed-off-by: bosnichd <bosnichd@amazon.com>
monroegm-disable-blank-issue-2
bosnichd 4 years ago committed by GitHub
parent d5ee6fb36f
commit 040b75c02c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -112,7 +112,8 @@ function(read_engine_restricted_path output_restricted_path)
# Set manifest path to path in the user home directory # Set manifest path to path in the user home directory
set(manifest_path ${LY_ROOT_FOLDER}/engine.json) set(manifest_path ${LY_ROOT_FOLDER}/engine.json)
if(EXISTS ${manifest_path}) if(EXISTS ${manifest_path})
o3de_restricted_path(${manifest_path} output_restricted_path) o3de_restricted_path(${manifest_path} read_restricted_path)
set(${output_restricted_path} ${read_restricted_path} PARENT_SCOPE)
endif() endif()
endfunction() endfunction()
@ -133,16 +134,17 @@ ly_set(PAL_HOST_PLATFORM_NAME_LOWERCASE ${PAL_HOST_PLATFORM_NAME_LOWERCASE})
set(PAL_RESTRICTED_PLATFORMS) 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) file(GLOB pal_restricted_files ${O3DE_ENGINE_RESTRICTED_PATH}/*/cmake/PAL_*.cmake)
foreach(pal_restricted_file ${pal_restricted_files}) foreach(pal_restricted_file ${pal_restricted_files})
string(FIND ${pal_restricted_file} "/cmake/PAL" end) # Get relative path from restricted root directory
if(${end} GREATER -1) cmake_path(RELATIVE_PATH pal_restricted_file BASE_DIRECTORY ${O3DE_ENGINE_RESTRICTED_PATH} OUTPUT_VARIABLE relative_pal_restricted_file)
math(EXPR platform_length "${end} - ${engine_restricted_length} - 1") # Split relative restricted path into path segments
math(EXPR platform_start "${engine_restricted_length} + 1") string(REPLACE "/" ";" pal_restricted_segments ${relative_pal_restricted_file})
string(SUBSTRING ${pal_restricted_file} ${platform_start} ${platform_length} platform) # Retrieve the first path segment which should be the restricted platform
list(APPEND PAL_RESTRICTED_PLATFORMS "${platform}") list(GET pal_restricted_segments 0 platform)
endif() # Append the new restricted platform
string(TOLOWER ${platform} platform_lower)
list(APPEND PAL_RESTRICTED_PLATFORMS ${platform_lower})
endforeach() endforeach()
ly_set(PAL_RESTRICTED_PLATFORMS ${PAL_RESTRICTED_PLATFORMS}) ly_set(PAL_RESTRICTED_PLATFORMS ${PAL_RESTRICTED_PLATFORMS})
@ -186,11 +188,17 @@ function(ly_get_absolute_pal_filename out_name in_name)
# Remove one path segment from the end of the current_object_path and prepend it to the list path_segments # 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 PARENT_PATH parent_path)
cmake_path(GET current_object_path FILENAME path_segment) cmake_path(GET current_object_path FILENAME path_segment)
list(PREPEND path_segments_visited 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}") cmake_path(SET current_object_path "${parent_path}")
set(is_prev_path_segment TRUE)
while(is_prev_path_segment) while(is_prev_path_segment)
# 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(SET current_object_path "${parent_path}")
# The Path is in a PAL structure # The Path is in a PAL structure
# Decompose the path into sections before "Platform" and after "Platform" # Decompose the path into sections before "Platform" and after "Platform"
if(path_segment STREQUAL "Platform") if(path_segment STREQUAL "Platform")
@ -205,21 +213,17 @@ function(ly_get_absolute_pal_filename out_name in_name)
break() break()
endif() endif()
# Remove one path segment from the end of the current_object_path and prepend it to the list path_segments list(PREPEND path_segments_visited ${path_segment})
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(SET current_object_path "${parent_path}")
endwhile() endwhile()
# Compose a candidate restricted path and examine if it exists # Compose a candidate restricted path and examine if it exists
cmake_path(APPEND object_restricted_path ${pre_platform_paths} "Platform" ${post_platform_paths} cmake_path(APPEND ${pre_platform_paths} "Platform" ${post_platform_paths}
OUTPUT_VARIABLE candidate_PAL_path) OUTPUT_VARIABLE candidate_PAL_path)
if(NOT EXISTS ${candidate_PAL_path}) if(NOT EXISTS ${candidate_PAL_path})
if("${candidate_platform_name}" IN_LIST PAL_RESTRICTED_PLATFORMS) string(TOLOWER ${candidate_platform_name} candidate_platform_name_lower)
if("${candidate_platform_name_lower}" IN_LIST PAL_RESTRICTED_PLATFORMS)
cmake_path(APPEND object_restricted_path ${candidate_platform_name} ${object_name} cmake_path(APPEND object_restricted_path ${candidate_platform_name} ${object_name}
${pre_platform_paths} ${post_platform_paths} OUTPUT_VARIABLE candidate_PAL_path) ${pre_platform_paths} OUTPUT_VARIABLE candidate_PAL_path)
endif() endif()
endif() endif()
if(EXISTS ${candidate_PAL_path}) if(EXISTS ${candidate_PAL_path})
@ -227,6 +231,7 @@ function(ly_get_absolute_pal_filename out_name in_name)
endif() endif()
endif() endif()
endif() endif()
cmake_path(ABSOLUTE_PATH full_name BASE_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
set(${out_name} ${full_name} PARENT_SCOPE) set(${out_name} ${full_name} PARENT_SCOPE)
endfunction() endfunction()

Loading…
Cancel
Save