BundleUtilities: Use find on UNIX for fast executable lookup
It makes whole executable process quicker on UNIX, especially for large bundles containing many files, since using find narrows results to only files having executable flags then all further tests follow. Since find ... -perm +0111 is not clearly POSIX compliant and some Linux versions refuse it, it is better to use longer but portable: find ... -perm \( -perm -0100 -o -perm -0010 -o -perm -0001 \)
This commit is contained in:
parent
f640b2a41f
commit
6c31379741
|
@ -378,7 +378,25 @@ endfunction()
|
|||
function(get_bundle_all_executables bundle exes_var)
|
||||
set(exes "")
|
||||
|
||||
if(UNIX)
|
||||
find_program(find_cmd "find")
|
||||
mark_as_advanced(find_cmd)
|
||||
endif()
|
||||
|
||||
# find command is much quicker than checking every file one by one on Unix
|
||||
# which can take long time for large bundles, and since anyway we expect
|
||||
# executable to have execute flag set we can narrow the list much quicker.
|
||||
if(find_cmd)
|
||||
execute_process(COMMAND "${find_cmd}" "${bundle}"
|
||||
-type f \( -perm -0100 -o -perm -0010 -o -perm -0001 \)
|
||||
OUTPUT_VARIABLE file_list
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
string(REPLACE "\n" ";" file_list "${file_list}")
|
||||
else()
|
||||
file(GLOB_RECURSE file_list "${bundle}/*")
|
||||
endif()
|
||||
|
||||
foreach(f ${file_list})
|
||||
is_file_executable("${f}" is_executable)
|
||||
if(is_executable)
|
||||
|
|
Loading…
Reference in New Issue