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

Change-Id: I658bf36195cbf39bb09166b19fa9643fbbed68ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1932091
Reviewed-by: Thomas Anderson <thomasanderson@chromium.org>
Commit-Queue: Joe Mason <joenotcharles@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#718845}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: ead882878e27646844a9483a6221b128b223f72c
This commit is contained in:
Joe Mason 2019-11-25 22:01:53 +00:00 коммит произвёл Commit Bot
Родитель 52927f5a11
Коммит e2349a5c52
1 изменённых файлов: 9 добавлений и 5 удалений

Просмотреть файл

@ -35,6 +35,10 @@ MSVC_TOOLSET_VERSION = {
'2017' : 'VC141',
}
def _HostIsWindows():
"""Returns True if running on a Windows host (including under cygwin)."""
return sys.platform in ('win32', 'cygwin')
def SetEnvironmentAndGetRuntimeDllDirs():
"""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
@ -49,7 +53,7 @@ def SetEnvironmentAndGetRuntimeDllDirs():
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
# 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):
if ShouldUpdateToolchain():
if len(sys.argv) > 1 and sys.argv[1] == 'update':
@ -225,8 +229,9 @@ def _CopyRuntimeImpl(target, source, verbose=True):
os.chmod(target, stat.S_IWRITE | stat.S_IREAD)
# Sometimes BUILTIN/Administrators and SYSTEM doesn't grant the access
# to the file on bots. crbug.com/956016.
subprocess.call(['icacls', target, '/grant', 'Administrators:f'])
subprocess.call(['icacls', target, '/grant', 'SYSTEM:f'])
if _HostIsWindows(): # Skip if icacls is not available.
subprocess.call(['icacls', target, '/grant', 'Administrators:f'])
subprocess.call(['icacls', target, '/grant', 'SYSTEM:f'])
def _SortByHighestVersionNumberFirst(list_of_str_versions):
"""This sorts |list_of_str_versions| according to version number rules
@ -472,8 +477,7 @@ def Update(force=False, no_download=False):
depot_tools_win_toolchain = \
bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')))
if ((sys.platform in ('win32', 'cygwin') or force) and
depot_tools_win_toolchain):
if (_HostIsWindows() or force) and depot_tools_win_toolchain:
import find_depot_tools
depot_tools_path = find_depot_tools.add_depot_tools_to_path()