1 From 4b16bef4a219af372d022f0ec4f15befb1449808 Mon Sep 17 00:00:00 2001
2 From: Roger Zanoni <rzanoni@igalia.com>
3 Date: Tue, 16 May 2023 16:11:15 +0200
4 Subject: [PATCH 04/10] Add an option to bypass sysroot checking and force
7 tools/gclient_hook.py | 8 +++++++-
8 tools/gn_args.py | 28 ++++++++++++++--------------
9 2 files changed, 21 insertions(+), 15 deletions(-)
11 diff --git a/tools/gclient_hook.py b/tools/gclient_hook.py
12 index 4e5f9f687..6a7bc0d46 100644
13 --- a/tools/gclient_hook.py
14 +++ b/tools/gclient_hook.py
15 @@ -20,6 +20,12 @@ parser.add_option(
18 help="Use an anternative base path for the generated gn outputs instead of using chromium source dir")
20 + '--bypass-sysroot-check',
21 + action='store_true',
22 + dest='bypasssysrootcheck',
24 + help='Don\'t chech if the sysroot exist while generating output directores.')
26 (options, args) = parser.parse_args()
28 @@ -141,7 +147,7 @@ if platform == 'windows':
29 gn_args['visual_studio_runtime_dirs'] = os.environ['VS_CRT_ROOT']
30 gn_args['windows_sdk_path'] = os.environ['SDK_ROOT']
32 -configs = GetAllPlatformConfigs(gn_args)
33 +configs = GetAllPlatformConfigs(gn_args, bypass_sysroot_check=options.bypasssysrootcheck)
34 for dir, config in configs.items():
35 # Create out directories and write the args.gn file.
36 base_out_dir = src_dir
37 diff --git a/tools/gn_args.py b/tools/gn_args.py
38 index 563a6b9cc..f782bd765 100644
39 --- a/tools/gn_args.py
40 +++ b/tools/gn_args.py
41 @@ -323,7 +323,7 @@ def GetMergedArgs(build_args):
42 return MergeDicts(dict, required)
45 -def ValidateArgs(args):
46 +def ValidateArgs(args, bypass_sysroot_check=False):
48 Validate GN arg combinations that we know about. Also provide suggestions
50 @@ -360,11 +360,11 @@ def ValidateArgs(args):
52 if platform == 'linux':
53 if target_cpu == 'x86':
54 - assert use_sysroot, 'target_cpu="x86" requires use_sysroot=true'
55 + assert use_sysroot or bypass_sysroot_check, 'target_cpu="x86" requires use_sysroot=true'
56 elif target_cpu == 'arm':
57 - assert use_sysroot, 'target_cpu="arm" requires use_sysroot=true'
58 + assert use_sysroot or bypass_sysroot_check, 'target_cpu="arm" requires use_sysroot=true'
59 elif target_cpu == 'arm64':
60 - assert use_sysroot, 'target_cpu="arm64" requires use_sysroot=true'
61 + assert use_sysroot or bypass_sysroot_check, 'target_cpu="arm64" requires use_sysroot=true'
63 # ASAN requires Release builds.
65 @@ -452,7 +452,7 @@ def ValidateArgs(args):
66 "visual_studio_path requires INCLUDE, LIB and PATH env variables"
69 -def GetConfigArgs(args, is_debug, cpu):
70 +def GetConfigArgs(args, is_debug, cpu, bypass_sysroot_check=False):
72 Return merged GN args for the configuration and validate.
74 @@ -478,11 +478,11 @@ def GetConfigArgs(args, is_debug, cpu):
75 if key.startswith('arm_'):
78 - ValidateArgs(result)
79 + ValidateArgs(result, bypass_sysroot_check)
83 -def GetConfigArgsSandbox(platform, args, is_debug, cpu):
84 +def GetConfigArgsSandbox(platform, args, is_debug, cpu, bypass_sysroot_check=False):
86 Return merged GN args for the cef_sandbox configuration and validate.
88 @@ -548,7 +548,7 @@ def LinuxSysrootExists(cpu):
89 return os.path.isdir(os.path.join(sysroot_root, sysroot_name))
92 -def GetAllPlatformConfigs(build_args):
93 +def GetAllPlatformConfigs(build_args, bypass_sysroot_check=False):
95 Return a map of directory name to GN args for the current platform.
97 @@ -568,10 +568,10 @@ def GetAllPlatformConfigs(build_args):
99 if platform == 'linux':
100 use_sysroot = GetArgValue(args, 'use_sysroot')
102 + if bypass_sysroot_check or use_sysroot:
103 # Only generate configurations for sysroots that have been installed.
104 for cpu in ('x64', 'arm', 'arm64'):
105 - if LinuxSysrootExists(cpu):
106 + if bypass_sysroot_check or LinuxSysrootExists(cpu):
107 supported_cpus.append(cpu)
109 msg('Not generating %s configuration due to missing sysroot directory'
110 @@ -593,17 +593,17 @@ def GetAllPlatformConfigs(build_args):
112 for cpu in supported_cpus:
114 - result['Debug_GN_' + cpu] = GetConfigArgs(args, True, cpu)
115 - result['Release_GN_' + cpu] = GetConfigArgs(args, False, cpu)
116 + result['Debug_GN_' + cpu] = GetConfigArgs(args, True, cpu, bypass_sysroot_check)
117 + result['Release_GN_' + cpu] = GetConfigArgs(args, False, cpu, bypass_sysroot_check)
119 if platform in ('windows', 'mac') and GetArgValue(args,
120 'is_official_build'):
121 # Build cef_sandbox.lib with a different configuration.
123 result['Debug_GN_' + cpu + '_sandbox'] = GetConfigArgsSandbox(
124 - platform, args, True, cpu)
125 + platform, args, True, cpu, bypass_sysroot_check)
126 result['Release_GN_' + cpu + '_sandbox'] = GetConfigArgsSandbox(
127 - platform, args, False, cpu)
128 + platform, args, False, cpu, bypass_sysroot_check)