perfetto: add support from blueprint generator to include extras
We will need this for the CTS tests which are built in the Android platform
only using Android.bp specific flags. Including of writing these as GN
then adding support to translate to the generator, just allow arbitary
extras to be tacked onto the end of the blueprint.
Also, on the side, export the include header for all static_library targets.
This is necessary to utilise these headers when in platform.
Bug: None
Change-Id: I5042a9f33c7bf6364940fa60cb17cbdef8ee3e3d
diff --git a/tools/gen_android_bp b/tools/gen_android_bp
index 83ca6a3..268abfa 100755
--- a/tools/gen_android_bp
+++ b/tools/gen_android_bp
@@ -151,6 +151,7 @@
self.out = []
self.export_include_dirs = []
self.generated_headers = []
+ self.export_generated_headers = []
self.defaults = []
self.cflags = []
self.local_include_dirs = []
@@ -169,6 +170,7 @@
self._output_field(output, 'out')
self._output_field(output, 'export_include_dirs')
self._output_field(output, 'generated_headers')
+ self._output_field(output, 'export_generated_headers')
self._output_field(output, 'defaults')
self._output_field(output, 'cflags')
self._output_field(output, 'local_include_dirs')
@@ -427,9 +429,9 @@
elif target['type'] == 'action':
modules = make_genrules_for_action(blueprint, desc, target_name)
elif target['type'] == 'static_library':
- modules = [
- Module('cc_library_static', label_to_module_name(target_name))
- ]
+ module = Module('cc_library_static', label_to_module_name(target_name))
+ module.export_include_dirs = ['include']
+ modules = [module]
elif target['type'] == 'shared_library':
modules = [
Module('cc_library_shared', label_to_module_name(target_name))
@@ -453,6 +455,10 @@
for dep in resolve_dependencies(desc, target_name):
apply_module_dependency(blueprint, desc, module, dep)
+ # 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
+
blueprint.add_module(module)
@@ -541,6 +547,11 @@
'GN description (e.g., gn desc out --format=json --all-toolchains "//*"'
)
parser.add_argument(
+ '--extras',
+ help='Extra targets to include at the end of the Blueprint file',
+ default=os.path.join(repo_root(), 'Android.bp.extras'),
+ )
+ parser.add_argument(
'--output',
help='Blueprint file to create',
default=os.path.join(repo_root(), 'Android.bp'),
@@ -578,6 +589,9 @@
""" % (__file__)
]
blueprint.to_string(output)
+ with open(args.extras, 'r') as r:
+ for line in r:
+ output.append(line.rstrip("\n\r"))
with open(args.output, 'w') as f:
f.write('\n'.join(output))