Commit ead88287 authored by Joe Mason's avatar Joe Mason Committed by Commit Bot

Don't call icacls when cross-compiling on non-Windows hosts

Change-Id: I658bf36195cbf39bb09166b19fa9643fbbed68ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1932091Reviewed-by: default avatarThomas Anderson <thomasanderson@chromium.org>
Commit-Queue: Joe Mason <joenotcharles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#718845}
parent b114d60b
...@@ -35,6 +35,10 @@ MSVC_TOOLSET_VERSION = { ...@@ -35,6 +35,10 @@ MSVC_TOOLSET_VERSION = {
'2017' : 'VC141', '2017' : 'VC141',
} }
def _HostIsWindows():
"""Returns True if running on a Windows host (including under cygwin)."""
return sys.platform in ('win32', 'cygwin')
def SetEnvironmentAndGetRuntimeDllDirs(): def SetEnvironmentAndGetRuntimeDllDirs():
"""Sets up os.environ to use the depot_tools VS toolchain with gyp, and """Sets up os.environ to use the depot_tools VS toolchain with gyp, and
returns the location of the VC runtime DLLs so they can be copied into returns the location of the VC runtime DLLs so they can be copied into
...@@ -49,7 +53,7 @@ def SetEnvironmentAndGetRuntimeDllDirs(): ...@@ -49,7 +53,7 @@ def SetEnvironmentAndGetRuntimeDllDirs():
bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1'))) bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')))
# When running on a non-Windows host, only do this if the SDK has explicitly # When running on a non-Windows host, only do this if the SDK has explicitly
# been downloaded before (in which case json_data_file will exist). # been downloaded before (in which case json_data_file will exist).
if ((sys.platform in ('win32', 'cygwin') or os.path.exists(json_data_file)) if ((_HostIsWindows() or os.path.exists(json_data_file))
and depot_tools_win_toolchain): and depot_tools_win_toolchain):
if ShouldUpdateToolchain(): if ShouldUpdateToolchain():
if len(sys.argv) > 1 and sys.argv[1] == 'update': if len(sys.argv) > 1 and sys.argv[1] == 'update':
...@@ -225,8 +229,9 @@ def _CopyRuntimeImpl(target, source, verbose=True): ...@@ -225,8 +229,9 @@ def _CopyRuntimeImpl(target, source, verbose=True):
os.chmod(target, stat.S_IWRITE | stat.S_IREAD) os.chmod(target, stat.S_IWRITE | stat.S_IREAD)
# Sometimes BUILTIN/Administrators and SYSTEM doesn't grant the access # Sometimes BUILTIN/Administrators and SYSTEM doesn't grant the access
# to the file on bots. crbug.com/956016. # to the file on bots. crbug.com/956016.
subprocess.call(['icacls', target, '/grant', 'Administrators:f']) if _HostIsWindows(): # Skip if icacls is not available.
subprocess.call(['icacls', target, '/grant', 'SYSTEM:f']) subprocess.call(['icacls', target, '/grant', 'Administrators:f'])
subprocess.call(['icacls', target, '/grant', 'SYSTEM:f'])
def _SortByHighestVersionNumberFirst(list_of_str_versions): def _SortByHighestVersionNumberFirst(list_of_str_versions):
"""This sorts |list_of_str_versions| according to version number rules """This sorts |list_of_str_versions| according to version number rules
...@@ -472,8 +477,7 @@ def Update(force=False, no_download=False): ...@@ -472,8 +477,7 @@ def Update(force=False, no_download=False):
depot_tools_win_toolchain = \ depot_tools_win_toolchain = \
bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1'))) bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')))
if ((sys.platform in ('win32', 'cygwin') or force) and if (_HostIsWindows() or force) and depot_tools_win_toolchain:
depot_tools_win_toolchain):
import find_depot_tools import find_depot_tools
depot_tools_path = find_depot_tools.add_depot_tools_to_path() depot_tools_path = find_depot_tools.add_depot_tools_to_path()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment