Use ModuleInfoJSONProvider for cc modules
LOCAL_STATIC_LIBRARIES, LOCAL_WHOLE_STATIC_LIBRARIES,
and LOCAL_HEADER_LIBRARIES are only exported to Make
so that it can generate module-info.json. Export
ModuleInfoJSONProvider from cc modules so that Soong can
generate the module-info.json entries, and remove the
properties from the generated Android.mk. This will prevent
Kati reanalysis when making some Android.bp changes.
Bug: 309006256
Test: Compare module-info.json
Test: Compare Kati's build.ninja
Change-Id: I6660f6802b9cea46eed553cac12f09a373eeb019
diff --git a/cc/androidmk.go b/cc/androidmk.go
index 54c7f97..bde096b 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -101,15 +101,6 @@
if len(c.Properties.AndroidMkSharedLibs) > 0 {
entries.AddStrings("LOCAL_SHARED_LIBRARIES", c.Properties.AndroidMkSharedLibs...)
}
- if len(c.Properties.AndroidMkStaticLibs) > 0 {
- entries.AddStrings("LOCAL_STATIC_LIBRARIES", c.Properties.AndroidMkStaticLibs...)
- }
- if len(c.Properties.AndroidMkWholeStaticLibs) > 0 {
- entries.AddStrings("LOCAL_WHOLE_STATIC_LIBRARIES", c.Properties.AndroidMkWholeStaticLibs...)
- }
- if len(c.Properties.AndroidMkHeaderLibs) > 0 {
- entries.AddStrings("LOCAL_HEADER_LIBRARIES", c.Properties.AndroidMkHeaderLibs...)
- }
if len(c.Properties.AndroidMkRuntimeLibs) > 0 {
entries.AddStrings("LOCAL_RUNTIME_LIBRARIES", c.Properties.AndroidMkRuntimeLibs...)
}
diff --git a/cc/binary.go b/cc/binary.go
index 61541ad..7aa8e20 100644
--- a/cc/binary.go
+++ b/cc/binary.go
@@ -541,6 +541,11 @@
return binary.Properties.Overrides
}
+func (binary *binaryDecorator) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
+ moduleInfoJSON.Class = []string{"EXECUTABLES"}
+ binary.baseLinker.moduleInfoJSON(ctx, moduleInfoJSON)
+}
+
var _ overridable = (*binaryDecorator)(nil)
func init() {
diff --git a/cc/cc.go b/cc/cc.go
index e6b9d8b..67067f5 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -544,6 +544,7 @@
isPreventInstall() bool
isCfiAssemblySupportEnabled() bool
getSharedFlags() *SharedFlags
+ notInPlatform() bool
}
type SharedFlags struct {
@@ -624,6 +625,8 @@
// Get the deps that have been explicitly specified in the properties.
linkerSpecifiedDeps(specifiedDeps specifiedDeps) specifiedDeps
+
+ moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON)
}
// specifiedDeps is a tuple struct representing dependencies of a linked binary owned by the linker.
@@ -1786,6 +1789,10 @@
return ctx.mod.isCfiAssemblySupportEnabled()
}
+func (ctx *moduleContextImpl) notInPlatform() bool {
+ return ctx.mod.NotInPlatform()
+}
+
func newBaseModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
return &Module{
hod: hod,
@@ -2140,6 +2147,39 @@
aconfig.CollectDependencyAconfigFiles(ctx, &c.mergedAconfigFiles)
c.maybeInstall(ctx, apexInfo)
+
+ if c.linker != nil {
+ moduleInfoJSON := ctx.ModuleInfoJSON()
+ c.linker.moduleInfoJSON(ctx, moduleInfoJSON)
+ moduleInfoJSON.SharedLibs = c.Properties.AndroidMkSharedLibs
+ moduleInfoJSON.StaticLibs = c.Properties.AndroidMkStaticLibs
+ moduleInfoJSON.SystemSharedLibs = c.Properties.AndroidMkSystemSharedLibs
+ moduleInfoJSON.RuntimeDependencies = c.Properties.AndroidMkRuntimeLibs
+
+ moduleInfoJSON.Dependencies = append(moduleInfoJSON.Dependencies, c.Properties.AndroidMkSharedLibs...)
+ moduleInfoJSON.Dependencies = append(moduleInfoJSON.Dependencies, c.Properties.AndroidMkStaticLibs...)
+ moduleInfoJSON.Dependencies = append(moduleInfoJSON.Dependencies, c.Properties.AndroidMkHeaderLibs...)
+ moduleInfoJSON.Dependencies = append(moduleInfoJSON.Dependencies, c.Properties.AndroidMkWholeStaticLibs...)
+
+ if c.sanitize != nil && len(moduleInfoJSON.Class) > 0 &&
+ (moduleInfoJSON.Class[0] == "STATIC_LIBRARIES" || moduleInfoJSON.Class[0] == "HEADER_LIBRARIES") {
+ if Bool(c.sanitize.Properties.SanitizeMutated.Cfi) {
+ moduleInfoJSON.SubName += ".cfi"
+ }
+ if Bool(c.sanitize.Properties.SanitizeMutated.Hwaddress) {
+ moduleInfoJSON.SubName += ".hwasan"
+ }
+ if Bool(c.sanitize.Properties.SanitizeMutated.Scs) {
+ moduleInfoJSON.SubName += ".scs"
+ }
+ }
+ moduleInfoJSON.SubName += c.Properties.SubName
+
+ if c.Properties.IsSdkVariant && c.Properties.SdkAndPlatformVariantVisibleToMake {
+ moduleInfoJSON.Uninstallable = true
+ }
+
+ }
}
func (c *Module) maybeUnhideFromMake() {
diff --git a/cc/fuzz.go b/cc/fuzz.go
index f5642d6..183849a 100644
--- a/cc/fuzz.go
+++ b/cc/fuzz.go
@@ -163,6 +163,11 @@
return flags
}
+func (fuzz *fuzzBinary) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
+ fuzz.binaryDecorator.moduleInfoJSON(ctx, moduleInfoJSON)
+ moduleInfoJSON.Class = []string{"EXECUTABLES"}
+}
+
// IsValidSharedDependency takes a module and determines if it is a unique shared library
// that should be installed in the fuzz target output directories. This function
// returns true, unless:
diff --git a/cc/library.go b/cc/library.go
index 4c8deef..592f70f 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -1041,6 +1041,40 @@
return specifiedDeps
}
+func (library *libraryDecorator) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
+ if library.static() {
+ moduleInfoJSON.Class = []string{"STATIC_LIBRARIES"}
+ moduleInfoJSON.Uninstallable = true
+ } else if library.shared() {
+ moduleInfoJSON.Class = []string{"SHARED_LIBRARIES"}
+ } else if library.header() {
+ moduleInfoJSON.Class = []string{"HEADER_LIBRARIES"}
+ moduleInfoJSON.Uninstallable = true
+ }
+
+ if library.buildStubs() && library.stubsVersion() != "" {
+ moduleInfoJSON.SubName += "." + library.stubsVersion()
+ }
+
+ // If a library providing a stub is included in an APEX, the private APIs of the library
+ // is accessible only inside the APEX. From outside of the APEX, clients can only use the
+ // public APIs via the stub. To enforce this, the (latest version of the) stub gets the
+ // name of the library. The impl library instead gets the `.bootstrap` suffix to so that
+ // they can be exceptionally used directly when APEXes are not available (e.g. during the
+ // very early stage in the boot process).
+ if len(library.Properties.Stubs.Versions) > 0 && !ctx.Host() && ctx.notInPlatform() &&
+ !ctx.inRamdisk() && !ctx.inVendorRamdisk() && !ctx.inRecovery() && !ctx.useVndk() && !ctx.static() {
+ if library.buildStubs() && library.isLatestStubVersion() {
+ moduleInfoJSON.SubName = ""
+ }
+ if !library.buildStubs() {
+ moduleInfoJSON.SubName = ".bootstrap"
+ }
+ }
+
+ library.baseLinker.moduleInfoJSON(ctx, moduleInfoJSON)
+}
+
func (library *libraryDecorator) linkStatic(ctx ModuleContext,
flags Flags, deps PathDeps, objs Objects) android.Path {
diff --git a/cc/linker.go b/cc/linker.go
index 357d1ce..85c128e 100644
--- a/cc/linker.go
+++ b/cc/linker.go
@@ -648,6 +648,9 @@
return specifiedDeps
}
+func (linker *baseLinker) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
+}
+
// Injecting version symbols
// Some host modules want a version number, but we don't want to rebuild it every time. Optionally add a step
// after linking that injects a constant placeholder with the current version number.
diff --git a/cc/ndk_library.go b/cc/ndk_library.go
index 98fb334..183e818 100644
--- a/cc/ndk_library.go
+++ b/cc/ndk_library.go
@@ -486,6 +486,12 @@
}
}
+func (linker *stubDecorator) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
+ linker.libraryDecorator.moduleInfoJSON(ctx, moduleInfoJSON)
+ // Overwrites the SubName computed by libraryDecorator
+ moduleInfoJSON.SubName = ndkLibrarySuffix + "." + linker.apiLevel.String()
+}
+
func (linker *stubDecorator) Name(name string) string {
return name + ndkLibrarySuffix
}
diff --git a/cc/object.go b/cc/object.go
index 0dba99f..6c0391f 100644
--- a/cc/object.go
+++ b/cc/object.go
@@ -238,3 +238,8 @@
func (object *objectLinker) isCrt() bool {
return Bool(object.Properties.Crt)
}
+
+func (object *objectLinker) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
+ object.baseLinker.moduleInfoJSON(ctx, moduleInfoJSON)
+ moduleInfoJSON.Class = []string{"STATIC_LIBRARIES"}
+}
diff --git a/cc/test.go b/cc/test.go
index d02145b..347d7c9 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -321,6 +321,13 @@
return []interface{}{&test.InstallerProperties}
}
+func (test *testDecorator) moduleInfoJSON(ctx android.ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
+ if android.PrefixInList(moduleInfoJSON.CompatibilitySuites, "mts-") &&
+ !android.InList("mts", moduleInfoJSON.CompatibilitySuites) {
+ moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, "mts")
+ }
+}
+
func NewTestInstaller() *baseInstaller {
return NewBaseInstaller("nativetest", "nativetest64", InstallInData)
}
@@ -355,6 +362,38 @@
return flags
}
+func (test *testBinary) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
+ if ctx.Host() && Bool(test.Properties.Test_options.Unit_test) {
+ moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, "host-unit-tests")
+ }
+ moduleInfoJSON.TestOptionsTags = append(moduleInfoJSON.TestOptionsTags, test.Properties.Test_options.Tags...)
+ moduleInfoJSON.TestMainlineModules = append(moduleInfoJSON.TestMainlineModules, test.Properties.Test_mainline_modules...)
+ if test.testConfig != nil {
+ if _, ok := test.testConfig.(android.WritablePath); ok {
+ moduleInfoJSON.AutoTestConfig = []string{"true"}
+ }
+ moduleInfoJSON.TestConfig = append(moduleInfoJSON.TestConfig, test.testConfig.String())
+ }
+ moduleInfoJSON.TestConfig = append(moduleInfoJSON.TestConfig, test.extraTestConfigs.Strings()...)
+
+ if Bool(test.Properties.Test_per_src) {
+ moduleInfoJSON.SubName = "_" + String(test.binaryDecorator.Properties.Stem)
+ }
+
+ moduleInfoJSON.DataDependencies = append(moduleInfoJSON.DataDependencies, test.Properties.Data_bins...)
+
+ if len(test.InstallerProperties.Test_suites) > 0 {
+ moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, test.InstallerProperties.Test_suites...)
+ } else {
+ moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, "null-suite")
+ }
+
+ test.binaryDecorator.moduleInfoJSON(ctx, moduleInfoJSON)
+ test.testDecorator.moduleInfoJSON(ctx, moduleInfoJSON)
+ moduleInfoJSON.Class = []string{"NATIVE_TESTS"}
+
+}
+
func (test *testBinary) installerProps() []interface{} {
return append(test.baseInstaller.installerProps(), test.testDecorator.installerProps()...)
}
@@ -532,6 +571,15 @@
return flags
}
+func (test *testLibrary) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
+ if len(test.InstallerProperties.Test_suites) > 0 {
+ moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, test.InstallerProperties.Test_suites...)
+ }
+
+ test.libraryDecorator.moduleInfoJSON(ctx, moduleInfoJSON)
+ test.testDecorator.moduleInfoJSON(ctx, moduleInfoJSON)
+}
+
func (test *testLibrary) installerProps() []interface{} {
return append(test.baseInstaller.installerProps(), test.testDecorator.installerProps()...)
}
@@ -626,6 +674,29 @@
benchmark.binaryDecorator.baseInstaller.install(ctx, file)
}
+func (benchmark *benchmarkDecorator) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
+ benchmark.binaryDecorator.moduleInfoJSON(ctx, moduleInfoJSON)
+
+ moduleInfoJSON.Class = []string{"NATIVE_TESTS"}
+ if len(benchmark.Properties.Test_suites) > 0 {
+ moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, benchmark.Properties.Test_suites...)
+ } else {
+ moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, "null-suite")
+ }
+
+ if android.PrefixInList(moduleInfoJSON.CompatibilitySuites, "mts-") &&
+ !android.InList("mts", moduleInfoJSON.CompatibilitySuites) {
+ moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, "mts")
+ }
+
+ if benchmark.testConfig != nil {
+ if _, ok := benchmark.testConfig.(android.WritablePath); ok {
+ moduleInfoJSON.AutoTestConfig = []string{"true"}
+ }
+ moduleInfoJSON.TestConfig = []string{benchmark.testConfig.String()}
+ }
+}
+
func NewBenchmark(hod android.HostOrDeviceSupported) *Module {
module, binary := newBinary(hod)
module.multilib = android.MultilibBoth
diff --git a/cc/vndk_prebuilt.go b/cc/vndk_prebuilt.go
index 3f3a025..eb1790f 100644
--- a/cc/vndk_prebuilt.go
+++ b/cc/vndk_prebuilt.go
@@ -187,6 +187,11 @@
return nil
}
+func (p *vndkPrebuiltLibraryDecorator) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
+ p.libraryDecorator.moduleInfoJSON(ctx, moduleInfoJSON)
+ moduleInfoJSON.SubName += p.androidMkSuffix
+}
+
func (p *vndkPrebuiltLibraryDecorator) MatchesWithDevice(config android.DeviceConfig) bool {
arches := config.Arches()
if len(arches) == 0 || arches[0].ArchType.String() != p.arch() {