[cef][wam] Make the recipe work with official chromium release tarballs
[AGL/meta-agl-demo.git] / recipes-wam / cef / files / cef / 0004-Add-an-option-to-bypass-sysroot-checking-and-force.patch
1 From 26d02223b99765f4c6d5ce5807947d4e0c925a0b 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 4/9] 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 3d4375ec0..c971b9399 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 @@ -144,7 +150,7 @@ if platform == 'windows':
29      gn_args['windows_sdk_path'] = os.environ['SDK_ROOT']
30      gn_args['windows_sdk_version'] = os.environ['SDK_VERSION']
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 c1acac17b..80545da49 100644
39 --- a/tools/gn_args.py
40 +++ b/tools/gn_args.py
41 @@ -327,7 +327,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 @@ -365,11 +365,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 @@ -460,7 +460,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 @@ -490,11 +490,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 @@ -566,7 +566,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 @@ -586,10 +586,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 @@ -611,17 +611,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.42.0
134