mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-04-25 16:08:45 +02:00
automate-git: Windows: Patch VS toolchain scripts before runhooks
Split `gclient sync` into separate `gclient sync --nohooks` and `gclient runhooks` steps so that we can optionally apply patches from `runhooks.patch` in-between. This is necessary because the src/tools/clang/scripts/update.py script is run via a hook and has dependencies on the VS toolchain scripts which must be patched to properly consider the GYP_MSVS_VERSION environment variable.
This commit is contained in:
parent
9d9ee8b45f
commit
06a5ef3cd8
@ -26,9 +26,6 @@ patches = [
|
|||||||
# Move chrome target locales output to a chrome/ directory to avoid
|
# Move chrome target locales output to a chrome/ directory to avoid
|
||||||
# conflicts with the CEF configuration.
|
# conflicts with the CEF configuration.
|
||||||
#
|
#
|
||||||
# Support custom VS toolchain on Windows.
|
|
||||||
# https://bugs.chromium.org/p/chromium/issues/detail?id=623342
|
|
||||||
#
|
|
||||||
# Write environment.* files with the correct SDK version on Windows.
|
# Write environment.* files with the correct SDK version on Windows.
|
||||||
# https://bugs.chromium.org/p/chromium/issues/detail?id=634788
|
# https://bugs.chromium.org/p/chromium/issues/detail?id=634788
|
||||||
#
|
#
|
||||||
@ -36,6 +33,14 @@ patches = [
|
|||||||
# https://bitbucket.org/chromiumembedded/cef/issues/2432
|
# https://bitbucket.org/chromiumembedded/cef/issues/2432
|
||||||
'name': 'gn_config',
|
'name': 'gn_config',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
# Patches that must be applied after `gclient sync --nohooks` and before
|
||||||
|
# `gclient runhooks`.
|
||||||
|
#
|
||||||
|
# Support custom VS toolchain on Windows.
|
||||||
|
# https://bugs.chromium.org/p/chromium/issues/detail?id=623342
|
||||||
|
'name': 'runhooks',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
# Support component builds (GN is_component_build=true).
|
# Support component builds (GN is_component_build=true).
|
||||||
# https://bitbucket.org/chromiumembedded/cef/issues/1617
|
# https://bitbucket.org/chromiumembedded/cef/issues/1617
|
||||||
|
@ -55,82 +55,6 @@ index 982fbe8d3f0d..e757be4688f1 100644
|
|||||||
+ "You must set the visual_studio_runtime_dirs if you set the visual " +
|
+ "You must set the visual_studio_runtime_dirs if you set the visual " +
|
||||||
+ "studio path")
|
+ "studio path")
|
||||||
}
|
}
|
||||||
diff --git build/toolchain/win/setup_toolchain.py build/toolchain/win/setup_toolchain.py
|
|
||||||
index fa31688f36a2..69d74aa31c47 100644
|
|
||||||
--- build/toolchain/win/setup_toolchain.py
|
|
||||||
+++ build/toolchain/win/setup_toolchain.py
|
|
||||||
@@ -142,22 +142,25 @@ def _LoadToolchainEnv(cpu, sdk_dir, target_store):
|
|
||||||
# variable.
|
|
||||||
if 'VSINSTALLDIR' in os.environ:
|
|
||||||
del os.environ['VSINSTALLDIR']
|
|
||||||
- other_path = os.path.normpath(os.path.join(
|
|
||||||
+ script_path = os.path.normpath(os.path.join(
|
|
||||||
os.environ['GYP_MSVS_OVERRIDE_PATH'],
|
|
||||||
'VC/Auxiliary/Build/vcvarsall.bat'))
|
|
||||||
- if not os.path.exists(other_path):
|
|
||||||
- raise Exception('%s is missing - make sure VC++ tools are installed.' %
|
|
||||||
- script_path)
|
|
||||||
- script_path = other_path
|
|
||||||
- cpu_arg = "amd64"
|
|
||||||
- if (cpu != 'x64'):
|
|
||||||
- # x64 is default target CPU thus any other CPU requires a target set
|
|
||||||
- cpu_arg += '_' + cpu
|
|
||||||
- args = [script_path, cpu_arg]
|
|
||||||
- # Store target must come before any SDK version declaration
|
|
||||||
- if (target_store):
|
|
||||||
- args.append(['store'])
|
|
||||||
- variables = _LoadEnvFromBat(args)
|
|
||||||
+ if os.path.exists(script_path):
|
|
||||||
+ cpu_arg = "amd64"
|
|
||||||
+ if (cpu != 'x64'):
|
|
||||||
+ # x64 is default target CPU thus any other CPU requires a target set
|
|
||||||
+ cpu_arg += '_' + cpu
|
|
||||||
+ args = [script_path, cpu_arg]
|
|
||||||
+ # Store target must come before any SDK version declaration
|
|
||||||
+ if (target_store):
|
|
||||||
+ args.append(['store'])
|
|
||||||
+ variables = _LoadEnvFromBat(args)
|
|
||||||
+ else:
|
|
||||||
+ variables = []
|
|
||||||
+ for k in sorted(os.environ.keys()):
|
|
||||||
+ variables.append('%s=%s' % (str(k), str(os.environ[k])))
|
|
||||||
+ variables = '\n'.join(variables)
|
|
||||||
+
|
|
||||||
return _ExtractImportantEnvironment(variables)
|
|
||||||
|
|
||||||
|
|
||||||
diff --git build/vs_toolchain.py build/vs_toolchain.py
|
|
||||||
index 97600e73ba10..36773b159453 100755
|
|
||||||
--- build/vs_toolchain.py
|
|
||||||
+++ build/vs_toolchain.py
|
|
||||||
@@ -89,9 +89,16 @@ def SetEnvironmentAndGetRuntimeDllDirs():
|
|
||||||
runtime_path = os.path.pathsep.join(vs_runtime_dll_dirs)
|
|
||||||
os.environ['PATH'] = runtime_path + os.path.pathsep + os.environ['PATH']
|
|
||||||
elif sys.platform == 'win32' and not depot_tools_win_toolchain:
|
|
||||||
+ has_override_path = True
|
|
||||||
if not 'GYP_MSVS_OVERRIDE_PATH' in os.environ:
|
|
||||||
+ has_override_path = False
|
|
||||||
os.environ['GYP_MSVS_OVERRIDE_PATH'] = DetectVisualStudioPath()
|
|
||||||
|
|
||||||
+ if has_override_path:
|
|
||||||
+ # Don't attempt to copy DLLs when using a custom toolchain.
|
|
||||||
+ # The DLLs should already be discoverable via the PATH env variable.
|
|
||||||
+ return None
|
|
||||||
+
|
|
||||||
# When using an installed toolchain these files aren't needed in the output
|
|
||||||
# directory in order to run binaries locally, but they are needed in order
|
|
||||||
# to create isolates or the mini_installer. Copying them to the output
|
|
||||||
@@ -140,6 +147,10 @@ def _RegistryGetValue(key, value):
|
|
||||||
def GetVisualStudioVersion():
|
|
||||||
"""Return best available version of Visual Studio.
|
|
||||||
"""
|
|
||||||
+ # Return the explicitly requested version, if any.
|
|
||||||
+ if 'GYP_MSVS_VERSION' in os.environ:
|
|
||||||
+ return os.environ['GYP_MSVS_VERSION']
|
|
||||||
+
|
|
||||||
supported_versions = list(MSVS_VERSIONS.keys())
|
|
||||||
|
|
||||||
# VS installed in depot_tools for Googlers
|
|
||||||
diff --git chrome/chrome_paks.gni chrome/chrome_paks.gni
|
diff --git chrome/chrome_paks.gni chrome/chrome_paks.gni
|
||||||
index 5121fa721a06..b5ab128722f0 100644
|
index 5121fa721a06..b5ab128722f0 100644
|
||||||
--- chrome/chrome_paks.gni
|
--- chrome/chrome_paks.gni
|
||||||
|
76
patch/patches/runhooks.patch
Normal file
76
patch/patches/runhooks.patch
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
diff --git build/toolchain/win/setup_toolchain.py build/toolchain/win/setup_toolchain.py
|
||||||
|
index fa31688f36a2..69d74aa31c47 100644
|
||||||
|
--- build/toolchain/win/setup_toolchain.py
|
||||||
|
+++ build/toolchain/win/setup_toolchain.py
|
||||||
|
@@ -142,22 +142,25 @@ def _LoadToolchainEnv(cpu, sdk_dir, target_store):
|
||||||
|
# variable.
|
||||||
|
if 'VSINSTALLDIR' in os.environ:
|
||||||
|
del os.environ['VSINSTALLDIR']
|
||||||
|
- other_path = os.path.normpath(os.path.join(
|
||||||
|
+ script_path = os.path.normpath(os.path.join(
|
||||||
|
os.environ['GYP_MSVS_OVERRIDE_PATH'],
|
||||||
|
'VC/Auxiliary/Build/vcvarsall.bat'))
|
||||||
|
- if not os.path.exists(other_path):
|
||||||
|
- raise Exception('%s is missing - make sure VC++ tools are installed.' %
|
||||||
|
- script_path)
|
||||||
|
- script_path = other_path
|
||||||
|
- cpu_arg = "amd64"
|
||||||
|
- if (cpu != 'x64'):
|
||||||
|
- # x64 is default target CPU thus any other CPU requires a target set
|
||||||
|
- cpu_arg += '_' + cpu
|
||||||
|
- args = [script_path, cpu_arg]
|
||||||
|
- # Store target must come before any SDK version declaration
|
||||||
|
- if (target_store):
|
||||||
|
- args.append(['store'])
|
||||||
|
- variables = _LoadEnvFromBat(args)
|
||||||
|
+ if os.path.exists(script_path):
|
||||||
|
+ cpu_arg = "amd64"
|
||||||
|
+ if (cpu != 'x64'):
|
||||||
|
+ # x64 is default target CPU thus any other CPU requires a target set
|
||||||
|
+ cpu_arg += '_' + cpu
|
||||||
|
+ args = [script_path, cpu_arg]
|
||||||
|
+ # Store target must come before any SDK version declaration
|
||||||
|
+ if (target_store):
|
||||||
|
+ args.append(['store'])
|
||||||
|
+ variables = _LoadEnvFromBat(args)
|
||||||
|
+ else:
|
||||||
|
+ variables = []
|
||||||
|
+ for k in sorted(os.environ.keys()):
|
||||||
|
+ variables.append('%s=%s' % (str(k), str(os.environ[k])))
|
||||||
|
+ variables = '\n'.join(variables)
|
||||||
|
+
|
||||||
|
return _ExtractImportantEnvironment(variables)
|
||||||
|
|
||||||
|
|
||||||
|
diff --git build/vs_toolchain.py build/vs_toolchain.py
|
||||||
|
index 97600e73ba10..36773b159453 100755
|
||||||
|
--- build/vs_toolchain.py
|
||||||
|
+++ build/vs_toolchain.py
|
||||||
|
@@ -89,9 +89,16 @@ def SetEnvironmentAndGetRuntimeDllDirs():
|
||||||
|
runtime_path = os.path.pathsep.join(vs_runtime_dll_dirs)
|
||||||
|
os.environ['PATH'] = runtime_path + os.path.pathsep + os.environ['PATH']
|
||||||
|
elif sys.platform == 'win32' and not depot_tools_win_toolchain:
|
||||||
|
+ has_override_path = True
|
||||||
|
if not 'GYP_MSVS_OVERRIDE_PATH' in os.environ:
|
||||||
|
+ has_override_path = False
|
||||||
|
os.environ['GYP_MSVS_OVERRIDE_PATH'] = DetectVisualStudioPath()
|
||||||
|
|
||||||
|
+ if has_override_path:
|
||||||
|
+ # Don't attempt to copy DLLs when using a custom toolchain.
|
||||||
|
+ # The DLLs should already be discoverable via the PATH env variable.
|
||||||
|
+ return None
|
||||||
|
+
|
||||||
|
# When using an installed toolchain these files aren't needed in the output
|
||||||
|
# directory in order to run binaries locally, but they are needed in order
|
||||||
|
# to create isolates or the mini_installer. Copying them to the output
|
||||||
|
@@ -140,6 +147,10 @@ def _RegistryGetValue(key, value):
|
||||||
|
def GetVisualStudioVersion():
|
||||||
|
"""Return best available version of Visual Studio.
|
||||||
|
"""
|
||||||
|
+ # Return the explicitly requested version, if any.
|
||||||
|
+ if 'GYP_MSVS_VERSION' in os.environ:
|
||||||
|
+ return os.environ['GYP_MSVS_VERSION']
|
||||||
|
+
|
||||||
|
supported_versions = list(MSVS_VERSIONS.keys())
|
||||||
|
|
||||||
|
# VS installed in depot_tools for Googlers
|
@ -295,7 +295,7 @@ def remove_deps_entry(path, entry):
|
|||||||
|
|
||||||
|
|
||||||
def apply_deps_patch():
|
def apply_deps_patch():
|
||||||
""" Patch the Chromium DEPS file if necessary. """
|
""" Patch the Chromium DEPS file before `gclient sync` if necessary. """
|
||||||
# Starting with 43.0.2357.126 the DEPS file is now 100% Git and the .DEPS.git
|
# Starting with 43.0.2357.126 the DEPS file is now 100% Git and the .DEPS.git
|
||||||
# file is no longer created. Look for the older file first in case we're
|
# file is no longer created. Look for the older file first in case we're
|
||||||
# building an older branch version.
|
# building an older branch version.
|
||||||
@ -325,6 +325,17 @@ def apply_deps_patch():
|
|||||||
raise Exception("Path does not exist: %s" % (deps_path))
|
raise Exception("Path does not exist: %s" % (deps_path))
|
||||||
|
|
||||||
|
|
||||||
|
def apply_runhooks_patch():
|
||||||
|
""" Patch the Chromium runhooks files before `gclient runhooks` if necessary. """
|
||||||
|
patch_file = os.path.join(cef_dir, 'patch', 'patches', 'runhooks')
|
||||||
|
if os.path.exists(patch_file + ".patch"):
|
||||||
|
# Attempt to apply the runhooks patch file.
|
||||||
|
patch_tool = os.path.join(cef_dir, 'tools', 'patcher.py')
|
||||||
|
run('%s %s --patch-file "%s" --patch-dir "%s"' %
|
||||||
|
(python_exe, patch_tool, patch_file,
|
||||||
|
chromium_src_dir), chromium_src_dir, depot_tools_dir)
|
||||||
|
|
||||||
|
|
||||||
def run_patch_updater(args='', output_file=None):
|
def run_patch_updater(args='', output_file=None):
|
||||||
""" Run the patch updater script. """
|
""" Run the patch updater script. """
|
||||||
tool = os.path.join(cef_src_dir, 'tools', 'patch_updater.py')
|
tool = os.path.join(cef_src_dir, 'tools', 'patch_updater.py')
|
||||||
@ -1452,9 +1463,15 @@ if chromium_checkout_changed:
|
|||||||
os.environ['GYP_CHROMIUM_NO_ACTION'] = '1'
|
os.environ['GYP_CHROMIUM_NO_ACTION'] = '1'
|
||||||
|
|
||||||
# Update third-party dependencies including branch/tag information.
|
# Update third-party dependencies including branch/tag information.
|
||||||
run("gclient sync %s--with_branch_heads --jobs 16" % \
|
run("gclient sync %s--nohooks --with_branch_heads --jobs 16" % \
|
||||||
('--reset ' if discard_local_changes else ''), chromium_dir, depot_tools_dir)
|
('--reset ' if discard_local_changes else ''), chromium_dir, depot_tools_dir)
|
||||||
|
|
||||||
|
# Patch the Chromium runhooks scripts if necessary.
|
||||||
|
apply_runhooks_patch()
|
||||||
|
|
||||||
|
# Runs hooks for files that have been modified in the local working copy.
|
||||||
|
run("gclient runhooks --jobs 16", chromium_dir, depot_tools_dir)
|
||||||
|
|
||||||
# Clear the GYP_CHROMIUM_NO_ACTION value.
|
# Clear the GYP_CHROMIUM_NO_ACTION value.
|
||||||
del os.environ['GYP_CHROMIUM_NO_ACTION']
|
del os.environ['GYP_CHROMIUM_NO_ACTION']
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user