Some fixes for paths with spaces (#6757)

* Some fixes for paths with spaces

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* PR comments

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
Esteban Papp
2022-01-10 10:00:29 -08:00
committed by GitHub
parent 93996bfb3f
commit 0f7e55cf59
11 changed files with 71 additions and 130 deletions
@@ -1,59 +0,0 @@
@echo off
REM
REM Copyright (c) Contributors to the Open 3D Engine Project.
REM For complete copyright and license terms please see the LICENSE at the root of this distribution.
REM
REM SPDX-License-Identifier: Apache-2.0 OR MIT
REM
REM
PUSHD "%~dp0"
SET CWD="%~dp0"
SET EXEPATH141="../../../../Bin64vc141/PythonBindingsExample.exe"
SET EXEPATH142="../../../../Bin64vc142/PythonBindingsExample.exe"
SET EXEPATH=""
IF EXIST %EXEPATH141% (
SET EXEPATH=%EXEPATH141%
) ELSE (
IF EXIST %EXEPATH142% (
SET EXEPATH=%EXEPATH142%
) ELSE (
ECHO PythonBindingsExample.exe not found.
)
)
IF /I %EXEPATH% EQU "" (
ECHO [FAILED] Could not run tests since a build of PythonBindingsExample.exe is missing
GOTO exit_app
)
ECHO Testing basics of tool Python bindings in %CWD%
%EXEPATH% --file test_hello_tool.py
IF %ERRORLEVEL% EQU 0 (
ECHO [WORKED] test_hello_tool.py
) ELSE (
ECHO [FAILED] test_hello_tool.py with %ERRORLEVEL%
GOTO exit_app
)
%EXEPATH% --file test_framework.py --arg entity
IF %ERRORLEVEL% EQU 0 (
ECHO [WORKED] test_framework.py --arg entity
) ELSE (
ECHO [FAILED] test_framework.py --arg entity with %ERRORLEVEL%
GOTO exit_app
)
%EXEPATH% --file test_framework.py --arg math
IF %ERRORLEVEL% EQU 0 (
ECHO [WORKED] test_framework.py --arg math
) ELSE (
ECHO [FAILED] test_framework.py --arg math with %ERRORLEVEL%
GOTO exit_app
)
:exit_app
POPD
+5 -5
View File
@@ -38,13 +38,13 @@ endif()
# Check for timestamp
if(LY_TIMESTAMP_REFERENCE)
if(NOT EXISTS ${LY_TIMESTAMP_REFERENCE})
if(NOT EXISTS "${LY_TIMESTAMP_REFERENCE}")
message(FATAL_ERROR "File LY_TIMESTAMP_REFERENCE=${LY_TIMESTAMP_REFERENCE} does not exists")
endif()
if(NOT LY_TIMESTAMP_FILE)
set(LY_TIMESTAMP_FILE ${LY_TIMESTAMP_REFERENCE}.stamp)
set(LY_TIMESTAMP_FILE "${LY_TIMESTAMP_REFERENCE}.stamp")
endif()
if(EXISTS ${LY_TIMESTAMP_FILE} AND NOT ${LY_TIMESTAMP_REFERENCE} IS_NEWER_THAN ${LY_TIMESTAMP_FILE})
if(EXISTS "${LY_TIMESTAMP_FILE}" AND NOT "${LY_TIMESTAMP_REFERENCE}" IS_NEWER_THAN "${LY_TIMESTAMP_FILE}")
# Stamp newer, nothing to do
return()
endif()
@@ -52,7 +52,7 @@ endif()
if(LY_LOCK_FILE)
# Lock the file
file(LOCK ${LY_LOCK_FILE} TIMEOUT 1200 RESULT_VARIABLE lock_result)
file(LOCK "${LY_LOCK_FILE}" TIMEOUT 1200 RESULT_VARIABLE lock_result)
if(NOT ${lock_result} EQUAL 0)
message(FATAL_ERROR "Lock failure ${lock_result}")
endif()
@@ -83,5 +83,5 @@ endif()
if(LY_TIMESTAMP_REFERENCE)
# Touch the timestamp file
file(TOUCH ${LY_TIMESTAMP_FILE})
file(TOUCH "${LY_TIMESTAMP_FILE}")
endif()
@@ -13,7 +13,7 @@ function(ly_copy source_file target_directory)
cmake_path(APPEND target_file "${target_directory}" "${target_filename}")
cmake_path(COMPARE "${source_file}" EQUAL "${target_file}" same_location)
if(NOT ${same_location})
file(LOCK ${target_file}.lock GUARD FUNCTION TIMEOUT 300)
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)
@@ -24,11 +24,11 @@ function(ly_copy source_file target_directory)
message(STATUS "Copying \"${source_file}\" to \"${target_directory}\"...")
file(MAKE_DIRECTORY "${full_target_directory}")
file(COPY "${source_file}" DESTINATION "${target_directory}" FILE_PERMISSIONS @LY_COPY_PERMISSIONS@ FOLLOW_SYMLINK_CHAIN)
file(TOUCH_NOCREATE ${target_file})
file(TOUCH_NOCREATE "${target_file}")
endif()
endif()
endfunction()
@LY_COPY_COMMANDS@
file(TOUCH @STAMP_OUTPUT_FILE@)
file(TOUCH "@STAMP_OUTPUT_FILE@")
@@ -14,7 +14,7 @@ function(ly_copy source_file target_directory)
cmake_path(APPEND target_file "${target_directory}" "${target_filename}")
cmake_path(COMPARE "${source_file}" EQUAL "${target_file}" same_location)
if(NOT ${same_location})
file(LOCK ${target_file}.lock GUARD FUNCTION TIMEOUT 300)
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)
@@ -39,4 +39,4 @@ endfunction()
@LY_COPY_COMMANDS@
file(TOUCH @STAMP_OUTPUT_FILE@)
file(TOUCH "@STAMP_OUTPUT_FILE@")
+29 -29
View File
@@ -31,36 +31,36 @@ endfunction()
function(fixup_python_framework framework_path)
file(REMOVE_RECURSE
${framework_path}/Versions/Current
${framework_path}/Versions/@LY_PYTHON_VERSION_MAJOR_MINOR@/Headers
${framework_path}/Versions/@LY_PYTHON_VERSION_MAJOR_MINOR@/lib/Python
${framework_path}/Versions/@LY_PYTHON_VERSION_MAJOR_MINOR@/lib/python@LY_PYTHON_VERSION_MAJOR_MINOR@/test
${framework_path}/Versions/@LY_PYTHON_VERSION_MAJOR_MINOR@/lib/python@LY_PYTHON_VERSION_MAJOR_MINOR@/site-packages/scipy/io/tests
${framework_path}/Python
${framework_path}/Resources
${framework_path}/Headers
"${framework_path}/Versions/Current"
"${framework_path}/Versions/@LY_PYTHON_VERSION_MAJOR_MINOR@/Headers"
"${framework_path}/Versions/@LY_PYTHON_VERSION_MAJOR_MINOR@/lib/Python"
"${framework_path}/Versions/@LY_PYTHON_VERSION_MAJOR_MINOR@/lib/python@LY_PYTHON_VERSION_MAJOR_MINOR@/test"
"${framework_path}/Versions/@LY_PYTHON_VERSION_MAJOR_MINOR@/lib/python@LY_PYTHON_VERSION_MAJOR_MINOR@/site-packages/scipy/io/tests"
"${framework_path}/Python"
"${framework_path}/Resources"
"${framework_path}/Headers"
)
file(GLOB_RECURSE exe_file_list "${framework_path}/**/*.exe")
if(exe_file_list)
file(REMOVE_RECURSE ${exe_file_list})
file(REMOVE_RECURSE "${exe_file_list}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink include/python@LY_PYTHON_VERSION_MAJOR_MINOR@m Headers
WORKING_DIRECTORY ${framework_path}/Versions/@LY_PYTHON_VERSION_MAJOR_MINOR@
execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink include/python@LY_PYTHON_VERSION_MAJOR_MINOR@m Headers
WORKING_DIRECTORY "${framework_path}/Versions/@LY_PYTHON_VERSION_MAJOR_MINOR@"
)
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink @LY_PYTHON_VERSION_MAJOR_MINOR@ Current
WORKING_DIRECTORY ${framework_path}/Versions/
execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink @LY_PYTHON_VERSION_MAJOR_MINOR@ Current
WORKING_DIRECTORY "${framework_path}/Versions/"
)
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink Versions/Current/Python Python
WORKING_DIRECTORY ${framework_path}
execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink Versions/Current/Python Python
WORKING_DIRECTORY "${framework_path}"
)
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink Versions/Current/Headers Headers
WORKING_DIRECTORY ${framework_path}
execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink Versions/Current/Headers Headers
WORKING_DIRECTORY "${framework_path}"
)
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink Versions/Current/Resources Resources
WORKING_DIRECTORY ${framework_path}
execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink Versions/Current/Resources Resources
WORKING_DIRECTORY "${framework_path}"
)
file(CHMOD ${framework_path}/Versions/Current/Python
file(CHMOD "${framework_path}/Versions/Current/Python"
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
@@ -72,7 +72,7 @@ function(codesign_file file entitlement_file)
return()
endif()
if(EXISTS ${entitlement_file})
if(EXISTS "${entitlement_file}")
execute_process(COMMAND "/usr/bin/codesign" "--force" "--sign" "@LY_CODE_SIGN_IDENTITY@" "--deep" "-o" "runtime" "--timestamp" "--entitlements" "${entitlement_file}" "${file}"
TIMEOUT 300
@@ -108,8 +108,8 @@ function(codesign_python_framework_binaries framework_path)
"${framework_path}/Versions/@LY_PYTHON_VERSION_MAJOR_MINOR@/Resources/**")
foreach(file ${files})
if(NOT EXISTS ${file})
file(REMOVE ${file})
if(NOT EXISTS "${file}")
file(REMOVE "${file}")
continue()
endif()
cmake_path(SET path_var "${file}")
@@ -164,16 +164,16 @@ function(ly_copy source_file target_directory)
endfunction()
function(ly_download_and_codesign_sdk_python)
execute_process(COMMAND ${CMAKE_COMMAND} -DPAL_PLATFORM_NAME=Mac -DLY_3RDPARTY_PATH=${CMAKE_INSTALL_PREFIX}/python -P ${CMAKE_INSTALL_PREFIX}/python/get_python.cmake
WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}
execute_process(COMMAND "${CMAKE_COMMAND}" -DPAL_PLATFORM_NAME=Mac "-DLY_3RDPARTY_PATH=${CMAKE_INSTALL_PREFIX}/python" -P "${CMAKE_INSTALL_PREFIX}/python/get_python.cmake"
WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}"
)
fixup_python_framework(${CMAKE_INSTALL_PREFIX}/python/runtime/@LY_PYTHON_PACKAGE_NAME@/Python.framework)
codesign_python_framework_binaries(${CMAKE_INSTALL_PREFIX}/python/runtime/@LY_PYTHON_PACKAGE_NAME@/Python.framework)
codesign_file(${CMAKE_INSTALL_PREFIX}/python/runtime/@LY_PYTHON_PACKAGE_NAME@/Python.framework @LY_ROOT_FOLDER@/python/Platform/Mac/PythonEntitlements.plist)
fixup_python_framework("${CMAKE_INSTALL_PREFIX}/python/runtime/@LY_PYTHON_PACKAGE_NAME@/Python.framework")
codesign_python_framework_binaries("${CMAKE_INSTALL_PREFIX}/python/runtime/@LY_PYTHON_PACKAGE_NAME@/Python.framework")
codesign_file("${CMAKE_INSTALL_PREFIX}/python/runtime/@LY_PYTHON_PACKAGE_NAME@/Python.framework" "@LY_ROOT_FOLDER@/python/Platform/Mac/PythonEntitlements.plist")
endfunction()
function(ly_codesign_sdk)
codesign_file(${LY_INSTALL_PATH_ORIGINAL}/O3DE_SDK.app "none")
codesign_file("${LY_INSTALL_PATH_ORIGINAL}/O3DE_SDK.app" "none")
endfunction()
@@ -127,7 +127,7 @@ function(ly_copy source_file target_directory)
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(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)
@@ -176,35 +176,35 @@ if(@target_file_dir@ MATCHES ".app/Contents/MacOS")
message(STATUS "Fixing ${bundle_path}/Contents/Frameworks/Python.framework...")
list(APPEND fixup_bundle_ignore Python python3.7m python3.7)
file(REMOVE_RECURSE
${bundle_path}/Contents/Frameworks/Python.framework/Versions/Current
${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/Headers
${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/lib/Python
${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/Python
${bundle_path}/Contents/Frameworks/Python.framework/Resources
${bundle_path}/Contents/Frameworks/Python.framework/Headers
"${bundle_path}/Contents/Frameworks/Python.framework/Versions/Current"
"${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/Headers"
"${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/lib/Python"
"${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/Python"
"${bundle_path}/Contents/Frameworks/Python.framework/Resources"
"${bundle_path}/Contents/Frameworks/Python.framework/Headers"
)
file(GLOB_RECURSE exe_file_list "${bundle_path}/Contents/Frameworks/Python.framework/**/*.exe")
if(exe_file_list)
file(REMOVE_RECURSE ${exe_file_list})
file(REMOVE_RECURSE "${exe_file_list}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink include/python3.7m Headers
WORKING_DIRECTORY ${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7
execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink include/python3.7m Headers
WORKING_DIRECTORY "${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7"
)
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink 3.7 Current
WORKING_DIRECTORY ${bundle_path}/Contents/Frameworks/Python.framework/Versions/
execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink 3.7 Current
WORKING_DIRECTORY "${bundle_path}/Contents/Frameworks/Python.framework/Versions/"
)
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink Versions/Current/Python Python
WORKING_DIRECTORY ${bundle_path}/Contents/Frameworks/Python.framework
execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink Versions/Current/Python Python
WORKING_DIRECTORY "${bundle_path}/Contents/Frameworks/Python.framework"
)
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink Versions/Current/Headers Headers
WORKING_DIRECTORY ${bundle_path}/Contents/Frameworks/Python.framework
execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink Versions/Current/Headers Headers
WORKING_DIRECTORY "${bundle_path}/Contents/Frameworks/Python.framework"
)
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink Versions/Current/Resources Resources
WORKING_DIRECTORY ${bundle_path}/Contents/Frameworks/Python.framework
execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink Versions/Current/Resources Resources
WORKING_DIRECTORY "${bundle_path}/Contents/Frameworks/Python.framework"
)
file(CHMOD ${bundle_path}/Contents/Frameworks/Python.framework/Versions/Current/Python
file(CHMOD "${bundle_path}/Contents/Frameworks/Python.framework/Versions/Current/Python"
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
@@ -215,8 +215,8 @@ if(@target_file_dir@ MATCHES ".app/Contents/MacOS")
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)
execute_process(COMMAND ${LY_INSTALL_NAME_TOOL} -add_rpath @executable_path/../lib ${bundle_path}/Contents/MacOS/Builders/DirectXShaderCompiler/bin/dxc-3.7)
if(EXISTS "${bundle_path}/Contents/MacOS/Builders/DirectXShaderCompiler/bin/dxc-3.7")
execute_process(COMMAND $"{LY_INSTALL_NAME_TOOL}" -add_rpath @executable_path/../lib ${bundle_path}/Contents/MacOS/Builders/DirectXShaderCompiler/bin/dxc-3.7)
endif()
# misplaced .DS_Store files can cause signing to fail
@@ -226,7 +226,7 @@ if(@target_file_dir@ MATCHES ".app/Contents/MacOS")
"${bundle_path/}**/*.cstemp"
)
if(remove_file_list)
file(REMOVE_RECURSE ${remove_file_list})
file(REMOVE_RECURSE "${remove_file_list}")
endif()
endif()
@@ -235,7 +235,7 @@ else() # Non-bundle case
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@)
execute_process(COMMAND "${LY_INSTALL_NAME_TOOL}" -change @rpath/Python @rpath/Python.framework/Versions/Current/Python "@target_file@")
endif()
endif()
+2 -1
View File
@@ -21,7 +21,8 @@ SET PYTHONHOME=%CMD_DIR%\runtime\python-3.7.10-rev2-windows\python
IF EXIST "%PYTHONHOME%" GOTO PYTHONHOME_EXISTS
ECHO Could not find Python for Windows in %CMD_DIR%\..
ECHO Python not found in %CMD_DIR%
ECHO Try running %CMD_DIR%\get_python.bat first.
exit /B 1
:PYTHONHOME_EXISTS
+1 -1
View File
@@ -17,7 +17,7 @@ SOURCE_DIRECTORY=${PWD}
pushd $OUTPUT_DIRECTORY
LAST_CONFIGURE_CMD_FILE=ci_last_configure_cmd.txt
CONFIGURE_CMD="cmake ${SOURCE_DIRECTORY} ${CMAKE_OPTIONS} ${EXTRA_CMAKE_OPTIONS}"
CONFIGURE_CMD="cmake '${SOURCE_DIRECTORY}' ${CMAKE_OPTIONS} ${EXTRA_CMAKE_OPTIONS}"
if [[ -n "$CMAKE_LY_PROJECTS" ]]; then
CONFIGURE_CMD="${CONFIGURE_CMD} -DLY_PROJECTS='${CMAKE_LY_PROJECTS}'"
fi
+1 -1
View File
@@ -17,7 +17,7 @@ SOURCE_DIRECTORY=${PWD}
pushd $OUTPUT_DIRECTORY
LAST_CONFIGURE_CMD_FILE=ci_last_configure_cmd.txt
CONFIGURE_CMD="cmake ${SOURCE_DIRECTORY} ${CMAKE_OPTIONS} ${EXTRA_CMAKE_OPTIONS}"
CONFIGURE_CMD="cmake '${SOURCE_DIRECTORY}' ${CMAKE_OPTIONS} ${EXTRA_CMAKE_OPTIONS}"
if [[ -n "$CMAKE_LY_PROJECTS" ]]; then
CONFIGURE_CMD="${CONFIGURE_CMD} -DLY_PROJECTS='${CMAKE_LY_PROJECTS}'"
fi
@@ -8,8 +8,7 @@ REM
REM
SETLOCAL EnableDelayedExpansion
CALL %~dp0env_windows.cmd
CALL "%~dp0env_windows.cmd"
IF NOT EXIST "%OUTPUT_DIRECTORY%" (
MKDIR %OUTPUT_DIRECTORY%.
@@ -29,7 +28,7 @@ REM Compute half the amount of processors so some jobs can run
SET /a HALF_PROCESSORS = NUMBER_OF_PROCESSORS / 2
SET LAST_CONFIGURE_CMD_FILE=ci_last_configure_cmd.txt
SET CONFIGURE_CMD=cmake %SOURCE_DIRECTORY% %CMAKE_OPTIONS% %EXTRA_CMAKE_OPTIONS%
SET CONFIGURE_CMD=cmake "%SOURCE_DIRECTORY%" %CMAKE_OPTIONS% %EXTRA_CMAKE_OPTIONS%
IF NOT "%CMAKE_LY_PROJECTS%"=="" (
SET CONFIGURE_CMD=!CONFIGURE_CMD! -DLY_PROJECTS="%CMAKE_LY_PROJECTS%"
)
+1 -1
View File
@@ -88,7 +88,7 @@ def build(build_config_filename, build_platform, build_type):
env_params[v] = build_params[v]
print(' {} = {} {}'.format(v, env_params[v], '(environment override)' if existing_param else ''))
print('--------------------------------------------------------------------------------', flush=True)
process_return = subprocess.run(build_cmd_path, cwd=cwd_dir, env=env_params)
process_return = subprocess.run([build_cmd_path], cwd=cwd_dir, env=env_params)
print('--------------------------------------------------------------------------------')
if process_return.returncode != 0:
print('[ci_build] FAIL: Command {} returned {}'.format(build_cmd_path, process_return.returncode), flush=True)