diff options
author | Spandan Das <spandandas@google.com> | 2023-03-21 19:45:36 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-03-21 19:45:36 +0000 |
commit | 6ffa77d82578c79d9a97be97cfd61c6972c85234 (patch) | |
tree | 4f5aebac5cf3ac09c5d36cdfe9f91003eaa140b9 | |
parent | 164b7ccb608152eac2a2cc0c815093bf39622502 (diff) | |
parent | ee86f0772b7be4f24122c16949c20058687c4b1a (diff) | |
download | orchestrator-6ffa77d82578c79d9a97be97cfd61c6972c85234.tar.gz |
Generate Android.bp files for C ModuleLib API surface am: d1373b8e21 am: 2af930a7fe am: f85a64b57f am: ee86f0772b
Original change: https://android-review.googlesource.com/c/platform/build/orchestrator/+/2494906
Change-Id: I89e9abca8ac7fc54bee3f65d07d8a243bb799298
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | core/api_assembly.py | 18 | ||||
-rw-r--r-- | core/cc/api_assembly.py | 54 |
2 files changed, 29 insertions, 43 deletions
diff --git a/core/api_assembly.py b/core/api_assembly.py index ea63a07..0844d4b 100644 --- a/core/api_assembly.py +++ b/core/api_assembly.py @@ -61,9 +61,6 @@ def assemble_apis(context, inner_trees): # and Android.bp/BUILD files to make those available to inner trees. # TODO: Parallelize? Skip unnecessary work? for stub_library in stub_libraries: - STUB_LANGUAGE_HANDLERS[stub_library.language](context, ninja, - build_file_generator, - stub_library) # TODO (b/265962882): Export APIs of version < current. # API files of older versions (29,30,...) are currently not # available in out/api_surfaces. @@ -74,12 +71,19 @@ def assemble_apis(context, inner_trees): # modules for all NDK libraries, starting from version=1. # This does not compromise on API correctness though, since the correct # version number will be passed to the ndkstubgen invocation. - if stub_library.language == "cc_libraries" and stub_library.api_surface == "publicapi": - for additional_version in range(1, - 34): # Till 33, 34 is current - stub_library.api_surface_version = str(additional_version) + # TODO(b/266830850): Revisit stubs versioning for Module-lib API + # surface. + if stub_library.language == "cc_libraries" and stub_library.api_surface in ["publicapi", "module-libapi"]: + versions = list(range(1,34)) # 34 is current + versions.append("current") + for version in versions: + stub_library.api_surface_version = str(version) STUB_LANGUAGE_HANDLERS[stub_library.language]( context, ninja, build_file_generator, stub_library) + else: + STUB_LANGUAGE_HANDLERS[stub_library.language](context, ninja, + build_file_generator, + stub_library) # TODO: Handle host_executables separately or as a StubLibrary language? diff --git a/core/cc/api_assembly.py b/core/cc/api_assembly.py index 8bc4ea3..f7395f3 100644 --- a/core/cc/api_assembly.py +++ b/core/cc/api_assembly.py @@ -38,7 +38,9 @@ DEVICE_CLANG_TRIPLES = { # API surfaces that should be imported into an inner tree. # TODO: Add `module-libapi` -_SUPPORTED_API_SURFACES_FOR_IMPORT = {"publicapi", "vendorapi"} +_SUPPORTED_API_SURFACES_FOR_IMPORT = { + "publicapi", "vendorapi", "module-libapi" +} class CcApiAssemblyContext(object): @@ -50,12 +52,6 @@ class CcApiAssemblyContext(object): self._linker = Linker() self._api_levels_file_added = False self._api_imports_module_added = False - self._api_library_src_added = { - "arm": set(), - "arm64": set(), - "x86": set(), - "x86_64": set(), - } self._api_stub_library_bp_file = None def get_cc_api_assembler(self): @@ -135,6 +131,7 @@ class CcApiAssemblyContext(object): api_imports_module = self._api_imports_module(context, bp_file) # TODO: Add header_libs explicitly if necessary. api_imports_module.extend_property("shared_libs", [library_name]) + api_imports_module.extend_property("apex_shared_libs", [library_name]) return stub_module def _api_stub_variant_module( @@ -170,11 +167,23 @@ class CcApiAssemblyContext(object): stub_variant.add_property("variant", "ndk") stub_variant.add_property("version", stub_library.api_surface_version) + stub_module.extend_property( + "variants", [f"ndk.{stub_library.api_surface_version}"]) bp_file.add_module(stub_variant) return stub_variant - # TODO : Handle other variants - return None + if stub_library.api_surface == "module-libapi": + stub_variant.add_property("variant", "apex") + stub_variant.add_property("version", + stub_library.api_surface_version) + stub_module.extend_property( + "variants", [f"apex.{stub_library.api_surface_version}"]) + bp_file.add_module(stub_variant) + return stub_variant + + raise Exception( + f"API surface {stub_library.api_surface} of library {stub_library.name} is not a recognized API surface." + ) def assemble_cc_api_library(self, context, ninja, build_file_generator, stub_library): @@ -337,33 +346,6 @@ class CcApiAssemblyContext(object): # Assemble the header files in out before compiling the rdeps ninja.add_global_phony(src_path_in_inner_tree, api_deps) - # TODO: Hack to make analysis of apex modules pass. - # Tracking bug: b/264963986 - # Creates an so file as `src` for the top-level - # `cc_api_library`. - # This is necessary since SystemApi import for apexes is WIP, - # and the mainline module variants (incorrectly) try to link - # against the `src` of the top-level `cc_api_library`. - # This property should be a no-op anyways, so hardcode it to - # arm64 for now. - if stub_library.name not in self._api_library_src_added[arch]: - for tree in ["system", "vendor", "apexes"]: - # Copy the file to the top-level cc_api_library in out. - # e.g. src: - # out/api_surfaces/publicapi/current/libc/arm/libc.so - # e.g. dst: out/api_surfaces/arm/libc.so - top_level_output_so = os.path.join( - context.out.api_surfaces_dir(), arch, soname) - ninja.add_copy_file(top_level_output_so, output_so) - # Create a phony target of this to inner tree - # e.g. src: out/api_surfaces/arm/libc.so - # e.g. dst: vendor/out/api_surfaces/arm/libc.so - ninja.add_global_phony( - os.path.join(tree, top_level_output_so), - [top_level_output_so]) - self._api_library_src_added[arch].add( - stub_library.name) - # Add the prebuilt stub library as src to Android.bp # The layout is # out/../libfoo |