7755da67133ba0b790a8cfa5b8250d356e2a48f1
[AGL/meta-agl-demo.git] / recipes-wam / cef / files / cef / 0004-Add-an-option-to-bypass-sysroot-checking-and-force.patch
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
5
6 ---
7  tools/gclient_hook.py |  8 +++++++-
8  tools/gn_args.py      | 28 ++++++++++++++--------------
9  2 files changed, 21 insertions(+), 15 deletions(-)
10
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(
16      dest='baseoutpath',
17      default='',
18      help="Use an anternative base path for the generated gn outputs instead of using chromium source dir")
19 +parser.add_option(
20 +    '--bypass-sysroot-check',
21 +    action='store_true',
22 +    dest='bypasssysrootcheck',
23 +    default=False,
24 +    help='Don\'t chech if the sysroot exist while generating output directores.')
25  
26  (options, args) = parser.parse_args()
27  
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']
31  
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)
43  
44  
45 -def ValidateArgs(args):
46 +def ValidateArgs(args, bypass_sysroot_check=False):
47    """
48    Validate GN arg combinations that we know about. Also provide suggestions
49    where appropriate.
50 @@ -360,11 +360,11 @@ def ValidateArgs(args):
51  
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'
62  
63    # ASAN requires Release builds.
64    if is_asan:
65 @@ -452,7 +452,7 @@ def ValidateArgs(args):
66            "visual_studio_path requires INCLUDE, LIB and PATH env variables"
67  
68  
69 -def GetConfigArgs(args, is_debug, cpu):
70 +def GetConfigArgs(args, is_debug, cpu, bypass_sysroot_check=False):
71    """
72    Return merged GN args for the configuration and validate.
73    """
74 @@ -478,11 +478,11 @@ def GetConfigArgs(args, is_debug, cpu):
75        if key.startswith('arm_'):
76          del result[key]
77  
78 -  ValidateArgs(result)
79 +  ValidateArgs(result, bypass_sysroot_check)
80    return result
81  
82  
83 -def GetConfigArgsSandbox(platform, args, is_debug, cpu):
84 +def GetConfigArgsSandbox(platform, args, is_debug, cpu, bypass_sysroot_check=False):
85    """
86    Return merged GN args for the cef_sandbox configuration and validate.
87    """
88 @@ -548,7 +548,7 @@ def LinuxSysrootExists(cpu):
89    return os.path.isdir(os.path.join(sysroot_root, sysroot_name))
90  
91  
92 -def GetAllPlatformConfigs(build_args):
93 +def GetAllPlatformConfigs(build_args, bypass_sysroot_check=False):
94    """
95    Return a map of directory name to GN args for the current platform.
96    """
97 @@ -568,10 +568,10 @@ def GetAllPlatformConfigs(build_args):
98  
99    if platform == 'linux':
100      use_sysroot = GetArgValue(args, 'use_sysroot')
101 -    if 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)
108          else:
109            msg('Not generating %s configuration due to missing sysroot directory'
110 @@ -593,17 +593,17 @@ def GetAllPlatformConfigs(build_args):
111  
112    for cpu in supported_cpus:
113      if create_debug:
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)
118  
119      if platform in ('windows', 'mac') and GetArgValue(args,
120                                                        'is_official_build'):
121        # Build cef_sandbox.lib with a different configuration.
122        if create_debug:
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)
129  
130    return result
131  
132 -- 
133 2.39.2
134