diff --git a/cc/androidmk.go b/cc/androidmk.go index 54c7f9773..bde096b78 100644 --- a/cc/androidmk.go +++ b/cc/androidmk.go @@ -101,15 +101,6 @@ func (c *Module) AndroidMkEntries() []android.AndroidMkEntries { 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 61541ad3b..7aa8e20cc 100644 --- a/cc/binary.go +++ b/cc/binary.go @@ -541,6 +541,11 @@ func (binary *binaryDecorator) overriddenModules() []string { 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 e6b9d8b6a..67067f508 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -544,6 +544,7 @@ type ModuleContextIntf interface { isPreventInstall() bool isCfiAssemblySupportEnabled() bool getSharedFlags() *SharedFlags + notInPlatform() bool } type SharedFlags struct { @@ -624,6 +625,8 @@ type linker interface { // 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 @@ func (ctx *moduleContextImpl) isCfiAssemblySupportEnabled() bool { 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 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { 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 f5642d67d..183849a55 100644 --- a/cc/fuzz.go +++ b/cc/fuzz.go @@ -163,6 +163,11 @@ func (fuzz *fuzzBinary) linkerFlags(ctx ModuleContext, flags Flags) Flags { 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 4c8deefcc..592f70f47 100644 --- a/cc/library.go +++ b/cc/library.go @@ -1041,6 +1041,40 @@ func (library *libraryDecorator) linkerSpecifiedDeps(specifiedDeps specifiedDeps 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 357d1cee0..85c128e46 100644 --- a/cc/linker.go +++ b/cc/linker.go @@ -648,6 +648,9 @@ func (linker *baseLinker) linkerSpecifiedDeps(specifiedDeps specifiedDeps) speci 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 98fb334e2..183e81805 100644 --- a/cc/ndk_library.go +++ b/cc/ndk_library.go @@ -486,6 +486,12 @@ func (linker *stubDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps { } } +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 0dba99f3d..6c0391f3b 100644 --- a/cc/object.go +++ b/cc/object.go @@ -238,3 +238,8 @@ func (object *objectLinker) object() bool { 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 d02145bd5..347d7c96f 100644 --- a/cc/test.go +++ b/cc/test.go @@ -321,6 +321,13 @@ func (test *testDecorator) installerProps() []interface{} { 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 @@ func (test *testBinary) linkerFlags(ctx ModuleContext, flags Flags) Flags { 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 @@ func (test *testLibrary) linkerFlags(ctx ModuleContext, flags Flags) Flags { 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 @@ func (benchmark *benchmarkDecorator) install(ctx ModuleContext, file android.Pat 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 3f3a0256d..eb1790f58 100644 --- a/cc/vndk_prebuilt.go +++ b/cc/vndk_prebuilt.go @@ -187,6 +187,11 @@ func (p *vndkPrebuiltLibraryDecorator) link(ctx ModuleContext, 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() {