Explorar el Código

Use new Python package on Mac to remove rpath hack. Fix ly_copy logic to avoid unnecessary copies. (#8695)

Signed-off-by: amzn-sj <[email protected]>
amzn-sj hace 3 años
padre
commit
7fb6549fdd
Se han modificado 3 ficheros con 36 adiciones y 35 borrados
  1. 2 2
      cmake/LYPython.cmake
  2. 33 32
      cmake/Platform/Mac/runtime_dependencies_mac.cmake.in
  3. 1 1
      python/python.sh

+ 2 - 2
cmake/LYPython.cmake

@@ -27,8 +27,8 @@ if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux" )
 elseif  (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin" )
     ly_set(LY_PYTHON_VERSION 3.7.12)
     ly_set(LY_PYTHON_VERSION_MAJOR_MINOR 3.7)
-    ly_set(LY_PYTHON_PACKAGE_NAME python-3.7.12-rev2-darwin)
-    ly_set(LY_PYTHON_PACKAGE_HASH ee4b77a907e08e3f3e6a08ea6418e8c083c78c20d264b4bc055e50d0db512001)
+    ly_set(LY_PYTHON_PACKAGE_NAME python-3.7.12-rev3-darwin)
+    ly_set(LY_PYTHON_PACKAGE_HASH 6938c7e60eda34f6e0cf725b3d0e511b0af83aa45817c7bf55401932ac2aafd1)
 elseif  (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows" )
     ly_set(LY_PYTHON_VERSION 3.7.12)
     ly_set(LY_PYTHON_VERSION_MAJOR_MINOR 3.7)

+ 33 - 32
cmake/Platform/Mac/runtime_dependencies_mac.cmake.in

@@ -32,6 +32,25 @@ if (NOT LY_INSTALL_NAME_TOOL)
     message(FATAL_ERROR "Unable to locate 'install_name_tool'")
 endif()
 
+# IS_NEWER_THAN returns true if:
+# 1. file1 is newer than file2
+# 2. Either file1 or file2 do not exist
+# 3. If both files have the same timestamp
+# We would like it to return false if the mod times are the same.
+function(ly_is_newer_than file1 file2 is_newer)
+
+    set(${is_newer} FALSE PARENT_SCOPE)
+
+    if("${file1}" IS_NEWER_THAN "${file2}")
+        file(TIMESTAMP "${file1}" file1_mod_time)
+        file(TIMESTAMP "${file2}" file2_mod_time)
+        if (NOT file1_mod_time EQUAL file2_mod_time)
+            set(${is_newer} TRUE PARENT_SCOPE)
+        endif()
+    endif()
+
+endfunction()
+
 function(ly_copy source_file target_directory)
     
     cmake_path(GET source_file FILENAME target_filename)
@@ -120,26 +139,17 @@ function(ly_copy source_file target_directory)
             file(MAKE_DIRECTORY "${target_directory}")
         endif()
 
-        set(is_framework FALSE)
-        if("${source_file}" MATCHES "\\.[Ff]ramework")
-            set(is_framework TRUE)
-        endif()
-        if(NOT is_framework)
-            # if it is a bundle, there is no contention about the files in the destination, each bundle target will copy everything
-            # we dont want these files to invalidate the bundle and cause a new signature
-            file(LOCK "${target_file}.lock" GUARD FUNCTION TIMEOUT 300)
-            file(SIZE "${source_file}" source_file_size)
-            if(EXISTS "${target_file}")
-                file(SIZE "${target_file}" target_file_size)
-            else()
-                set(target_file_size 0)
-            endif()
-        else()
-            set(source_file_size 0)
-            set(target_file_size 0)
-        endif()
+        unset(is_source_newer)
+
+        # ly_is_newer_than will be true if:
+        # 1. The source library was rebuilt.
+        # 2. The library is a 3rdParty lib and it was downloaded after the target was copied.
+        # 3. The library is being copied over for the first time(target does not exist).
+        # While downloaded 3rdParty libs will have the creation time set to when it was built,
+        # their modification time will reflect the time it was downloaded.
+        ly_is_newer_than(${source_file} ${target_file} is_source_newer)
         
-        if((NOT source_file_size EQUAL target_file_size) OR "${source_file}" IS_NEWER_THAN "${target_file}")
+        if(${is_source_newer})
             message(STATUS "Copying \"${source_file}\" to \"${target_directory}\"...")
             file(MAKE_DIRECTORY "${target_directory}")
             file(COPY "${source_file}" DESTINATION "${target_directory}" FILE_PERMISSIONS @LY_COPY_PERMISSIONS@ FOLLOW_SYMLINK_CHAIN)
@@ -160,9 +170,7 @@ 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()
+        ly_is_newer_than(${bundle_path} ${fixup_timestamp_file} anything_new)
     endif()
     if(anything_new)
         unset(fixup_bundle_ignore)
@@ -211,8 +219,6 @@ if(@target_file_dir@ MATCHES ".app/Contents/MacOS")
         list(REMOVE_DUPLICATES plugin_libs)
         list(REMOVE_DUPLICATES plugin_dirs)
         fixup_bundle("${bundle_path}" "${plugin_libs}" "${plugin_dirs}" IGNORE_ITEM ${fixup_bundle_ignore})
-        file(TOUCH "${bundle_path}")
-        file(TOUCH "${fixup_timestamp_file}")
 
         # fixup bundle ends up removing the rpath of dxc (despite we exclude it)
         if(EXISTS "${bundle_path}/Contents/MacOS/Builders/DirectXShaderCompiler/bin/dxc-3.7")
@@ -223,19 +229,14 @@ if(@target_file_dir@ MATCHES ".app/Contents/MacOS")
         # Interrupted signatures can leave cstemp files behind that fail next signature
         file(GLOB_RECURSE remove_file_list 
             "${bundle_path}/**/.DS_Store"
-            "${bundle_path/}**/*.cstemp"
+            "${bundle_path}/**/*.cstemp"
         )
         if(remove_file_list)
             file(REMOVE_RECURSE "${remove_file_list}")
         endif()
 
-    endif()
-
-else() # Non-bundle case
+        file(TOUCH "${bundle_path}")
+        file(TOUCH "${fixup_timestamp_file}")
 
-    if(depends_on_python)
-        # RPATH fix python
-        execute_process(COMMAND "${LY_INSTALL_NAME_TOOL}" -change @rpath/Python @rpath/Python.framework/Versions/Current/Python "@target_file@")
     endif()
-
 endif()

+ 1 - 1
python/python.sh

@@ -17,7 +17,7 @@ done
 DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
 
 if [[ "$OSTYPE" == *"darwin"* ]]; then
-    PYTHON=$DIR/runtime/python-3.7.12-rev2-darwin/Python.framework/Versions/3.7/bin/python3
+    PYTHON=$DIR/runtime/python-3.7.12-rev3-darwin/Python.framework/Versions/3.7/bin/python3
 elif [[ "$OSTYPE" == "msys" ]]; then
     PYTHON=$DIR/runtime/python-3.7.12-rev2-windows/python/python.exe
 else