LYN-4071 Mac compile times are excessive
commit
98767862af
@ -0,0 +1,28 @@
|
||||
#
|
||||
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
# its licensors.
|
||||
#
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this
|
||||
# distribution (the "License"). All use of this software is governed by the License,
|
||||
# or, if provided, by the license below or the license accompanying this file. Do not
|
||||
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
#
|
||||
|
||||
cmake_policy(SET CMP0012 NEW) # new policy for the if that evaluates a boolean out of "if(NOT ${same_location})"
|
||||
|
||||
function(ly_copy source_file target_directory)
|
||||
get_filename_component(target_filename "${source_file}" NAME)
|
||||
cmake_path(COMPARE "${source_file}" EQUAL "${target_directory}/${target_filename}" same_location)
|
||||
if(NOT ${same_location})
|
||||
if(NOT EXISTS "${target_directory}")
|
||||
file(MAKE_DIRECTORY "${target_directory}")
|
||||
endif()
|
||||
if("${source_file}" IS_NEWER_THAN "${target_directory}/${target_filename}")
|
||||
file(COPY "${source_file}" DESTINATION "${target_directory}" FILE_PERMISSIONS @LY_COPY_PERMISSIONS@ FOLLOW_SYMLINK_CHAIN)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
file(LOCK "${CMAKE_BINARY_DIR}/runtimedependencies.lock" TIMEOUT 300)
|
||||
@LY_COPY_COMMANDS@
|
||||
@ -1,121 +0,0 @@
|
||||
#!/usr/bin/cmake -P
|
||||
|
||||
#
|
||||
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
# its licensors.
|
||||
#
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this
|
||||
# distribution (the "License"). All use of this software is governed by the License,
|
||||
# or, if provided, by the license below or the license accompanying this file. Do not
|
||||
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
#
|
||||
|
||||
# We use windeployqt on Linux to copy the necessary Qt libraries and files to
|
||||
# the build directory. After these files are copied, we need to adjust their
|
||||
# rpath to point to Qt from the build tree.
|
||||
|
||||
# This script is invoked through the CommandExecution.cmake script. The invoked
|
||||
# commandline is something like:
|
||||
# cmake -P CommandExecution.cmake EXEC_COMMAND cmake -E env ... cmake -P windeployqt_wrapper.cmake args
|
||||
# ^ 1 ^ 2 ^ 3
|
||||
# cmake #1 invokes cmake #2 which invokes cmake #3. But cmake #1 also sees 2 -P
|
||||
# arguments, so cmake #1 also invokes windeployqt_wrapper.cmake after
|
||||
# CommandExecution.cmake finishes. We don't want to run this script 2x, so
|
||||
# detect this case and exit early
|
||||
|
||||
# Find the first -P argument
|
||||
foreach(argi RANGE 1 ${CMAKE_ARGC})
|
||||
if("${CMAKE_ARGV${argi}}" STREQUAL "-P")
|
||||
math(EXPR script_argi "${argi} + 1")
|
||||
set(script_file "${CMAKE_ARGV${script_argi}}")
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(NOT script_file STREQUAL "${CMAKE_CURRENT_LIST_FILE}")
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(runtime_directory ${CMAKE_ARGV3})
|
||||
|
||||
foreach(argi RANGE 4 ${CMAKE_ARGC})
|
||||
list(APPEND command_arguments "${CMAKE_ARGV${argi}}")
|
||||
endforeach()
|
||||
execute_process(COMMAND ${command_arguments} RESULT_VARIABLE command_result OUTPUT_VARIABLE command_output ERROR_VARIABLE command_err)
|
||||
|
||||
if(command_result)
|
||||
message(FATAL_ERROR "windeployqt returned a non-zero exit status. stdout: ${command_output} stderr: ${command_err}")
|
||||
endif()
|
||||
|
||||
# Process the output to find the list of files that were updated
|
||||
|
||||
# Transform the output to a list
|
||||
string(REGEX REPLACE ";" "\\\\;" command_output "${command_output}")
|
||||
string(REGEX REPLACE "\n" ";" command_output "${command_output}")
|
||||
|
||||
foreach(line IN LISTS command_output)
|
||||
# windeployqt has output that looks like this if it updated a file:
|
||||
# > Checking /path/to/src/file.so, /path/to/dst/file.so
|
||||
# > Updating file.so
|
||||
# If the file was not modified, it will look like this:
|
||||
# > Checking /path/to/src/file.so, /path/to/dst/file.so
|
||||
# > file.so is up to date
|
||||
if(line MATCHES "^Checking .*")
|
||||
set(curfile "${line}")
|
||||
continue()
|
||||
endif()
|
||||
|
||||
if(line MATCHES "^Updating .*")
|
||||
# curline has 3 parts, 1) "Checking ", 2) source_file, 3) updated_target_file. We
|
||||
# just need part 3. But we also want to handle the unfortunate
|
||||
# possibility of spaces in the filename.
|
||||
|
||||
string(REGEX REPLACE "^Checking " "" curfile "${curfile}")
|
||||
string(REPLACE ", " ";" curfile "${curfile}")
|
||||
list(LENGTH curfile curfile_parts_count)
|
||||
if(NOT curfile_parts_count EQUAL 2)
|
||||
message(SEND_ERROR "Unable to parse output of windeployqt output line ${curfile}")
|
||||
continue()
|
||||
endif()
|
||||
list(GET curfile 1 updated_file)
|
||||
|
||||
file(RELATIVE_PATH relative_file "${runtime_directory}" "${updated_file}")
|
||||
|
||||
get_filename_component(basename "${relative_file}" NAME)
|
||||
if(basename MATCHES "^libQt5Core\\.so.*")
|
||||
# We don't need to patch QtCore
|
||||
continue()
|
||||
endif()
|
||||
|
||||
# READ_ELF has a CAPTURE_ERROR argument, but that is only set on
|
||||
# platforms that don't support cmake's elf parser. On linux, no error
|
||||
# will be set, even when the input is not an ELF formatted file. We
|
||||
# want to skip any non-executable files, so check for the ELF tag at
|
||||
# the head of the file.
|
||||
file(READ "${updated_file}" elf_tag LIMIT 4 HEX)
|
||||
if(NOT elf_tag STREQUAL 7f454c46) # Binary \0x7f followed by ELF
|
||||
continue()
|
||||
endif()
|
||||
|
||||
# READ_ELF is an undocumented command that allows us to introspect the
|
||||
# current rpath set in the file
|
||||
file(READ_ELF "${updated_file}" RUNPATH plugin_runpath)
|
||||
|
||||
get_filename_component(dirname "${relative_file}" DIRECTORY)
|
||||
if(dirname)
|
||||
file(RELATIVE_PATH parent_dirs "${updated_file}" "${runtime_directory}")
|
||||
string(REGEX REPLACE "/../$" "" parent_dirs "${parent_dirs}")
|
||||
set(new_runpath "\$ORIGIN/${parent_dirs}")
|
||||
else()
|
||||
set(new_runpath "\$ORIGIN")
|
||||
endif()
|
||||
|
||||
# RPATH_CHANGE is an undocumented command that allows for replacing an
|
||||
# existing rpath entry with a new value, as long as the new value's
|
||||
# strlen is <= the current rpath
|
||||
file(RPATH_CHANGE FILE "${updated_file}" OLD_RPATH "${plugin_runpath}" NEW_RPATH "${new_runpath}")
|
||||
|
||||
unset(curfile)
|
||||
endif()
|
||||
endforeach()
|
||||
@ -0,0 +1,146 @@
|
||||
#
|
||||
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
# its licensors.
|
||||
#
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this
|
||||
# distribution (the "License"). All use of this software is governed by the License,
|
||||
# or, if provided, by the license below or the license accompanying this file. Do not
|
||||
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
#
|
||||
|
||||
function(gp_resolve_item_override context item exepath dirs resolved_item_var resolved_var)
|
||||
# Qt frameworks could resolve the binary to eg qt/lib/QtCore.framework/Headers/QtCore instead of qt/lib/QtCore.framework/Versions/5/QtCore
|
||||
# This is because GetPrerequisites.cmake gp_resolve_item function searches for the first file that matches the "frameworks name"
|
||||
if(${${resolved_var}} AND ${item} MATCHES "/(Qt[^\\.]+\\.framework)/(.*)")
|
||||
set(qt_framework ${CMAKE_MATCH_1})
|
||||
set(qt_framework_subpath ${CMAKE_MATCH_2})
|
||||
string(REGEX REPLACE "(.*)/(Qt[^\\.]+\\.framework)/(.*)" "\\1/\\2/${qt_framework_subpath}" new_resolved_item "${${resolved_item_var}}")
|
||||
set(${resolved_item_var} ${new_resolved_item} PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
include(BundleUtilities)
|
||||
|
||||
cmake_policy(SET CMP0012 NEW) # new policy for the if that evaluates a boolean out of the LY_BUILD_FIXUP_BUNDLE expansion
|
||||
|
||||
set(anything_new FALSE)
|
||||
set(plugin_libs)
|
||||
set(plugin_dirs)
|
||||
|
||||
function(ly_copy source_file target_directory)
|
||||
|
||||
get_filename_component(target_filename "${source_file}" NAME)
|
||||
|
||||
# If source_file is a Framework and target_directory is a bundle
|
||||
if("${source_file}" MATCHES "\\.[Ff]ramework[^\\.]" AND "${target_directory}" MATCHES "\\.app/Contents/MacOS")
|
||||
|
||||
if(NOT @LY_BUILD_FIXUP_BUNDLE@)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# fixup origin to copy the whole Framework folder and change destination to Contents/Frameworks
|
||||
string(REGEX REPLACE "(.*\\.[Ff]ramework).*" "\\1" source_file "${source_file}")
|
||||
get_filename_component(source_file_folder "${source_file}" DIRECTORY)
|
||||
|
||||
set(local_plugin_dirs ${plugin_dirs})
|
||||
list(APPEND local_plugin_dirs "${source_file_folder}")
|
||||
set(plugin_dirs ${local_plugin_dirs} PARENT_SCOPE)
|
||||
return()
|
||||
|
||||
elseif("${source_file}" MATCHES "qt/plugins" AND "${target_directory}" MATCHES "\\.app/Contents/MacOS")
|
||||
|
||||
if(NOT @LY_BUILD_FIXUP_BUNDLE@)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# fixup the destination so it ends up in Contents/Plugins
|
||||
string(REGEX REPLACE "(.*\\.app/Contents)/MacOS" "\\1/plugins" target_directory "${target_directory}")
|
||||
|
||||
set(local_plugin_dirs ${plugin_dirs})
|
||||
list(APPEND local_plugin_dirs "${target_directory}")
|
||||
set(plugin_dirs ${local_plugin_dirs} PARENT_SCOPE)
|
||||
set(local_plugin_libs ${plugin_libs})
|
||||
list(APPEND local_plugin_libs "${target_directory}/${target_filename}")
|
||||
set(plugin_libs ${local_plugin_libs} PARENT_SCOPE)
|
||||
|
||||
elseif("${source_file}" MATCHES "qt/translations" AND "${target_directory}" MATCHES "\\.app/Contents/MacOS")
|
||||
|
||||
return() # skip, is this used?
|
||||
|
||||
elseif("${source_file}" MATCHES ".dylib")
|
||||
|
||||
set(local_plugin_dirs ${plugin_dirs})
|
||||
list(APPEND local_plugin_dirs "${target_directory}")
|
||||
set(plugin_dirs ${local_plugin_dirs} PARENT_SCOPE)
|
||||
|
||||
endif()
|
||||
|
||||
cmake_path(COMPARE "${source_file}" EQUAL "${target_directory}/${target_filename}" same_location)
|
||||
if(NOT ${same_location})
|
||||
if(NOT EXISTS "${target_directory}")
|
||||
file(MAKE_DIRECTORY "${target_directory}")
|
||||
endif()
|
||||
if(NOT EXISTS "${target_directory}/${target_filename}" OR "${source_file}" IS_NEWER_THAN "${target_directory}/${target_filename}")
|
||||
message(STATUS "Copying \"${source_file}\" to \"${target_directory}\"...")
|
||||
file(COPY "${source_file}" DESTINATION "${target_directory}" FILE_PERMISSIONS @LY_COPY_PERMISSIONS@ FOLLOW_SYMLINK_CHAIN)
|
||||
file(TOUCH ${target_directory}/${target_filename})
|
||||
set(anything_new TRUE PARENT_SCOPE)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
@LY_COPY_COMMANDS@
|
||||
|
||||
if(NOT @LY_BUILD_FIXUP_BUNDLE@)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(@target_file_dir@ MATCHES ".app/Contents/MacOS")
|
||||
string(REGEX REPLACE "(.*\\.app)/Contents/MacOS.*" "\\1" bundle_path "@target_file_dir@")
|
||||
set(fixup_timestamp_file "${bundle_path}.fixup.stamp")
|
||||
if(NOT anything_new)
|
||||
if(NOT EXISTS "${fixup_timestamp_file}" OR "${bundle_path}" IS_NEWER_THAN "${fixup_timestamp_file}")
|
||||
set(anything_new TRUE)
|
||||
endif()
|
||||
endif()
|
||||
if(anything_new)
|
||||
# LYN-4505: Patch dxc, is configured in the wrong folder in 3p
|
||||
if(EXISTS ${bundle_path}/Contents/MacOS/Builders/DirectXShaderCompiler/bin/dxc-3.7)
|
||||
# we copy to not invalidate the copy check from above
|
||||
file(COPY ${bundle_path}/Contents/MacOS/Builders/DirectXShaderCompiler/lib/libdxcompiler.3.7.dylib
|
||||
DESTINATION ${bundle_path}/Contents/MacOS/Builders/DirectXShaderCompiler/bin
|
||||
)
|
||||
endif()
|
||||
# Python.framework being copied by fixup_bundle
|
||||
#if(EXISTS ${bundle_path}/Contents/Frameworks/Python.framework)
|
||||
# # LYN-4502: Patch python bundle, it contains some windows executables, some files that fixup_bundle doesnt like and has
|
||||
# # duplicated binaries between Versions/3.7 and Versions/Current.
|
||||
# file(GLOB exe_files
|
||||
# ${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/command/*.exe
|
||||
# ${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_vendor/distlib/*.exe
|
||||
# ${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/*.exe
|
||||
# )
|
||||
# foreach(exe_file ${exe_files})
|
||||
# file(REMOVE ${exe_file})
|
||||
# endforeach()
|
||||
# file(REMOVE_RECURSE
|
||||
# ${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/lib/python3.7/test
|
||||
# ${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/scipy/io/tests
|
||||
# ${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/Resources
|
||||
# ${bundle_path}/Contents/Frameworks/Python.framework/Python
|
||||
# ${bundle_path}/Contents/Frameworks/Python.framework/Resources/Python.app
|
||||
# ${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/Python
|
||||
# )
|
||||
# file(REMOVE_RECURSE ${bundle_path}/Contents/Frameworks/Python.framework/Versions/Current)
|
||||
# execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink 3.7 Current
|
||||
# WORKING_DIRECTORY ${bundle_path}/Contents/Frameworks/Python.framework/Versions/
|
||||
# )
|
||||
#endif()
|
||||
list(REMOVE_DUPLICATES plugin_libs)
|
||||
list(REMOVE_DUPLICATES plugin_dirs)
|
||||
fixup_bundle("${bundle_path}" "${plugin_libs}" "${plugin_dirs}")
|
||||
file(TOUCH "${bundle_path}")
|
||||
file(TOUCH "${fixup_timestamp_file}")
|
||||
endif()
|
||||
endif()
|
||||
Loading…
Reference in New Issue