gn2bp: Set the output name for libcronet.so

.so file name needs to match with CronetLibraryLoader.java
(e.g. libcronet.109.0.5386.0.so)

Test: m, atest CtsCronetTestCases
Change-Id: I82285c32e82fc27ba5233e1bef7195ec57c35bea
This commit is contained in:
Motomu Utsumi
2022-11-30 16:41:15 +09:00
parent 8ca1241589
commit ee47af6e0c
3 changed files with 15 additions and 0 deletions

View File

@@ -6618,6 +6618,7 @@ cc_library_shared {
linker_scripts: [
"base/android/library_loader/anchor_functions.lds",
],
stem: "libcronet.109.0.5386.0",
target: {
android_arm: {
generated_headers: [

View File

@@ -308,6 +308,8 @@ class Module(object):
self.stubs = {}
self.cppflags = set()
self.rtti = False
# Name of the output. Used for setting .so file name for libcronet
self.stem = None
def to_string(self, output):
if self.comment:
@@ -354,6 +356,7 @@ class Module(object):
self._output_field(output, 'proto')
self._output_field(output, 'linker_scripts')
self._output_field(output, 'cppflags')
self._output_field(output, 'stem')
if self.rtti:
self._output_field(output, 'rtti')
@@ -963,6 +966,13 @@ def create_modules_from_target(blueprint, gn, gn_target_name):
if module.type == 'cc_library_static':
module.export_generated_headers = module.generated_headers
if module.name == 'cronet_aml_components_cronet_android_cronet':
if target.output_name is None:
raise Error('Failed to get output_name for libcronet name')
# .so file name needs to match with CronetLibraryLoader.java (e.g. libcronet.109.0.5386.0.so)
# So setting the output name based on the output_name from the desc.json
module.stem = 'lib' + target.output_name
# 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.

View File

@@ -155,6 +155,9 @@ class GnParser(object):
self.is_finalized = False
self.arch = dict()
# This is used to get the name/version of libcronet
self.output_name = None
def host_supported(self):
return 'host' in self.arch
@@ -347,6 +350,7 @@ class GnParser(object):
target.ldflags.update(desc.get('ldflags', []))
target.arch[arch].defines.update(desc.get('defines', []))
target.arch[arch].include_dirs.update(desc.get('include_dirs', []))
target.output_name = desc.get('output_name', None)
if "-frtti" in target.arch[arch].cflags:
target.rtti = True