blob: 0b65acafa5634b06b2265a3b2d5277a35507e546 [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 (
Inseob Kimae553032019-05-14 18:52:49 +090018 "encoding/json"
Martin Stjernholm257eb0c2018-10-15 13:05:27 +010019 "errors"
Jooyung Han0302a842019-10-30 18:43:49 +090020 "fmt"
Inseob Kim1f086e22019-05-09 13:29:15 +090021 "path/filepath"
Inseob Kim242ef0c2019-10-22 20:15:20 +090022 "sort"
Jiyong Parkd5b18a52017-08-03 21:22:50 +090023 "strings"
24 "sync"
25
Justin Yun8effde42017-06-23 19:24:43 +090026 "android/soong/android"
Vic Yangefd249e2018-11-12 20:19:56 -080027 "android/soong/cc/config"
Justin Yun8effde42017-06-23 19:24:43 +090028)
29
30type VndkProperties struct {
31 Vndk struct {
32 // declared as a VNDK or VNDK-SP module. The vendor variant
33 // will be installed in /system instead of /vendor partition.
34 //
Roland Levillaindfe75b32019-07-23 16:53:32 +010035 // `vendor_available` must be explicitly set to either true or
Jiyong Park82e2bf32017-08-16 14:05:54 +090036 // false together with `vndk: {enabled: true}`.
Justin Yun8effde42017-06-23 19:24:43 +090037 Enabled *bool
38
39 // declared as a VNDK-SP module, which is a subset of VNDK.
40 //
41 // `vndk: { enabled: true }` must set together.
42 //
43 // All these modules are allowed to link to VNDK-SP or LL-NDK
44 // modules only. Other dependency will cause link-type errors.
45 //
46 // If `support_system_process` is not set or set to false,
47 // the module is VNDK-core and can link to other VNDK-core,
48 // VNDK-SP or LL-NDK modules only.
49 Support_system_process *bool
Logan Chienf3511742017-10-31 18:04:35 +080050
51 // Extending another module
52 Extends *string
Justin Yun8effde42017-06-23 19:24:43 +090053 }
54}
55
56type vndkdep struct {
57 Properties VndkProperties
58}
59
60func (vndk *vndkdep) props() []interface{} {
61 return []interface{}{&vndk.Properties}
62}
63
64func (vndk *vndkdep) begin(ctx BaseModuleContext) {}
65
66func (vndk *vndkdep) deps(ctx BaseModuleContext, deps Deps) Deps {
67 return deps
68}
69
70func (vndk *vndkdep) isVndk() bool {
71 return Bool(vndk.Properties.Vndk.Enabled)
72}
73
74func (vndk *vndkdep) isVndkSp() bool {
75 return Bool(vndk.Properties.Vndk.Support_system_process)
76}
77
Logan Chienf3511742017-10-31 18:04:35 +080078func (vndk *vndkdep) isVndkExt() bool {
79 return vndk.Properties.Vndk.Extends != nil
80}
81
82func (vndk *vndkdep) getVndkExtendsModuleName() string {
83 return String(vndk.Properties.Vndk.Extends)
84}
85
Justin Yun8effde42017-06-23 19:24:43 +090086func (vndk *vndkdep) typeName() string {
87 if !vndk.isVndk() {
88 return "native:vendor"
89 }
Logan Chienf3511742017-10-31 18:04:35 +080090 if !vndk.isVndkExt() {
91 if !vndk.isVndkSp() {
92 return "native:vendor:vndk"
93 }
94 return "native:vendor:vndksp"
Justin Yun8effde42017-06-23 19:24:43 +090095 }
Logan Chienf3511742017-10-31 18:04:35 +080096 if !vndk.isVndkSp() {
97 return "native:vendor:vndkext"
98 }
99 return "native:vendor:vndkspext"
Justin Yun8effde42017-06-23 19:24:43 +0900100}
101
Ivan Lozano183a3212019-10-18 14:18:45 -0700102func (vndk *vndkdep) vndkCheckLinkType(ctx android.ModuleContext, to *Module, tag DependencyTag) {
Justin Yun8effde42017-06-23 19:24:43 +0900103 if to.linker == nil {
104 return
105 }
Jiyong Park82e2bf32017-08-16 14:05:54 +0900106 if !vndk.isVndk() {
107 // Non-VNDK modules (those installed to /vendor) can't depend on modules marked with
108 // vendor_available: false.
109 violation := false
Nan Zhang0007d812017-11-07 10:57:05 -0800110 if lib, ok := to.linker.(*llndkStubDecorator); ok && !Bool(lib.Properties.Vendor_available) {
Jiyong Park82e2bf32017-08-16 14:05:54 +0900111 violation = true
112 } else {
113 if _, ok := to.linker.(libraryInterface); ok && to.VendorProperties.Vendor_available != nil && !Bool(to.VendorProperties.Vendor_available) {
114 // Vendor_available == nil && !Bool(Vendor_available) should be okay since
115 // it means a vendor-only library which is a valid dependency for non-VNDK
116 // modules.
117 violation = true
118 }
119 }
120 if violation {
121 ctx.ModuleErrorf("Vendor module that is not VNDK should not link to %q which is marked as `vendor_available: false`", to.Name())
122 }
123 }
Justin Yun8effde42017-06-23 19:24:43 +0900124 if lib, ok := to.linker.(*libraryDecorator); !ok || !lib.shared() {
125 // Check only shared libraries.
126 // Other (static and LL-NDK) libraries are allowed to link.
127 return
128 }
Ivan Lozano52767be2019-10-18 14:49:46 -0700129 if !to.UseVndk() {
Justin Yun8effde42017-06-23 19:24:43 +0900130 ctx.ModuleErrorf("(%s) should not link to %q which is not a vendor-available library",
131 vndk.typeName(), to.Name())
132 return
133 }
Logan Chienf3511742017-10-31 18:04:35 +0800134 if tag == vndkExtDepTag {
135 // Ensure `extends: "name"` property refers a vndk module that has vendor_available
136 // and has identical vndk properties.
137 if to.vndkdep == nil || !to.vndkdep.isVndk() {
138 ctx.ModuleErrorf("`extends` refers a non-vndk module %q", to.Name())
139 return
140 }
141 if vndk.isVndkSp() != to.vndkdep.isVndkSp() {
142 ctx.ModuleErrorf(
143 "`extends` refers a module %q with mismatched support_system_process",
144 to.Name())
145 return
146 }
147 if !Bool(to.VendorProperties.Vendor_available) {
148 ctx.ModuleErrorf(
149 "`extends` refers module %q which does not have `vendor_available: true`",
150 to.Name())
151 return
152 }
153 }
Justin Yun8effde42017-06-23 19:24:43 +0900154 if to.vndkdep == nil {
155 return
156 }
Logan Chienf3511742017-10-31 18:04:35 +0800157
Logan Chiend3c59a22018-03-29 14:08:15 +0800158 // Check the dependencies of VNDK shared libraries.
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100159 if err := vndkIsVndkDepAllowed(vndk, to.vndkdep); err != nil {
160 ctx.ModuleErrorf("(%s) should not link to %q (%s): %v",
161 vndk.typeName(), to.Name(), to.vndkdep.typeName(), err)
Logan Chienf3511742017-10-31 18:04:35 +0800162 return
163 }
Logan Chiend3c59a22018-03-29 14:08:15 +0800164}
Logan Chienf3511742017-10-31 18:04:35 +0800165
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100166func vndkIsVndkDepAllowed(from *vndkdep, to *vndkdep) error {
Logan Chiend3c59a22018-03-29 14:08:15 +0800167 // Check the dependencies of VNDK, VNDK-Ext, VNDK-SP, VNDK-SP-Ext and vendor modules.
168 if from.isVndkExt() {
169 if from.isVndkSp() {
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100170 if to.isVndk() && !to.isVndkSp() {
171 return errors.New("VNDK-SP extensions must not depend on VNDK or VNDK extensions")
172 }
173 return nil
Logan Chiend3c59a22018-03-29 14:08:15 +0800174 }
175 // VNDK-Ext may depend on VNDK, VNDK-Ext, VNDK-SP, VNDK-SP-Ext, or vendor libs.
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100176 return nil
Justin Yun8effde42017-06-23 19:24:43 +0900177 }
Logan Chiend3c59a22018-03-29 14:08:15 +0800178 if from.isVndk() {
179 if to.isVndkExt() {
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100180 return errors.New("VNDK-core and VNDK-SP must not depend on VNDK extensions")
Logan Chiend3c59a22018-03-29 14:08:15 +0800181 }
182 if from.isVndkSp() {
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100183 if !to.isVndkSp() {
184 return errors.New("VNDK-SP must only depend on VNDK-SP")
185 }
186 return nil
Logan Chiend3c59a22018-03-29 14:08:15 +0800187 }
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100188 if !to.isVndk() {
189 return errors.New("VNDK-core must only depend on VNDK-core or VNDK-SP")
190 }
191 return nil
Logan Chiend3c59a22018-03-29 14:08:15 +0800192 }
193 // Vendor modules may depend on VNDK, VNDK-Ext, VNDK-SP, VNDK-SP-Ext, or vendor libs.
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100194 return nil
Justin Yun8effde42017-06-23 19:24:43 +0900195}
Jiyong Parkd5b18a52017-08-03 21:22:50 +0900196
197var (
Jooyung Hana463f722019-11-01 08:45:59 +0900198 vndkCoreLibrariesKey = android.NewOnceKey("vndkCoreLibrarires")
199 vndkSpLibrariesKey = android.NewOnceKey("vndkSpLibrarires")
200 llndkLibrariesKey = android.NewOnceKey("llndkLibrarires")
201 vndkPrivateLibrariesKey = android.NewOnceKey("vndkPrivateLibrarires")
202 vndkUsingCoreVariantLibrariesKey = android.NewOnceKey("vndkUsingCoreVariantLibrarires")
Jooyung Hana463f722019-11-01 08:45:59 +0900203 vndkMustUseVendorVariantListKey = android.NewOnceKey("vndkMustUseVendorVariantListKey")
204 vndkLibrariesLock sync.Mutex
Jiyong Parkd5b18a52017-08-03 21:22:50 +0900205
Inseob Kimae553032019-05-14 18:52:49 +0900206 headerExts = []string{".h", ".hh", ".hpp", ".hxx", ".h++", ".inl", ".inc", ".ipp", ".h.generic"}
207)
Inseob Kim1f086e22019-05-09 13:29:15 +0900208
Jooyung Han0302a842019-10-30 18:43:49 +0900209func vndkCoreLibraries(config android.Config) map[string]string {
Inseob Kim9516ee92019-05-09 10:56:13 +0900210 return config.Once(vndkCoreLibrariesKey, func() interface{} {
Jooyung Han0302a842019-10-30 18:43:49 +0900211 return make(map[string]string)
212 }).(map[string]string)
Inseob Kim9516ee92019-05-09 10:56:13 +0900213}
214
Jooyung Han0302a842019-10-30 18:43:49 +0900215func vndkSpLibraries(config android.Config) map[string]string {
Inseob Kim9516ee92019-05-09 10:56:13 +0900216 return config.Once(vndkSpLibrariesKey, func() interface{} {
Jooyung Han0302a842019-10-30 18:43:49 +0900217 return make(map[string]string)
218 }).(map[string]string)
Inseob Kim9516ee92019-05-09 10:56:13 +0900219}
220
Jooyung Han0302a842019-10-30 18:43:49 +0900221func isLlndkLibrary(baseModuleName string, config android.Config) bool {
222 _, ok := llndkLibraries(config)[baseModuleName]
223 return ok
224}
225
226func llndkLibraries(config android.Config) map[string]string {
Inseob Kim9516ee92019-05-09 10:56:13 +0900227 return config.Once(llndkLibrariesKey, func() interface{} {
Jooyung Han0302a842019-10-30 18:43:49 +0900228 return make(map[string]string)
229 }).(map[string]string)
Inseob Kim9516ee92019-05-09 10:56:13 +0900230}
231
Jooyung Han0302a842019-10-30 18:43:49 +0900232func isVndkPrivateLibrary(baseModuleName string, config android.Config) bool {
233 _, ok := vndkPrivateLibraries(config)[baseModuleName]
234 return ok
235}
236
237func vndkPrivateLibraries(config android.Config) map[string]string {
Inseob Kim9516ee92019-05-09 10:56:13 +0900238 return config.Once(vndkPrivateLibrariesKey, func() interface{} {
Jooyung Han0302a842019-10-30 18:43:49 +0900239 return make(map[string]string)
240 }).(map[string]string)
Inseob Kim9516ee92019-05-09 10:56:13 +0900241}
242
Jooyung Han0302a842019-10-30 18:43:49 +0900243func vndkUsingCoreVariantLibraries(config android.Config) map[string]string {
Inseob Kim9516ee92019-05-09 10:56:13 +0900244 return config.Once(vndkUsingCoreVariantLibrariesKey, func() interface{} {
Jooyung Han0302a842019-10-30 18:43:49 +0900245 return make(map[string]string)
246 }).(map[string]string)
Inseob Kim9516ee92019-05-09 10:56:13 +0900247}
248
Jooyung Han097087b2019-10-22 19:32:18 +0900249func vndkMustUseVendorVariantList(cfg android.Config) []string {
250 return cfg.Once(vndkMustUseVendorVariantListKey, func() interface{} {
Jooyung Han097087b2019-10-22 19:32:18 +0900251 return config.VndkMustUseVendorVariantList
252 }).([]string)
253}
254
255// test may call this to override global configuration(config.VndkMustUseVendorVariantList)
256// when it is called, it must be before the first call to vndkMustUseVendorVariantList()
257func setVndkMustUseVendorVariantListForTest(config android.Config, mustUseVendorVariantList []string) {
Jooyung Hana463f722019-11-01 08:45:59 +0900258 config.Once(vndkMustUseVendorVariantListKey, func() interface{} {
Jooyung Han097087b2019-10-22 19:32:18 +0900259 return mustUseVendorVariantList
260 })
261}
262
Inseob Kim1f086e22019-05-09 13:29:15 +0900263func processLlndkLibrary(mctx android.BottomUpMutatorContext, m *Module) {
264 lib := m.linker.(*llndkStubDecorator)
Jooyung Han0302a842019-10-30 18:43:49 +0900265 name := m.BaseModuleName()
266 filename := m.BaseModuleName() + ".so"
Inseob Kim9516ee92019-05-09 10:56:13 +0900267
Inseob Kim1f086e22019-05-09 13:29:15 +0900268 vndkLibrariesLock.Lock()
269 defer vndkLibrariesLock.Unlock()
Inseob Kim9516ee92019-05-09 10:56:13 +0900270
Jooyung Han0302a842019-10-30 18:43:49 +0900271 llndkLibraries(mctx.Config())[name] = filename
Inseob Kim1f086e22019-05-09 13:29:15 +0900272 if !Bool(lib.Properties.Vendor_available) {
Jooyung Han0302a842019-10-30 18:43:49 +0900273 vndkPrivateLibraries(mctx.Config())[name] = filename
Jiyong Parkd5b18a52017-08-03 21:22:50 +0900274 }
275}
Inseob Kim1f086e22019-05-09 13:29:15 +0900276
277func processVndkLibrary(mctx android.BottomUpMutatorContext, m *Module) {
Jooyung Han0302a842019-10-30 18:43:49 +0900278 name := m.BaseModuleName()
279 filename, err := getVndkFileName(m)
280 if err != nil {
281 panic(err)
282 }
Inseob Kim1f086e22019-05-09 13:29:15 +0900283
284 vndkLibrariesLock.Lock()
285 defer vndkLibrariesLock.Unlock()
286
Jooyung Han097087b2019-10-22 19:32:18 +0900287 if inList(name, vndkMustUseVendorVariantList(mctx.Config())) {
288 m.Properties.MustUseVendorVariant = true
289 }
Jooyung Han0302a842019-10-30 18:43:49 +0900290 if mctx.DeviceConfig().VndkUseCoreVariant() && !m.Properties.MustUseVendorVariant {
291 vndkUsingCoreVariantLibraries(mctx.Config())[name] = filename
Inseob Kim1f086e22019-05-09 13:29:15 +0900292 }
Jooyung Han0302a842019-10-30 18:43:49 +0900293
Inseob Kim1f086e22019-05-09 13:29:15 +0900294 if m.vndkdep.isVndkSp() {
Jooyung Han0302a842019-10-30 18:43:49 +0900295 vndkSpLibraries(mctx.Config())[name] = filename
Inseob Kim1f086e22019-05-09 13:29:15 +0900296 } else {
Jooyung Han0302a842019-10-30 18:43:49 +0900297 vndkCoreLibraries(mctx.Config())[name] = filename
Inseob Kim1f086e22019-05-09 13:29:15 +0900298 }
299 if !Bool(m.VendorProperties.Vendor_available) {
Jooyung Han0302a842019-10-30 18:43:49 +0900300 vndkPrivateLibraries(mctx.Config())[name] = filename
Inseob Kim1f086e22019-05-09 13:29:15 +0900301 }
302}
303
Jooyung Han31c470b2019-10-18 16:26:59 +0900304func IsForVndkApex(mctx android.BottomUpMutatorContext, m *Module) bool {
305 if !m.Enabled() {
306 return false
307 }
308
Jooyung Han87a7f302019-10-29 05:18:21 +0900309 if !mctx.Device() {
310 return false
311 }
312
Jooyung Han31c470b2019-10-18 16:26:59 +0900313 if m.Target().NativeBridge == android.NativeBridgeEnabled {
314 return false
315 }
316
317 // prebuilt vndk modules should match with device
318 // TODO(b/142675459): Use enabled: to select target device in vndk_prebuilt_shared
319 // When b/142675459 is landed, remove following check
320 if p, ok := m.linker.(*vndkPrebuiltLibraryDecorator); ok && !p.matchesWithDevice(mctx.DeviceConfig()) {
321 return false
322 }
323
324 if lib, ok := m.linker.(libraryInterface); ok {
325 useCoreVariant := m.vndkVersion() == mctx.DeviceConfig().PlatformVndkVersion() &&
Jooyung Han87a7f302019-10-29 05:18:21 +0900326 mctx.DeviceConfig().VndkUseCoreVariant() && !m.MustUseVendorVariant()
Ivan Lozano52767be2019-10-18 14:49:46 -0700327 return lib.shared() && m.UseVndk() && m.IsVndk() && !m.isVndkExt() && !useCoreVariant
Jooyung Han31c470b2019-10-18 16:26:59 +0900328 }
329 return false
330}
331
Inseob Kim1f086e22019-05-09 13:29:15 +0900332// gather list of vndk-core, vndk-sp, and ll-ndk libs
333func VndkMutator(mctx android.BottomUpMutatorContext) {
334 m, ok := mctx.Module().(*Module)
335 if !ok {
336 return
337 }
Inseob Kim1f086e22019-05-09 13:29:15 +0900338 if !m.Enabled() {
339 return
340 }
Justin Yun7390ea32019-09-08 11:34:06 +0900341 if m.Target().NativeBridge == android.NativeBridgeEnabled {
342 // Skip native_bridge modules
343 return
344 }
Inseob Kim1f086e22019-05-09 13:29:15 +0900345
346 if _, ok := m.linker.(*llndkStubDecorator); ok {
347 processLlndkLibrary(mctx, m)
348 return
349 }
350
351 lib, is_lib := m.linker.(*libraryDecorator)
352 prebuilt_lib, is_prebuilt_lib := m.linker.(*prebuiltLibraryLinker)
353
Inseob Kim64c43952019-08-26 16:52:35 +0900354 if (is_lib && lib.buildShared()) || (is_prebuilt_lib && prebuilt_lib.buildShared()) {
355 if m.vndkdep != nil && m.vndkdep.isVndk() && !m.vndkdep.isVndkExt() {
Inseob Kim1f086e22019-05-09 13:29:15 +0900356 processVndkLibrary(mctx, m)
357 return
358 }
359 }
360}
361
362func init() {
Jooyung Han2216fb12019-11-06 16:46:15 +0900363 android.RegisterModuleType("vndk_libraries_txt", VndkLibrariesTxt)
Inseob Kim1f086e22019-05-09 13:29:15 +0900364 android.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton)
Inseob Kim1f086e22019-05-09 13:29:15 +0900365}
366
Jooyung Han2216fb12019-11-06 16:46:15 +0900367type vndkLibrariesTxt struct {
368 android.ModuleBase
369 outputFile android.OutputPath
370}
371
372// vndk_libraries_txt is a special kind of module type in that it name is one of
373// - llndk.libraries.txt
374// - vndkcore.libraries.txt
375// - vndksp.libraries.txt
376// - vndkprivate.libraries.txt
377// - vndkcorevariant.libraries.txt
378// A module behaves like a prebuilt_etc but its content is generated by soong.
379// By being a soong module, these files can be referenced by other soong modules.
380// For example, apex_vndk can depend on these files as prebuilt.
381func VndkLibrariesTxt() android.Module {
382 m := &vndkLibrariesTxt{}
383 android.InitAndroidModule(m)
384 return m
385}
386
387func insertVndkVersion(filename string, vndkVersion string) string {
388 if index := strings.LastIndex(filename, "."); index != -1 {
389 return filename[:index] + "." + vndkVersion + filename[index:]
390 }
391 return filename
392}
393
394func (txt *vndkLibrariesTxt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
395 var list []string
396 switch txt.Name() {
397 case "llndk.libraries.txt":
398 for _, filename := range android.SortedStringMapValues(llndkLibraries(ctx.Config())) {
399 if strings.HasPrefix(filename, "libclang_rt.hwasan-") {
400 continue
401 }
402 list = append(list, filename)
403 }
404 case "vndkcore.libraries.txt":
405 list = android.SortedStringMapValues(vndkCoreLibraries(ctx.Config()))
406 case "vndksp.libraries.txt":
407 list = android.SortedStringMapValues(vndkSpLibraries(ctx.Config()))
408 case "vndkprivate.libraries.txt":
409 list = android.SortedStringMapValues(vndkPrivateLibraries(ctx.Config()))
410 case "vndkcorevariant.libraries.txt":
411 list = android.SortedStringMapValues(vndkUsingCoreVariantLibraries(ctx.Config()))
412 default:
413 ctx.ModuleErrorf("name(%s) is unknown.", txt.Name())
414 return
415 }
416
417 filename := insertVndkVersion(txt.Name(), ctx.DeviceConfig().PlatformVndkVersion())
418 txt.outputFile = android.PathForModuleOut(ctx, filename).OutputPath
419 ctx.Build(pctx, android.BuildParams{
420 Rule: android.WriteFile,
421 Output: txt.outputFile,
422 Description: "Writing " + txt.outputFile.String(),
423 Args: map[string]string{
424 "content": strings.Join(list, "\\n"),
425 },
426 })
427
428 installPath := android.PathForModuleInstall(ctx, "etc")
429 ctx.InstallFile(installPath, filename, txt.outputFile)
430}
431
432func (txt *vndkLibrariesTxt) AndroidMkEntries() android.AndroidMkEntries {
433 return android.AndroidMkEntries{
434 Class: "ETC",
435 OutputFile: android.OptionalPathForPath(txt.outputFile),
436 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
437 func(entries *android.AndroidMkEntries) {
438 entries.SetString("LOCAL_MODULE_STEM", txt.outputFile.Base())
439 },
440 },
441 }
442}
443
Inseob Kim1f086e22019-05-09 13:29:15 +0900444func VndkSnapshotSingleton() android.Singleton {
445 return &vndkSnapshotSingleton{}
446}
447
Jooyung Han0302a842019-10-30 18:43:49 +0900448type vndkSnapshotSingleton struct {
Jooyung Han2216fb12019-11-06 16:46:15 +0900449 installedLlndkLibraries []string
450 llndkLibrariesFile android.Path
451 vndkSpLibrariesFile android.Path
452 vndkCoreLibrariesFile android.Path
453 vndkPrivateLibrariesFile android.Path
454 vndkLibrariesFile android.Path
455 vndkSnapshotZipFile android.OptionalPath
Jooyung Han0302a842019-10-30 18:43:49 +0900456}
Inseob Kim1f086e22019-05-09 13:29:15 +0900457
Inseob Kim1f086e22019-05-09 13:29:15 +0900458func (c *vndkSnapshotSingleton) GenerateBuildActions(ctx android.SingletonContext) {
Jooyung Han0302a842019-10-30 18:43:49 +0900459 // build these files even if PlatformVndkVersion or BoardVndkVersion is not set
460 c.buildVndkLibrariesTxtFiles(ctx)
461
Inseob Kim1f086e22019-05-09 13:29:15 +0900462 // BOARD_VNDK_VERSION must be set to 'current' in order to generate a VNDK snapshot.
463 if ctx.DeviceConfig().VndkVersion() != "current" {
464 return
465 }
466
467 if ctx.DeviceConfig().PlatformVndkVersion() == "" {
468 return
469 }
470
471 if ctx.DeviceConfig().BoardVndkRuntimeDisable() {
472 return
473 }
474
Inseob Kim242ef0c2019-10-22 20:15:20 +0900475 var snapshotOutputs android.Paths
476
477 /*
478 VNDK snapshot zipped artifacts directory structure:
479 {SNAPSHOT_ARCH}/
480 arch-{TARGET_ARCH}-{TARGET_ARCH_VARIANT}/
481 shared/
482 vndk-core/
483 (VNDK-core libraries, e.g. libbinder.so)
484 vndk-sp/
485 (VNDK-SP libraries, e.g. libc++.so)
486 arch-{TARGET_2ND_ARCH}-{TARGET_2ND_ARCH_VARIANT}/
487 shared/
488 vndk-core/
489 (VNDK-core libraries, e.g. libbinder.so)
490 vndk-sp/
491 (VNDK-SP libraries, e.g. libc++.so)
492 binder32/
493 (This directory is newly introduced in v28 (Android P) to hold
494 prebuilts built for 32-bit binder interface.)
495 arch-{TARGET_ARCH}-{TARGE_ARCH_VARIANT}/
496 ...
497 configs/
498 (various *.txt configuration files)
499 include/
500 (header files of same directory structure with source tree)
501 NOTICE_FILES/
502 (notice files of libraries, e.g. libcutils.so.txt)
503 */
Inseob Kim1f086e22019-05-09 13:29:15 +0900504
505 snapshotDir := "vndk-snapshot"
Inseob Kim242ef0c2019-10-22 20:15:20 +0900506 snapshotArchDir := filepath.Join(snapshotDir, ctx.DeviceConfig().DeviceArch())
Inseob Kim1f086e22019-05-09 13:29:15 +0900507
Inseob Kim242ef0c2019-10-22 20:15:20 +0900508 targetArchDirMap := make(map[android.ArchType]string)
Inseob Kimae553032019-05-14 18:52:49 +0900509 for _, target := range ctx.Config().Targets[android.Android] {
Inseob Kim242ef0c2019-10-22 20:15:20 +0900510 dir := snapshotArchDir
Inseob Kimae553032019-05-14 18:52:49 +0900511 if ctx.DeviceConfig().BinderBitness() == "32" {
512 dir = filepath.Join(dir, "binder32")
513 }
514 arch := "arch-" + target.Arch.ArchType.String()
515 if target.Arch.ArchVariant != "" {
516 arch += "-" + target.Arch.ArchVariant
517 }
518 dir = filepath.Join(dir, arch)
Inseob Kim242ef0c2019-10-22 20:15:20 +0900519 targetArchDirMap[target.Arch.ArchType] = dir
Inseob Kim1f086e22019-05-09 13:29:15 +0900520 }
Inseob Kim242ef0c2019-10-22 20:15:20 +0900521 configsDir := filepath.Join(snapshotArchDir, "configs")
522 noticeDir := filepath.Join(snapshotArchDir, "NOTICE_FILES")
523 includeDir := filepath.Join(snapshotArchDir, "include")
524
525 // set of include paths exported by VNDK libraries
526 exportedIncludes := make(map[string]bool)
527
528 // generated header files among exported headers.
529 var generatedHeaders android.Paths
530
531 // set of notice files copied.
Inseob Kim1f086e22019-05-09 13:29:15 +0900532 noticeBuilt := make(map[string]bool)
533
Inseob Kim242ef0c2019-10-22 20:15:20 +0900534 // paths of VNDK modules for GPL license checking
535 modulePaths := make(map[string]string)
536
537 // actual module names of .so files
538 // e.g. moduleNames["libprotobuf-cpp-full-3.9.1.so"] = "libprotobuf-cpp-full"
539 moduleNames := make(map[string]string)
540
541 installSnapshotFileFromPath := func(path android.Path, out string) android.OutputPath {
542 outPath := android.PathForOutput(ctx, out)
Inseob Kimae553032019-05-14 18:52:49 +0900543 ctx.Build(pctx, android.BuildParams{
544 Rule: android.Cp,
545 Input: path,
Inseob Kim242ef0c2019-10-22 20:15:20 +0900546 Output: outPath,
Inseob Kimae553032019-05-14 18:52:49 +0900547 Description: "vndk snapshot " + out,
548 Args: map[string]string{
549 "cpFlags": "-f -L",
550 },
551 })
Inseob Kim242ef0c2019-10-22 20:15:20 +0900552 return outPath
Inseob Kimae553032019-05-14 18:52:49 +0900553 }
Inseob Kim242ef0c2019-10-22 20:15:20 +0900554
555 installSnapshotFileFromContent := func(content, out string) android.OutputPath {
556 outPath := android.PathForOutput(ctx, out)
Inseob Kimae553032019-05-14 18:52:49 +0900557 ctx.Build(pctx, android.BuildParams{
558 Rule: android.WriteFile,
Inseob Kim242ef0c2019-10-22 20:15:20 +0900559 Output: outPath,
Inseob Kimae553032019-05-14 18:52:49 +0900560 Description: "vndk snapshot " + out,
561 Args: map[string]string{
562 "content": content,
563 },
564 })
Inseob Kim242ef0c2019-10-22 20:15:20 +0900565 return outPath
Inseob Kimae553032019-05-14 18:52:49 +0900566 }
567
Inseob Kimae553032019-05-14 18:52:49 +0900568 type vndkSnapshotLibraryInterface interface {
569 exportedFlagsProducer
570 libraryInterface
571 }
572
573 var _ vndkSnapshotLibraryInterface = (*prebuiltLibraryLinker)(nil)
574 var _ vndkSnapshotLibraryInterface = (*libraryDecorator)(nil)
575
Inseob Kim242ef0c2019-10-22 20:15:20 +0900576 installVndkSnapshotLib := func(m *Module, l vndkSnapshotLibraryInterface, vndkType string) (android.Paths, bool) {
577 targetArchDir, ok := targetArchDirMap[m.Target().Arch.ArchType]
578 if !ok {
579 return nil, false
580 }
Inseob Kimae553032019-05-14 18:52:49 +0900581
Inseob Kim242ef0c2019-10-22 20:15:20 +0900582 var ret android.Paths
583
584 libPath := m.outputFile.Path()
585 stem := libPath.Base()
586 snapshotLibOut := filepath.Join(targetArchDir, "shared", vndkType, stem)
587 ret = append(ret, installSnapshotFileFromPath(libPath, snapshotLibOut))
588
589 moduleNames[stem] = ctx.ModuleName(m)
590 modulePaths[stem] = ctx.ModuleDir(m)
591
592 if m.NoticeFile().Valid() {
593 noticeName := stem + ".txt"
594 // skip already copied notice file
595 if _, ok := noticeBuilt[noticeName]; !ok {
596 noticeBuilt[noticeName] = true
597 ret = append(ret, installSnapshotFileFromPath(
598 m.NoticeFile().Path(), filepath.Join(noticeDir, noticeName)))
599 }
600 }
Inseob Kimae553032019-05-14 18:52:49 +0900601
602 if ctx.Config().VndkSnapshotBuildArtifacts() {
603 prop := struct {
604 ExportedDirs []string `json:",omitempty"`
605 ExportedSystemDirs []string `json:",omitempty"`
606 ExportedFlags []string `json:",omitempty"`
607 RelativeInstallPath string `json:",omitempty"`
608 }{}
609 prop.ExportedFlags = l.exportedFlags()
Jiyong Park74955042019-10-22 20:19:51 +0900610 prop.ExportedDirs = l.exportedDirs().Strings()
611 prop.ExportedSystemDirs = l.exportedSystemDirs().Strings()
Inseob Kimae553032019-05-14 18:52:49 +0900612 prop.RelativeInstallPath = m.RelativeInstallPath()
613
Inseob Kim242ef0c2019-10-22 20:15:20 +0900614 propOut := snapshotLibOut + ".json"
Inseob Kimae553032019-05-14 18:52:49 +0900615
616 j, err := json.Marshal(prop)
617 if err != nil {
618 ctx.Errorf("json marshal to %q failed: %#v", propOut, err)
Inseob Kim242ef0c2019-10-22 20:15:20 +0900619 return nil, false
Inseob Kimae553032019-05-14 18:52:49 +0900620 }
Inseob Kim242ef0c2019-10-22 20:15:20 +0900621 ret = append(ret, installSnapshotFileFromContent(string(j), propOut))
Inseob Kimae553032019-05-14 18:52:49 +0900622 }
Inseob Kim242ef0c2019-10-22 20:15:20 +0900623 return ret, true
Inseob Kimae553032019-05-14 18:52:49 +0900624 }
625
Inseob Kim242ef0c2019-10-22 20:15:20 +0900626 isVndkSnapshotLibrary := func(m *Module) (i vndkSnapshotLibraryInterface, vndkType string, isVndkSnapshotLib bool) {
Inseob Kimae553032019-05-14 18:52:49 +0900627 if m.Target().NativeBridge == android.NativeBridgeEnabled {
628 return nil, "", false
629 }
Ivan Lozano52767be2019-10-18 14:49:46 -0700630 if !m.UseVndk() || !m.IsForPlatform() || !m.installable() {
Inseob Kimae553032019-05-14 18:52:49 +0900631 return nil, "", false
632 }
633 l, ok := m.linker.(vndkSnapshotLibraryInterface)
634 if !ok || !l.shared() {
635 return nil, "", false
636 }
Inseob Kim242ef0c2019-10-22 20:15:20 +0900637 if m.vndkVersion() == ctx.DeviceConfig().PlatformVndkVersion() && m.IsVndk() && !m.isVndkExt() {
638 if m.isVndkSp() {
639 return l, "vndk-sp", true
640 } else {
641 return l, "vndk-core", true
642 }
Inseob Kimae553032019-05-14 18:52:49 +0900643 }
Inseob Kim242ef0c2019-10-22 20:15:20 +0900644
645 return nil, "", false
Inseob Kimae553032019-05-14 18:52:49 +0900646 }
647
Inseob Kim1f086e22019-05-09 13:29:15 +0900648 ctx.VisitAllModules(func(module android.Module) {
649 m, ok := module.(*Module)
Inseob Kimae553032019-05-14 18:52:49 +0900650 if !ok || !m.Enabled() {
Inseob Kim1f086e22019-05-09 13:29:15 +0900651 return
652 }
653
Inseob Kim242ef0c2019-10-22 20:15:20 +0900654 l, vndkType, ok := isVndkSnapshotLibrary(m)
Inseob Kimae553032019-05-14 18:52:49 +0900655 if !ok {
dimitry51ea18a2019-05-20 10:39:52 +0200656 return
657 }
658
Inseob Kim242ef0c2019-10-22 20:15:20 +0900659 libs, ok := installVndkSnapshotLib(m, l, vndkType)
Inseob Kimae553032019-05-14 18:52:49 +0900660 if !ok {
Inseob Kim1f086e22019-05-09 13:29:15 +0900661 return
662 }
663
Inseob Kim242ef0c2019-10-22 20:15:20 +0900664 snapshotOutputs = append(snapshotOutputs, libs...)
Inseob Kim1f086e22019-05-09 13:29:15 +0900665
Inseob Kim242ef0c2019-10-22 20:15:20 +0900666 // We glob headers from include directories inside source tree. So we first gather
667 // all include directories inside our source tree. On the contrast, we manually
668 // collect generated headers from dependencies as they can't globbed.
Inseob Kimae553032019-05-14 18:52:49 +0900669 generatedHeaders = append(generatedHeaders, l.exportedDeps()...)
670 for _, dir := range append(l.exportedDirs(), l.exportedSystemDirs()...) {
Inseob Kim242ef0c2019-10-22 20:15:20 +0900671 exportedIncludes[dir.String()] = true
Inseob Kimae553032019-05-14 18:52:49 +0900672 }
673 })
Inseob Kim1f086e22019-05-09 13:29:15 +0900674
Inseob Kimae553032019-05-14 18:52:49 +0900675 if ctx.Config().VndkSnapshotBuildArtifacts() {
Inseob Kim242ef0c2019-10-22 20:15:20 +0900676 globbedHeaders := make(map[string]bool)
Inseob Kimae553032019-05-14 18:52:49 +0900677
Inseob Kim242ef0c2019-10-22 20:15:20 +0900678 for _, dir := range android.SortedStringKeys(exportedIncludes) {
679 // Skip if dir is for generated headers
Inseob Kimae553032019-05-14 18:52:49 +0900680 if strings.HasPrefix(dir, android.PathForOutput(ctx).String()) {
681 continue
Inseob Kim1f086e22019-05-09 13:29:15 +0900682 }
Inseob Kimae553032019-05-14 18:52:49 +0900683 exts := headerExts
684 // Glob all files under this special directory, because of C++ headers.
685 if strings.HasPrefix(dir, "external/libcxx/include") {
686 exts = []string{""}
Inseob Kim1f086e22019-05-09 13:29:15 +0900687 }
Inseob Kimae553032019-05-14 18:52:49 +0900688 for _, ext := range exts {
689 glob, err := ctx.GlobWithDeps(dir+"/**/*"+ext, nil)
690 if err != nil {
691 ctx.Errorf("%#v\n", err)
692 return
693 }
694 for _, header := range glob {
695 if strings.HasSuffix(header, "/") {
696 continue
697 }
Inseob Kim242ef0c2019-10-22 20:15:20 +0900698 globbedHeaders[header] = true
Inseob Kimae553032019-05-14 18:52:49 +0900699 }
700 }
Inseob Kim1f086e22019-05-09 13:29:15 +0900701 }
Inseob Kim1f086e22019-05-09 13:29:15 +0900702
Inseob Kim242ef0c2019-10-22 20:15:20 +0900703 for _, header := range android.SortedStringKeys(globbedHeaders) {
704 snapshotOutputs = append(snapshotOutputs, installSnapshotFileFromPath(
705 android.PathForSource(ctx, header), filepath.Join(includeDir, header)))
Inseob Kimae553032019-05-14 18:52:49 +0900706 }
Inseob Kim1f086e22019-05-09 13:29:15 +0900707
Inseob Kimae553032019-05-14 18:52:49 +0900708 isHeader := func(path string) bool {
709 for _, ext := range headerExts {
710 if strings.HasSuffix(path, ext) {
711 return true
712 }
713 }
714 return false
715 }
Inseob Kim1f086e22019-05-09 13:29:15 +0900716
Inseob Kim242ef0c2019-10-22 20:15:20 +0900717 // For generated headers, manually install one by one, rather than glob
Inseob Kimae553032019-05-14 18:52:49 +0900718 for _, path := range android.PathsToDirectorySortedPaths(android.FirstUniquePaths(generatedHeaders)) {
719 header := path.String()
720
721 if !isHeader(header) {
722 continue
723 }
724
Inseob Kim242ef0c2019-10-22 20:15:20 +0900725 snapshotOutputs = append(snapshotOutputs, installSnapshotFileFromPath(
726 path, filepath.Join(includeDir, header)))
Inseob Kimae553032019-05-14 18:52:49 +0900727 }
728 }
729
Inseob Kim242ef0c2019-10-22 20:15:20 +0900730 snapshotOutputs = append(snapshotOutputs,
731 installSnapshotFileFromPath(c.vndkCoreLibrariesFile, filepath.Join(configsDir, "vndkcore.libraries.txt")),
732 installSnapshotFileFromPath(c.vndkPrivateLibrariesFile, filepath.Join(configsDir, "vndkprivate.libraries.txt")),
733 installSnapshotFileFromPath(c.vndkSpLibrariesFile, filepath.Join(configsDir, "vndksp.libraries.txt")),
734 installSnapshotFileFromPath(c.llndkLibrariesFile, filepath.Join(configsDir, "llndk.libraries.txt")),
735 )
Inseob Kim1f086e22019-05-09 13:29:15 +0900736
Inseob Kim242ef0c2019-10-22 20:15:20 +0900737 /*
738 Dump a map to a list file as:
Inseob Kim1f086e22019-05-09 13:29:15 +0900739
Inseob Kim242ef0c2019-10-22 20:15:20 +0900740 {key1} {value1}
741 {key2} {value2}
742 ...
743 */
744 installMapListFile := func(m map[string]string, path string) android.OutputPath {
745 var txtBuilder strings.Builder
746 for idx, k := range android.SortedStringKeys(m) {
747 if idx > 0 {
748 txtBuilder.WriteString("\\n")
749 }
750 txtBuilder.WriteString(k)
751 txtBuilder.WriteString(" ")
752 txtBuilder.WriteString(m[k])
Inseob Kim1f086e22019-05-09 13:29:15 +0900753 }
Inseob Kim242ef0c2019-10-22 20:15:20 +0900754 return installSnapshotFileFromContent(txtBuilder.String(), path)
Inseob Kim1f086e22019-05-09 13:29:15 +0900755 }
756
Inseob Kim242ef0c2019-10-22 20:15:20 +0900757 /*
758 module_paths.txt contains paths on which VNDK modules are defined.
759 e.g.,
760 libbase.so system/core/base
761 libc.so bionic/libc
762 ...
763 */
764 snapshotOutputs = append(snapshotOutputs, installMapListFile(modulePaths, filepath.Join(configsDir, "module_paths.txt")))
765
766 /*
767 module_names.txt contains names as which VNDK modules are defined,
768 because output filename and module name can be different with stem and suffix properties.
769
770 e.g.,
771 libcutils.so libcutils
772 libprotobuf-cpp-full-3.9.2.so libprotobuf-cpp-full
773 ...
774 */
775 snapshotOutputs = append(snapshotOutputs, installMapListFile(moduleNames, filepath.Join(configsDir, "module_names.txt")))
776
777 // All artifacts are ready. Sort them to normalize ninja and then zip.
778 sort.Slice(snapshotOutputs, func(i, j int) bool {
779 return snapshotOutputs[i].String() < snapshotOutputs[j].String()
780 })
781
782 zipPath := android.PathForOutput(ctx, snapshotDir, "android-vndk-"+ctx.DeviceConfig().DeviceArch()+".zip")
783 zipRule := android.NewRuleBuilder()
784
785 // If output files are too many, soong_zip command can exceed ARG_MAX.
786 // So first dump file lists into a single list file, and then feed it to Soong
787 snapshotOutputList := android.PathForOutput(ctx, snapshotDir, "android-vndk-"+ctx.DeviceConfig().DeviceArch()+"_list")
788 zipRule.Command().
789 Text("( xargs").
790 FlagWithRspFileInputList("-n1 echo < ", snapshotOutputs).
791 FlagWithOutput("| tr -d \\' > ", snapshotOutputList).
792 Text(")")
793
794 zipRule.Temporary(snapshotOutputList)
795
796 zipRule.Command().
797 BuiltTool(ctx, "soong_zip").
798 FlagWithOutput("-o ", zipPath).
799 FlagWithArg("-C ", android.PathForOutput(ctx, snapshotDir).String()).
800 FlagWithInput("-l ", snapshotOutputList)
801
802 zipRule.Build(pctx, ctx, zipPath.String(), "vndk snapshot "+zipPath.String())
803 c.vndkSnapshotZipFile = android.OptionalPathForPath(zipPath)
Inseob Kim1f086e22019-05-09 13:29:15 +0900804}
Jooyung Han097087b2019-10-22 19:32:18 +0900805
Jooyung Han0302a842019-10-30 18:43:49 +0900806func getVndkFileName(m *Module) (string, error) {
807 if library, ok := m.linker.(*libraryDecorator); ok {
808 return library.getLibNameHelper(m.BaseModuleName(), true) + ".so", nil
809 }
810 if prebuilt, ok := m.linker.(*prebuiltLibraryLinker); ok {
811 return prebuilt.libraryDecorator.getLibNameHelper(m.BaseModuleName(), true) + ".so", nil
812 }
813 return "", fmt.Errorf("VNDK library should have libraryDecorator or prebuiltLibraryLinker as linker: %T", m.linker)
Jooyung Han097087b2019-10-22 19:32:18 +0900814}
815
816func (c *vndkSnapshotSingleton) buildVndkLibrariesTxtFiles(ctx android.SingletonContext) {
Jooyung Han0302a842019-10-30 18:43:49 +0900817 // Make uses LLNDK_LIBRARIES to determine which libraries to install.
818 // HWASAN is only part of the LL-NDK in builds in which libc depends on HWASAN.
819 // Therefore, by removing the library here, we cause it to only be installed if libc
820 // depends on it.
821 installedLlndkLibraries := make(map[string]string)
822 for lib, filename := range llndkLibraries(ctx.Config()) {
823 if strings.HasPrefix(lib, "libclang_rt.hwasan-") {
824 continue
Jooyung Han097087b2019-10-22 19:32:18 +0900825 }
Jooyung Han0302a842019-10-30 18:43:49 +0900826 installedLlndkLibraries[lib] = filename
827 }
Jooyung Han097087b2019-10-22 19:32:18 +0900828
Jooyung Han0302a842019-10-30 18:43:49 +0900829 installListFile := func(list []string, fileName string) android.Path {
830 out := android.PathForOutput(ctx, "vndk", fileName)
831 ctx.Build(pctx, android.BuildParams{
832 Rule: android.WriteFile,
833 Output: out,
834 Description: "Writing " + out.String(),
835 Args: map[string]string{
836 "content": strings.Join(list, "\\n"),
837 },
838 })
839 return out
840 }
Jooyung Han097087b2019-10-22 19:32:18 +0900841
Jooyung Han0302a842019-10-30 18:43:49 +0900842 c.installedLlndkLibraries = android.SortedStringKeys(installedLlndkLibraries)
Jooyung Han097087b2019-10-22 19:32:18 +0900843
Jooyung Han0302a842019-10-30 18:43:49 +0900844 llndk := android.SortedStringMapValues(installedLlndkLibraries)
845 vndkcore := android.SortedStringMapValues(vndkCoreLibraries(ctx.Config()))
846 vndksp := android.SortedStringMapValues(vndkSpLibraries(ctx.Config()))
847 vndkprivate := android.SortedStringMapValues(vndkPrivateLibraries(ctx.Config()))
Jooyung Han0302a842019-10-30 18:43:49 +0900848
Inseob Kim242ef0c2019-10-22 20:15:20 +0900849 c.llndkLibrariesFile = installListFile(llndk, "llndk.libraries.txt")
Jooyung Han0302a842019-10-30 18:43:49 +0900850 c.vndkCoreLibrariesFile = installListFile(vndkcore, "vndkcore.libraries.txt")
851 c.vndkSpLibrariesFile = installListFile(vndksp, "vndksp.libraries.txt")
852 c.vndkPrivateLibrariesFile = installListFile(vndkprivate, "vndkprivate.libraries.txt")
Jooyung Han097087b2019-10-22 19:32:18 +0900853
Jooyung Han2216fb12019-11-06 16:46:15 +0900854 // Build list of vndk libs as merged & tagged & filter-out(libclang_rt):
Jooyung Han0302a842019-10-30 18:43:49 +0900855 // Since each target have different set of libclang_rt.* files,
856 // keep the common set of files in vndk.libraries.txt
857 var merged []string
Jooyung Han097087b2019-10-22 19:32:18 +0900858 filterOutLibClangRt := func(libList []string) (filtered []string) {
859 for _, lib := range libList {
860 if !strings.HasPrefix(lib, "libclang_rt.") {
861 filtered = append(filtered, lib)
862 }
863 }
864 return
865 }
866 merged = append(merged, addPrefix(filterOutLibClangRt(llndk), "LLNDK: ")...)
867 merged = append(merged, addPrefix(vndksp, "VNDK-SP: ")...)
868 merged = append(merged, addPrefix(filterOutLibClangRt(vndkcore), "VNDK-core: ")...)
869 merged = append(merged, addPrefix(vndkprivate, "VNDK-private: ")...)
Jooyung Han0302a842019-10-30 18:43:49 +0900870 c.vndkLibrariesFile = installListFile(merged, "vndk.libraries.txt")
871}
Jooyung Han097087b2019-10-22 19:32:18 +0900872
Jooyung Han0302a842019-10-30 18:43:49 +0900873func (c *vndkSnapshotSingleton) MakeVars(ctx android.MakeVarsContext) {
874 // Make uses LLNDK_MOVED_TO_APEX_LIBRARIES to avoid installing libraries on /system if
875 // they been moved to an apex.
876 movedToApexLlndkLibraries := []string{}
877 for _, lib := range c.installedLlndkLibraries {
878 // Skip bionic libs, they are handled in different manner
879 if android.DirectlyInAnyApex(&notOnHostContext{}, lib) && !isBionic(lib) {
880 movedToApexLlndkLibraries = append(movedToApexLlndkLibraries, lib)
881 }
882 }
883 ctx.Strict("LLNDK_MOVED_TO_APEX_LIBRARIES", strings.Join(movedToApexLlndkLibraries, " "))
884 ctx.Strict("LLNDK_LIBRARIES", strings.Join(c.installedLlndkLibraries, " "))
885 ctx.Strict("VNDK_CORE_LIBRARIES", strings.Join(android.SortedStringKeys(vndkCoreLibraries(ctx.Config())), " "))
886 ctx.Strict("VNDK_SAMEPROCESS_LIBRARIES", strings.Join(android.SortedStringKeys(vndkSpLibraries(ctx.Config())), " "))
887 ctx.Strict("VNDK_PRIVATE_LIBRARIES", strings.Join(android.SortedStringKeys(vndkPrivateLibraries(ctx.Config())), " "))
888 ctx.Strict("VNDK_USING_CORE_VARIANT_LIBRARIES", strings.Join(android.SortedStringKeys(vndkUsingCoreVariantLibraries(ctx.Config())), " "))
889
Jooyung Han0302a842019-10-30 18:43:49 +0900890 ctx.Strict("VNDK_LIBRARIES_FILE", c.vndkLibrariesFile.String())
Inseob Kim242ef0c2019-10-22 20:15:20 +0900891 ctx.Strict("SOONG_VNDK_SNAPSHOT_ZIP", c.vndkSnapshotZipFile.String())
Jooyung Han097087b2019-10-22 19:32:18 +0900892}