@ -29,7 +29,8 @@ function(o3de_restricted_id o3de_json_file restricted)
ly_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}" )
# R e s t r i c t e d f i e l d s c a n n e v e r b e a r e q u i r e m e n t s o n o w a r n i n g i s i s s u e d
return ( )
endif ( )
if ( restricted_entry )
set ( ${ restricted } ${ restricted_entry } PARENT_SCOPE )
@ -148,86 +149,89 @@ function(ly_get_absolute_pal_filename out_name in_name)
set ( full_name ${ in_name } )
if ( ${ ARGC } GREATER 4 )
# T h e u s e r h a s s u p p l i e d a n o b j e c t r e s t r i c t e d p a t h , t h e o b j e c t p a t h a n d t h e o b j e c t n a m e f o r c o n s i d e r a t i o n
set ( object_restricted_path ${ ARGV2 } )
set ( object_path ${ ARGV3 } )
# T h e o b j e c t n a m e i s u s e d t o r e s o l v e a m b i g u i t i e s w h e n a P A L d i r e c t o r y i s r e q u e s t e d f r o m
# t w o d i f f e r e n t e x t e r n a l s u b d i r e c t o r y r o o t p a t h s
# S u c h a s i f a P A L d i r e c t o r y f o r t w o r o o t o b j e c t p a t h s w i t h s a m e r e l a t i v e s t r u c t u r e w a s r e q u e s t e d t o b e P a l i f i e d
# i . e < g e m - r o o t 1 > / P l a t f o r m / < p l a t f o r m - n a m e > / I O a n d < g e m - r o o t 2 > / P l a t f o r m / < p l a t f o r m - n a m e > / I O
# N o r m a l l y t h e r e s t r i c t e d P A L p a t h f o r b o t h g e m s w o u l d b e " < r e s t r i c t e d - r o o t - p a t h > / < p l a t f o r m - n a m e > / I O " .
# T h e o b j e c t n a m e c a n b e u s e d t o m a k e t h i s p a t h u n i q u e
# " < r e s t r i c t e d - r o o t - p a t h > / < p l a t f o r m - n a m e > / < c u s t o m - n a m e 1 > / I O " f o r g e m 1 a n d
# " < r e s t r i c t e d - r o o t - p a t h > / < p l a t f o r m - n a m e > / < c u s t o m - n a m e 2 > / I O " f o r g e m 2
set ( object_name ${ ARGV4 } )
# i f t h e f i l e i s n o t i n t h e o b j e c t p a t h t h e n w e c a n n o t d e t e r m i n e a P A L f i l e f o r i t
file ( RELATIVE_PATH relative_path ${ object_path } ${ full_name } )
if ( NOT ( IS_ABSOLUTE relative_path OR relative_path MATCHES [[^(\.\./ ) +(.* ) ] ] ) )
if ( NOT EXISTS ${ full_name } )
string ( REGEX MATCH "${object_path}/(.*)/Platform/([^/]*)/?(.*)$" match ${ full_name } )
if ( NOT CMAKE_MATCH_1 )
string ( REGEX MATCH "${object_path}/Platform/([^/]*)/?(.*)$" match ${ full_name } )
set ( full_name ${ object_restricted_path } / ${ CMAKE_MATCH_1 } / ${ object_name } )
if ( CMAKE_MATCH_2 )
string ( APPEND full_name "/" ${ CMAKE_MATCH_2 } )
endif ( )
elseif ( "${CMAKE_MATCH_2}" IN_LIST PAL_RESTRICTED_PLATFORMS )
set ( full_name ${ object_restricted_path } / ${ CMAKE_MATCH_2 } / ${ object_name } / ${ CMAKE_MATCH_1 } )
if ( CMAKE_MATCH_3 )
string ( APPEND full_name "/" ${ CMAKE_MATCH_3 } )
endif ( )
endif ( )
endif ( )
endif ( )
set ( ${ out_name } ${ full_name } PARENT_SCOPE )
elseif ( ${ ARGC } GREATER 3 )
# T h e D e f a u l t o b j e c t p a t h f o r p a t h i s t h e L Y _ R O O T _ F O L D E R
cmake_path ( SET object_path NORMALIZE "${LY_ROOT_FOLDER}" )
if ( ${ ARGC } GREATER 3 )
# T h e u s e r h a s s u p p l i e d a n o b j e c t r e s t r i c t e d p a t h , t h e o b j e c t p a t h f o r c o n s i d e r a t i o n
set ( object_restricted_path ${ ARGV2 } )
set ( object_path ${ ARGV3 } )
# i f t h e f i l e i s n o t i n t h e o b j e c t p a t h t h e n w e c a n n o t d e t e r m i n e a P A L f i l e f o r i t
file ( RELATIVE_PATH relative_path ${ object_path } ${ full_name } )
if ( NOT ( IS_ABSOLUTE relative_path OR relative_path MATCHES [[^(\.\./ ) +(.* ) ] ] ) )
if ( NOT EXISTS ${ full_name } )
string ( REGEX MATCH "${object_path}/(.*)/Platform/([^/]*)/?(.*)$" match ${ full_name } )
if ( NOT CMAKE_MATCH_1 )
string ( REGEX MATCH "${object_path}/Platform/([^/]*)/?(.*)$" match ${ full_name } )
set ( full_name ${ object_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 ${ object_restricted_path } / ${ CMAKE_MATCH_2 } / ${ CMAKE_MATCH_1 } )
if ( CMAKE_MATCH_3 )
string ( APPEND full_name "/" ${ CMAKE_MATCH_3 } )
endif ( )
endif ( )
cmake_path ( SET object_path NORMALIZE ${ ARGV3 } )
endif ( )
# T h e D e f a u l t r e s t r i c t e d o b j e c t p a t h i s t h e r e s u l t o f t h e r e a d _ e n g i n e _ r e s t r i c t e d _ p a t h f u n c t i o n
cmake_path ( SET object_restricted_path NORMALIZE "${O3DE_ENGINE_RESTRICTED_PATH}" )
if ( ${ ARGC } GREATER 2 )
# T h e u s e r h a s s u p p l i e d a n o b j e c t r e s t r i c t e d p a t h
cmake_path ( SET object_restricted_path NORMALIZE ${ ARGV2 } )
endif ( )
set ( ${ out_name } ${ full_name } PARENT_SCOPE )
else ( )
# T h e u s e r h a s n o t s u p p l i e d a n y p a t h s o w e m u s t a s s u m e i t i s t h e o 3 d e e n g i n e r e s t r i c t e d a n d o 3 d e e n g i n e p a t h
# i f t h e f i l e i s n o t i n t h e o 3 d e e n g i n e p a t h t h e n w e c a n n o t d e t e r m i n e a P A L f i l e f o r i t
file ( RELATIVE_PATH relative_path ${ LY_ROOT_FOLDER } ${ full_name } )
if ( NOT ( IS_ABSOLUTE relative_path OR relative_path MATCHES [[^(\.\./ ) +(.* ) ] ] ) )
# T h e i n p u t p a t h m u s t e x i s t i n o r d e r t o f o r m a P A L p a t h
if ( NOT EXISTS ${ full_name } )
string ( REGEX MATCH "${LY_ROOT_FOLDER}/(.*)/Platform/([^/]*)/?(.*)$" match ${ full_name } )
if ( NOT 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 } )
if ( CMAKE_MATCH_3 )
string ( APPEND full_name "/" ${ CMAKE_MATCH_3 } )
endif ( )
# i f t h e f i l e i s n o t i n t h e o b j e c t p a t h t h e n w e c a n n o t d e t e r m i n e a P A L f i l e f o r i t
cmake_path ( IS_PREFIX object_path ${ full_name } is_input_path_in_root )
if ( is_input_path_in_root )
cmake_path ( RELATIVE_PATH full_name BASE_DIRECTORY ${ object_path } OUTPUT_VARIABLE relative_object_path )
cmake_path ( SET current_object_path ${ relative_object_path } )
# R e m o v e o n e p a t h s e g m e n t f r o m t h e e n d o f t h e c u r r e n t _ o b j e c t _ p a t h a n d p r e p e n d i t t o t h e l i s t p a t h _ s e g m e n t s
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}" )
while ( is_prev_path_segment )
# T h e P a t h i s i n a P A L s t r u c t u r e
# D e c o m p o s e t h e p a t h i n t o s e c t i o n s b e f o r e " P l a t f o r m " a n d a f t e r " P l a t f o r m "
if ( path_segment STREQUAL "Platform" )
# T h e f i r s t p a t h s e g m e n t a f t e r t h e " < p r e - p l a t f o r m - p a t h s > / P l a t f o r m / < p o s t - p l a t f o r m - p a t h s > "
# i s a p o t e n t i a l p l a t f o r m n a m e . S t o r e i t o f f f o r l a t e r c h e c k s
list ( GET path_segments_visited 0 candidate_platform_name )
# S t o r e o f f a l l t h e p a t h s e g m e n t s i t e r a t e d f r o m t h e e n d i n t h e p o s t - " P l a t f o r m " p a t h
cmake_path ( APPEND post_platform_paths ${ path_segments_visited } )
# T h e p a r e n t p a t h i s j u s t t h e p r e - " P l a t f o r m " s e c t i o n o f t h e p a t h
cmake_path ( SET pre_platform_paths "${parent_path}" )
break ( )
endif ( )
# R e m o v e o n e p a t h s e g m e n t f r o m t h e e n d o f t h e c u r r e n t _ o b j e c t _ p a t h a n d p r e p e n d i t t o t h e l i s t p a t h _ s e g m e n t s
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 ( )
# C o m p o s e a c a n d i d a t e r e s t r i c t e d p a t h a n d e x a m i n e i f i t e x i s t s
cmake_path ( APPEND object_restricted_path ${ pre_platform_paths } "Platform" ${ post_platform_paths }
O U T P U T _ V A R I A B L E c a n d i d a t e _ P A L _ p a t h )
if ( NOT EXISTS ${ candidate_PAL_path } )
if ( "${candidate_platform_name}" IN_LIST PAL_RESTRICTED_PLATFORMS )
cmake_path ( APPEND object_restricted_path ${ candidate_platform_name } ${ object_name }
$ { p r e _ p l a t f o r m _ p a t h s } $ { p o s t _ p l a t f o r m _ p a t h s } O U T P U T _ V A R I A B L E c a n d i d a t e _ P A L _ p a t h )
endif ( )
endif ( )
if ( EXISTS ${ candidate_PAL_path } )
cmake_path ( SET full_name ${ candidate_PAL_path } )
endif ( )
endif ( )
endif ( )
set ( ${ out_name } ${ full_name } PARENT_SCOPE )
endif ( )
endfunction ( )
function ( ly_get_list_relative_pal_filename out_name in_name )
ly_get_absolute_pal_filename ( abs_name ${ in_name } ${ ARGN } )
file ( RELATIVE_PATH relative_name ${ CMAKE_CURRENT_LIST_DIR } ${ abs_name } )
cmake_path( RELATIVE_PATH abs_name BASE_DIRECTORY ${ CMAKE_CURRENT_LIST_DIR } OUTPUT_VARIABLE relative_name )
set ( ${ out_name } ${ relative_name } PARENT_SCOPE )
endfunction ( )