Merge changes I12916061,I410f0532,I90b6f7f1

* changes:
  gn2bp: Add `-Wno-null-pointer-subtraction` to the default flags
  gn2bp: Add genrules to their respective architecture sink
  gn2bp: Generate per-architecture genrule for `action_foreach`
This commit is contained in:
Patrick Rohr
2022-11-22 04:03:34 +00:00
committed by Gerrit Code Review
3 changed files with 492 additions and 343 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -211,6 +211,8 @@ class Target(object):
self.cppflags = set()
self.local_include_dirs = set()
self.export_system_include_dirs = set()
self.generated_headers = set()
self.export_generated_headers = set()
def to_string(self, output):
nested_out = []
@@ -226,6 +228,8 @@ class Target(object):
self._output_field(nested_out, 'cppflags')
self._output_field(nested_out, 'local_include_dirs')
self._output_field(nested_out, 'export_system_include_dirs')
self._output_field(nested_out, 'generated_headers')
self._output_field(nested_out, 'export_generated_headers')
if nested_out:
output.append(' %s: {' % self.name)
@@ -968,6 +972,15 @@ def set_module_flags(module, cflags, defines):
if '-fexceptions' in flag:
module.cppflags.add('-fexceptions')
def add_genrule_per_arch(module, dep_module, type):
module.generated_headers.update(dep_module.genrule_headers)
# If the module is a static library, export all the generated headers.
if type == 'cc_library_static':
module.export_generated_headers.update(dep_module.genrule_headers)
module.srcs.update(dep_module.genrule_srcs)
module.shared_libs.update(dep_module.genrule_shared_libs)
module.header_libs.update(dep_module.genrule_header_libs)
def set_module_include_dirs(module, cflags, include_dirs):
for flag in cflags:
if '-isystem' in flag:
@@ -1089,11 +1102,6 @@ def create_modules_from_target(blueprint, gn, gn_target_name):
module.local_include_dirs = [d for d in module.local_include_dirs
if d not in local_include_dirs_denylist]
# If the module is a static library, export all the generated headers.
if module.type == 'cc_library_static':
module.export_generated_headers = module.generated_headers
# dep_name is an unmangled GN target name (e.g. //foo:bar(toolchain)).
# Currently, only one module is generated from target even target has multiple toolchains.
# And module is generated based on the first visited target.
@@ -1134,10 +1142,13 @@ def create_modules_from_target(blueprint, gn, gn_target_name):
elif dep_module.type == 'cc_defaults':
module.defaults.append(dep_module.name)
elif dep_module.type == 'genrule':
module.generated_headers.update(dep_module.genrule_headers)
module.srcs.update(dep_module.genrule_srcs)
module.shared_libs.update(dep_module.genrule_shared_libs)
module.header_libs.update(dep_module.genrule_header_libs)
for arch_name, arch in target.arch.items():
if dep_module.name.endswith(arch_name):
add_genrule_per_arch(module.target[arch_name], dep_module, module.type)
if dep_module.name.endswith("_gen"):
module.srcs.update(dep_module.genrule_srcs)
module.generated_headers.update(dep_module.genrule_headers)
module.export_generated_headers.update(dep_module.genrule_headers)
elif dep_module.type == 'cc_binary':
continue # Ignore executables deps (used by cmdline integration tests).
else:
@@ -1198,6 +1209,7 @@ def create_blueprint_for_targets(gn, targets):
'-Wno-sign-compare',
'-Wno-sign-promo',
'-Wno-unused-parameter',
'-Wno-null-pointer-subtraction', # Needed to libevent
'-Wno-deprecated-non-prototype', # needed for zlib
'-fvisibility=hidden',
'-Wno-ambiguous-reversed-operator', # needed for icui18n

View File

@@ -280,7 +280,8 @@ class GnParser(object):
# Action modules can differ depending on the target architecture, yet
# genrule's do not allow to overload cmd per target OS / arch. Create a
# separate action for every architecture.
if type_ == 'action':
# Cover both action and action_foreach
if type_.startswith('action'):
target_name += '__' + arch
target = self.all_targets.get(target_name)