blob: a1d67af10fc3a8b9785be057282da868e155be3a [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
Justin Yun8effde42017-06-23 19:24:43 +090052 }
53}
54
55type vndkdep struct {
56 Properties VndkProperties
57}
58
59func (vndk *vndkdep) props() []interface{} {
60 return []interface{}{&vndk.Properties}
61}
62
63func (vndk *vndkdep) begin(ctx BaseModuleContext) {}
64
65func (vndk *vndkdep) deps(ctx BaseModuleContext, deps Deps) Deps {
66 return deps
67}
68
69func (vndk *vndkdep) isVndk() bool {
70 return Bool(vndk.Properties.Vndk.Enabled)
71}
72
73func (vndk *vndkdep) isVndkSp() bool {
74 return Bool(vndk.Properties.Vndk.Support_system_process)
75}
76
Logan Chienf3511742017-10-31 18:04:35 +080077func (vndk *vndkdep) isVndkExt() bool {
78 return vndk.Properties.Vndk.Extends != nil
79}
80
81func (vndk *vndkdep) getVndkExtendsModuleName() string {
82 return String(vndk.Properties.Vndk.Extends)
83}
84
Justin Yun8effde42017-06-23 19:24:43 +090085func (vndk *vndkdep) typeName() string {
86 if !vndk.isVndk() {
87 return "native:vendor"
88 }
Logan Chienf3511742017-10-31 18:04:35 +080089 if !vndk.isVndkExt() {
90 if !vndk.isVndkSp() {
91 return "native:vendor:vndk"
92 }
93 return "native:vendor:vndksp"
Justin Yun8effde42017-06-23 19:24:43 +090094 }
Logan Chienf3511742017-10-31 18:04:35 +080095 if !vndk.isVndkSp() {
96 return "native:vendor:vndkext"
97 }
98 return "native:vendor:vndkspext"
Justin Yun8effde42017-06-23 19:24:43 +090099}
100
Logan Chienf3511742017-10-31 18:04:35 +0800101func (vndk *vndkdep) vndkCheckLinkType(ctx android.ModuleContext, to *Module, tag dependencyTag) {
Justin Yun8effde42017-06-23 19:24:43 +0900102 if to.linker == nil {
103 return
104 }
Jiyong Park82e2bf32017-08-16 14:05:54 +0900105 if !vndk.isVndk() {
106 // Non-VNDK modules (those installed to /vendor) can't depend on modules marked with
107 // vendor_available: false.
108 violation := false
Nan Zhang0007d812017-11-07 10:57:05 -0800109 if lib, ok := to.linker.(*llndkStubDecorator); ok && !Bool(lib.Properties.Vendor_available) {
Jiyong Park82e2bf32017-08-16 14:05:54 +0900110 violation = true
111 } else {
112 if _, ok := to.linker.(libraryInterface); ok && to.VendorProperties.Vendor_available != nil && !Bool(to.VendorProperties.Vendor_available) {
113 // Vendor_available == nil && !Bool(Vendor_available) should be okay since
114 // it means a vendor-only library which is a valid dependency for non-VNDK
115 // modules.
116 violation = true
117 }
118 }
119 if violation {
120 ctx.ModuleErrorf("Vendor module that is not VNDK should not link to %q which is marked as `vendor_available: false`", to.Name())
121 }
122 }
Justin Yun8effde42017-06-23 19:24:43 +0900123 if lib, ok := to.linker.(*libraryDecorator); !ok || !lib.shared() {
124 // Check only shared libraries.
125 // Other (static and LL-NDK) libraries are allowed to link.
126 return
127 }
128 if !to.Properties.UseVndk {
129 ctx.ModuleErrorf("(%s) should not link to %q which is not a vendor-available library",
130 vndk.typeName(), to.Name())
131 return
132 }
Logan Chienf3511742017-10-31 18:04:35 +0800133 if tag == vndkExtDepTag {
134 // Ensure `extends: "name"` property refers a vndk module that has vendor_available
135 // and has identical vndk properties.
136 if to.vndkdep == nil || !to.vndkdep.isVndk() {
137 ctx.ModuleErrorf("`extends` refers a non-vndk module %q", to.Name())
138 return
139 }
140 if vndk.isVndkSp() != to.vndkdep.isVndkSp() {
141 ctx.ModuleErrorf(
142 "`extends` refers a module %q with mismatched support_system_process",
143 to.Name())
144 return
145 }
146 if !Bool(to.VendorProperties.Vendor_available) {
147 ctx.ModuleErrorf(
148 "`extends` refers module %q which does not have `vendor_available: true`",
149 to.Name())
150 return
151 }
152 }
Justin Yun8effde42017-06-23 19:24:43 +0900153 if to.vndkdep == nil {
154 return
155 }
Logan Chienf3511742017-10-31 18:04:35 +0800156
Logan Chiend3c59a22018-03-29 14:08:15 +0800157 // Check the dependencies of VNDK shared libraries.
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100158 if err := vndkIsVndkDepAllowed(vndk, to.vndkdep); err != nil {
159 ctx.ModuleErrorf("(%s) should not link to %q (%s): %v",
160 vndk.typeName(), to.Name(), to.vndkdep.typeName(), err)
Logan Chienf3511742017-10-31 18:04:35 +0800161 return
162 }
Logan Chiend3c59a22018-03-29 14:08:15 +0800163}
Logan Chienf3511742017-10-31 18:04:35 +0800164
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100165func vndkIsVndkDepAllowed(from *vndkdep, to *vndkdep) error {
Logan Chiend3c59a22018-03-29 14:08:15 +0800166 // Check the dependencies of VNDK, VNDK-Ext, VNDK-SP, VNDK-SP-Ext and vendor modules.
167 if from.isVndkExt() {
168 if from.isVndkSp() {
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100169 if to.isVndk() && !to.isVndkSp() {
170 return errors.New("VNDK-SP extensions must not depend on VNDK or VNDK extensions")
171 }
172 return nil
Logan Chiend3c59a22018-03-29 14:08:15 +0800173 }
174 // VNDK-Ext may depend on VNDK, VNDK-Ext, VNDK-SP, VNDK-SP-Ext, or vendor libs.
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100175 return nil
Justin Yun8effde42017-06-23 19:24:43 +0900176 }
Logan Chiend3c59a22018-03-29 14:08:15 +0800177 if from.isVndk() {
178 if to.isVndkExt() {
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100179 return errors.New("VNDK-core and VNDK-SP must not depend on VNDK extensions")
Logan Chiend3c59a22018-03-29 14:08:15 +0800180 }
181 if from.isVndkSp() {
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100182 if !to.isVndkSp() {
183 return errors.New("VNDK-SP must only depend on VNDK-SP")
184 }
185 return nil
Logan Chiend3c59a22018-03-29 14:08:15 +0800186 }
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100187 if !to.isVndk() {
188 return errors.New("VNDK-core must only depend on VNDK-core or VNDK-SP")
189 }
190 return nil
Logan Chiend3c59a22018-03-29 14:08:15 +0800191 }
192 // Vendor modules may depend on VNDK, VNDK-Ext, VNDK-SP, VNDK-SP-Ext, or vendor libs.
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100193 return nil
Justin Yun8effde42017-06-23 19:24:43 +0900194}
Jiyong Parkd5b18a52017-08-03 21:22:50 +0900195
196var (
Inseob Kim9516ee92019-05-09 10:56:13 +0900197 vndkCoreLibrariesKey = android.NewOnceKey("vndkCoreLibrarires")
198 vndkSpLibrariesKey = android.NewOnceKey("vndkSpLibrarires")
199 llndkLibrariesKey = android.NewOnceKey("llndkLibrarires")
200 vndkPrivateLibrariesKey = android.NewOnceKey("vndkPrivateLibrarires")
201 vndkUsingCoreVariantLibrariesKey = android.NewOnceKey("vndkUsingCoreVariantLibrarires")
Inseob Kim1f086e22019-05-09 13:29:15 +0900202 modulePathsKey = android.NewOnceKey("modulePaths")
203 vndkSnapshotOutputsKey = android.NewOnceKey("vndkSnapshotOutputs")
Inseob Kim9516ee92019-05-09 10:56:13 +0900204 vndkLibrariesLock sync.Mutex
Jiyong Parkd5b18a52017-08-03 21:22:50 +0900205)
206
Inseob Kim1f086e22019-05-09 13:29:15 +0900207type 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
Inseob Kim9516ee92019-05-09 10:56:13 +0900216func vndkCoreLibraries(config android.Config) *[]string {
217 return config.Once(vndkCoreLibrariesKey, func() interface{} {
218 return &[]string{}
219 }).(*[]string)
220}
221
222func vndkSpLibraries(config android.Config) *[]string {
223 return config.Once(vndkSpLibrariesKey, func() interface{} {
224 return &[]string{}
225 }).(*[]string)
226}
227
228func llndkLibraries(config android.Config) *[]string {
229 return config.Once(llndkLibrariesKey, func() interface{} {
230 return &[]string{}
231 }).(*[]string)
232}
233
234func vndkPrivateLibraries(config android.Config) *[]string {
235 return config.Once(vndkPrivateLibrariesKey, func() interface{} {
236 return &[]string{}
237 }).(*[]string)
238}
239
240func vndkUsingCoreVariantLibraries(config android.Config) *[]string {
241 return config.Once(vndkUsingCoreVariantLibrariesKey, func() interface{} {
242 return &[]string{}
243 }).(*[]string)
244}
245
Inseob Kim1f086e22019-05-09 13:29:15 +0900246func 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}
Inseob Kim9516ee92019-05-09 10:56:13 +0900251
Inseob Kim1f086e22019-05-09 13:29:15 +0900252func vndkSnapshotOutputs(config android.Config) *vndkSnapshotOutputPaths {
253 return config.Once(vndkSnapshotOutputsKey, func() interface{} {
254 return &vndkSnapshotOutputPaths{}
255 }).(*vndkSnapshotOutputPaths)
256}
Inseob Kim9516ee92019-05-09 10:56:13 +0900257
Inseob Kim1f086e22019-05-09 13:29:15 +0900258func processLlndkLibrary(mctx android.BottomUpMutatorContext, m *Module) {
259 lib := m.linker.(*llndkStubDecorator)
260 name := strings.TrimSuffix(m.Name(), llndkLibrarySuffix)
Inseob Kim9516ee92019-05-09 10:56:13 +0900261
Inseob Kim1f086e22019-05-09 13:29:15 +0900262 vndkLibrariesLock.Lock()
263 defer vndkLibrariesLock.Unlock()
Inseob Kim9516ee92019-05-09 10:56:13 +0900264
Inseob Kim1f086e22019-05-09 13:29:15 +0900265 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)
Jiyong Parkd5b18a52017-08-03 21:22:50 +0900275 }
276 }
277}
Inseob Kim1f086e22019-05-09 13:29:15 +0900278
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
317// gather list of vndk-core, vndk-sp, and ll-ndk libs
318func VndkMutator(mctx android.BottomUpMutatorContext) {
319 m, ok := mctx.Module().(*Module)
320 if !ok {
321 return
322 }
323
324 if !m.Enabled() {
325 return
326 }
327
328 if _, ok := m.linker.(*llndkStubDecorator); ok {
329 processLlndkLibrary(mctx, m)
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)
476 }
477 tryBuildNotice(m)
478 } else if inList(name, *vndkSpLibraries) {
479 if is_2nd {
480 out := installVndkSnapshotLib(ctx, name, m, vndkSpLib2ndPath)
481 outputs.vndkSpLibs2nd = append(outputs.vndkSpLibs2nd, out)
482 } else {
483 out := installVndkSnapshotLib(ctx, name, m, vndkSpLibPath)
484 outputs.vndkSpLibs = append(outputs.vndkSpLibs, out)
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
521 } else {
522 modulePathTxtBuilder.WriteString("\\n")
523 }
524 modulePathTxtBuilder.WriteString(lib)
525 modulePathTxtBuilder.WriteString(".so ")
526 modulePathTxtBuilder.WriteString(dir)
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)
538}