aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorInseob Kim2019-05-09 19:34:42 -0500
committerandroid-build-merger2019-05-09 19:34:42 -0500
commit66c5cac22bf5e141bed893ff371b09058ec3cf88 (patch)
treeba62801d62499f9407c1058e32b10553ce81b2df
parent7b7f45b3fcdb6ff4a7cedb300bb20ee52d775064 (diff)
parenta1591ab08cdd8908e1d3d08c2f4f7be9b5b94957 (diff)
downloadplatform-build-soong-66c5cac22bf5e141bed893ff371b09058ec3cf88.tar.gz
platform-build-soong-66c5cac22bf5e141bed893ff371b09058ec3cf88.tar.xz
platform-build-soong-66c5cac22bf5e141bed893ff371b09058ec3cf88.zip
Merge "Attach global variables to Context"
am: a1591ab08c Change-Id: I755960fab4c3b3b7f9e2075e6cd1538dfe112321
-rw-r--r--cc/androidmk.go2
-rw-r--r--cc/cc.go71
-rw-r--r--cc/library.go6
-rw-r--r--cc/makevars.go14
-rw-r--r--cc/sabi.go2
-rw-r--r--cc/sanitize.go2
-rw-r--r--cc/vendor_public_library.go13
-rw-r--r--cc/vndk.go88
8 files changed, 130 insertions, 68 deletions
diff --git a/cc/androidmk.go b/cc/androidmk.go
index 79469ee3..c7883e2f 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -86,7 +86,7 @@ func (c *Module) AndroidMk() android.AndroidMkData {
86 if len(c.Properties.AndroidMkWholeStaticLibs) > 0 { 86 if len(c.Properties.AndroidMkWholeStaticLibs) > 0 {
87 fmt.Fprintln(w, "LOCAL_WHOLE_STATIC_LIBRARIES := "+strings.Join(c.Properties.AndroidMkWholeStaticLibs, " ")) 87 fmt.Fprintln(w, "LOCAL_WHOLE_STATIC_LIBRARIES := "+strings.Join(c.Properties.AndroidMkWholeStaticLibs, " "))
88 } 88 }
89 fmt.Fprintln(w, "LOCAL_SOONG_LINK_TYPE :=", c.getMakeLinkType()) 89 fmt.Fprintln(w, "LOCAL_SOONG_LINK_TYPE :=", c.makeLinkType)
90 if c.useVndk() { 90 if c.useVndk() {
91 fmt.Fprintln(w, "LOCAL_USE_VNDK := true") 91 fmt.Fprintln(w, "LOCAL_USE_VNDK := true")
92 } 92 }
diff --git a/cc/cc.go b/cc/cc.go
index bb24942a..eaf41d88 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -246,14 +246,14 @@ type ModuleContextIntf interface {
246 sdkVersion() string 246 sdkVersion() string
247 useVndk() bool 247 useVndk() bool
248 isNdk() bool 248 isNdk() bool
249 isLlndk() bool 249 isLlndk(config android.Config) bool
250 isLlndkPublic() bool 250 isLlndkPublic(config android.Config) bool
251 isVndkPrivate() bool 251 isVndkPrivate(config android.Config) bool
252 isVndk() bool 252 isVndk() bool
253 isVndkSp() bool 253 isVndkSp() bool
254 isVndkExt() bool 254 isVndkExt() bool
255 inRecovery() bool 255 inRecovery() bool
256 shouldCreateVndkSourceAbiDump() bool 256 shouldCreateVndkSourceAbiDump(config android.Config) bool
257 selectedStl() string 257 selectedStl() string
258 baseModuleName() string 258 baseModuleName() string
259 getVndkExtendsModuleName() string 259 getVndkExtendsModuleName() string
@@ -408,6 +408,8 @@ type Module struct {
408 408
409 // only non-nil when this is a shared library that reuses the objects of a static library 409 // only non-nil when this is a shared library that reuses the objects of a static library
410 staticVariant *Module 410 staticVariant *Module
411
412 makeLinkType string
411} 413}
412 414
413func (c *Module) OutputFile() android.OptionalPath { 415func (c *Module) OutputFile() android.OptionalPath {
@@ -510,19 +512,19 @@ func (c *Module) isNdk() bool {
510 return inList(c.Name(), ndkMigratedLibs) 512 return inList(c.Name(), ndkMigratedLibs)
511} 513}
512 514
513func (c *Module) isLlndk() bool { 515func (c *Module) isLlndk(config android.Config) bool {
514 // Returns true for both LLNDK (public) and LLNDK-private libs. 516 // Returns true for both LLNDK (public) and LLNDK-private libs.
515 return inList(c.Name(), llndkLibraries) 517 return inList(c.Name(), *llndkLibraries(config))
516} 518}
517 519
518func (c *Module) isLlndkPublic() bool { 520func (c *Module) isLlndkPublic(config android.Config) bool {
519 // Returns true only for LLNDK (public) libs. 521 // Returns true only for LLNDK (public) libs.
520 return c.isLlndk() && !c.isVndkPrivate() 522 return c.isLlndk(config) && !c.isVndkPrivate(config)
521} 523}
522 524
523func (c *Module) isVndkPrivate() bool { 525func (c *Module) isVndkPrivate(config android.Config) bool {
524 // Returns true for LLNDK-private, VNDK-SP-private, and VNDK-core-private. 526 // Returns true for LLNDK-private, VNDK-SP-private, and VNDK-core-private.
525 return inList(c.Name(), vndkPrivateLibraries) 527 return inList(c.Name(), *vndkPrivateLibraries(config))
526} 528}
527 529
528func (c *Module) isVndk() bool { 530func (c *Module) isVndk() bool {
@@ -687,16 +689,16 @@ func (ctx *moduleContextImpl) isNdk() bool {
687 return ctx.mod.isNdk() 689 return ctx.mod.isNdk()
688} 690}
689 691
690func (ctx *moduleContextImpl) isLlndk() bool { 692func (ctx *moduleContextImpl) isLlndk(config android.Config) bool {
691 return ctx.mod.isLlndk() 693 return ctx.mod.isLlndk(config)
692} 694}
693 695
694func (ctx *moduleContextImpl) isLlndkPublic() bool { 696func (ctx *moduleContextImpl) isLlndkPublic(config android.Config) bool {
695 return ctx.mod.isLlndkPublic() 697 return ctx.mod.isLlndkPublic(config)
696} 698}
697 699
698func (ctx *moduleContextImpl) isVndkPrivate() bool { 700func (ctx *moduleContextImpl) isVndkPrivate(config android.Config) bool {
699 return ctx.mod.isVndkPrivate() 701 return ctx.mod.isVndkPrivate(config)
700} 702}
701 703
702func (ctx *moduleContextImpl) isVndk() bool { 704func (ctx *moduleContextImpl) isVndk() bool {
@@ -728,7 +730,7 @@ func (ctx *moduleContextImpl) inRecovery() bool {
728} 730}
729 731
730// Check whether ABI dumps should be created for this module. 732// Check whether ABI dumps should be created for this module.
731func (ctx *moduleContextImpl) shouldCreateVndkSourceAbiDump() bool { 733func (ctx *moduleContextImpl) shouldCreateVndkSourceAbiDump(config android.Config) bool {
732 if ctx.ctx.Config().IsEnvTrue("SKIP_ABI_CHECKS") { 734 if ctx.ctx.Config().IsEnvTrue("SKIP_ABI_CHECKS") {
733 return false 735 return false
734 } 736 }
@@ -753,10 +755,10 @@ func (ctx *moduleContextImpl) shouldCreateVndkSourceAbiDump() bool {
753 if ctx.isNdk() { 755 if ctx.isNdk() {
754 return true 756 return true
755 } 757 }
756 if ctx.isLlndkPublic() { 758 if ctx.isLlndkPublic(config) {
757 return true 759 return true
758 } 760 }
759 if ctx.useVndk() && ctx.isVndk() && !ctx.isVndkPrivate() { 761 if ctx.useVndk() && ctx.isVndk() && !ctx.isVndkPrivate(config) {
760 // Return true if this is VNDK-core, VNDK-SP, or VNDK-Ext and this is not 762 // Return true if this is VNDK-core, VNDK-SP, or VNDK-Ext and this is not
761 // VNDK-private. 763 // VNDK-private.
762 return true 764 return true
@@ -907,6 +909,8 @@ func orderStaticModuleDeps(module *Module, staticDeps []*Module, sharedDeps []*M
907} 909}
908 910
909func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { 911func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
912 c.makeLinkType = c.getMakeLinkType(actx.Config())
913
910 ctx := &moduleContext{ 914 ctx := &moduleContext{
911 ModuleContext: actx, 915 ModuleContext: actx,
912 moduleContextImpl: moduleContextImpl{ 916 moduleContextImpl: moduleContextImpl{
@@ -1186,6 +1190,9 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
1186 // 1190 //
1187 // The caller can then know to add the variantLibs dependencies differently from the 1191 // The caller can then know to add the variantLibs dependencies differently from the
1188 // nonvariantLibs 1192 // nonvariantLibs
1193
1194 llndkLibraries := llndkLibraries(actx.Config())
1195 vendorPublicLibraries := vendorPublicLibraries(actx.Config())
1189 rewriteNdkLibs := func(list []string) (nonvariantLibs []string, variantLibs []string) { 1196 rewriteNdkLibs := func(list []string) (nonvariantLibs []string, variantLibs []string) {
1190 variantLibs = []string{} 1197 variantLibs = []string{}
1191 nonvariantLibs = []string{} 1198 nonvariantLibs = []string{}
@@ -1198,9 +1205,9 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
1198 } else { 1205 } else {
1199 variantLibs = append(variantLibs, name+ndkLibrarySuffix) 1206 variantLibs = append(variantLibs, name+ndkLibrarySuffix)
1200 } 1207 }
1201 } else if ctx.useVndk() && inList(name, llndkLibraries) { 1208 } else if ctx.useVndk() && inList(name, *llndkLibraries) {
1202 nonvariantLibs = append(nonvariantLibs, name+llndkLibrarySuffix) 1209 nonvariantLibs = append(nonvariantLibs, name+llndkLibrarySuffix)
1203 } else if (ctx.Platform() || ctx.ProductSpecific()) && inList(name, vendorPublicLibraries) { 1210 } else if (ctx.Platform() || ctx.ProductSpecific()) && inList(name, *vendorPublicLibraries) {
1204 vendorPublicLib := name + vendorPublicLibrarySuffix 1211 vendorPublicLib := name + vendorPublicLibrarySuffix
1205 if actx.OtherModuleExists(vendorPublicLib) { 1212 if actx.OtherModuleExists(vendorPublicLib) {
1206 nonvariantLibs = append(nonvariantLibs, vendorPublicLib) 1213 nonvariantLibs = append(nonvariantLibs, vendorPublicLib)
@@ -1501,6 +1508,7 @@ func checkLinkType(ctx android.ModuleContext, from *Module, to *Module, tag depe
1501// it is subject to be double loaded. Such lib should be explicitly marked as double_loadable: true 1508// it is subject to be double loaded. Such lib should be explicitly marked as double_loadable: true
1502// or as vndk-sp (vndk: { enabled: true, support_system_process: true}). 1509// or as vndk-sp (vndk: { enabled: true, support_system_process: true}).
1503func checkDoubleLoadableLibraries(ctx android.TopDownMutatorContext) { 1510func checkDoubleLoadableLibraries(ctx android.TopDownMutatorContext) {
1511 llndkLibraries := llndkLibraries(ctx.Config())
1504 check := func(child, parent android.Module) bool { 1512 check := func(child, parent android.Module) bool {
1505 to, ok := child.(*Module) 1513 to, ok := child.(*Module)
1506 if !ok { 1514 if !ok {
@@ -1517,7 +1525,7 @@ func checkDoubleLoadableLibraries(ctx android.TopDownMutatorContext) {
1517 return true 1525 return true
1518 } 1526 }
1519 1527
1520 if to.isVndkSp() || inList(child.Name(), llndkLibraries) || Bool(to.VendorProperties.Double_loadable) { 1528 if to.isVndkSp() || inList(child.Name(), *llndkLibraries) || Bool(to.VendorProperties.Double_loadable) {
1521 return false 1529 return false
1522 } 1530 }
1523 1531
@@ -1532,7 +1540,7 @@ func checkDoubleLoadableLibraries(ctx android.TopDownMutatorContext) {
1532 } 1540 }
1533 if module, ok := ctx.Module().(*Module); ok { 1541 if module, ok := ctx.Module().(*Module); ok {
1534 if lib, ok := module.linker.(*libraryDecorator); ok && lib.shared() { 1542 if lib, ok := module.linker.(*libraryDecorator); ok && lib.shared() {
1535 if inList(ctx.ModuleName(), llndkLibraries) || Bool(module.VendorProperties.Double_loadable) { 1543 if inList(ctx.ModuleName(), *llndkLibraries) || Bool(module.VendorProperties.Double_loadable) {
1536 ctx.WalkDeps(check) 1544 ctx.WalkDeps(check)
1537 } 1545 }
1538 } 1546 }
@@ -1546,6 +1554,9 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
1546 directStaticDeps := []*Module{} 1554 directStaticDeps := []*Module{}
1547 directSharedDeps := []*Module{} 1555 directSharedDeps := []*Module{}
1548 1556
1557 llndkLibraries := llndkLibraries(ctx.Config())
1558 vendorPublicLibraries := vendorPublicLibraries(ctx.Config())
1559
1549 ctx.VisitDirectDeps(func(dep android.Module) { 1560 ctx.VisitDirectDeps(func(dep android.Module) {
1550 depName := ctx.OtherModuleName(dep) 1561 depName := ctx.OtherModuleName(dep)
1551 depTag := ctx.OtherModuleDependencyTag(dep) 1562 depTag := ctx.OtherModuleDependencyTag(dep)
@@ -1788,8 +1799,8 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
1788 libName := strings.TrimSuffix(depName, llndkLibrarySuffix) 1799 libName := strings.TrimSuffix(depName, llndkLibrarySuffix)
1789 libName = strings.TrimSuffix(libName, vendorPublicLibrarySuffix) 1800 libName = strings.TrimSuffix(libName, vendorPublicLibrarySuffix)
1790 libName = strings.TrimPrefix(libName, "prebuilt_") 1801 libName = strings.TrimPrefix(libName, "prebuilt_")
1791 isLLndk := inList(libName, llndkLibraries) 1802 isLLndk := inList(libName, *llndkLibraries)
1792 isVendorPublicLib := inList(libName, vendorPublicLibraries) 1803 isVendorPublicLib := inList(libName, *vendorPublicLibraries)
1793 bothVendorAndCoreVariantsExist := ccDep.hasVendorVariant() || isLLndk 1804 bothVendorAndCoreVariantsExist := ccDep.hasVendorVariant() || isLLndk
1794 1805
1795 if ctx.DeviceConfig().VndkUseCoreVariant() && ccDep.isVndk() && !ccDep.mustUseVendorVariant() { 1806 if ctx.DeviceConfig().VndkUseCoreVariant() && ccDep.isVndk() && !ccDep.mustUseVendorVariant() {
@@ -1919,10 +1930,12 @@ func (c *Module) staticBinary() bool {
1919 return false 1930 return false
1920} 1931}
1921 1932
1922func (c *Module) getMakeLinkType() string { 1933func (c *Module) getMakeLinkType(config android.Config) string {
1923 if c.useVndk() { 1934 if c.useVndk() {
1924 if inList(c.Name(), vndkCoreLibraries) || inList(c.Name(), vndkSpLibraries) || inList(c.Name(), llndkLibraries) { 1935 if inList(c.Name(), *vndkCoreLibraries(config)) ||
1925 if inList(c.Name(), vndkPrivateLibraries) { 1936 inList(c.Name(), *vndkSpLibraries(config)) ||
1937 inList(c.Name(), *llndkLibraries(config)) {
1938 if inList(c.Name(), *vndkPrivateLibraries(config)) {
1926 return "native:vndk_private" 1939 return "native:vndk_private"
1927 } else { 1940 } else {
1928 return "native:vndk" 1941 return "native:vndk"
@@ -1937,7 +1950,7 @@ func (c *Module) getMakeLinkType() string {
1937 // TODO(b/114741097): use the correct ndk stl once build errors have been fixed 1950 // TODO(b/114741097): use the correct ndk stl once build errors have been fixed
1938 //family, link := getNdkStlFamilyAndLinkType(c) 1951 //family, link := getNdkStlFamilyAndLinkType(c)
1939 //return fmt.Sprintf("native:ndk:%s:%s", family, link) 1952 //return fmt.Sprintf("native:ndk:%s:%s", family, link)
1940 } else if inList(c.Name(), vndkUsingCoreVariantLibraries) { 1953 } else if inList(c.Name(), *vndkUsingCoreVariantLibraries(config)) {
1941 return "native:platform_vndk" 1954 return "native:platform_vndk"
1942 } else { 1955 } else {
1943 return "native:platform" 1956 return "native:platform"
diff --git a/cc/library.go b/cc/library.go
index 1f79becb..c2ab098f 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -429,7 +429,7 @@ func (library *libraryDecorator) shouldCreateVndkSourceAbiDump(ctx ModuleContext
429 if library.Properties.Header_abi_checker.Enabled != nil { 429 if library.Properties.Header_abi_checker.Enabled != nil {
430 return Bool(library.Properties.Header_abi_checker.Enabled) 430 return Bool(library.Properties.Header_abi_checker.Enabled)
431 } 431 }
432 return ctx.shouldCreateVndkSourceAbiDump() 432 return ctx.shouldCreateVndkSourceAbiDump(ctx.Config())
433} 433}
434 434
435func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects { 435func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects {
@@ -783,7 +783,7 @@ func (library *libraryDecorator) nativeCoverage() bool {
783} 783}
784 784
785func getRefAbiDumpFile(ctx ModuleContext, vndkVersion, fileName string) android.Path { 785func getRefAbiDumpFile(ctx ModuleContext, vndkVersion, fileName string) android.Path {
786 isLlndkOrNdk := inList(ctx.baseModuleName(), llndkLibraries) || inList(ctx.baseModuleName(), ndkMigratedLibs) 786 isLlndkOrNdk := inList(ctx.baseModuleName(), *llndkLibraries(ctx.Config())) || inList(ctx.baseModuleName(), ndkMigratedLibs)
787 787
788 refAbiDumpTextFile := android.PathForVndkRefAbiDump(ctx, vndkVersion, fileName, isLlndkOrNdk, ctx.isVndk(), false) 788 refAbiDumpTextFile := android.PathForVndkRefAbiDump(ctx, vndkVersion, fileName, isLlndkOrNdk, ctx.isVndk(), false)
789 refAbiDumpGzipFile := android.PathForVndkRefAbiDump(ctx, vndkVersion, fileName, isLlndkOrNdk, ctx.isVndk(), true) 789 refAbiDumpGzipFile := android.PathForVndkRefAbiDump(ctx, vndkVersion, fileName, isLlndkOrNdk, ctx.isVndk(), true)
@@ -827,7 +827,7 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objec
827 refAbiDumpFile := getRefAbiDumpFile(ctx, vndkVersion, fileName) 827 refAbiDumpFile := getRefAbiDumpFile(ctx, vndkVersion, fileName)
828 if refAbiDumpFile != nil { 828 if refAbiDumpFile != nil {
829 library.sAbiDiff = SourceAbiDiff(ctx, library.sAbiOutputFile.Path(), 829 library.sAbiDiff = SourceAbiDiff(ctx, library.sAbiOutputFile.Path(),
830 refAbiDumpFile, fileName, exportedHeaderFlags, ctx.isLlndk(), ctx.isNdk(), ctx.isVndkExt()) 830 refAbiDumpFile, fileName, exportedHeaderFlags, ctx.isLlndk(ctx.Config()), ctx.isNdk(), ctx.isVndkExt())
831 } 831 }
832 } 832 }
833} 833}
diff --git a/cc/makevars.go b/cc/makevars.go
index dc91525a..3c24f347 100644
--- a/cc/makevars.go
+++ b/cc/makevars.go
@@ -64,6 +64,8 @@ func makeStringOfWarningAllowedProjects() string {
64} 64}
65 65
66func makeVarsProvider(ctx android.MakeVarsContext) { 66func makeVarsProvider(ctx android.MakeVarsContext) {
67 vendorPublicLibraries := vendorPublicLibraries(ctx.Config())
68
67 ctx.Strict("LLVM_RELEASE_VERSION", "${config.ClangShortVersion}") 69 ctx.Strict("LLVM_RELEASE_VERSION", "${config.ClangShortVersion}")
68 ctx.Strict("LLVM_PREBUILTS_VERSION", "${config.ClangVersion}") 70 ctx.Strict("LLVM_PREBUILTS_VERSION", "${config.ClangVersion}")
69 ctx.Strict("LLVM_PREBUILTS_BASE", "${config.ClangBase}") 71 ctx.Strict("LLVM_PREBUILTS_BASE", "${config.ClangBase}")
@@ -92,18 +94,18 @@ func makeVarsProvider(ctx android.MakeVarsContext) {
92 94
93 ctx.Strict("BOARD_VNDK_VERSION", ctx.DeviceConfig().VndkVersion()) 95 ctx.Strict("BOARD_VNDK_VERSION", ctx.DeviceConfig().VndkVersion())
94 96
95 ctx.Strict("VNDK_CORE_LIBRARIES", strings.Join(vndkCoreLibraries, " ")) 97 ctx.Strict("VNDK_CORE_LIBRARIES", strings.Join(*vndkCoreLibraries(ctx.Config()), " "))
96 ctx.Strict("VNDK_SAMEPROCESS_LIBRARIES", strings.Join(vndkSpLibraries, " ")) 98 ctx.Strict("VNDK_SAMEPROCESS_LIBRARIES", strings.Join(*vndkSpLibraries(ctx.Config()), " "))
97 ctx.Strict("LLNDK_LIBRARIES", strings.Join(llndkLibraries, " ")) 99 ctx.Strict("LLNDK_LIBRARIES", strings.Join(*llndkLibraries(ctx.Config()), " "))
98 ctx.Strict("VNDK_PRIVATE_LIBRARIES", strings.Join(vndkPrivateLibraries, " ")) 100 ctx.Strict("VNDK_PRIVATE_LIBRARIES", strings.Join(*vndkPrivateLibraries(ctx.Config()), " "))
99 ctx.Strict("VNDK_USING_CORE_VARIANT_LIBRARIES", strings.Join(vndkUsingCoreVariantLibraries, " ")) 101 ctx.Strict("VNDK_USING_CORE_VARIANT_LIBRARIES", strings.Join(*vndkUsingCoreVariantLibraries(ctx.Config()), " "))
100 102
101 // Filter vendor_public_library that are exported to make 103 // Filter vendor_public_library that are exported to make
102 exportedVendorPublicLibraries := []string{} 104 exportedVendorPublicLibraries := []string{}
103 ctx.VisitAllModules(func(module android.Module) { 105 ctx.VisitAllModules(func(module android.Module) {
104 if ccModule, ok := module.(*Module); ok { 106 if ccModule, ok := module.(*Module); ok {
105 baseName := ccModule.BaseModuleName() 107 baseName := ccModule.BaseModuleName()
106 if inList(baseName, vendorPublicLibraries) && module.ExportedToMake() { 108 if inList(baseName, *vendorPublicLibraries) && module.ExportedToMake() {
107 if !inList(baseName, exportedVendorPublicLibraries) { 109 if !inList(baseName, exportedVendorPublicLibraries) {
108 exportedVendorPublicLibraries = append(exportedVendorPublicLibraries, baseName) 110 exportedVendorPublicLibraries = append(exportedVendorPublicLibraries, baseName)
109 } 111 }
diff --git a/cc/sabi.go b/cc/sabi.go
index 4a864994..451176f1 100644
--- a/cc/sabi.go
+++ b/cc/sabi.go
@@ -78,7 +78,7 @@ func (sabimod *sabi) flags(ctx ModuleContext, flags Flags) Flags {
78 78
79func sabiDepsMutator(mctx android.TopDownMutatorContext) { 79func sabiDepsMutator(mctx android.TopDownMutatorContext) {
80 if c, ok := mctx.Module().(*Module); ok && 80 if c, ok := mctx.Module().(*Module); ok &&
81 ((c.isVndk() && c.useVndk()) || inList(c.Name(), llndkLibraries) || 81 ((c.isVndk() && c.useVndk()) || inList(c.Name(), *llndkLibraries(mctx.Config())) ||
82 (c.sabi != nil && c.sabi.Properties.CreateSAbiDumps)) { 82 (c.sabi != nil && c.sabi.Properties.CreateSAbiDumps)) {
83 mctx.VisitDirectDeps(func(m android.Module) { 83 mctx.VisitDirectDeps(func(m android.Module) {
84 tag := mctx.OtherModuleDependencyTag(m) 84 tag := mctx.OtherModuleDependencyTag(m)
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 2d80c221..acf2befd 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -817,7 +817,7 @@ func sanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) {
817 } 817 }
818 818
819 if mctx.Device() && runtimeLibrary != "" { 819 if mctx.Device() && runtimeLibrary != "" {
820 if inList(runtimeLibrary, llndkLibraries) && !c.static() && c.useVndk() { 820 if inList(runtimeLibrary, *llndkLibraries(mctx.Config())) && !c.static() && c.useVndk() {
821 runtimeLibrary = runtimeLibrary + llndkLibrarySuffix 821 runtimeLibrary = runtimeLibrary + llndkLibrarySuffix
822 } 822 }
823 823
diff --git a/cc/vendor_public_library.go b/cc/vendor_public_library.go
index 2072ad99..5738d25a 100644
--- a/cc/vendor_public_library.go
+++ b/cc/vendor_public_library.go
@@ -24,10 +24,16 @@ import (
24var ( 24var (
25 vendorPublicLibrarySuffix = ".vendorpublic" 25 vendorPublicLibrarySuffix = ".vendorpublic"
26 26
27 vendorPublicLibraries = []string{} 27 vendorPublicLibrariesKey = android.NewOnceKey("vendorPublicLibraries")
28 vendorPublicLibrariesLock sync.Mutex 28 vendorPublicLibrariesLock sync.Mutex
29) 29)
30 30
31func vendorPublicLibraries(config android.Config) *[]string {
32 return config.Once(vendorPublicLibrariesKey, func() interface{} {
33 return &[]string{}
34 }).(*[]string)
35}
36
31// Creates a stub shared library for a vendor public library. Vendor public libraries 37// Creates a stub shared library for a vendor public library. Vendor public libraries
32// are vendor libraries (owned by them and installed to /vendor partition) that are 38// are vendor libraries (owned by them and installed to /vendor partition) that are
33// exposed to Android apps via JNI. The libraries are made public by being listed in 39// exposed to Android apps via JNI. The libraries are made public by being listed in
@@ -82,12 +88,13 @@ func (stub *vendorPublicLibraryStubDecorator) compilerInit(ctx BaseModuleContext
82 88
83 vendorPublicLibrariesLock.Lock() 89 vendorPublicLibrariesLock.Lock()
84 defer vendorPublicLibrariesLock.Unlock() 90 defer vendorPublicLibrariesLock.Unlock()
85 for _, lib := range vendorPublicLibraries { 91 vendorPublicLibraries := vendorPublicLibraries(ctx.Config())
92 for _, lib := range *vendorPublicLibraries {
86 if lib == name { 93 if lib == name {
87 return 94 return
88 } 95 }
89 } 96 }
90 vendorPublicLibraries = append(vendorPublicLibraries, name) 97 *vendorPublicLibraries = append(*vendorPublicLibraries, name)
91} 98}
92 99
93func (stub *vendorPublicLibraryStubDecorator) compilerFlags(ctx ModuleContext, flags Flags, deps PathDeps) Flags { 100func (stub *vendorPublicLibraryStubDecorator) compilerFlags(ctx ModuleContext, flags Flags, deps PathDeps) Flags {
diff --git a/cc/vndk.go b/cc/vndk.go
index 44a83e76..7859fa21 100644
--- a/cc/vndk.go
+++ b/cc/vndk.go
@@ -192,29 +192,63 @@ func vndkIsVndkDepAllowed(from *vndkdep, to *vndkdep) error {
192} 192}
193 193
194var ( 194var (
195 vndkCoreLibraries []string 195 vndkCoreLibrariesKey = android.NewOnceKey("vndkCoreLibrarires")
196 vndkSpLibraries []string 196 vndkSpLibrariesKey = android.NewOnceKey("vndkSpLibrarires")
197 llndkLibraries []string 197 llndkLibrariesKey = android.NewOnceKey("llndkLibrarires")
198 vndkPrivateLibraries []string 198 vndkPrivateLibrariesKey = android.NewOnceKey("vndkPrivateLibrarires")
199 vndkUsingCoreVariantLibraries []string 199 vndkUsingCoreVariantLibrariesKey = android.NewOnceKey("vndkUsingCoreVariantLibrarires")
200 vndkLibrariesLock sync.Mutex 200 vndkLibrariesLock sync.Mutex
201) 201)
202 202
203func vndkCoreLibraries(config android.Config) *[]string {
204 return config.Once(vndkCoreLibrariesKey, func() interface{} {
205 return &[]string{}
206 }).(*[]string)
207}
208
209func vndkSpLibraries(config android.Config) *[]string {
210 return config.Once(vndkSpLibrariesKey, func() interface{} {
211 return &[]string{}
212 }).(*[]string)
213}
214
215func llndkLibraries(config android.Config) *[]string {
216 return config.Once(llndkLibrariesKey, func() interface{} {
217 return &[]string{}
218 }).(*[]string)
219}
220
221func vndkPrivateLibraries(config android.Config) *[]string {
222 return config.Once(vndkPrivateLibrariesKey, func() interface{} {
223 return &[]string{}
224 }).(*[]string)
225}
226
227func vndkUsingCoreVariantLibraries(config android.Config) *[]string {
228 return config.Once(vndkUsingCoreVariantLibrariesKey, func() interface{} {
229 return &[]string{}
230 }).(*[]string)
231}
232
203// gather list of vndk-core, vndk-sp, and ll-ndk libs 233// gather list of vndk-core, vndk-sp, and ll-ndk libs
204func VndkMutator(mctx android.BottomUpMutatorContext) { 234func VndkMutator(mctx android.BottomUpMutatorContext) {
205 if m, ok := mctx.Module().(*Module); ok && m.Enabled() { 235 if m, ok := mctx.Module().(*Module); ok && m.Enabled() {
206 if lib, ok := m.linker.(*llndkStubDecorator); ok { 236 if lib, ok := m.linker.(*llndkStubDecorator); ok {
207 vndkLibrariesLock.Lock() 237 vndkLibrariesLock.Lock()
208 defer vndkLibrariesLock.Unlock() 238 defer vndkLibrariesLock.Unlock()
239
240 llndkLibraries := llndkLibraries(mctx.Config())
241 vndkPrivateLibraries := vndkPrivateLibraries(mctx.Config())
242
209 name := strings.TrimSuffix(m.Name(), llndkLibrarySuffix) 243 name := strings.TrimSuffix(m.Name(), llndkLibrarySuffix)
210 if !inList(name, llndkLibraries) { 244 if !inList(name, *llndkLibraries) {
211 llndkLibraries = append(llndkLibraries, name) 245 *llndkLibraries = append(*llndkLibraries, name)
212 sort.Strings(llndkLibraries) 246 sort.Strings(*llndkLibraries)
213 } 247 }
214 if !Bool(lib.Properties.Vendor_available) { 248 if !Bool(lib.Properties.Vendor_available) {
215 if !inList(name, vndkPrivateLibraries) { 249 if !inList(name, *vndkPrivateLibraries) {
216 vndkPrivateLibraries = append(vndkPrivateLibraries, name) 250 *vndkPrivateLibraries = append(*vndkPrivateLibraries, name)
217 sort.Strings(vndkPrivateLibraries) 251 sort.Strings(*vndkPrivateLibraries)
218 } 252 }
219 } 253 }
220 } else { 254 } else {
@@ -225,27 +259,33 @@ func VndkMutator(mctx android.BottomUpMutatorContext) {
225 if m.vndkdep.isVndk() && !m.vndkdep.isVndkExt() { 259 if m.vndkdep.isVndk() && !m.vndkdep.isVndkExt() {
226 vndkLibrariesLock.Lock() 260 vndkLibrariesLock.Lock()
227 defer vndkLibrariesLock.Unlock() 261 defer vndkLibrariesLock.Unlock()
262
263 vndkUsingCoreVariantLibraries := vndkUsingCoreVariantLibraries(mctx.Config())
264 vndkSpLibraries := vndkSpLibraries(mctx.Config())
265 vndkCoreLibraries := vndkCoreLibraries(mctx.Config())
266 vndkPrivateLibraries := vndkPrivateLibraries(mctx.Config())
267
228 if mctx.DeviceConfig().VndkUseCoreVariant() && !inList(name, config.VndkMustUseVendorVariantList) { 268 if mctx.DeviceConfig().VndkUseCoreVariant() && !inList(name, config.VndkMustUseVendorVariantList) {
229 if !inList(name, vndkUsingCoreVariantLibraries) { 269 if !inList(name, *vndkUsingCoreVariantLibraries) {
230 vndkUsingCoreVariantLibraries = append(vndkUsingCoreVariantLibraries, name) 270 *vndkUsingCoreVariantLibraries = append(*vndkUsingCoreVariantLibraries, name)
231 sort.Strings(vndkUsingCoreVariantLibraries) 271 sort.Strings(*vndkUsingCoreVariantLibraries)
232 } 272 }
233 } 273 }
234 if m.vndkdep.isVndkSp() { 274 if m.vndkdep.isVndkSp() {
235 if !inList(name, vndkSpLibraries) { 275 if !inList(name, *vndkSpLibraries) {
236 vndkSpLibraries = append(vndkSpLibraries, name) 276 *vndkSpLibraries = append(*vndkSpLibraries, name)
237 sort.Strings(vndkSpLibraries) 277 sort.Strings(*vndkSpLibraries)
238 } 278 }
239 } else { 279 } else {
240 if !inList(name, vndkCoreLibraries) { 280 if !inList(name, *vndkCoreLibraries) {
241 vndkCoreLibraries = append(vndkCoreLibraries, name) 281 *vndkCoreLibraries = append(*vndkCoreLibraries, name)
242 sort.Strings(vndkCoreLibraries) 282 sort.Strings(*vndkCoreLibraries)
243 } 283 }
244 } 284 }
245 if !Bool(m.VendorProperties.Vendor_available) { 285 if !Bool(m.VendorProperties.Vendor_available) {
246 if !inList(name, vndkPrivateLibraries) { 286 if !inList(name, *vndkPrivateLibraries) {
247 vndkPrivateLibraries = append(vndkPrivateLibraries, name) 287 *vndkPrivateLibraries = append(*vndkPrivateLibraries, name)
248 sort.Strings(vndkPrivateLibraries) 288 sort.Strings(*vndkPrivateLibraries)
249 } 289 }
250 } 290 }
251 } 291 }