blob: 23bb095bcc87b5a97a4d4e4149a9baef2562b66f [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"
Jaewoong Jung4b79e982020-06-01 10:45:49 -070028 "android/soong/etc"
Colin Cross6e511a92020-07-27 21:26:48 -070029
30 "github.com/google/blueprint"
Justin Yun8effde42017-06-23 19:24:43 +090031)
32
Jooyung Han39edb6c2019-11-06 16:53:07 +090033const (
34 llndkLibrariesTxt = "llndk.libraries.txt"
35 vndkCoreLibrariesTxt = "vndkcore.libraries.txt"
36 vndkSpLibrariesTxt = "vndksp.libraries.txt"
37 vndkPrivateLibrariesTxt = "vndkprivate.libraries.txt"
38 vndkUsingCoreVariantLibrariesTxt = "vndkcorevariant.libraries.txt"
39)
40
41func VndkLibrariesTxtModules(vndkVersion string) []string {
42 if vndkVersion == "current" {
43 return []string{
44 llndkLibrariesTxt,
45 vndkCoreLibrariesTxt,
46 vndkSpLibrariesTxt,
47 vndkPrivateLibrariesTxt,
Jooyung Han39edb6c2019-11-06 16:53:07 +090048 }
49 }
50 // Snapshot vndks have their own *.libraries.VER.txt files.
51 // Note that snapshots don't have "vndkcorevariant.libraries.VER.txt"
52 return []string{
53 insertVndkVersion(llndkLibrariesTxt, vndkVersion),
54 insertVndkVersion(vndkCoreLibrariesTxt, vndkVersion),
55 insertVndkVersion(vndkSpLibrariesTxt, vndkVersion),
56 insertVndkVersion(vndkPrivateLibrariesTxt, vndkVersion),
57 }
58}
59
Justin Yun8effde42017-06-23 19:24:43 +090060type VndkProperties struct {
61 Vndk struct {
62 // declared as a VNDK or VNDK-SP module. The vendor variant
63 // will be installed in /system instead of /vendor partition.
64 //
Roland Levillaindfe75b32019-07-23 16:53:32 +010065 // `vendor_available` must be explicitly set to either true or
Jiyong Park82e2bf32017-08-16 14:05:54 +090066 // false together with `vndk: {enabled: true}`.
Justin Yun8effde42017-06-23 19:24:43 +090067 Enabled *bool
68
69 // declared as a VNDK-SP module, which is a subset of VNDK.
70 //
71 // `vndk: { enabled: true }` must set together.
72 //
73 // All these modules are allowed to link to VNDK-SP or LL-NDK
74 // modules only. Other dependency will cause link-type errors.
75 //
76 // If `support_system_process` is not set or set to false,
77 // the module is VNDK-core and can link to other VNDK-core,
78 // VNDK-SP or LL-NDK modules only.
79 Support_system_process *bool
Logan Chienf3511742017-10-31 18:04:35 +080080
81 // Extending another module
82 Extends *string
Justin Yun8effde42017-06-23 19:24:43 +090083 }
84}
85
86type vndkdep struct {
87 Properties VndkProperties
88}
89
90func (vndk *vndkdep) props() []interface{} {
91 return []interface{}{&vndk.Properties}
92}
93
94func (vndk *vndkdep) begin(ctx BaseModuleContext) {}
95
96func (vndk *vndkdep) deps(ctx BaseModuleContext, deps Deps) Deps {
97 return deps
98}
99
100func (vndk *vndkdep) isVndk() bool {
101 return Bool(vndk.Properties.Vndk.Enabled)
102}
103
104func (vndk *vndkdep) isVndkSp() bool {
105 return Bool(vndk.Properties.Vndk.Support_system_process)
106}
107
Logan Chienf3511742017-10-31 18:04:35 +0800108func (vndk *vndkdep) isVndkExt() bool {
109 return vndk.Properties.Vndk.Extends != nil
110}
111
112func (vndk *vndkdep) getVndkExtendsModuleName() string {
113 return String(vndk.Properties.Vndk.Extends)
114}
115
Justin Yun8effde42017-06-23 19:24:43 +0900116func (vndk *vndkdep) typeName() string {
117 if !vndk.isVndk() {
118 return "native:vendor"
119 }
Logan Chienf3511742017-10-31 18:04:35 +0800120 if !vndk.isVndkExt() {
121 if !vndk.isVndkSp() {
122 return "native:vendor:vndk"
123 }
124 return "native:vendor:vndksp"
Justin Yun8effde42017-06-23 19:24:43 +0900125 }
Logan Chienf3511742017-10-31 18:04:35 +0800126 if !vndk.isVndkSp() {
127 return "native:vendor:vndkext"
128 }
129 return "native:vendor:vndkspext"
Justin Yun8effde42017-06-23 19:24:43 +0900130}
131
Colin Cross6e511a92020-07-27 21:26:48 -0700132func (vndk *vndkdep) vndkCheckLinkType(ctx android.ModuleContext, to *Module, tag blueprint.DependencyTag) {
Justin Yun8effde42017-06-23 19:24:43 +0900133 if to.linker == nil {
134 return
135 }
Jiyong Park82e2bf32017-08-16 14:05:54 +0900136 if !vndk.isVndk() {
Justin Yun5f7f7e82019-11-18 19:52:14 +0900137 // Non-VNDK modules (those installed to /vendor, /product, or /system/product) can't depend
138 // on modules marked with vendor_available: false.
Jiyong Park82e2bf32017-08-16 14:05:54 +0900139 violation := false
Nan Zhang0007d812017-11-07 10:57:05 -0800140 if lib, ok := to.linker.(*llndkStubDecorator); ok && !Bool(lib.Properties.Vendor_available) {
Jiyong Park82e2bf32017-08-16 14:05:54 +0900141 violation = true
142 } else {
143 if _, ok := to.linker.(libraryInterface); ok && to.VendorProperties.Vendor_available != nil && !Bool(to.VendorProperties.Vendor_available) {
144 // Vendor_available == nil && !Bool(Vendor_available) should be okay since
Justin Yun5f7f7e82019-11-18 19:52:14 +0900145 // it means a vendor-only, or product-only library which is a valid dependency
146 // for non-VNDK modules.
Jiyong Park82e2bf32017-08-16 14:05:54 +0900147 violation = true
148 }
149 }
150 if violation {
151 ctx.ModuleErrorf("Vendor module that is not VNDK should not link to %q which is marked as `vendor_available: false`", to.Name())
152 }
153 }
Justin Yun8effde42017-06-23 19:24:43 +0900154 if lib, ok := to.linker.(*libraryDecorator); !ok || !lib.shared() {
155 // Check only shared libraries.
156 // Other (static and LL-NDK) libraries are allowed to link.
157 return
158 }
Ivan Lozano52767be2019-10-18 14:49:46 -0700159 if !to.UseVndk() {
Justin Yun8effde42017-06-23 19:24:43 +0900160 ctx.ModuleErrorf("(%s) should not link to %q which is not a vendor-available library",
161 vndk.typeName(), to.Name())
162 return
163 }
Logan Chienf3511742017-10-31 18:04:35 +0800164 if tag == vndkExtDepTag {
165 // Ensure `extends: "name"` property refers a vndk module that has vendor_available
166 // and has identical vndk properties.
167 if to.vndkdep == nil || !to.vndkdep.isVndk() {
168 ctx.ModuleErrorf("`extends` refers a non-vndk module %q", to.Name())
169 return
170 }
171 if vndk.isVndkSp() != to.vndkdep.isVndkSp() {
172 ctx.ModuleErrorf(
173 "`extends` refers a module %q with mismatched support_system_process",
174 to.Name())
175 return
176 }
177 if !Bool(to.VendorProperties.Vendor_available) {
178 ctx.ModuleErrorf(
179 "`extends` refers module %q which does not have `vendor_available: true`",
180 to.Name())
181 return
182 }
183 }
Justin Yun8effde42017-06-23 19:24:43 +0900184 if to.vndkdep == nil {
185 return
186 }
Logan Chienf3511742017-10-31 18:04:35 +0800187
Logan Chiend3c59a22018-03-29 14:08:15 +0800188 // Check the dependencies of VNDK shared libraries.
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100189 if err := vndkIsVndkDepAllowed(vndk, to.vndkdep); err != nil {
190 ctx.ModuleErrorf("(%s) should not link to %q (%s): %v",
191 vndk.typeName(), to.Name(), to.vndkdep.typeName(), err)
Logan Chienf3511742017-10-31 18:04:35 +0800192 return
193 }
Logan Chiend3c59a22018-03-29 14:08:15 +0800194}
Logan Chienf3511742017-10-31 18:04:35 +0800195
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100196func vndkIsVndkDepAllowed(from *vndkdep, to *vndkdep) error {
Logan Chiend3c59a22018-03-29 14:08:15 +0800197 // Check the dependencies of VNDK, VNDK-Ext, VNDK-SP, VNDK-SP-Ext and vendor modules.
198 if from.isVndkExt() {
199 if from.isVndkSp() {
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100200 if to.isVndk() && !to.isVndkSp() {
201 return errors.New("VNDK-SP extensions must not depend on VNDK or VNDK extensions")
202 }
203 return nil
Logan Chiend3c59a22018-03-29 14:08:15 +0800204 }
205 // VNDK-Ext may depend on VNDK, VNDK-Ext, VNDK-SP, VNDK-SP-Ext, or vendor libs.
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100206 return nil
Justin Yun8effde42017-06-23 19:24:43 +0900207 }
Logan Chiend3c59a22018-03-29 14:08:15 +0800208 if from.isVndk() {
209 if to.isVndkExt() {
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100210 return errors.New("VNDK-core and VNDK-SP must not depend on VNDK extensions")
Logan Chiend3c59a22018-03-29 14:08:15 +0800211 }
212 if from.isVndkSp() {
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100213 if !to.isVndkSp() {
214 return errors.New("VNDK-SP must only depend on VNDK-SP")
215 }
216 return nil
Logan Chiend3c59a22018-03-29 14:08:15 +0800217 }
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100218 if !to.isVndk() {
219 return errors.New("VNDK-core must only depend on VNDK-core or VNDK-SP")
220 }
221 return nil
Logan Chiend3c59a22018-03-29 14:08:15 +0800222 }
223 // Vendor modules may depend on VNDK, VNDK-Ext, VNDK-SP, VNDK-SP-Ext, or vendor libs.
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100224 return nil
Justin Yun8effde42017-06-23 19:24:43 +0900225}
Jiyong Parkd5b18a52017-08-03 21:22:50 +0900226
227var (
Jooyung Hana463f722019-11-01 08:45:59 +0900228 vndkCoreLibrariesKey = android.NewOnceKey("vndkCoreLibrarires")
229 vndkSpLibrariesKey = android.NewOnceKey("vndkSpLibrarires")
230 llndkLibrariesKey = android.NewOnceKey("llndkLibrarires")
231 vndkPrivateLibrariesKey = android.NewOnceKey("vndkPrivateLibrarires")
Kiyoung Kime1aa8ea2019-12-30 11:12:55 +0900232 vndkUsingCoreVariantLibrariesKey = android.NewOnceKey("vndkUsingCoreVariantLibraries")
Jooyung Hana463f722019-11-01 08:45:59 +0900233 vndkMustUseVendorVariantListKey = android.NewOnceKey("vndkMustUseVendorVariantListKey")
234 vndkLibrariesLock sync.Mutex
Inseob Kimae553032019-05-14 18:52:49 +0900235)
Inseob Kim1f086e22019-05-09 13:29:15 +0900236
Jooyung Han0302a842019-10-30 18:43:49 +0900237func vndkCoreLibraries(config android.Config) map[string]string {
Inseob Kim9516ee92019-05-09 10:56:13 +0900238 return config.Once(vndkCoreLibrariesKey, 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 vndkSpLibraries(config android.Config) map[string]string {
Inseob Kim9516ee92019-05-09 10:56:13 +0900244 return config.Once(vndkSpLibrariesKey, 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 Han0302a842019-10-30 18:43:49 +0900249func isLlndkLibrary(baseModuleName string, config android.Config) bool {
250 _, ok := llndkLibraries(config)[baseModuleName]
251 return ok
252}
253
254func llndkLibraries(config android.Config) map[string]string {
Inseob Kim9516ee92019-05-09 10:56:13 +0900255 return config.Once(llndkLibrariesKey, func() interface{} {
Jooyung Han0302a842019-10-30 18:43:49 +0900256 return make(map[string]string)
257 }).(map[string]string)
Inseob Kim9516ee92019-05-09 10:56:13 +0900258}
259
Jooyung Han0302a842019-10-30 18:43:49 +0900260func isVndkPrivateLibrary(baseModuleName string, config android.Config) bool {
261 _, ok := vndkPrivateLibraries(config)[baseModuleName]
262 return ok
263}
264
265func vndkPrivateLibraries(config android.Config) map[string]string {
Inseob Kim9516ee92019-05-09 10:56:13 +0900266 return config.Once(vndkPrivateLibrariesKey, func() interface{} {
Jooyung Han0302a842019-10-30 18:43:49 +0900267 return make(map[string]string)
268 }).(map[string]string)
Inseob Kim9516ee92019-05-09 10:56:13 +0900269}
270
Jooyung Han0302a842019-10-30 18:43:49 +0900271func vndkUsingCoreVariantLibraries(config android.Config) map[string]string {
Inseob Kim9516ee92019-05-09 10:56:13 +0900272 return config.Once(vndkUsingCoreVariantLibrariesKey, func() interface{} {
Jooyung Han0302a842019-10-30 18:43:49 +0900273 return make(map[string]string)
274 }).(map[string]string)
Inseob Kim9516ee92019-05-09 10:56:13 +0900275}
276
Jooyung Han097087b2019-10-22 19:32:18 +0900277func vndkMustUseVendorVariantList(cfg android.Config) []string {
278 return cfg.Once(vndkMustUseVendorVariantListKey, func() interface{} {
Jooyung Han097087b2019-10-22 19:32:18 +0900279 return config.VndkMustUseVendorVariantList
280 }).([]string)
281}
282
283// test may call this to override global configuration(config.VndkMustUseVendorVariantList)
284// when it is called, it must be before the first call to vndkMustUseVendorVariantList()
285func setVndkMustUseVendorVariantListForTest(config android.Config, mustUseVendorVariantList []string) {
Jooyung Hana463f722019-11-01 08:45:59 +0900286 config.Once(vndkMustUseVendorVariantListKey, func() interface{} {
Jooyung Han097087b2019-10-22 19:32:18 +0900287 return mustUseVendorVariantList
288 })
289}
290
Inseob Kim1f086e22019-05-09 13:29:15 +0900291func processLlndkLibrary(mctx android.BottomUpMutatorContext, m *Module) {
292 lib := m.linker.(*llndkStubDecorator)
Jooyung Han0302a842019-10-30 18:43:49 +0900293 name := m.BaseModuleName()
294 filename := m.BaseModuleName() + ".so"
Inseob Kim9516ee92019-05-09 10:56:13 +0900295
Inseob Kim1f086e22019-05-09 13:29:15 +0900296 vndkLibrariesLock.Lock()
297 defer vndkLibrariesLock.Unlock()
Inseob Kim9516ee92019-05-09 10:56:13 +0900298
Jooyung Han0302a842019-10-30 18:43:49 +0900299 llndkLibraries(mctx.Config())[name] = filename
Inseob Kim1f086e22019-05-09 13:29:15 +0900300 if !Bool(lib.Properties.Vendor_available) {
Jooyung Han0302a842019-10-30 18:43:49 +0900301 vndkPrivateLibraries(mctx.Config())[name] = filename
Jiyong Parkd5b18a52017-08-03 21:22:50 +0900302 }
Jooyung Han61b66e92020-03-21 14:21:46 +0000303 if mctx.OtherModuleExists(name) {
304 mctx.AddFarVariationDependencies(m.Target().Variations(), llndkImplDep, name)
305 }
Jiyong Parkd5b18a52017-08-03 21:22:50 +0900306}
Inseob Kim1f086e22019-05-09 13:29:15 +0900307
308func processVndkLibrary(mctx android.BottomUpMutatorContext, m *Module) {
Jooyung Han0302a842019-10-30 18:43:49 +0900309 name := m.BaseModuleName()
310 filename, err := getVndkFileName(m)
311 if err != nil {
312 panic(err)
313 }
Inseob Kim1f086e22019-05-09 13:29:15 +0900314
Jiyong Park2478e4e2020-05-18 09:30:14 +0000315 if m.HasStubsVariants() && name != "libz" {
316 // b/155456180 libz is the ONLY exception here. We don't want to make
317 // libz an LLNDK library because we in general can't guarantee that
318 // libz will behave consistently especially about the compression.
319 // i.e. the compressed output might be different across releases.
320 // As the library is an external one, it's risky to keep the compatibility
321 // promise if it becomes an LLNDK.
Jiyong Parkea97f512020-03-31 15:31:17 +0900322 mctx.PropertyErrorf("vndk.enabled", "This library provides stubs. Shouldn't be VNDK. Consider making it as LLNDK")
323 }
324
Inseob Kim1f086e22019-05-09 13:29:15 +0900325 vndkLibrariesLock.Lock()
326 defer vndkLibrariesLock.Unlock()
327
Jooyung Han097087b2019-10-22 19:32:18 +0900328 if inList(name, vndkMustUseVendorVariantList(mctx.Config())) {
329 m.Properties.MustUseVendorVariant = true
330 }
Jooyung Han0302a842019-10-30 18:43:49 +0900331 if mctx.DeviceConfig().VndkUseCoreVariant() && !m.Properties.MustUseVendorVariant {
332 vndkUsingCoreVariantLibraries(mctx.Config())[name] = filename
Inseob Kim1f086e22019-05-09 13:29:15 +0900333 }
Jooyung Han0302a842019-10-30 18:43:49 +0900334
Inseob Kim1f086e22019-05-09 13:29:15 +0900335 if m.vndkdep.isVndkSp() {
Jooyung Han0302a842019-10-30 18:43:49 +0900336 vndkSpLibraries(mctx.Config())[name] = filename
Inseob Kim1f086e22019-05-09 13:29:15 +0900337 } else {
Jooyung Han0302a842019-10-30 18:43:49 +0900338 vndkCoreLibraries(mctx.Config())[name] = filename
Inseob Kim1f086e22019-05-09 13:29:15 +0900339 }
340 if !Bool(m.VendorProperties.Vendor_available) {
Jooyung Han0302a842019-10-30 18:43:49 +0900341 vndkPrivateLibraries(mctx.Config())[name] = filename
Inseob Kim1f086e22019-05-09 13:29:15 +0900342 }
343}
344
Yo Chiang08fac0c2020-07-29 01:08:20 +0800345// Check for modules that mustn't be VNDK
Yo Chiangbba545e2020-06-09 16:15:37 +0800346func shouldSkipVndkMutator(m *Module) bool {
Jooyung Han31c470b2019-10-18 16:26:59 +0900347 if !m.Enabled() {
Yo Chiangbba545e2020-06-09 16:15:37 +0800348 return true
Jooyung Han31c470b2019-10-18 16:26:59 +0900349 }
Yo Chiangbba545e2020-06-09 16:15:37 +0800350 if !m.Device() {
351 // Skip non-device modules
352 return true
Jooyung Han87a7f302019-10-29 05:18:21 +0900353 }
Jooyung Han31c470b2019-10-18 16:26:59 +0900354 if m.Target().NativeBridge == android.NativeBridgeEnabled {
Yo Chiangbba545e2020-06-09 16:15:37 +0800355 // Skip native_bridge modules
356 return true
357 }
358 return false
359}
360
361func IsForVndkApex(mctx android.BottomUpMutatorContext, m *Module) bool {
362 if shouldSkipVndkMutator(m) {
Jooyung Han31c470b2019-10-18 16:26:59 +0900363 return false
364 }
365
366 // prebuilt vndk modules should match with device
367 // TODO(b/142675459): Use enabled: to select target device in vndk_prebuilt_shared
368 // When b/142675459 is landed, remove following check
369 if p, ok := m.linker.(*vndkPrebuiltLibraryDecorator); ok && !p.matchesWithDevice(mctx.DeviceConfig()) {
370 return false
371 }
372
373 if lib, ok := m.linker.(libraryInterface); ok {
Jooyung Han73d20d02020-03-27 16:06:55 +0900374 // VNDK APEX for VNDK-Lite devices will have VNDK-SP libraries from core variants
375 if mctx.DeviceConfig().VndkVersion() == "" {
376 // b/73296261: filter out libz.so because it is considered as LLNDK for VNDK-lite devices
377 if mctx.ModuleName() == "libz" {
378 return false
379 }
380 return m.ImageVariation().Variation == android.CoreVariation && lib.shared() && m.isVndkSp()
381 }
382
Justin Yun5f7f7e82019-11-18 19:52:14 +0900383 useCoreVariant := m.VndkVersion() == mctx.DeviceConfig().PlatformVndkVersion() &&
Jooyung Han87a7f302019-10-29 05:18:21 +0900384 mctx.DeviceConfig().VndkUseCoreVariant() && !m.MustUseVendorVariant()
Jooyung Hana57af4a2020-01-23 05:36:59 +0000385 return lib.shared() && m.inVendor() && m.IsVndk() && !m.isVndkExt() && !useCoreVariant
Jooyung Han31c470b2019-10-18 16:26:59 +0900386 }
387 return false
388}
389
Inseob Kim1f086e22019-05-09 13:29:15 +0900390// gather list of vndk-core, vndk-sp, and ll-ndk libs
391func VndkMutator(mctx android.BottomUpMutatorContext) {
392 m, ok := mctx.Module().(*Module)
393 if !ok {
394 return
395 }
Yo Chiangbba545e2020-06-09 16:15:37 +0800396
397 if shouldSkipVndkMutator(m) {
Justin Yun7390ea32019-09-08 11:34:06 +0900398 return
399 }
Inseob Kim1f086e22019-05-09 13:29:15 +0900400
401 if _, ok := m.linker.(*llndkStubDecorator); ok {
402 processLlndkLibrary(mctx, m)
403 return
404 }
405
406 lib, is_lib := m.linker.(*libraryDecorator)
407 prebuilt_lib, is_prebuilt_lib := m.linker.(*prebuiltLibraryLinker)
408
Inseob Kim64c43952019-08-26 16:52:35 +0900409 if (is_lib && lib.buildShared()) || (is_prebuilt_lib && prebuilt_lib.buildShared()) {
410 if m.vndkdep != nil && m.vndkdep.isVndk() && !m.vndkdep.isVndkExt() {
Inseob Kim1f086e22019-05-09 13:29:15 +0900411 processVndkLibrary(mctx, m)
412 return
413 }
414 }
415}
416
417func init() {
Jooyung Han39edb6c2019-11-06 16:53:07 +0900418 android.RegisterModuleType("vndk_libraries_txt", VndkLibrariesTxtFactory)
Inseob Kim1f086e22019-05-09 13:29:15 +0900419 android.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton)
Inseob Kim1f086e22019-05-09 13:29:15 +0900420}
421
Jooyung Han2216fb12019-11-06 16:46:15 +0900422type vndkLibrariesTxt struct {
423 android.ModuleBase
424 outputFile android.OutputPath
425}
426
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700427var _ etc.PrebuiltEtcModule = &vndkLibrariesTxt{}
Jooyung Han39edb6c2019-11-06 16:53:07 +0900428var _ android.OutputFileProducer = &vndkLibrariesTxt{}
429
Jooyung Han2216fb12019-11-06 16:46:15 +0900430// vndk_libraries_txt is a special kind of module type in that it name is one of
431// - llndk.libraries.txt
432// - vndkcore.libraries.txt
433// - vndksp.libraries.txt
434// - vndkprivate.libraries.txt
435// - vndkcorevariant.libraries.txt
436// A module behaves like a prebuilt_etc but its content is generated by soong.
437// By being a soong module, these files can be referenced by other soong modules.
438// For example, apex_vndk can depend on these files as prebuilt.
Jooyung Han39edb6c2019-11-06 16:53:07 +0900439func VndkLibrariesTxtFactory() android.Module {
Jooyung Han2216fb12019-11-06 16:46:15 +0900440 m := &vndkLibrariesTxt{}
441 android.InitAndroidModule(m)
442 return m
443}
444
445func insertVndkVersion(filename string, vndkVersion string) string {
446 if index := strings.LastIndex(filename, "."); index != -1 {
447 return filename[:index] + "." + vndkVersion + filename[index:]
448 }
449 return filename
450}
451
452func (txt *vndkLibrariesTxt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
453 var list []string
454 switch txt.Name() {
Jooyung Han39edb6c2019-11-06 16:53:07 +0900455 case llndkLibrariesTxt:
Jooyung Han2216fb12019-11-06 16:46:15 +0900456 for _, filename := range android.SortedStringMapValues(llndkLibraries(ctx.Config())) {
457 if strings.HasPrefix(filename, "libclang_rt.hwasan-") {
458 continue
459 }
460 list = append(list, filename)
461 }
Jooyung Han39edb6c2019-11-06 16:53:07 +0900462 case vndkCoreLibrariesTxt:
Jooyung Han2216fb12019-11-06 16:46:15 +0900463 list = android.SortedStringMapValues(vndkCoreLibraries(ctx.Config()))
Jooyung Han39edb6c2019-11-06 16:53:07 +0900464 case vndkSpLibrariesTxt:
Jooyung Han2216fb12019-11-06 16:46:15 +0900465 list = android.SortedStringMapValues(vndkSpLibraries(ctx.Config()))
Jooyung Han39edb6c2019-11-06 16:53:07 +0900466 case vndkPrivateLibrariesTxt:
Jooyung Han2216fb12019-11-06 16:46:15 +0900467 list = android.SortedStringMapValues(vndkPrivateLibraries(ctx.Config()))
Jooyung Han39edb6c2019-11-06 16:53:07 +0900468 case vndkUsingCoreVariantLibrariesTxt:
Jooyung Han2216fb12019-11-06 16:46:15 +0900469 list = android.SortedStringMapValues(vndkUsingCoreVariantLibraries(ctx.Config()))
470 default:
471 ctx.ModuleErrorf("name(%s) is unknown.", txt.Name())
472 return
473 }
474
Kiyoung Kime1aa8ea2019-12-30 11:12:55 +0900475 var filename string
476 if txt.Name() != vndkUsingCoreVariantLibrariesTxt {
477 filename = insertVndkVersion(txt.Name(), ctx.DeviceConfig().PlatformVndkVersion())
478 } else {
479 filename = txt.Name()
480 }
481
Jooyung Han2216fb12019-11-06 16:46:15 +0900482 txt.outputFile = android.PathForModuleOut(ctx, filename).OutputPath
483 ctx.Build(pctx, android.BuildParams{
484 Rule: android.WriteFile,
485 Output: txt.outputFile,
486 Description: "Writing " + txt.outputFile.String(),
487 Args: map[string]string{
488 "content": strings.Join(list, "\\n"),
489 },
490 })
491
492 installPath := android.PathForModuleInstall(ctx, "etc")
493 ctx.InstallFile(installPath, filename, txt.outputFile)
494}
495
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900496func (txt *vndkLibrariesTxt) AndroidMkEntries() []android.AndroidMkEntries {
497 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jooyung Han2216fb12019-11-06 16:46:15 +0900498 Class: "ETC",
499 OutputFile: android.OptionalPathForPath(txt.outputFile),
500 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
501 func(entries *android.AndroidMkEntries) {
502 entries.SetString("LOCAL_MODULE_STEM", txt.outputFile.Base())
503 },
504 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900505 }}
Jooyung Han2216fb12019-11-06 16:46:15 +0900506}
507
Jooyung Han39edb6c2019-11-06 16:53:07 +0900508func (txt *vndkLibrariesTxt) OutputFile() android.OutputPath {
509 return txt.outputFile
510}
511
512func (txt *vndkLibrariesTxt) OutputFiles(tag string) (android.Paths, error) {
513 return android.Paths{txt.outputFile}, nil
514}
515
516func (txt *vndkLibrariesTxt) SubDir() string {
517 return ""
518}
519
Inseob Kim1f086e22019-05-09 13:29:15 +0900520func VndkSnapshotSingleton() android.Singleton {
521 return &vndkSnapshotSingleton{}
522}
523
Jooyung Han0302a842019-10-30 18:43:49 +0900524type vndkSnapshotSingleton struct {
Jooyung Han39edb6c2019-11-06 16:53:07 +0900525 vndkLibrariesFile android.OutputPath
526 vndkSnapshotZipFile android.OptionalPath
Jooyung Han0302a842019-10-30 18:43:49 +0900527}
Inseob Kim1f086e22019-05-09 13:29:15 +0900528
Inseob Kimeda2e9c2020-03-03 22:06:32 +0900529func isVndkSnapshotLibrary(config android.DeviceConfig, m *Module) (i snapshotLibraryInterface, vndkType string, isVndkSnapshotLib bool) {
530 if m.Target().NativeBridge == android.NativeBridgeEnabled {
531 return nil, "", false
532 }
533 if !m.inVendor() || !m.installable() || m.isSnapshotPrebuilt() {
534 return nil, "", false
535 }
536 l, ok := m.linker.(snapshotLibraryInterface)
537 if !ok || !l.shared() {
538 return nil, "", false
539 }
540 if m.VndkVersion() == config.PlatformVndkVersion() && m.IsVndk() && !m.isVndkExt() {
541 if m.isVndkSp() {
542 return l, "vndk-sp", true
543 } else {
544 return l, "vndk-core", true
545 }
546 }
547
548 return nil, "", false
549}
550
Inseob Kim1f086e22019-05-09 13:29:15 +0900551func (c *vndkSnapshotSingleton) GenerateBuildActions(ctx android.SingletonContext) {
Jooyung Han0302a842019-10-30 18:43:49 +0900552 // build these files even if PlatformVndkVersion or BoardVndkVersion is not set
553 c.buildVndkLibrariesTxtFiles(ctx)
554
Inseob Kim1f086e22019-05-09 13:29:15 +0900555 // BOARD_VNDK_VERSION must be set to 'current' in order to generate a VNDK snapshot.
556 if ctx.DeviceConfig().VndkVersion() != "current" {
557 return
558 }
559
560 if ctx.DeviceConfig().PlatformVndkVersion() == "" {
561 return
562 }
563
Inseob Kim242ef0c2019-10-22 20:15:20 +0900564 var snapshotOutputs android.Paths
565
566 /*
567 VNDK snapshot zipped artifacts directory structure:
568 {SNAPSHOT_ARCH}/
569 arch-{TARGET_ARCH}-{TARGET_ARCH_VARIANT}/
570 shared/
571 vndk-core/
572 (VNDK-core libraries, e.g. libbinder.so)
573 vndk-sp/
574 (VNDK-SP libraries, e.g. libc++.so)
575 arch-{TARGET_2ND_ARCH}-{TARGET_2ND_ARCH_VARIANT}/
576 shared/
577 vndk-core/
578 (VNDK-core libraries, e.g. libbinder.so)
579 vndk-sp/
580 (VNDK-SP libraries, e.g. libc++.so)
581 binder32/
582 (This directory is newly introduced in v28 (Android P) to hold
583 prebuilts built for 32-bit binder interface.)
584 arch-{TARGET_ARCH}-{TARGE_ARCH_VARIANT}/
585 ...
586 configs/
587 (various *.txt configuration files)
588 include/
589 (header files of same directory structure with source tree)
590 NOTICE_FILES/
591 (notice files of libraries, e.g. libcutils.so.txt)
592 */
Inseob Kim1f086e22019-05-09 13:29:15 +0900593
594 snapshotDir := "vndk-snapshot"
Inseob Kim242ef0c2019-10-22 20:15:20 +0900595 snapshotArchDir := filepath.Join(snapshotDir, ctx.DeviceConfig().DeviceArch())
Inseob Kim1f086e22019-05-09 13:29:15 +0900596
Inseob Kim242ef0c2019-10-22 20:15:20 +0900597 configsDir := filepath.Join(snapshotArchDir, "configs")
598 noticeDir := filepath.Join(snapshotArchDir, "NOTICE_FILES")
599 includeDir := filepath.Join(snapshotArchDir, "include")
600
Inseob Kim242ef0c2019-10-22 20:15:20 +0900601 // set of notice files copied.
Inseob Kim1f086e22019-05-09 13:29:15 +0900602 noticeBuilt := make(map[string]bool)
603
Inseob Kim242ef0c2019-10-22 20:15:20 +0900604 // paths of VNDK modules for GPL license checking
605 modulePaths := make(map[string]string)
606
607 // actual module names of .so files
608 // e.g. moduleNames["libprotobuf-cpp-full-3.9.1.so"] = "libprotobuf-cpp-full"
609 moduleNames := make(map[string]string)
610
Inseob Kim8471cda2019-11-15 09:59:12 +0900611 var headers android.Paths
Inseob Kim242ef0c2019-10-22 20:15:20 +0900612
Inseob Kim8471cda2019-11-15 09:59:12 +0900613 installVndkSnapshotLib := func(m *Module, l snapshotLibraryInterface, vndkType string) (android.Paths, bool) {
Inseob Kim242ef0c2019-10-22 20:15:20 +0900614 var ret android.Paths
615
Inseob Kim8471cda2019-11-15 09:59:12 +0900616 targetArch := "arch-" + m.Target().Arch.ArchType.String()
617 if m.Target().Arch.ArchVariant != "" {
618 targetArch += "-" + m.Target().Arch.ArchVariant
Inseob Kim242ef0c2019-10-22 20:15:20 +0900619 }
Inseob Kimae553032019-05-14 18:52:49 +0900620
Inseob Kim8471cda2019-11-15 09:59:12 +0900621 libPath := m.outputFile.Path()
622 snapshotLibOut := filepath.Join(snapshotArchDir, targetArch, "shared", vndkType, libPath.Base())
623 ret = append(ret, copyFile(ctx, libPath, snapshotLibOut))
624
Inseob Kimae553032019-05-14 18:52:49 +0900625 if ctx.Config().VndkSnapshotBuildArtifacts() {
626 prop := struct {
627 ExportedDirs []string `json:",omitempty"`
628 ExportedSystemDirs []string `json:",omitempty"`
629 ExportedFlags []string `json:",omitempty"`
630 RelativeInstallPath string `json:",omitempty"`
631 }{}
632 prop.ExportedFlags = l.exportedFlags()
Jiyong Park74955042019-10-22 20:19:51 +0900633 prop.ExportedDirs = l.exportedDirs().Strings()
634 prop.ExportedSystemDirs = l.exportedSystemDirs().Strings()
Inseob Kimae553032019-05-14 18:52:49 +0900635 prop.RelativeInstallPath = m.RelativeInstallPath()
636
Inseob Kim242ef0c2019-10-22 20:15:20 +0900637 propOut := snapshotLibOut + ".json"
Inseob Kimae553032019-05-14 18:52:49 +0900638
639 j, err := json.Marshal(prop)
640 if err != nil {
641 ctx.Errorf("json marshal to %q failed: %#v", propOut, err)
Inseob Kim242ef0c2019-10-22 20:15:20 +0900642 return nil, false
Inseob Kimae553032019-05-14 18:52:49 +0900643 }
Inseob Kim8471cda2019-11-15 09:59:12 +0900644 ret = append(ret, writeStringToFile(ctx, string(j), propOut))
Inseob Kimae553032019-05-14 18:52:49 +0900645 }
Inseob Kim242ef0c2019-10-22 20:15:20 +0900646 return ret, true
Inseob Kimae553032019-05-14 18:52:49 +0900647 }
648
Inseob Kim1f086e22019-05-09 13:29:15 +0900649 ctx.VisitAllModules(func(module android.Module) {
650 m, ok := module.(*Module)
Inseob Kimae553032019-05-14 18:52:49 +0900651 if !ok || !m.Enabled() {
Inseob Kim1f086e22019-05-09 13:29:15 +0900652 return
653 }
654
Inseob Kimeda2e9c2020-03-03 22:06:32 +0900655 l, vndkType, ok := isVndkSnapshotLibrary(ctx.DeviceConfig(), m)
Inseob Kimae553032019-05-14 18:52:49 +0900656 if !ok {
dimitry51ea18a2019-05-20 10:39:52 +0200657 return
658 }
659
Inseob Kim8471cda2019-11-15 09:59:12 +0900660 // install .so files for appropriate modules.
661 // Also install .json files if VNDK_SNAPSHOT_BUILD_ARTIFACTS
Inseob Kim242ef0c2019-10-22 20:15:20 +0900662 libs, ok := installVndkSnapshotLib(m, l, vndkType)
Inseob Kimae553032019-05-14 18:52:49 +0900663 if !ok {
Inseob Kim1f086e22019-05-09 13:29:15 +0900664 return
665 }
Inseob Kim242ef0c2019-10-22 20:15:20 +0900666 snapshotOutputs = append(snapshotOutputs, libs...)
Inseob Kim1f086e22019-05-09 13:29:15 +0900667
Inseob Kim8471cda2019-11-15 09:59:12 +0900668 // These are for generating module_names.txt and module_paths.txt
669 stem := m.outputFile.Path().Base()
670 moduleNames[stem] = ctx.ModuleName(m)
671 modulePaths[stem] = ctx.ModuleDir(m)
672
Bob Badoura75b0572020-02-18 20:21:55 -0800673 if len(m.NoticeFiles()) > 0 {
Inseob Kim8471cda2019-11-15 09:59:12 +0900674 noticeName := stem + ".txt"
675 // skip already copied notice file
676 if _, ok := noticeBuilt[noticeName]; !ok {
677 noticeBuilt[noticeName] = true
Bob Badoura75b0572020-02-18 20:21:55 -0800678 snapshotOutputs = append(snapshotOutputs, combineNotices(
679 ctx, m.NoticeFiles(), filepath.Join(noticeDir, noticeName)))
Inseob Kim8471cda2019-11-15 09:59:12 +0900680 }
681 }
682
683 if ctx.Config().VndkSnapshotBuildArtifacts() {
Inseob Kimeda2e9c2020-03-03 22:06:32 +0900684 headers = append(headers, l.snapshotHeaders()...)
Inseob Kimae553032019-05-14 18:52:49 +0900685 }
686 })
Inseob Kim1f086e22019-05-09 13:29:15 +0900687
Inseob Kim8471cda2019-11-15 09:59:12 +0900688 // install all headers after removing duplicates
689 for _, header := range android.FirstUniquePaths(headers) {
690 snapshotOutputs = append(snapshotOutputs, copyFile(
691 ctx, header, filepath.Join(includeDir, header.String())))
Inseob Kimae553032019-05-14 18:52:49 +0900692 }
693
Jooyung Han39edb6c2019-11-06 16:53:07 +0900694 // install *.libraries.txt except vndkcorevariant.libraries.txt
695 ctx.VisitAllModules(func(module android.Module) {
696 m, ok := module.(*vndkLibrariesTxt)
697 if !ok || !m.Enabled() || m.Name() == vndkUsingCoreVariantLibrariesTxt {
698 return
699 }
Inseob Kim8471cda2019-11-15 09:59:12 +0900700 snapshotOutputs = append(snapshotOutputs, copyFile(
701 ctx, m.OutputFile(), filepath.Join(configsDir, m.Name())))
Jooyung Han39edb6c2019-11-06 16:53:07 +0900702 })
Inseob Kim1f086e22019-05-09 13:29:15 +0900703
Inseob Kim242ef0c2019-10-22 20:15:20 +0900704 /*
705 Dump a map to a list file as:
Inseob Kim1f086e22019-05-09 13:29:15 +0900706
Inseob Kim242ef0c2019-10-22 20:15:20 +0900707 {key1} {value1}
708 {key2} {value2}
709 ...
710 */
711 installMapListFile := func(m map[string]string, path string) android.OutputPath {
712 var txtBuilder strings.Builder
713 for idx, k := range android.SortedStringKeys(m) {
714 if idx > 0 {
715 txtBuilder.WriteString("\\n")
716 }
717 txtBuilder.WriteString(k)
718 txtBuilder.WriteString(" ")
719 txtBuilder.WriteString(m[k])
Inseob Kim1f086e22019-05-09 13:29:15 +0900720 }
Inseob Kim8471cda2019-11-15 09:59:12 +0900721 return writeStringToFile(ctx, txtBuilder.String(), path)
Inseob Kim1f086e22019-05-09 13:29:15 +0900722 }
723
Inseob Kim242ef0c2019-10-22 20:15:20 +0900724 /*
725 module_paths.txt contains paths on which VNDK modules are defined.
726 e.g.,
727 libbase.so system/core/base
728 libc.so bionic/libc
729 ...
730 */
731 snapshotOutputs = append(snapshotOutputs, installMapListFile(modulePaths, filepath.Join(configsDir, "module_paths.txt")))
732
733 /*
734 module_names.txt contains names as which VNDK modules are defined,
735 because output filename and module name can be different with stem and suffix properties.
736
737 e.g.,
738 libcutils.so libcutils
739 libprotobuf-cpp-full-3.9.2.so libprotobuf-cpp-full
740 ...
741 */
742 snapshotOutputs = append(snapshotOutputs, installMapListFile(moduleNames, filepath.Join(configsDir, "module_names.txt")))
743
744 // All artifacts are ready. Sort them to normalize ninja and then zip.
745 sort.Slice(snapshotOutputs, func(i, j int) bool {
746 return snapshotOutputs[i].String() < snapshotOutputs[j].String()
747 })
748
749 zipPath := android.PathForOutput(ctx, snapshotDir, "android-vndk-"+ctx.DeviceConfig().DeviceArch()+".zip")
750 zipRule := android.NewRuleBuilder()
751
Inseob Kim8471cda2019-11-15 09:59:12 +0900752 // filenames in rspfile from FlagWithRspFileInputList might be single-quoted. Remove it with xargs
Inseob Kim242ef0c2019-10-22 20:15:20 +0900753 snapshotOutputList := android.PathForOutput(ctx, snapshotDir, "android-vndk-"+ctx.DeviceConfig().DeviceArch()+"_list")
754 zipRule.Command().
Inseob Kim8471cda2019-11-15 09:59:12 +0900755 Text("tr").
756 FlagWithArg("-d ", "\\'").
757 FlagWithRspFileInputList("< ", snapshotOutputs).
758 FlagWithOutput("> ", snapshotOutputList)
Inseob Kim242ef0c2019-10-22 20:15:20 +0900759
760 zipRule.Temporary(snapshotOutputList)
761
762 zipRule.Command().
763 BuiltTool(ctx, "soong_zip").
764 FlagWithOutput("-o ", zipPath).
765 FlagWithArg("-C ", android.PathForOutput(ctx, snapshotDir).String()).
766 FlagWithInput("-l ", snapshotOutputList)
767
768 zipRule.Build(pctx, ctx, zipPath.String(), "vndk snapshot "+zipPath.String())
Inseob Kim8471cda2019-11-15 09:59:12 +0900769 zipRule.DeleteTemporaryFiles()
Inseob Kim242ef0c2019-10-22 20:15:20 +0900770 c.vndkSnapshotZipFile = android.OptionalPathForPath(zipPath)
Inseob Kim1f086e22019-05-09 13:29:15 +0900771}
Jooyung Han097087b2019-10-22 19:32:18 +0900772
Jooyung Han0302a842019-10-30 18:43:49 +0900773func getVndkFileName(m *Module) (string, error) {
774 if library, ok := m.linker.(*libraryDecorator); ok {
775 return library.getLibNameHelper(m.BaseModuleName(), true) + ".so", nil
776 }
777 if prebuilt, ok := m.linker.(*prebuiltLibraryLinker); ok {
778 return prebuilt.libraryDecorator.getLibNameHelper(m.BaseModuleName(), true) + ".so", nil
779 }
780 return "", fmt.Errorf("VNDK library should have libraryDecorator or prebuiltLibraryLinker as linker: %T", m.linker)
Jooyung Han097087b2019-10-22 19:32:18 +0900781}
782
783func (c *vndkSnapshotSingleton) buildVndkLibrariesTxtFiles(ctx android.SingletonContext) {
Jooyung Han39edb6c2019-11-06 16:53:07 +0900784 llndk := android.SortedStringMapValues(llndkLibraries(ctx.Config()))
Jooyung Han0302a842019-10-30 18:43:49 +0900785 vndkcore := android.SortedStringMapValues(vndkCoreLibraries(ctx.Config()))
786 vndksp := android.SortedStringMapValues(vndkSpLibraries(ctx.Config()))
787 vndkprivate := android.SortedStringMapValues(vndkPrivateLibraries(ctx.Config()))
Jooyung Han0302a842019-10-30 18:43:49 +0900788
Jooyung Han2216fb12019-11-06 16:46:15 +0900789 // Build list of vndk libs as merged & tagged & filter-out(libclang_rt):
Jooyung Han0302a842019-10-30 18:43:49 +0900790 // Since each target have different set of libclang_rt.* files,
791 // keep the common set of files in vndk.libraries.txt
792 var merged []string
Jooyung Han097087b2019-10-22 19:32:18 +0900793 filterOutLibClangRt := func(libList []string) (filtered []string) {
794 for _, lib := range libList {
795 if !strings.HasPrefix(lib, "libclang_rt.") {
796 filtered = append(filtered, lib)
797 }
798 }
799 return
800 }
801 merged = append(merged, addPrefix(filterOutLibClangRt(llndk), "LLNDK: ")...)
802 merged = append(merged, addPrefix(vndksp, "VNDK-SP: ")...)
803 merged = append(merged, addPrefix(filterOutLibClangRt(vndkcore), "VNDK-core: ")...)
804 merged = append(merged, addPrefix(vndkprivate, "VNDK-private: ")...)
Jooyung Han39edb6c2019-11-06 16:53:07 +0900805 c.vndkLibrariesFile = android.PathForOutput(ctx, "vndk", "vndk.libraries.txt")
806 ctx.Build(pctx, android.BuildParams{
807 Rule: android.WriteFile,
808 Output: c.vndkLibrariesFile,
809 Description: "Writing " + c.vndkLibrariesFile.String(),
810 Args: map[string]string{
811 "content": strings.Join(merged, "\\n"),
812 },
813 })
Jooyung Han0302a842019-10-30 18:43:49 +0900814}
Jooyung Han097087b2019-10-22 19:32:18 +0900815
Jooyung Han0302a842019-10-30 18:43:49 +0900816func (c *vndkSnapshotSingleton) MakeVars(ctx android.MakeVarsContext) {
817 // Make uses LLNDK_MOVED_TO_APEX_LIBRARIES to avoid installing libraries on /system if
818 // they been moved to an apex.
819 movedToApexLlndkLibraries := []string{}
Jooyung Han39edb6c2019-11-06 16:53:07 +0900820 for lib := range llndkLibraries(ctx.Config()) {
Jooyung Han0302a842019-10-30 18:43:49 +0900821 // Skip bionic libs, they are handled in different manner
822 if android.DirectlyInAnyApex(&notOnHostContext{}, lib) && !isBionic(lib) {
823 movedToApexLlndkLibraries = append(movedToApexLlndkLibraries, lib)
824 }
825 }
826 ctx.Strict("LLNDK_MOVED_TO_APEX_LIBRARIES", strings.Join(movedToApexLlndkLibraries, " "))
Jooyung Han39edb6c2019-11-06 16:53:07 +0900827
828 // Make uses LLNDK_LIBRARIES to determine which libraries to install.
829 // HWASAN is only part of the LL-NDK in builds in which libc depends on HWASAN.
830 // Therefore, by removing the library here, we cause it to only be installed if libc
831 // depends on it.
832 installedLlndkLibraries := []string{}
833 for lib := range llndkLibraries(ctx.Config()) {
834 if strings.HasPrefix(lib, "libclang_rt.hwasan-") {
835 continue
836 }
837 installedLlndkLibraries = append(installedLlndkLibraries, lib)
838 }
839 sort.Strings(installedLlndkLibraries)
840 ctx.Strict("LLNDK_LIBRARIES", strings.Join(installedLlndkLibraries, " "))
841
Jooyung Han0302a842019-10-30 18:43:49 +0900842 ctx.Strict("VNDK_CORE_LIBRARIES", strings.Join(android.SortedStringKeys(vndkCoreLibraries(ctx.Config())), " "))
843 ctx.Strict("VNDK_SAMEPROCESS_LIBRARIES", strings.Join(android.SortedStringKeys(vndkSpLibraries(ctx.Config())), " "))
844 ctx.Strict("VNDK_PRIVATE_LIBRARIES", strings.Join(android.SortedStringKeys(vndkPrivateLibraries(ctx.Config())), " "))
845 ctx.Strict("VNDK_USING_CORE_VARIANT_LIBRARIES", strings.Join(android.SortedStringKeys(vndkUsingCoreVariantLibraries(ctx.Config())), " "))
846
Jooyung Han0302a842019-10-30 18:43:49 +0900847 ctx.Strict("VNDK_LIBRARIES_FILE", c.vndkLibrariesFile.String())
Inseob Kim242ef0c2019-10-22 20:15:20 +0900848 ctx.Strict("SOONG_VNDK_SNAPSHOT_ZIP", c.vndkSnapshotZipFile.String())
Jooyung Han097087b2019-10-22 19:32:18 +0900849}