aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorInseob Kim2019-05-08 23:29:15 -0500
committerInseob Kim2019-05-14 20:26:54 -0500
commit1f086e2f0d36dfa17d75fca37060d46e95ef193b (patch)
tree6f4c60a034df1934ac2121463da0f84490e79c14
parent0967b34dd95018719bc5bc2876f68a4921d81368 (diff)
downloadplatform-build-soong-1f086e2f0d36dfa17d75fca37060d46e95ef193b.tar.gz
platform-build-soong-1f086e2f0d36dfa17d75fca37060d46e95ef193b.tar.xz
platform-build-soong-1f086e2f0d36dfa17d75fca37060d46e95ef193b.zip
Generate VNDK snapshot with Soong except configs
This is the first commit to generate VNDK snapshot with Soong: .so files, some txt files, and notice files are captured with Soong. As ld.config.txt is currently in Android.mk and will be deprecated soon, configs files (and zipping all of artifacts) are still handled with Makefile. Bug: 131564934 Test: 1) DIST_DIR=out/dist development/vndk/snapshot/build.sh Test: 2) try installing vndk snapshot with: development/vndk/snapshot/update.py Change-Id: I8629e1e25bfc461fd495565bb4872c9af176cf92
-rw-r--r--android/config.go24
-rw-r--r--android/util.go25
-rw-r--r--android/variable.go2
-rw-r--r--cc/cc.go6
-rw-r--r--cc/cc_test.go49
-rw-r--r--cc/vndk.go353
6 files changed, 401 insertions, 58 deletions
diff --git a/android/config.go b/android/config.go
index 15e2ad4c..a18feb6d 100644
--- a/android/config.go
+++ b/android/config.go
@@ -288,6 +288,10 @@ func TestArchConfig(buildDir string, env map[string]string) Config {
288 288
289 config.BuildOsVariant = config.Targets[BuildOs][0].String() 289 config.BuildOsVariant = config.Targets[BuildOs][0].String()
290 config.BuildOsCommonVariant = getCommonTargets(config.Targets[BuildOs])[0].String() 290 config.BuildOsCommonVariant = getCommonTargets(config.Targets[BuildOs])[0].String()
291 config.TestProductVariables.DeviceArch = proptools.StringPtr("arm64")
292 config.TestProductVariables.DeviceArchVariant = proptools.StringPtr("armv8-a")
293 config.TestProductVariables.DeviceSecondaryArch = proptools.StringPtr("arm")
294 config.TestProductVariables.DeviceSecondaryArchVariant = proptools.StringPtr("armv7-a-neon")
291 295
292 return testConfig 296 return testConfig
293} 297}
@@ -1100,3 +1104,23 @@ func (c *config) ProductPrivateSepolicyDirs() []string {
1100func (c *config) ProductCompatibleProperty() bool { 1104func (c *config) ProductCompatibleProperty() bool {
1101 return Bool(c.productVariables.ProductCompatibleProperty) 1105 return Bool(c.productVariables.ProductCompatibleProperty)
1102} 1106}
1107
1108func (c *deviceConfig) BoardVndkRuntimeDisable() bool {
1109 return Bool(c.config.productVariables.BoardVndkRuntimeDisable)
1110}
1111
1112func (c *deviceConfig) DeviceArch() string {
1113 return String(c.config.productVariables.DeviceArch)
1114}
1115
1116func (c *deviceConfig) DeviceArchVariant() string {
1117 return String(c.config.productVariables.DeviceArchVariant)
1118}
1119
1120func (c *deviceConfig) DeviceSecondaryArch() string {
1121 return String(c.config.productVariables.DeviceSecondaryArch)
1122}
1123
1124func (c *deviceConfig) DeviceSecondaryArchVariant() string {
1125 return String(c.config.productVariables.DeviceSecondaryArchVariant)
1126}
diff --git a/android/util.go b/android/util.go
index f9dce6fe..f7a3437c 100644
--- a/android/util.go
+++ b/android/util.go
@@ -52,6 +52,31 @@ func JoinWithPrefix(strs []string, prefix string) string {
52 return string(ret) 52 return string(ret)
53} 53}
54 54
55func JoinWithSuffix(strs []string, suffix string, separator string) string {
56 if len(strs) == 0 {
57 return ""
58 }
59
60 if len(strs) == 1 {
61 return strs[0] + suffix
62 }
63
64 n := len(" ") * (len(strs) - 1)
65 for _, s := range strs {
66 n += len(suffix) + len(s)
67 }
68
69 ret := make([]byte, 0, n)
70 for i, s := range strs {
71 if i != 0 {
72 ret = append(ret, separator...)
73 }
74 ret = append(ret, s...)
75 ret = append(ret, suffix...)
76 }
77 return string(ret)
78}
79
55func sortedKeys(m map[string][]string) []string { 80func sortedKeys(m map[string][]string) []string {
56 s := make([]string, 0, len(m)) 81 s := make([]string, 0, len(m))
57 for k := range m { 82 for k := range m {
diff --git a/android/variable.go b/android/variable.go
index c5006716..ff3ebaf0 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -279,6 +279,8 @@ type productVariables struct {
279 BoardPlatPrivateSepolicyDirs []string `json:",omitempty"` 279 BoardPlatPrivateSepolicyDirs []string `json:",omitempty"`
280 BoardSepolicyM4Defs []string `json:",omitempty"` 280 BoardSepolicyM4Defs []string `json:",omitempty"`
281 281
282 BoardVndkRuntimeDisable *bool `json:",omitempty"`
283
282 VendorVars map[string]map[string]string `json:",omitempty"` 284 VendorVars map[string]map[string]string `json:",omitempty"`
283 285
284 Ndk_abis *bool `json:",omitempty"` 286 Ndk_abis *bool `json:",omitempty"`
diff --git a/cc/cc.go b/cc/cc.go
index eaf41d88..a3b9a92d 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -1011,7 +1011,7 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
1011 } 1011 }
1012 } 1012 }
1013 1013
1014 if c.installer != nil && !c.Properties.PreventInstall && c.IsForPlatform() && c.outputFile.Valid() { 1014 if c.installable() {
1015 c.installer.install(ctx, c.outputFile.Path()) 1015 c.installer.install(ctx, c.outputFile.Path())
1016 if ctx.Failed() { 1016 if ctx.Failed() {
1017 return 1017 return
@@ -1968,6 +1968,10 @@ func (c *Module) IsInstallableToApex() bool {
1968 return false 1968 return false
1969} 1969}
1970 1970
1971func (c *Module) installable() bool {
1972 return c.installer != nil && !c.Properties.PreventInstall && c.IsForPlatform() && c.outputFile.Valid()
1973}
1974
1971func (c *Module) imageVariation() string { 1975func (c *Module) imageVariation() string {
1972 variation := "core" 1976 variation := "core"
1973 if c.useVndk() { 1977 if c.useVndk() {
diff --git a/cc/cc_test.go b/cc/cc_test.go
index f3d5e60d..36d8aa41 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -20,6 +20,7 @@ import (
20 "fmt" 20 "fmt"
21 "io/ioutil" 21 "io/ioutil"
22 "os" 22 "os"
23 "path/filepath"
23 "reflect" 24 "reflect"
24 "sort" 25 "sort"
25 "strings" 26 "strings"
@@ -75,6 +76,7 @@ func createTestContext(t *testing.T, config android.Config, bp string, os androi
75 ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) { 76 ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
76 ctx.TopDown("double_loadable", checkDoubleLoadableLibraries).Parallel() 77 ctx.TopDown("double_loadable", checkDoubleLoadableLibraries).Parallel()
77 }) 78 })
79 ctx.RegisterSingletonType("vndk-snapshot", android.SingletonFactoryAdaptor(VndkSnapshotSingleton))
78 ctx.Register() 80 ctx.Register()
79 81
80 // add some modules that are required by the compiler and/or linker 82 // add some modules that are required by the compiler and/or linker
@@ -286,8 +288,28 @@ func checkVndkModule(t *testing.T, ctx *android.TestContext, name, subDir string
286 } 288 }
287} 289}
288 290
291func checkVndkSnapshot(t *testing.T, ctx *android.TestContext, name, subDir, variant string) {
292 vndkSnapshot := ctx.SingletonForTests("vndk-snapshot")
293
294 snapshotPath := filepath.Join(subDir, name+".so")
295 mod := ctx.ModuleForTests(name, variant).Module().(*Module)
296 if !mod.outputFile.Valid() {
297 t.Errorf("%q must have output\n", name)
298 return
299 }
300
301 out := vndkSnapshot.Output(snapshotPath)
302 if out.Input != mod.outputFile.Path() {
303 t.Errorf("The input of VNDK snapshot must be %q, but %q", out.Input.String(), mod.outputFile.String())
304 }
305}
306
289func TestVndk(t *testing.T) { 307func TestVndk(t *testing.T) {
290 ctx := testCc(t, ` 308 config := android.TestArchConfig(buildDir, nil)
309 config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
310 config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
311
312 ctx := testCcWithConfig(t, `
291 cc_library { 313 cc_library {
292 name: "libvndk", 314 name: "libvndk",
293 vendor_available: true, 315 vendor_available: true,
@@ -325,12 +347,35 @@ func TestVndk(t *testing.T) {
325 }, 347 },
326 nocrt: true, 348 nocrt: true,
327 } 349 }
328 `) 350 `, config)
329 351
330 checkVndkModule(t, ctx, "libvndk", "vndk-VER", false, "") 352 checkVndkModule(t, ctx, "libvndk", "vndk-VER", false, "")
331 checkVndkModule(t, ctx, "libvndk_private", "vndk-VER", false, "") 353 checkVndkModule(t, ctx, "libvndk_private", "vndk-VER", false, "")
332 checkVndkModule(t, ctx, "libvndk_sp", "vndk-sp-VER", true, "") 354 checkVndkModule(t, ctx, "libvndk_sp", "vndk-sp-VER", true, "")
333 checkVndkModule(t, ctx, "libvndk_sp_private", "vndk-sp-VER", true, "") 355 checkVndkModule(t, ctx, "libvndk_sp_private", "vndk-sp-VER", true, "")
356
357 // Check VNDK snapshot output.
358
359 snapshotDir := "vndk-snapshot"
360 snapshotVariantPath := filepath.Join(buildDir, snapshotDir, "arm64")
361
362 vndkLibPath := filepath.Join(snapshotVariantPath, fmt.Sprintf("arch-%s-%s",
363 "arm64", "armv8-a"))
364 vndkLib2ndPath := filepath.Join(snapshotVariantPath, fmt.Sprintf("arch-%s-%s",
365 "arm", "armv7-a-neon"))
366
367 vndkCoreLibPath := filepath.Join(vndkLibPath, "shared", "vndk-core")
368 vndkSpLibPath := filepath.Join(vndkLibPath, "shared", "vndk-sp")
369 vndkCoreLib2ndPath := filepath.Join(vndkLib2ndPath, "shared", "vndk-core")
370 vndkSpLib2ndPath := filepath.Join(vndkLib2ndPath, "shared", "vndk-sp")
371
372 variant := "android_arm64_armv8-a_vendor_shared"
373 variant2nd := "android_arm_armv7-a-neon_vendor_shared"
374
375 checkVndkSnapshot(t, ctx, "libvndk", vndkCoreLibPath, variant)
376 checkVndkSnapshot(t, ctx, "libvndk", vndkCoreLib2ndPath, variant2nd)
377 checkVndkSnapshot(t, ctx, "libvndk_sp", vndkSpLibPath, variant)
378 checkVndkSnapshot(t, ctx, "libvndk_sp", vndkSpLib2ndPath, variant2nd)
334} 379}
335 380
336func TestVndkDepError(t *testing.T) { 381func TestVndkDepError(t *testing.T) {
diff --git a/cc/vndk.go b/cc/vndk.go
index 7859fa21..a1d67af1 100644
--- a/cc/vndk.go
+++ b/cc/vndk.go
@@ -16,6 +16,8 @@ package cc
16 16
17import ( 17import (
18 "errors" 18 "errors"
19 "fmt"
20 "path/filepath"
19 "sort" 21 "sort"
20 "strings" 22 "strings"
21 "sync" 23 "sync"
@@ -197,9 +199,20 @@ var (
197 llndkLibrariesKey = android.NewOnceKey("llndkLibrarires") 199 llndkLibrariesKey = android.NewOnceKey("llndkLibrarires")
198 vndkPrivateLibrariesKey = android.NewOnceKey("vndkPrivateLibrarires") 200 vndkPrivateLibrariesKey = android.NewOnceKey("vndkPrivateLibrarires")
199 vndkUsingCoreVariantLibrariesKey = android.NewOnceKey("vndkUsingCoreVariantLibrarires") 201 vndkUsingCoreVariantLibrariesKey = android.NewOnceKey("vndkUsingCoreVariantLibrarires")
202 modulePathsKey = android.NewOnceKey("modulePaths")
203 vndkSnapshotOutputsKey = android.NewOnceKey("vndkSnapshotOutputs")
200 vndkLibrariesLock sync.Mutex 204 vndkLibrariesLock sync.Mutex
201) 205)
202 206
207type vndkSnapshotOutputPaths struct {
208 configs android.Paths
209 notices android.Paths
210 vndkCoreLibs android.Paths
211 vndkCoreLibs2nd android.Paths
212 vndkSpLibs android.Paths
213 vndkSpLibs2nd android.Paths
214}
215
203func vndkCoreLibraries(config android.Config) *[]string { 216func vndkCoreLibraries(config android.Config) *[]string {
204 return config.Once(vndkCoreLibrariesKey, func() interface{} { 217 return config.Once(vndkCoreLibrariesKey, func() interface{} {
205 return &[]string{} 218 return &[]string{}
@@ -230,66 +243,296 @@ func vndkUsingCoreVariantLibraries(config android.Config) *[]string {
230 }).(*[]string) 243 }).(*[]string)
231} 244}
232 245
246func modulePaths(config android.Config) map[string]string {
247 return config.Once(modulePathsKey, func() interface{} {
248 return make(map[string]string)
249 }).(map[string]string)
250}
251
252func vndkSnapshotOutputs(config android.Config) *vndkSnapshotOutputPaths {
253 return config.Once(vndkSnapshotOutputsKey, func() interface{} {
254 return &vndkSnapshotOutputPaths{}
255 }).(*vndkSnapshotOutputPaths)
256}
257
258func processLlndkLibrary(mctx android.BottomUpMutatorContext, m *Module) {
259 lib := m.linker.(*llndkStubDecorator)
260 name := strings.TrimSuffix(m.Name(), llndkLibrarySuffix)
261
262 vndkLibrariesLock.Lock()
263 defer vndkLibrariesLock.Unlock()
264
265 llndkLibraries := llndkLibraries(mctx.Config())
266 if !inList(name, *llndkLibraries) {
267 *llndkLibraries = append(*llndkLibraries, name)
268 sort.Strings(*llndkLibraries)
269 }
270 if !Bool(lib.Properties.Vendor_available) {
271 vndkPrivateLibraries := vndkPrivateLibraries(mctx.Config())
272 if !inList(name, *vndkPrivateLibraries) {
273 *vndkPrivateLibraries = append(*vndkPrivateLibraries, name)
274 sort.Strings(*vndkPrivateLibraries)
275 }
276 }
277}
278
279func processVndkLibrary(mctx android.BottomUpMutatorContext, m *Module) {
280 name := strings.TrimPrefix(m.Name(), "prebuilt_")
281
282 vndkLibrariesLock.Lock()
283 defer vndkLibrariesLock.Unlock()
284
285 modulePaths := modulePaths(mctx.Config())
286 if mctx.DeviceConfig().VndkUseCoreVariant() && !inList(name, config.VndkMustUseVendorVariantList) {
287 vndkUsingCoreVariantLibraries := vndkUsingCoreVariantLibraries(mctx.Config())
288 if !inList(name, *vndkUsingCoreVariantLibraries) {
289 *vndkUsingCoreVariantLibraries = append(*vndkUsingCoreVariantLibraries, name)
290 sort.Strings(*vndkUsingCoreVariantLibraries)
291 }
292 }
293 if m.vndkdep.isVndkSp() {
294 vndkSpLibraries := vndkSpLibraries(mctx.Config())
295 if !inList(name, *vndkSpLibraries) {
296 *vndkSpLibraries = append(*vndkSpLibraries, name)
297 sort.Strings(*vndkSpLibraries)
298 modulePaths[name] = mctx.ModuleDir()
299 }
300 } else {
301 vndkCoreLibraries := vndkCoreLibraries(mctx.Config())
302 if !inList(name, *vndkCoreLibraries) {
303 *vndkCoreLibraries = append(*vndkCoreLibraries, name)
304 sort.Strings(*vndkCoreLibraries)
305 modulePaths[name] = mctx.ModuleDir()
306 }
307 }
308 if !Bool(m.VendorProperties.Vendor_available) {
309 vndkPrivateLibraries := vndkPrivateLibraries(mctx.Config())
310 if !inList(name, *vndkPrivateLibraries) {
311 *vndkPrivateLibraries = append(*vndkPrivateLibraries, name)
312 sort.Strings(*vndkPrivateLibraries)
313 }
314 }
315}
316
233// gather list of vndk-core, vndk-sp, and ll-ndk libs 317// gather list of vndk-core, vndk-sp, and ll-ndk libs
234func VndkMutator(mctx android.BottomUpMutatorContext) { 318func VndkMutator(mctx android.BottomUpMutatorContext) {
235 if m, ok := mctx.Module().(*Module); ok && m.Enabled() { 319 m, ok := mctx.Module().(*Module)
236 if lib, ok := m.linker.(*llndkStubDecorator); ok { 320 if !ok {
237 vndkLibrariesLock.Lock() 321 return
238 defer vndkLibrariesLock.Unlock() 322 }
239 323
240 llndkLibraries := llndkLibraries(mctx.Config()) 324 if !m.Enabled() {
241 vndkPrivateLibraries := vndkPrivateLibraries(mctx.Config()) 325 return
242 326 }
243 name := strings.TrimSuffix(m.Name(), llndkLibrarySuffix) 327
244 if !inList(name, *llndkLibraries) { 328 if _, ok := m.linker.(*llndkStubDecorator); ok {
245 *llndkLibraries = append(*llndkLibraries, name) 329 processLlndkLibrary(mctx, m)
246 sort.Strings(*llndkLibraries) 330 return
331 }
332
333 lib, is_lib := m.linker.(*libraryDecorator)
334 prebuilt_lib, is_prebuilt_lib := m.linker.(*prebuiltLibraryLinker)
335
336 if (is_lib && lib.shared()) || (is_prebuilt_lib && prebuilt_lib.shared()) {
337 if m.vndkdep.isVndk() && !m.vndkdep.isVndkExt() {
338 processVndkLibrary(mctx, m)
339 return
340 }
341 }
342}
343
344func init() {
345 android.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton)
346 android.RegisterMakeVarsProvider(pctx, func(ctx android.MakeVarsContext) {
347 outputs := vndkSnapshotOutputs(ctx.Config())
348
349 ctx.Strict("SOONG_VNDK_SNAPSHOT_CONFIGS", strings.Join(outputs.configs.Strings(), " "))
350 ctx.Strict("SOONG_VNDK_SNAPSHOT_NOTICES", strings.Join(outputs.notices.Strings(), " "))
351 ctx.Strict("SOONG_VNDK_SNAPSHOT_CORE_LIBS", strings.Join(outputs.vndkCoreLibs.Strings(), " "))
352 ctx.Strict("SOONG_VNDK_SNAPSHOT_SP_LIBS", strings.Join(outputs.vndkSpLibs.Strings(), " "))
353 ctx.Strict("SOONG_VNDK_SNAPSHOT_CORE_LIBS_2ND", strings.Join(outputs.vndkCoreLibs2nd.Strings(), " "))
354 ctx.Strict("SOONG_VNDK_SNAPSHOT_SP_LIBS_2ND", strings.Join(outputs.vndkSpLibs2nd.Strings(), " "))
355 })
356}
357
358func VndkSnapshotSingleton() android.Singleton {
359 return &vndkSnapshotSingleton{}
360}
361
362type vndkSnapshotSingleton struct{}
363
364func installVndkSnapshotLib(ctx android.SingletonContext, name string, module *Module, dir string) android.Path {
365 if !module.outputFile.Valid() {
366 panic(fmt.Errorf("module %s has no outputFile\n", name))
367 }
368
369 out := android.PathForOutput(ctx, dir, name+".so")
370
371 ctx.Build(pctx, android.BuildParams{
372 Rule: android.Cp,
373 Input: module.outputFile.Path(),
374 Output: out,
375 Description: "vndk snapshot " + dir + "/" + name + ".so",
376 Args: map[string]string{
377 "cpFlags": "-f -L",
378 },
379 })
380
381 return out
382}
383
384func (c *vndkSnapshotSingleton) GenerateBuildActions(ctx android.SingletonContext) {
385 // BOARD_VNDK_VERSION must be set to 'current' in order to generate a VNDK snapshot.
386 if ctx.DeviceConfig().VndkVersion() != "current" {
387 return
388 }
389
390 if ctx.DeviceConfig().PlatformVndkVersion() == "" {
391 return
392 }
393
394 if ctx.DeviceConfig().BoardVndkRuntimeDisable() {
395 return
396 }
397
398 outputs := vndkSnapshotOutputs(ctx.Config())
399
400 snapshotDir := "vndk-snapshot"
401
402 var vndkLibPath, vndkLib2ndPath string
403
404 snapshotVariantPath := filepath.Join(snapshotDir, ctx.DeviceConfig().DeviceArch())
405 if ctx.DeviceConfig().BinderBitness() == "32" {
406 vndkLibPath = filepath.Join(snapshotVariantPath, "binder32", fmt.Sprintf(
407 "arch-%s-%s", ctx.DeviceConfig().DeviceArch(), ctx.DeviceConfig().DeviceArchVariant()))
408 vndkLib2ndPath = filepath.Join(snapshotVariantPath, "binder32", fmt.Sprintf(
409 "arch-%s-%s", ctx.DeviceConfig().DeviceSecondaryArch(), ctx.DeviceConfig().DeviceSecondaryArchVariant()))
410 } else {
411 vndkLibPath = filepath.Join(snapshotVariantPath, fmt.Sprintf(
412 "arch-%s-%s", ctx.DeviceConfig().DeviceArch(), ctx.DeviceConfig().DeviceArchVariant()))
413 vndkLib2ndPath = filepath.Join(snapshotVariantPath, fmt.Sprintf(
414 "arch-%s-%s", ctx.DeviceConfig().DeviceSecondaryArch(), ctx.DeviceConfig().DeviceSecondaryArchVariant()))
415 }
416
417 vndkCoreLibPath := filepath.Join(vndkLibPath, "shared", "vndk-core")
418 vndkSpLibPath := filepath.Join(vndkLibPath, "shared", "vndk-sp")
419 vndkCoreLib2ndPath := filepath.Join(vndkLib2ndPath, "shared", "vndk-core")
420 vndkSpLib2ndPath := filepath.Join(vndkLib2ndPath, "shared", "vndk-sp")
421 noticePath := filepath.Join(snapshotVariantPath, "NOTICE_FILES")
422 noticeBuilt := make(map[string]bool)
423
424 tryBuildNotice := func(m *Module) {
425 name := ctx.ModuleName(m)
426
427 if _, ok := noticeBuilt[name]; ok {
428 return
429 }
430
431 noticeBuilt[name] = true
432
433 if m.NoticeFile().Valid() {
434 out := android.PathForOutput(ctx, noticePath, name+".so.txt")
435 ctx.Build(pctx, android.BuildParams{
436 Rule: android.Cp,
437 Input: m.NoticeFile().Path(),
438 Output: out,
439 Description: "vndk snapshot notice " + name + ".so.txt",
440 Args: map[string]string{
441 "cpFlags": "-f -L",
442 },
443 })
444 outputs.notices = append(outputs.notices, out)
445 }
446 }
447
448 vndkCoreLibraries := vndkCoreLibraries(ctx.Config())
449 vndkSpLibraries := vndkSpLibraries(ctx.Config())
450 vndkPrivateLibraries := vndkPrivateLibraries(ctx.Config())
451
452 ctx.VisitAllModules(func(module android.Module) {
453 m, ok := module.(*Module)
454 if !ok || !m.Enabled() || !m.useVndk() || !m.installable() {
455 return
456 }
457
458 lib, is_lib := m.linker.(*libraryDecorator)
459 prebuilt_lib, is_prebuilt_lib := m.linker.(*prebuiltLibraryLinker)
460
461 if !(is_lib && lib.shared()) && !(is_prebuilt_lib && prebuilt_lib.shared()) {
462 return
463 }
464
465 is_2nd := m.Target().Arch.ArchType != ctx.Config().DevicePrimaryArchType()
466
467 name := ctx.ModuleName(module)
468
469 if inList(name, *vndkCoreLibraries) {
470 if is_2nd {
471 out := installVndkSnapshotLib(ctx, name, m, vndkCoreLib2ndPath)
472 outputs.vndkCoreLibs2nd = append(outputs.vndkCoreLibs2nd, out)
473 } else {
474 out := installVndkSnapshotLib(ctx, name, m, vndkCoreLibPath)
475 outputs.vndkCoreLibs = append(outputs.vndkCoreLibs, out)
247 } 476 }
248 if !Bool(lib.Properties.Vendor_available) { 477 tryBuildNotice(m)
249 if !inList(name, *vndkPrivateLibraries) { 478 } else if inList(name, *vndkSpLibraries) {
250 *vndkPrivateLibraries = append(*vndkPrivateLibraries, name) 479 if is_2nd {
251 sort.Strings(*vndkPrivateLibraries) 480 out := installVndkSnapshotLib(ctx, name, m, vndkSpLib2ndPath)
252 } 481 outputs.vndkSpLibs2nd = append(outputs.vndkSpLibs2nd, out)
482 } else {
483 out := installVndkSnapshotLib(ctx, name, m, vndkSpLibPath)
484 outputs.vndkSpLibs = append(outputs.vndkSpLibs, out)
253 } 485 }
486 tryBuildNotice(m)
487 }
488 })
489
490 configsPath := filepath.Join(snapshotVariantPath, "configs")
491 vndkCoreTxt := android.PathForOutput(ctx, configsPath, "vndkcore.libraries.txt")
492 vndkPrivateTxt := android.PathForOutput(ctx, configsPath, "vndkprivate.libraries.txt")
493 modulePathTxt := android.PathForOutput(ctx, configsPath, "module_paths.txt")
494
495 ctx.Build(pctx, android.BuildParams{
496 Rule: android.WriteFile,
497 Output: vndkCoreTxt,
498 Description: "vndk snapshot vndkcore.libraries.txt",
499 Args: map[string]string{
500 "content": android.JoinWithSuffix(*vndkCoreLibraries, ".so", "\\n"),
501 },
502 })
503 outputs.configs = append(outputs.configs, vndkCoreTxt)
504
505 ctx.Build(pctx, android.BuildParams{
506 Rule: android.WriteFile,
507 Output: vndkPrivateTxt,
508 Description: "vndk snapshot vndkprivate.libraries.txt",
509 Args: map[string]string{
510 "content": android.JoinWithSuffix(*vndkPrivateLibraries, ".so", "\\n"),
511 },
512 })
513 outputs.configs = append(outputs.configs, vndkPrivateTxt)
514
515 var modulePathTxtBuilder strings.Builder
516
517 first := true
518 for lib, dir := range modulePaths(ctx.Config()) {
519 if first {
520 first = false
254 } else { 521 } else {
255 lib, is_lib := m.linker.(*libraryDecorator) 522 modulePathTxtBuilder.WriteString("\\n")
256 prebuilt_lib, is_prebuilt_lib := m.linker.(*prebuiltLibraryLinker)
257 if (is_lib && lib.shared()) || (is_prebuilt_lib && prebuilt_lib.shared()) {
258 name := strings.TrimPrefix(m.Name(), "prebuilt_")
259 if m.vndkdep.isVndk() && !m.vndkdep.isVndkExt() {
260 vndkLibrariesLock.Lock()
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
268 if mctx.DeviceConfig().VndkUseCoreVariant() && !inList(name, config.VndkMustUseVendorVariantList) {
269 if !inList(name, *vndkUsingCoreVariantLibraries) {
270 *vndkUsingCoreVariantLibraries = append(*vndkUsingCoreVariantLibraries, name)
271 sort.Strings(*vndkUsingCoreVariantLibraries)
272 }
273 }
274 if m.vndkdep.isVndkSp() {
275 if !inList(name, *vndkSpLibraries) {
276 *vndkSpLibraries = append(*vndkSpLibraries, name)
277 sort.Strings(*vndkSpLibraries)
278 }
279 } else {
280 if !inList(name, *vndkCoreLibraries) {
281 *vndkCoreLibraries = append(*vndkCoreLibraries, name)
282 sort.Strings(*vndkCoreLibraries)
283 }
284 }
285 if !Bool(m.VendorProperties.Vendor_available) {
286 if !inList(name, *vndkPrivateLibraries) {
287 *vndkPrivateLibraries = append(*vndkPrivateLibraries, name)
288 sort.Strings(*vndkPrivateLibraries)
289 }
290 }
291 }
292 }
293 } 523 }
524 modulePathTxtBuilder.WriteString(lib)
525 modulePathTxtBuilder.WriteString(".so ")
526 modulePathTxtBuilder.WriteString(dir)
294 } 527 }
528
529 ctx.Build(pctx, android.BuildParams{
530 Rule: android.WriteFile,
531 Output: modulePathTxt,
532 Description: "vndk snapshot module_paths.txt",
533 Args: map[string]string{
534 "content": modulePathTxtBuilder.String(),
535 },
536 })
537 outputs.configs = append(outputs.configs, modulePathTxt)
295} 538}