blob: f9f376432b4992f84a5cfa1966b19ed962f13bf1 [file] [log] [blame]
Justin Yun8effde42017-06-23 19:24:43 +09001// Copyright 2017 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package cc
16
17import (
Martin Stjernholm257eb0c2018-10-15 13:05:27 +010018 "errors"
Inseob Kim1f086e22019-05-09 13:29:15 +090019 "fmt"
20 "path/filepath"
Colin Cross766efbc2017-08-17 14:55:15 -070021 "sort"
Jiyong Parkd5b18a52017-08-03 21:22:50 +090022 "strings"
23 "sync"
24
Justin Yun8effde42017-06-23 19:24:43 +090025 "android/soong/android"
Vic Yangefd249e2018-11-12 20:19:56 -080026 "android/soong/cc/config"
Justin Yun8effde42017-06-23 19:24:43 +090027)
28
29type VndkProperties struct {
30 Vndk struct {
31 // declared as a VNDK or VNDK-SP module. The vendor variant
32 // will be installed in /system instead of /vendor partition.
33 //
Jiyong Park82e2bf32017-08-16 14:05:54 +090034 // `vendor_vailable` must be explicitly set to either true or
35 // false together with `vndk: {enabled: true}`.
Justin Yun8effde42017-06-23 19:24:43 +090036 Enabled *bool
37
38 // declared as a VNDK-SP module, which is a subset of VNDK.
39 //
40 // `vndk: { enabled: true }` must set together.
41 //
42 // All these modules are allowed to link to VNDK-SP or LL-NDK
43 // modules only. Other dependency will cause link-type errors.
44 //
45 // If `support_system_process` is not set or set to false,
46 // the module is VNDK-core and can link to other VNDK-core,
47 // VNDK-SP or LL-NDK modules only.
48 Support_system_process *bool
Logan Chienf3511742017-10-31 18:04:35 +080049
50 // Extending another module
51 Extends *string
Jooyung Han76106d92019-05-20 18:49:10 +090052
53 // for vndk_prebuilt_shared, this is set by "version" property.
54 // Otherwise, this is set as PLATFORM_VNDK_VERSION.
55 Version string `blueprint:"mutated"`
Justin Yun8effde42017-06-23 19:24:43 +090056 }
57}
58
59type vndkdep struct {
60 Properties VndkProperties
61}
62
63func (vndk *vndkdep) props() []interface{} {
64 return []interface{}{&vndk.Properties}
65}
66
67func (vndk *vndkdep) begin(ctx BaseModuleContext) {}
68
69func (vndk *vndkdep) deps(ctx BaseModuleContext, deps Deps) Deps {
70 return deps
71}
72
73func (vndk *vndkdep) isVndk() bool {
74 return Bool(vndk.Properties.Vndk.Enabled)
75}
76
77func (vndk *vndkdep) isVndkSp() bool {
78 return Bool(vndk.Properties.Vndk.Support_system_process)
79}
80
Logan Chienf3511742017-10-31 18:04:35 +080081func (vndk *vndkdep) isVndkExt() bool {
82 return vndk.Properties.Vndk.Extends != nil
83}
84
85func (vndk *vndkdep) getVndkExtendsModuleName() string {
86 return String(vndk.Properties.Vndk.Extends)
87}
88
Justin Yun8effde42017-06-23 19:24:43 +090089func (vndk *vndkdep) typeName() string {
90 if !vndk.isVndk() {
91 return "native:vendor"
92 }
Logan Chienf3511742017-10-31 18:04:35 +080093 if !vndk.isVndkExt() {
94 if !vndk.isVndkSp() {
95 return "native:vendor:vndk"
96 }
97 return "native:vendor:vndksp"
Justin Yun8effde42017-06-23 19:24:43 +090098 }
Logan Chienf3511742017-10-31 18:04:35 +080099 if !vndk.isVndkSp() {
100 return "native:vendor:vndkext"
101 }
102 return "native:vendor:vndkspext"
Justin Yun8effde42017-06-23 19:24:43 +0900103}
104
Logan Chienf3511742017-10-31 18:04:35 +0800105func (vndk *vndkdep) vndkCheckLinkType(ctx android.ModuleContext, to *Module, tag dependencyTag) {
Justin Yun8effde42017-06-23 19:24:43 +0900106 if to.linker == nil {
107 return
108 }
Jiyong Park82e2bf32017-08-16 14:05:54 +0900109 if !vndk.isVndk() {
110 // Non-VNDK modules (those installed to /vendor) can't depend on modules marked with
111 // vendor_available: false.
112 violation := false
Nan Zhang0007d812017-11-07 10:57:05 -0800113 if lib, ok := to.linker.(*llndkStubDecorator); ok && !Bool(lib.Properties.Vendor_available) {
Jiyong Park82e2bf32017-08-16 14:05:54 +0900114 violation = true
115 } else {
116 if _, ok := to.linker.(libraryInterface); ok && to.VendorProperties.Vendor_available != nil && !Bool(to.VendorProperties.Vendor_available) {
117 // Vendor_available == nil && !Bool(Vendor_available) should be okay since
118 // it means a vendor-only library which is a valid dependency for non-VNDK
119 // modules.
120 violation = true
121 }
122 }
123 if violation {
124 ctx.ModuleErrorf("Vendor module that is not VNDK should not link to %q which is marked as `vendor_available: false`", to.Name())
125 }
126 }
Justin Yun8effde42017-06-23 19:24:43 +0900127 if lib, ok := to.linker.(*libraryDecorator); !ok || !lib.shared() {
128 // Check only shared libraries.
129 // Other (static and LL-NDK) libraries are allowed to link.
130 return
131 }
132 if !to.Properties.UseVndk {
133 ctx.ModuleErrorf("(%s) should not link to %q which is not a vendor-available library",
134 vndk.typeName(), to.Name())
135 return
136 }
Logan Chienf3511742017-10-31 18:04:35 +0800137 if tag == vndkExtDepTag {
138 // Ensure `extends: "name"` property refers a vndk module that has vendor_available
139 // and has identical vndk properties.
140 if to.vndkdep == nil || !to.vndkdep.isVndk() {
141 ctx.ModuleErrorf("`extends` refers a non-vndk module %q", to.Name())
142 return
143 }
144 if vndk.isVndkSp() != to.vndkdep.isVndkSp() {
145 ctx.ModuleErrorf(
146 "`extends` refers a module %q with mismatched support_system_process",
147 to.Name())
148 return
149 }
150 if !Bool(to.VendorProperties.Vendor_available) {
151 ctx.ModuleErrorf(
152 "`extends` refers module %q which does not have `vendor_available: true`",
153 to.Name())
154 return
155 }
156 }
Justin Yun8effde42017-06-23 19:24:43 +0900157 if to.vndkdep == nil {
158 return
159 }
Logan Chienf3511742017-10-31 18:04:35 +0800160
Logan Chiend3c59a22018-03-29 14:08:15 +0800161 // Check the dependencies of VNDK shared libraries.
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100162 if err := vndkIsVndkDepAllowed(vndk, to.vndkdep); err != nil {
163 ctx.ModuleErrorf("(%s) should not link to %q (%s): %v",
164 vndk.typeName(), to.Name(), to.vndkdep.typeName(), err)
Logan Chienf3511742017-10-31 18:04:35 +0800165 return
166 }
Logan Chiend3c59a22018-03-29 14:08:15 +0800167}
Logan Chienf3511742017-10-31 18:04:35 +0800168
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100169func vndkIsVndkDepAllowed(from *vndkdep, to *vndkdep) error {
Logan Chiend3c59a22018-03-29 14:08:15 +0800170 // Check the dependencies of VNDK, VNDK-Ext, VNDK-SP, VNDK-SP-Ext and vendor modules.
171 if from.isVndkExt() {
172 if from.isVndkSp() {
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100173 if to.isVndk() && !to.isVndkSp() {
174 return errors.New("VNDK-SP extensions must not depend on VNDK or VNDK extensions")
175 }
176 return nil
Logan Chiend3c59a22018-03-29 14:08:15 +0800177 }
178 // VNDK-Ext may depend on VNDK, VNDK-Ext, VNDK-SP, VNDK-SP-Ext, or vendor libs.
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100179 return nil
Justin Yun8effde42017-06-23 19:24:43 +0900180 }
Logan Chiend3c59a22018-03-29 14:08:15 +0800181 if from.isVndk() {
182 if to.isVndkExt() {
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100183 return errors.New("VNDK-core and VNDK-SP must not depend on VNDK extensions")
Logan Chiend3c59a22018-03-29 14:08:15 +0800184 }
185 if from.isVndkSp() {
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100186 if !to.isVndkSp() {
187 return errors.New("VNDK-SP must only depend on VNDK-SP")
188 }
189 return nil
Logan Chiend3c59a22018-03-29 14:08:15 +0800190 }
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100191 if !to.isVndk() {
192 return errors.New("VNDK-core must only depend on VNDK-core or VNDK-SP")
193 }
194 return nil
Logan Chiend3c59a22018-03-29 14:08:15 +0800195 }
196 // Vendor modules may depend on VNDK, VNDK-Ext, VNDK-SP, VNDK-SP-Ext, or vendor libs.
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100197 return nil
Justin Yun8effde42017-06-23 19:24:43 +0900198}
Jiyong Parkd5b18a52017-08-03 21:22:50 +0900199
200var (
Inseob Kim9516ee92019-05-09 10:56:13 +0900201 vndkCoreLibrariesKey = android.NewOnceKey("vndkCoreLibrarires")
202 vndkSpLibrariesKey = android.NewOnceKey("vndkSpLibrarires")
203 llndkLibrariesKey = android.NewOnceKey("llndkLibrarires")
204 vndkPrivateLibrariesKey = android.NewOnceKey("vndkPrivateLibrarires")
205 vndkUsingCoreVariantLibrariesKey = android.NewOnceKey("vndkUsingCoreVariantLibrarires")
Inseob Kim1f086e22019-05-09 13:29:15 +0900206 modulePathsKey = android.NewOnceKey("modulePaths")
207 vndkSnapshotOutputsKey = android.NewOnceKey("vndkSnapshotOutputs")
Inseob Kim9516ee92019-05-09 10:56:13 +0900208 vndkLibrariesLock sync.Mutex
Jiyong Parkd5b18a52017-08-03 21:22:50 +0900209)
210
Inseob Kim1f086e22019-05-09 13:29:15 +0900211type vndkSnapshotOutputPaths struct {
212 configs android.Paths
213 notices android.Paths
214 vndkCoreLibs android.Paths
215 vndkCoreLibs2nd android.Paths
216 vndkSpLibs android.Paths
217 vndkSpLibs2nd android.Paths
218}
219
Inseob Kim9516ee92019-05-09 10:56:13 +0900220func vndkCoreLibraries(config android.Config) *[]string {
221 return config.Once(vndkCoreLibrariesKey, func() interface{} {
222 return &[]string{}
223 }).(*[]string)
224}
225
226func vndkSpLibraries(config android.Config) *[]string {
227 return config.Once(vndkSpLibrariesKey, func() interface{} {
228 return &[]string{}
229 }).(*[]string)
230}
231
232func llndkLibraries(config android.Config) *[]string {
233 return config.Once(llndkLibrariesKey, func() interface{} {
234 return &[]string{}
235 }).(*[]string)
236}
237
238func vndkPrivateLibraries(config android.Config) *[]string {
239 return config.Once(vndkPrivateLibrariesKey, func() interface{} {
240 return &[]string{}
241 }).(*[]string)
242}
243
244func vndkUsingCoreVariantLibraries(config android.Config) *[]string {
245 return config.Once(vndkUsingCoreVariantLibrariesKey, func() interface{} {
246 return &[]string{}
247 }).(*[]string)
248}
249
Inseob Kim1f086e22019-05-09 13:29:15 +0900250func modulePaths(config android.Config) map[string]string {
251 return config.Once(modulePathsKey, func() interface{} {
252 return make(map[string]string)
253 }).(map[string]string)
254}
Inseob Kim9516ee92019-05-09 10:56:13 +0900255
Inseob Kim1f086e22019-05-09 13:29:15 +0900256func vndkSnapshotOutputs(config android.Config) *vndkSnapshotOutputPaths {
257 return config.Once(vndkSnapshotOutputsKey, func() interface{} {
258 return &vndkSnapshotOutputPaths{}
259 }).(*vndkSnapshotOutputPaths)
260}
Inseob Kim9516ee92019-05-09 10:56:13 +0900261
Inseob Kim1f086e22019-05-09 13:29:15 +0900262func processLlndkLibrary(mctx android.BottomUpMutatorContext, m *Module) {
263 lib := m.linker.(*llndkStubDecorator)
264 name := strings.TrimSuffix(m.Name(), llndkLibrarySuffix)
Inseob Kim9516ee92019-05-09 10:56:13 +0900265
Inseob Kim1f086e22019-05-09 13:29:15 +0900266 vndkLibrariesLock.Lock()
267 defer vndkLibrariesLock.Unlock()
Inseob Kim9516ee92019-05-09 10:56:13 +0900268
Inseob Kim1f086e22019-05-09 13:29:15 +0900269 llndkLibraries := llndkLibraries(mctx.Config())
270 if !inList(name, *llndkLibraries) {
271 *llndkLibraries = append(*llndkLibraries, name)
272 sort.Strings(*llndkLibraries)
273 }
274 if !Bool(lib.Properties.Vendor_available) {
275 vndkPrivateLibraries := vndkPrivateLibraries(mctx.Config())
276 if !inList(name, *vndkPrivateLibraries) {
277 *vndkPrivateLibraries = append(*vndkPrivateLibraries, name)
278 sort.Strings(*vndkPrivateLibraries)
Jiyong Parkd5b18a52017-08-03 21:22:50 +0900279 }
280 }
281}
Inseob Kim1f086e22019-05-09 13:29:15 +0900282
283func processVndkLibrary(mctx android.BottomUpMutatorContext, m *Module) {
284 name := strings.TrimPrefix(m.Name(), "prebuilt_")
285
286 vndkLibrariesLock.Lock()
287 defer vndkLibrariesLock.Unlock()
288
289 modulePaths := modulePaths(mctx.Config())
290 if mctx.DeviceConfig().VndkUseCoreVariant() && !inList(name, config.VndkMustUseVendorVariantList) {
291 vndkUsingCoreVariantLibraries := vndkUsingCoreVariantLibraries(mctx.Config())
292 if !inList(name, *vndkUsingCoreVariantLibraries) {
293 *vndkUsingCoreVariantLibraries = append(*vndkUsingCoreVariantLibraries, name)
294 sort.Strings(*vndkUsingCoreVariantLibraries)
295 }
296 }
297 if m.vndkdep.isVndkSp() {
298 vndkSpLibraries := vndkSpLibraries(mctx.Config())
299 if !inList(name, *vndkSpLibraries) {
300 *vndkSpLibraries = append(*vndkSpLibraries, name)
301 sort.Strings(*vndkSpLibraries)
302 modulePaths[name] = mctx.ModuleDir()
303 }
304 } else {
305 vndkCoreLibraries := vndkCoreLibraries(mctx.Config())
306 if !inList(name, *vndkCoreLibraries) {
307 *vndkCoreLibraries = append(*vndkCoreLibraries, name)
308 sort.Strings(*vndkCoreLibraries)
309 modulePaths[name] = mctx.ModuleDir()
310 }
311 }
312 if !Bool(m.VendorProperties.Vendor_available) {
313 vndkPrivateLibraries := vndkPrivateLibraries(mctx.Config())
314 if !inList(name, *vndkPrivateLibraries) {
315 *vndkPrivateLibraries = append(*vndkPrivateLibraries, name)
316 sort.Strings(*vndkPrivateLibraries)
317 }
318 }
319}
320
321// gather list of vndk-core, vndk-sp, and ll-ndk libs
322func VndkMutator(mctx android.BottomUpMutatorContext) {
323 m, ok := mctx.Module().(*Module)
324 if !ok {
325 return
326 }
327
328 if !m.Enabled() {
329 return
330 }
331
Jooyung Han76106d92019-05-20 18:49:10 +0900332 if m.isVndk() {
333 if lib, ok := m.linker.(*vndkPrebuiltLibraryDecorator); ok {
334 m.vndkdep.Properties.Vndk.Version = lib.version()
335 } else {
336 m.vndkdep.Properties.Vndk.Version = mctx.DeviceConfig().PlatformVndkVersion()
337 }
338 }
339
Inseob Kim1f086e22019-05-09 13:29:15 +0900340 if _, ok := m.linker.(*llndkStubDecorator); ok {
341 processLlndkLibrary(mctx, m)
342 return
343 }
344
345 lib, is_lib := m.linker.(*libraryDecorator)
346 prebuilt_lib, is_prebuilt_lib := m.linker.(*prebuiltLibraryLinker)
347
348 if (is_lib && lib.shared()) || (is_prebuilt_lib && prebuilt_lib.shared()) {
349 if m.vndkdep.isVndk() && !m.vndkdep.isVndkExt() {
350 processVndkLibrary(mctx, m)
351 return
352 }
353 }
354}
355
356func init() {
357 android.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton)
358 android.RegisterMakeVarsProvider(pctx, func(ctx android.MakeVarsContext) {
359 outputs := vndkSnapshotOutputs(ctx.Config())
360
361 ctx.Strict("SOONG_VNDK_SNAPSHOT_CONFIGS", strings.Join(outputs.configs.Strings(), " "))
362 ctx.Strict("SOONG_VNDK_SNAPSHOT_NOTICES", strings.Join(outputs.notices.Strings(), " "))
363 ctx.Strict("SOONG_VNDK_SNAPSHOT_CORE_LIBS", strings.Join(outputs.vndkCoreLibs.Strings(), " "))
364 ctx.Strict("SOONG_VNDK_SNAPSHOT_SP_LIBS", strings.Join(outputs.vndkSpLibs.Strings(), " "))
365 ctx.Strict("SOONG_VNDK_SNAPSHOT_CORE_LIBS_2ND", strings.Join(outputs.vndkCoreLibs2nd.Strings(), " "))
366 ctx.Strict("SOONG_VNDK_SNAPSHOT_SP_LIBS_2ND", strings.Join(outputs.vndkSpLibs2nd.Strings(), " "))
367 })
368}
369
370func VndkSnapshotSingleton() android.Singleton {
371 return &vndkSnapshotSingleton{}
372}
373
374type vndkSnapshotSingleton struct{}
375
376func installVndkSnapshotLib(ctx android.SingletonContext, name string, module *Module, dir string) android.Path {
377 if !module.outputFile.Valid() {
378 panic(fmt.Errorf("module %s has no outputFile\n", name))
379 }
380
381 out := android.PathForOutput(ctx, dir, name+".so")
382
383 ctx.Build(pctx, android.BuildParams{
384 Rule: android.Cp,
385 Input: module.outputFile.Path(),
386 Output: out,
387 Description: "vndk snapshot " + dir + "/" + name + ".so",
388 Args: map[string]string{
389 "cpFlags": "-f -L",
390 },
391 })
392
393 return out
394}
395
396func (c *vndkSnapshotSingleton) GenerateBuildActions(ctx android.SingletonContext) {
397 // BOARD_VNDK_VERSION must be set to 'current' in order to generate a VNDK snapshot.
398 if ctx.DeviceConfig().VndkVersion() != "current" {
399 return
400 }
401
402 if ctx.DeviceConfig().PlatformVndkVersion() == "" {
403 return
404 }
405
406 if ctx.DeviceConfig().BoardVndkRuntimeDisable() {
407 return
408 }
409
410 outputs := vndkSnapshotOutputs(ctx.Config())
411
412 snapshotDir := "vndk-snapshot"
413
414 var vndkLibPath, vndkLib2ndPath string
415
416 snapshotVariantPath := filepath.Join(snapshotDir, ctx.DeviceConfig().DeviceArch())
417 if ctx.DeviceConfig().BinderBitness() == "32" {
418 vndkLibPath = filepath.Join(snapshotVariantPath, "binder32", fmt.Sprintf(
419 "arch-%s-%s", ctx.DeviceConfig().DeviceArch(), ctx.DeviceConfig().DeviceArchVariant()))
420 vndkLib2ndPath = filepath.Join(snapshotVariantPath, "binder32", fmt.Sprintf(
421 "arch-%s-%s", ctx.DeviceConfig().DeviceSecondaryArch(), ctx.DeviceConfig().DeviceSecondaryArchVariant()))
422 } else {
423 vndkLibPath = filepath.Join(snapshotVariantPath, fmt.Sprintf(
424 "arch-%s-%s", ctx.DeviceConfig().DeviceArch(), ctx.DeviceConfig().DeviceArchVariant()))
425 vndkLib2ndPath = filepath.Join(snapshotVariantPath, fmt.Sprintf(
426 "arch-%s-%s", ctx.DeviceConfig().DeviceSecondaryArch(), ctx.DeviceConfig().DeviceSecondaryArchVariant()))
427 }
428
429 vndkCoreLibPath := filepath.Join(vndkLibPath, "shared", "vndk-core")
430 vndkSpLibPath := filepath.Join(vndkLibPath, "shared", "vndk-sp")
431 vndkCoreLib2ndPath := filepath.Join(vndkLib2ndPath, "shared", "vndk-core")
432 vndkSpLib2ndPath := filepath.Join(vndkLib2ndPath, "shared", "vndk-sp")
433 noticePath := filepath.Join(snapshotVariantPath, "NOTICE_FILES")
434 noticeBuilt := make(map[string]bool)
435
436 tryBuildNotice := func(m *Module) {
437 name := ctx.ModuleName(m)
438
439 if _, ok := noticeBuilt[name]; ok {
440 return
441 }
442
443 noticeBuilt[name] = true
444
445 if m.NoticeFile().Valid() {
446 out := android.PathForOutput(ctx, noticePath, name+".so.txt")
447 ctx.Build(pctx, android.BuildParams{
448 Rule: android.Cp,
449 Input: m.NoticeFile().Path(),
450 Output: out,
451 Description: "vndk snapshot notice " + name + ".so.txt",
452 Args: map[string]string{
453 "cpFlags": "-f -L",
454 },
455 })
456 outputs.notices = append(outputs.notices, out)
457 }
458 }
459
460 vndkCoreLibraries := vndkCoreLibraries(ctx.Config())
461 vndkSpLibraries := vndkSpLibraries(ctx.Config())
462 vndkPrivateLibraries := vndkPrivateLibraries(ctx.Config())
463
464 ctx.VisitAllModules(func(module android.Module) {
465 m, ok := module.(*Module)
466 if !ok || !m.Enabled() || !m.useVndk() || !m.installable() {
467 return
468 }
469
dimitry51ea18a2019-05-20 10:39:52 +0200470 if m.Target().NativeBridge == android.NativeBridgeEnabled {
471 return
472 }
473
Inseob Kim1f086e22019-05-09 13:29:15 +0900474 lib, is_lib := m.linker.(*libraryDecorator)
475 prebuilt_lib, is_prebuilt_lib := m.linker.(*prebuiltLibraryLinker)
476
477 if !(is_lib && lib.shared()) && !(is_prebuilt_lib && prebuilt_lib.shared()) {
478 return
479 }
480
481 is_2nd := m.Target().Arch.ArchType != ctx.Config().DevicePrimaryArchType()
482
483 name := ctx.ModuleName(module)
484
485 if inList(name, *vndkCoreLibraries) {
486 if is_2nd {
487 out := installVndkSnapshotLib(ctx, name, m, vndkCoreLib2ndPath)
488 outputs.vndkCoreLibs2nd = append(outputs.vndkCoreLibs2nd, out)
489 } else {
490 out := installVndkSnapshotLib(ctx, name, m, vndkCoreLibPath)
491 outputs.vndkCoreLibs = append(outputs.vndkCoreLibs, out)
492 }
493 tryBuildNotice(m)
494 } else if inList(name, *vndkSpLibraries) {
495 if is_2nd {
496 out := installVndkSnapshotLib(ctx, name, m, vndkSpLib2ndPath)
497 outputs.vndkSpLibs2nd = append(outputs.vndkSpLibs2nd, out)
498 } else {
499 out := installVndkSnapshotLib(ctx, name, m, vndkSpLibPath)
500 outputs.vndkSpLibs = append(outputs.vndkSpLibs, out)
501 }
502 tryBuildNotice(m)
503 }
504 })
505
506 configsPath := filepath.Join(snapshotVariantPath, "configs")
507 vndkCoreTxt := android.PathForOutput(ctx, configsPath, "vndkcore.libraries.txt")
508 vndkPrivateTxt := android.PathForOutput(ctx, configsPath, "vndkprivate.libraries.txt")
509 modulePathTxt := android.PathForOutput(ctx, configsPath, "module_paths.txt")
510
511 ctx.Build(pctx, android.BuildParams{
512 Rule: android.WriteFile,
513 Output: vndkCoreTxt,
514 Description: "vndk snapshot vndkcore.libraries.txt",
515 Args: map[string]string{
516 "content": android.JoinWithSuffix(*vndkCoreLibraries, ".so", "\\n"),
517 },
518 })
519 outputs.configs = append(outputs.configs, vndkCoreTxt)
520
521 ctx.Build(pctx, android.BuildParams{
522 Rule: android.WriteFile,
523 Output: vndkPrivateTxt,
524 Description: "vndk snapshot vndkprivate.libraries.txt",
525 Args: map[string]string{
526 "content": android.JoinWithSuffix(*vndkPrivateLibraries, ".so", "\\n"),
527 },
528 })
529 outputs.configs = append(outputs.configs, vndkPrivateTxt)
530
531 var modulePathTxtBuilder strings.Builder
532
Colin Cross4c2c46f2019-06-03 15:26:05 -0700533 modulePaths := modulePaths(ctx.Config())
534 var libs []string
535 for lib := range modulePaths {
536 libs = append(libs, lib)
537 }
538 sort.Strings(libs)
539
Inseob Kim1f086e22019-05-09 13:29:15 +0900540 first := true
Colin Cross4c2c46f2019-06-03 15:26:05 -0700541 for _, lib := range libs {
Inseob Kim1f086e22019-05-09 13:29:15 +0900542 if first {
543 first = false
544 } else {
545 modulePathTxtBuilder.WriteString("\\n")
546 }
547 modulePathTxtBuilder.WriteString(lib)
548 modulePathTxtBuilder.WriteString(".so ")
Colin Cross4c2c46f2019-06-03 15:26:05 -0700549 modulePathTxtBuilder.WriteString(modulePaths[lib])
Inseob Kim1f086e22019-05-09 13:29:15 +0900550 }
551
552 ctx.Build(pctx, android.BuildParams{
553 Rule: android.WriteFile,
554 Output: modulePathTxt,
555 Description: "vndk snapshot module_paths.txt",
556 Args: map[string]string{
557 "content": modulePathTxtBuilder.String(),
558 },
559 })
560 outputs.configs = append(outputs.configs, modulePathTxt)
561}