Switch tracing source sets into static libraries
Change the source sets under src/tracing to static libraries and
implement static library support in the blueprint generator. This is the
first step in providing something Perfetto clients can link against.
Change-Id: I00f5dffc6d5cc931be807f00be1d9cf71a65436b
diff --git a/tools/gen_android_bp b/tools/gen_android_bp
index 87c6a55..3b4be0c 100755
--- a/tools/gen_android_bp
+++ b/tools/gen_android_bp
@@ -178,7 +178,7 @@
self.modules[module.name] = module
def to_string(self, output):
- for m in self.modules.itervalues():
+ for m in sorted(self.modules.itervalues(), key=lambda m: m.name):
m.to_string(output)
@@ -237,11 +237,6 @@
module: Module to which dependencies should be added.
dep_name: GN target of the dependency.
"""
- # Don't try to inject library/source dependencies into genrules because they
- # are not compiled in the traditional sense.
- if module.type == 'genrule':
- return
-
# If the dependency refers to a library which we can replace with an Android
# equivalent, stop recursing and patch the dependency in.
if label_without_toolchain(dep_name) in builtin_deps:
@@ -264,7 +259,12 @@
module.srcs.append(':' + label_to_module_name(dep_name))
module.generated_headers.append(
label_to_module_name(dep_name) + '_headers')
- elif type in ['group', 'source_set', 'executable'] and 'sources' in target:
+ elif type == 'static_library' and label_to_module_name(
+ dep_name) != module.name:
+ create_modules_from_target(blueprint, desc, dep_name)
+ module.static_libs.append(label_to_module_name(dep_name))
+ elif type in ['group', 'source_set', 'executable', 'static_library'
+ ] and 'sources' in target:
# Ignore source files that are generated by actions since they will be
# implicitly added by the genrule dependencies.
module.srcs.extend(
@@ -397,17 +397,22 @@
modules = [Module(module_type, label_to_module_name(target_name))]
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))
+ ]
else:
raise Error('Unknown target type: %s' % target['type'])
for module in modules:
module.comment = 'GN target: %s' % target_name
+ # Don't try to inject library/source dependencies into genrules because
+ # they are not compiled in the traditional sense.
if module.type != 'genrule':
module.defaults = [defaults_module]
-
- apply_module_dependency(blueprint, desc, module, target_name)
- for dep in resolve_dependencies(desc, target_name):
- apply_module_dependency(blueprint, desc, module, dep)
+ apply_module_dependency(blueprint, desc, module, target_name)
+ for dep in resolve_dependencies(desc, target_name):
+ apply_module_dependency(blueprint, desc, module, dep)
blueprint.add_module(module)