blob: 04b865f6bc0c6f5ba930555e41e64187eea4674e [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"
Justin Yun8effde42017-06-23 19:24:43 +090029)
30
Jooyung Han39edb6c2019-11-06 16:53:07 +090031const (
32 llndkLibrariesTxt = "llndk.libraries.txt"
33 vndkCoreLibrariesTxt = "vndkcore.libraries.txt"
34 vndkSpLibrariesTxt = "vndksp.libraries.txt"
35 vndkPrivateLibrariesTxt = "vndkprivate.libraries.txt"
36 vndkUsingCoreVariantLibrariesTxt = "vndkcorevariant.libraries.txt"
37)
38
39func VndkLibrariesTxtModules(vndkVersion string) []string {
40 if vndkVersion == "current" {
41 return []string{
42 llndkLibrariesTxt,
43 vndkCoreLibrariesTxt,
44 vndkSpLibrariesTxt,
45 vndkPrivateLibrariesTxt,
Jooyung Han39edb6c2019-11-06 16:53:07 +090046 }
47 }
48 // Snapshot vndks have their own *.libraries.VER.txt files.
49 // Note that snapshots don't have "vndkcorevariant.libraries.VER.txt"
50 return []string{
51 insertVndkVersion(llndkLibrariesTxt, vndkVersion),
52 insertVndkVersion(vndkCoreLibrariesTxt, vndkVersion),
53 insertVndkVersion(vndkSpLibrariesTxt, vndkVersion),
54 insertVndkVersion(vndkPrivateLibrariesTxt, vndkVersion),
55 }
56}
57
Justin Yun8effde42017-06-23 19:24:43 +090058type VndkProperties struct {
59 Vndk struct {
60 // declared as a VNDK or VNDK-SP module. The vendor variant
61 // will be installed in /system instead of /vendor partition.
62 //
Roland Levillaindfe75b32019-07-23 16:53:32 +010063 // `vendor_available` must be explicitly set to either true or
Jiyong Park82e2bf32017-08-16 14:05:54 +090064 // false together with `vndk: {enabled: true}`.
Justin Yun8effde42017-06-23 19:24:43 +090065 Enabled *bool
66
67 // declared as a VNDK-SP module, which is a subset of VNDK.
68 //
69 // `vndk: { enabled: true }` must set together.
70 //
71 // All these modules are allowed to link to VNDK-SP or LL-NDK
72 // modules only. Other dependency will cause link-type errors.
73 //
74 // If `support_system_process` is not set or set to false,
75 // the module is VNDK-core and can link to other VNDK-core,
76 // VNDK-SP or LL-NDK modules only.
77 Support_system_process *bool
Logan Chienf3511742017-10-31 18:04:35 +080078
79 // Extending another module
80 Extends *string
Justin Yun8effde42017-06-23 19:24:43 +090081 }
82}
83
84type vndkdep struct {
85 Properties VndkProperties
86}
87
88func (vndk *vndkdep) props() []interface{} {
89 return []interface{}{&vndk.Properties}
90}
91
92func (vndk *vndkdep) begin(ctx BaseModuleContext) {}
93
94func (vndk *vndkdep) deps(ctx BaseModuleContext, deps Deps) Deps {
95 return deps
96}
97
98func (vndk *vndkdep) isVndk() bool {
99 return Bool(vndk.Properties.Vndk.Enabled)
100}
101
102func (vndk *vndkdep) isVndkSp() bool {
103 return Bool(vndk.Properties.Vndk.Support_system_process)
104}
105
Logan Chienf3511742017-10-31 18:04:35 +0800106func (vndk *vndkdep) isVndkExt() bool {
107 return vndk.Properties.Vndk.Extends != nil
108}
109
110func (vndk *vndkdep) getVndkExtendsModuleName() string {
111 return String(vndk.Properties.Vndk.Extends)
112}
113
Justin Yun8effde42017-06-23 19:24:43 +0900114func (vndk *vndkdep) typeName() string {
115 if !vndk.isVndk() {
116 return "native:vendor"
117 }
Logan Chienf3511742017-10-31 18:04:35 +0800118 if !vndk.isVndkExt() {
119 if !vndk.isVndkSp() {
120 return "native:vendor:vndk"
121 }
122 return "native:vendor:vndksp"
Justin Yun8effde42017-06-23 19:24:43 +0900123 }
Logan Chienf3511742017-10-31 18:04:35 +0800124 if !vndk.isVndkSp() {
125 return "native:vendor:vndkext"
126 }
127 return "native:vendor:vndkspext"
Justin Yun8effde42017-06-23 19:24:43 +0900128}
129
Ivan Lozano183a3212019-10-18 14:18:45 -0700130func (vndk *vndkdep) vndkCheckLinkType(ctx android.ModuleContext, to *Module, tag DependencyTag) {
Justin Yun8effde42017-06-23 19:24:43 +0900131 if to.linker == nil {
132 return
133 }
Jiyong Park82e2bf32017-08-16 14:05:54 +0900134 if !vndk.isVndk() {
Justin Yun5f7f7e82019-11-18 19:52:14 +0900135 // Non-VNDK modules (those installed to /vendor, /product, or /system/product) can't depend
136 // on modules marked with vendor_available: false.
Jiyong Park82e2bf32017-08-16 14:05:54 +0900137 violation := false
Nan Zhang0007d812017-11-07 10:57:05 -0800138 if lib, ok := to.linker.(*llndkStubDecorator); ok && !Bool(lib.Properties.Vendor_available) {
Jiyong Park82e2bf32017-08-16 14:05:54 +0900139 violation = true
140 } else {
141 if _, ok := to.linker.(libraryInterface); ok && to.VendorProperties.Vendor_available != nil && !Bool(to.VendorProperties.Vendor_available) {
142 // Vendor_available == nil && !Bool(Vendor_available) should be okay since
Justin Yun5f7f7e82019-11-18 19:52:14 +0900143 // it means a vendor-only, or product-only library which is a valid dependency
144 // for non-VNDK modules.
Jiyong Park82e2bf32017-08-16 14:05:54 +0900145 violation = true
146 }
147 }
148 if violation {
149 ctx.ModuleErrorf("Vendor module that is not VNDK should not link to %q which is marked as `vendor_available: false`", to.Name())
150 }
151 }
Justin Yun8effde42017-06-23 19:24:43 +0900152 if lib, ok := to.linker.(*libraryDecorator); !ok || !lib.shared() {
153 // Check only shared libraries.
154 // Other (static and LL-NDK) libraries are allowed to link.
155 return
156 }
Ivan Lozano52767be2019-10-18 14:49:46 -0700157 if !to.UseVndk() {
Justin Yun8effde42017-06-23 19:24:43 +0900158 ctx.ModuleErrorf("(%s) should not link to %q which is not a vendor-available library",
159 vndk.typeName(), to.Name())
160 return
161 }
Logan Chienf3511742017-10-31 18:04:35 +0800162 if tag == vndkExtDepTag {
163 // Ensure `extends: "name"` property refers a vndk module that has vendor_available
164 // and has identical vndk properties.
165 if to.vndkdep == nil || !to.vndkdep.isVndk() {
166 ctx.ModuleErrorf("`extends` refers a non-vndk module %q", to.Name())
167 return
168 }
169 if vndk.isVndkSp() != to.vndkdep.isVndkSp() {
170 ctx.ModuleErrorf(
171 "`extends` refers a module %q with mismatched support_system_process",
172 to.Name())
173 return
174 }
175 if !Bool(to.VendorProperties.Vendor_available) {
176 ctx.ModuleErrorf(
177 "`extends` refers module %q which does not have `vendor_available: true`",
178 to.Name())
179 return
180 }
181 }
Justin Yun8effde42017-06-23 19:24:43 +0900182 if to.vndkdep == nil {
183 return
184 }
Logan Chienf3511742017-10-31 18:04:35 +0800185
Logan Chiend3c59a22018-03-29 14:08:15 +0800186 // Check the dependencies of VNDK shared libraries.
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100187 if err := vndkIsVndkDepAllowed(vndk, to.vndkdep); err != nil {
188 ctx.ModuleErrorf("(%s) should not link to %q (%s): %v",
189 vndk.typeName(), to.Name(), to.vndkdep.typeName(), err)
Logan Chienf3511742017-10-31 18:04:35 +0800190 return
191 }
Logan Chiend3c59a22018-03-29 14:08:15 +0800192}
Logan Chienf3511742017-10-31 18:04:35 +0800193
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100194func vndkIsVndkDepAllowed(from *vndkdep, to *vndkdep) error {
Logan Chiend3c59a22018-03-29 14:08:15 +0800195 // Check the dependencies of VNDK, VNDK-Ext, VNDK-SP, VNDK-SP-Ext and vendor modules.
196 if from.isVndkExt() {
197 if from.isVndkSp() {
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100198 if to.isVndk() && !to.isVndkSp() {
199 return errors.New("VNDK-SP extensions must not depend on VNDK or VNDK extensions")
200 }
201 return nil
Logan Chiend3c59a22018-03-29 14:08:15 +0800202 }
203 // VNDK-Ext may depend on VNDK, VNDK-Ext, VNDK-SP, VNDK-SP-Ext, or vendor libs.
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100204 return nil
Justin Yun8effde42017-06-23 19:24:43 +0900205 }
Logan Chiend3c59a22018-03-29 14:08:15 +0800206 if from.isVndk() {
207 if to.isVndkExt() {
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100208 return errors.New("VNDK-core and VNDK-SP must not depend on VNDK extensions")
Logan Chiend3c59a22018-03-29 14:08:15 +0800209 }
210 if from.isVndkSp() {
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100211 if !to.isVndkSp() {
212 return errors.New("VNDK-SP must only depend on VNDK-SP")
213 }
214 return nil
Logan Chiend3c59a22018-03-29 14:08:15 +0800215 }
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100216 if !to.isVndk() {
217 return errors.New("VNDK-core must only depend on VNDK-core or VNDK-SP")
218 }
219 return nil
Logan Chiend3c59a22018-03-29 14:08:15 +0800220 }
221 // Vendor modules may depend on VNDK, VNDK-Ext, VNDK-SP, VNDK-SP-Ext, or vendor libs.
Martin Stjernholm257eb0c2018-10-15 13:05:27 +0100222 return nil
Justin Yun8effde42017-06-23 19:24:43 +0900223}
Jiyong Parkd5b18a52017-08-03 21:22:50 +0900224
225var (
Jooyung Hana463f722019-11-01 08:45:59 +0900226 vndkCoreLibrariesKey = android.NewOnceKey("vndkCoreLibrarires")
227 vndkSpLibrariesKey = android.NewOnceKey("vndkSpLibrarires")
228 llndkLibrariesKey = android.NewOnceKey("llndkLibrarires")
229 vndkPrivateLibrariesKey = android.NewOnceKey("vndkPrivateLibrarires")
Kiyoung Kime1aa8ea2019-12-30 11:12:55 +0900230 vndkUsingCoreVariantLibrariesKey = android.NewOnceKey("vndkUsingCoreVariantLibraries")
Jooyung Hana463f722019-11-01 08:45:59 +0900231 vndkMustUseVendorVariantListKey = android.NewOnceKey("vndkMustUseVendorVariantListKey")
232 vndkLibrariesLock sync.Mutex
Inseob Kimae553032019-05-14 18:52:49 +0900233)
Inseob Kim1f086e22019-05-09 13:29:15 +0900234
Jooyung Han0302a842019-10-30 18:43:49 +0900235func vndkCoreLibraries(config android.Config) map[string]string {
Inseob Kim9516ee92019-05-09 10:56:13 +0900236 return config.Once(vndkCoreLibrariesKey, func() interface{} {
Jooyung Han0302a842019-10-30 18:43:49 +0900237 return make(map[string]string)
238 }).(map[string]string)
Inseob Kim9516ee92019-05-09 10:56:13 +0900239}
240
Jooyung Han0302a842019-10-30 18:43:49 +0900241func vndkSpLibraries(config android.Config) map[string]string {
Inseob Kim9516ee92019-05-09 10:56:13 +0900242 return config.Once(vndkSpLibrariesKey, func() interface{} {
Jooyung Han0302a842019-10-30 18:43:49 +0900243 return make(map[string]string)
244 }).(map[string]string)
Inseob Kim9516ee92019-05-09 10:56:13 +0900245}
246
Jooyung Han0302a842019-10-30 18:43:49 +0900247func isLlndkLibrary(baseModuleName string, config android.Config) bool {
248 _, ok := llndkLibraries(config)[baseModuleName]
249 return ok
250}
251
252func llndkLibraries(config android.Config) map[string]string {
Inseob Kim9516ee92019-05-09 10:56:13 +0900253 return config.Once(llndkLibrariesKey, func() interface{} {
Jooyung Han0302a842019-10-30 18:43:49 +0900254 return make(map[string]string)
255 }).(map[string]string)
Inseob Kim9516ee92019-05-09 10:56:13 +0900256}
257
Jooyung Han0302a842019-10-30 18:43:49 +0900258func isVndkPrivateLibrary(baseModuleName string, config android.Config) bool {
259 _, ok := vndkPrivateLibraries(config)[baseModuleName]
260 return ok
261}
262
263func vndkPrivateLibraries(config android.Config) map[string]string {
Inseob Kim9516ee92019-05-09 10:56:13 +0900264 return config.Once(vndkPrivateLibrariesKey, func() interface{} {
Jooyung Han0302a842019-10-30 18:43:49 +0900265 return make(map[string]string)
266 }).(map[string]string)
Inseob Kim9516ee92019-05-09 10:56:13 +0900267}
268
Jooyung Han0302a842019-10-30 18:43:49 +0900269func vndkUsingCoreVariantLibraries(config android.Config) map[string]string {
Inseob Kim9516ee92019-05-09 10:56:13 +0900270 return config.Once(vndkUsingCoreVariantLibrariesKey, func() interface{} {
Jooyung Han0302a842019-10-30 18:43:49 +0900271 return make(map[string]string)
272 }).(map[string]string)
Inseob Kim9516ee92019-05-09 10:56:13 +0900273}
274
Jooyung Han097087b2019-10-22 19:32:18 +0900275func vndkMustUseVendorVariantList(cfg android.Config) []string {
276 return cfg.Once(vndkMustUseVendorVariantListKey, func() interface{} {
Jooyung Han097087b2019-10-22 19:32:18 +0900277 return config.VndkMustUseVendorVariantList
278 }).([]string)
279}
280
281// test may call this to override global configuration(config.VndkMustUseVendorVariantList)
282// when it is called, it must be before the first call to vndkMustUseVendorVariantList()
283func setVndkMustUseVendorVariantListForTest(config android.Config, mustUseVendorVariantList []string) {
Jooyung Hana463f722019-11-01 08:45:59 +0900284 config.Once(vndkMustUseVendorVariantListKey, func() interface{} {
Jooyung Han097087b2019-10-22 19:32:18 +0900285 return mustUseVendorVariantList
286 })
287}
288
Inseob Kim1f086e22019-05-09 13:29:15 +0900289func processLlndkLibrary(mctx android.BottomUpMutatorContext, m *Module) {
290 lib := m.linker.(*llndkStubDecorator)
Jooyung Han0302a842019-10-30 18:43:49 +0900291 name := m.BaseModuleName()
292 filename := m.BaseModuleName() + ".so"
Inseob Kim9516ee92019-05-09 10:56:13 +0900293
Inseob Kim1f086e22019-05-09 13:29:15 +0900294 vndkLibrariesLock.Lock()
295 defer vndkLibrariesLock.Unlock()
Inseob Kim9516ee92019-05-09 10:56:13 +0900296
Jooyung Han0302a842019-10-30 18:43:49 +0900297 llndkLibraries(mctx.Config())[name] = filename
Inseob Kim1f086e22019-05-09 13:29:15 +0900298 if !Bool(lib.Properties.Vendor_available) {
Jooyung Han0302a842019-10-30 18:43:49 +0900299 vndkPrivateLibraries(mctx.Config())[name] = filename
Jiyong Parkd5b18a52017-08-03 21:22:50 +0900300 }
Jooyung Han61b66e92020-03-21 14:21:46 +0000301 if mctx.OtherModuleExists(name) {
302 mctx.AddFarVariationDependencies(m.Target().Variations(), llndkImplDep, name)
303 }
Jiyong Parkd5b18a52017-08-03 21:22:50 +0900304}
Inseob Kim1f086e22019-05-09 13:29:15 +0900305
306func processVndkLibrary(mctx android.BottomUpMutatorContext, m *Module) {
Jooyung Han0302a842019-10-30 18:43:49 +0900307 name := m.BaseModuleName()
308 filename, err := getVndkFileName(m)
309 if err != nil {
310 panic(err)
311 }
Inseob Kim1f086e22019-05-09 13:29:15 +0900312
Jiyong Park2478e4e2020-05-18 09:30:14 +0000313 if m.HasStubsVariants() && name != "libz" {
314 // b/155456180 libz is the ONLY exception here. We don't want to make
315 // libz an LLNDK library because we in general can't guarantee that
316 // libz will behave consistently especially about the compression.
317 // i.e. the compressed output might be different across releases.
318 // As the library is an external one, it's risky to keep the compatibility
319 // promise if it becomes an LLNDK.
Jiyong Parkea97f512020-03-31 15:31:17 +0900320 mctx.PropertyErrorf("vndk.enabled", "This library provides stubs. Shouldn't be VNDK. Consider making it as LLNDK")
321 }
322
Inseob Kim1f086e22019-05-09 13:29:15 +0900323 vndkLibrariesLock.Lock()
324 defer vndkLibrariesLock.Unlock()
325
Jooyung Han097087b2019-10-22 19:32:18 +0900326 if inList(name, vndkMustUseVendorVariantList(mctx.Config())) {
327 m.Properties.MustUseVendorVariant = true
328 }
Jooyung Han0302a842019-10-30 18:43:49 +0900329 if mctx.DeviceConfig().VndkUseCoreVariant() && !m.Properties.MustUseVendorVariant {
330 vndkUsingCoreVariantLibraries(mctx.Config())[name] = filename
Inseob Kim1f086e22019-05-09 13:29:15 +0900331 }
Jooyung Han0302a842019-10-30 18:43:49 +0900332
Inseob Kim1f086e22019-05-09 13:29:15 +0900333 if m.vndkdep.isVndkSp() {
Jooyung Han0302a842019-10-30 18:43:49 +0900334 vndkSpLibraries(mctx.Config())[name] = filename
Inseob Kim1f086e22019-05-09 13:29:15 +0900335 } else {
Jooyung Han0302a842019-10-30 18:43:49 +0900336 vndkCoreLibraries(mctx.Config())[name] = filename
Inseob Kim1f086e22019-05-09 13:29:15 +0900337 }
338 if !Bool(m.VendorProperties.Vendor_available) {
Jooyung Han0302a842019-10-30 18:43:49 +0900339 vndkPrivateLibraries(mctx.Config())[name] = filename
Inseob Kim1f086e22019-05-09 13:29:15 +0900340 }
341}
342
Jooyung Han31c470b2019-10-18 16:26:59 +0900343func IsForVndkApex(mctx android.BottomUpMutatorContext, m *Module) bool {
344 if !m.Enabled() {
345 return false
346 }
347
Jooyung Han87a7f302019-10-29 05:18:21 +0900348 if !mctx.Device() {
349 return false
350 }
351
Jooyung Han31c470b2019-10-18 16:26:59 +0900352 if m.Target().NativeBridge == android.NativeBridgeEnabled {
353 return false
354 }
355
356 // prebuilt vndk modules should match with device
357 // TODO(b/142675459): Use enabled: to select target device in vndk_prebuilt_shared
358 // When b/142675459 is landed, remove following check
359 if p, ok := m.linker.(*vndkPrebuiltLibraryDecorator); ok && !p.matchesWithDevice(mctx.DeviceConfig()) {
360 return false
361 }
362
363 if lib, ok := m.linker.(libraryInterface); ok {
Jooyung Han73d20d02020-03-27 16:06:55 +0900364 // VNDK APEX for VNDK-Lite devices will have VNDK-SP libraries from core variants
365 if mctx.DeviceConfig().VndkVersion() == "" {
366 // b/73296261: filter out libz.so because it is considered as LLNDK for VNDK-lite devices
367 if mctx.ModuleName() == "libz" {
368 return false
369 }
370 return m.ImageVariation().Variation == android.CoreVariation && lib.shared() && m.isVndkSp()
371 }
372
Justin Yun5f7f7e82019-11-18 19:52:14 +0900373 useCoreVariant := m.VndkVersion() == mctx.DeviceConfig().PlatformVndkVersion() &&
Jooyung Han87a7f302019-10-29 05:18:21 +0900374 mctx.DeviceConfig().VndkUseCoreVariant() && !m.MustUseVendorVariant()
Jooyung Hana57af4a2020-01-23 05:36:59 +0000375 return lib.shared() && m.inVendor() && m.IsVndk() && !m.isVndkExt() && !useCoreVariant
Jooyung Han31c470b2019-10-18 16:26:59 +0900376 }
377 return false
378}
379
Inseob Kim1f086e22019-05-09 13:29:15 +0900380// gather list of vndk-core, vndk-sp, and ll-ndk libs
381func VndkMutator(mctx android.BottomUpMutatorContext) {
382 m, ok := mctx.Module().(*Module)
383 if !ok {
384 return
385 }
Inseob Kim1f086e22019-05-09 13:29:15 +0900386 if !m.Enabled() {
387 return
388 }
Justin Yun7390ea32019-09-08 11:34:06 +0900389 if m.Target().NativeBridge == android.NativeBridgeEnabled {
390 // Skip native_bridge modules
391 return
392 }
Inseob Kim1f086e22019-05-09 13:29:15 +0900393
394 if _, ok := m.linker.(*llndkStubDecorator); ok {
395 processLlndkLibrary(mctx, m)
396 return
397 }
398
399 lib, is_lib := m.linker.(*libraryDecorator)
400 prebuilt_lib, is_prebuilt_lib := m.linker.(*prebuiltLibraryLinker)
401
Inseob Kim64c43952019-08-26 16:52:35 +0900402 if (is_lib && lib.buildShared()) || (is_prebuilt_lib && prebuilt_lib.buildShared()) {
403 if m.vndkdep != nil && m.vndkdep.isVndk() && !m.vndkdep.isVndkExt() {
Inseob Kim1f086e22019-05-09 13:29:15 +0900404 processVndkLibrary(mctx, m)
405 return
406 }
407 }
408}
409
410func init() {
Jooyung Han39edb6c2019-11-06 16:53:07 +0900411 android.RegisterModuleType("vndk_libraries_txt", VndkLibrariesTxtFactory)
Inseob Kim1f086e22019-05-09 13:29:15 +0900412 android.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton)
Inseob Kim1f086e22019-05-09 13:29:15 +0900413}
414
Jooyung Han2216fb12019-11-06 16:46:15 +0900415type vndkLibrariesTxt struct {
416 android.ModuleBase
417 outputFile android.OutputPath
418}
419
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700420var _ etc.PrebuiltEtcModule = &vndkLibrariesTxt{}
Jooyung Han39edb6c2019-11-06 16:53:07 +0900421var _ android.OutputFileProducer = &vndkLibrariesTxt{}
422
Jooyung Han2216fb12019-11-06 16:46:15 +0900423// vndk_libraries_txt is a special kind of module type in that it name is one of
424// - llndk.libraries.txt
425// - vndkcore.libraries.txt
426// - vndksp.libraries.txt
427// - vndkprivate.libraries.txt
428// - vndkcorevariant.libraries.txt
429// A module behaves like a prebuilt_etc but its content is generated by soong.
430// By being a soong module, these files can be referenced by other soong modules.
431// For example, apex_vndk can depend on these files as prebuilt.
Jooyung Han39edb6c2019-11-06 16:53:07 +0900432func VndkLibrariesTxtFactory() android.Module {
Jooyung Han2216fb12019-11-06 16:46:15 +0900433 m := &vndkLibrariesTxt{}
434 android.InitAndroidModule(m)
435 return m
436}
437
438func insertVndkVersion(filename string, vndkVersion string) string {
439 if index := strings.LastIndex(filename, "."); index != -1 {
440 return filename[:index] + "." + vndkVersion + filename[index:]
441 }
442 return filename
443}
444
445func (txt *vndkLibrariesTxt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
446 var list []string
447 switch txt.Name() {
Jooyung Han39edb6c2019-11-06 16:53:07 +0900448 case llndkLibrariesTxt:
Jooyung Han2216fb12019-11-06 16:46:15 +0900449 for _, filename := range android.SortedStringMapValues(llndkLibraries(ctx.Config())) {
450 if strings.HasPrefix(filename, "libclang_rt.hwasan-") {
451 continue
452 }
453 list = append(list, filename)
454 }
Jooyung Han39edb6c2019-11-06 16:53:07 +0900455 case vndkCoreLibrariesTxt:
Jooyung Han2216fb12019-11-06 16:46:15 +0900456 list = android.SortedStringMapValues(vndkCoreLibraries(ctx.Config()))
Jooyung Han39edb6c2019-11-06 16:53:07 +0900457 case vndkSpLibrariesTxt:
Jooyung Han2216fb12019-11-06 16:46:15 +0900458 list = android.SortedStringMapValues(vndkSpLibraries(ctx.Config()))
Jooyung Han39edb6c2019-11-06 16:53:07 +0900459 case vndkPrivateLibrariesTxt:
Jooyung Han2216fb12019-11-06 16:46:15 +0900460 list = android.SortedStringMapValues(vndkPrivateLibraries(ctx.Config()))
Jooyung Han39edb6c2019-11-06 16:53:07 +0900461 case vndkUsingCoreVariantLibrariesTxt:
Jooyung Han2216fb12019-11-06 16:46:15 +0900462 list = android.SortedStringMapValues(vndkUsingCoreVariantLibraries(ctx.Config()))
463 default:
464 ctx.ModuleErrorf("name(%s) is unknown.", txt.Name())
465 return
466 }
467
Kiyoung Kime1aa8ea2019-12-30 11:12:55 +0900468 var filename string
469 if txt.Name() != vndkUsingCoreVariantLibrariesTxt {
470 filename = insertVndkVersion(txt.Name(), ctx.DeviceConfig().PlatformVndkVersion())
471 } else {
472 filename = txt.Name()
473 }
474
Jooyung Han2216fb12019-11-06 16:46:15 +0900475 txt.outputFile = android.PathForModuleOut(ctx, filename).OutputPath
476 ctx.Build(pctx, android.BuildParams{
477 Rule: android.WriteFile,
478 Output: txt.outputFile,
479 Description: "Writing " + txt.outputFile.String(),
480 Args: map[string]string{
481 "content": strings.Join(list, "\\n"),
482 },
483 })
484
485 installPath := android.PathForModuleInstall(ctx, "etc")
486 ctx.InstallFile(installPath, filename, txt.outputFile)
487}
488
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900489func (txt *vndkLibrariesTxt) AndroidMkEntries() []android.AndroidMkEntries {
490 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jooyung Han2216fb12019-11-06 16:46:15 +0900491 Class: "ETC",
492 OutputFile: android.OptionalPathForPath(txt.outputFile),
493 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
494 func(entries *android.AndroidMkEntries) {
495 entries.SetString("LOCAL_MODULE_STEM", txt.outputFile.Base())
496 },
497 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900498 }}
Jooyung Han2216fb12019-11-06 16:46:15 +0900499}
500
Jooyung Han39edb6c2019-11-06 16:53:07 +0900501func (txt *vndkLibrariesTxt) OutputFile() android.OutputPath {
502 return txt.outputFile
503}
504
505func (txt *vndkLibrariesTxt) OutputFiles(tag string) (android.Paths, error) {
506 return android.Paths{txt.outputFile}, nil
507}
508
509func (txt *vndkLibrariesTxt) SubDir() string {
510 return ""
511}
512
Inseob Kim1f086e22019-05-09 13:29:15 +0900513func VndkSnapshotSingleton() android.Singleton {
514 return &vndkSnapshotSingleton{}
515}
516
Jooyung Han0302a842019-10-30 18:43:49 +0900517type vndkSnapshotSingleton struct {
Jooyung Han39edb6c2019-11-06 16:53:07 +0900518 vndkLibrariesFile android.OutputPath
519 vndkSnapshotZipFile android.OptionalPath
Jooyung Han0302a842019-10-30 18:43:49 +0900520}
Inseob Kim1f086e22019-05-09 13:29:15 +0900521
Inseob Kimeda2e9c2020-03-03 22:06:32 +0900522func isVndkSnapshotLibrary(config android.DeviceConfig, m *Module) (i snapshotLibraryInterface, vndkType string, isVndkSnapshotLib bool) {
523 if m.Target().NativeBridge == android.NativeBridgeEnabled {
524 return nil, "", false
525 }
526 if !m.inVendor() || !m.installable() || m.isSnapshotPrebuilt() {
527 return nil, "", false
528 }
529 l, ok := m.linker.(snapshotLibraryInterface)
530 if !ok || !l.shared() {
531 return nil, "", false
532 }
533 if m.VndkVersion() == config.PlatformVndkVersion() && m.IsVndk() && !m.isVndkExt() {
534 if m.isVndkSp() {
535 return l, "vndk-sp", true
536 } else {
537 return l, "vndk-core", true
538 }
539 }
540
541 return nil, "", false
542}
543
Inseob Kim1f086e22019-05-09 13:29:15 +0900544func (c *vndkSnapshotSingleton) GenerateBuildActions(ctx android.SingletonContext) {
Jooyung Han0302a842019-10-30 18:43:49 +0900545 // build these files even if PlatformVndkVersion or BoardVndkVersion is not set
546 c.buildVndkLibrariesTxtFiles(ctx)
547
Inseob Kim1f086e22019-05-09 13:29:15 +0900548 // BOARD_VNDK_VERSION must be set to 'current' in order to generate a VNDK snapshot.
549 if ctx.DeviceConfig().VndkVersion() != "current" {
550 return
551 }
552
553 if ctx.DeviceConfig().PlatformVndkVersion() == "" {
554 return
555 }
556
557 if ctx.DeviceConfig().BoardVndkRuntimeDisable() {
558 return
559 }
560
Inseob Kim242ef0c2019-10-22 20:15:20 +0900561 var snapshotOutputs android.Paths
562
563 /*
564 VNDK snapshot zipped artifacts directory structure:
565 {SNAPSHOT_ARCH}/
566 arch-{TARGET_ARCH}-{TARGET_ARCH_VARIANT}/
567 shared/
568 vndk-core/
569 (VNDK-core libraries, e.g. libbinder.so)
570 vndk-sp/
571 (VNDK-SP libraries, e.g. libc++.so)
572 arch-{TARGET_2ND_ARCH}-{TARGET_2ND_ARCH_VARIANT}/
573 shared/
574 vndk-core/
575 (VNDK-core libraries, e.g. libbinder.so)
576 vndk-sp/
577 (VNDK-SP libraries, e.g. libc++.so)
578 binder32/
579 (This directory is newly introduced in v28 (Android P) to hold
580 prebuilts built for 32-bit binder interface.)
581 arch-{TARGET_ARCH}-{TARGE_ARCH_VARIANT}/
582 ...
583 configs/
584 (various *.txt configuration files)
585 include/
586 (header files of same directory structure with source tree)
587 NOTICE_FILES/
588 (notice files of libraries, e.g. libcutils.so.txt)
589 */
Inseob Kim1f086e22019-05-09 13:29:15 +0900590
591 snapshotDir := "vndk-snapshot"
Inseob Kim242ef0c2019-10-22 20:15:20 +0900592 snapshotArchDir := filepath.Join(snapshotDir, ctx.DeviceConfig().DeviceArch())
Inseob Kim1f086e22019-05-09 13:29:15 +0900593
Inseob Kim242ef0c2019-10-22 20:15:20 +0900594 configsDir := filepath.Join(snapshotArchDir, "configs")
595 noticeDir := filepath.Join(snapshotArchDir, "NOTICE_FILES")
596 includeDir := filepath.Join(snapshotArchDir, "include")
597
Inseob Kim242ef0c2019-10-22 20:15:20 +0900598 // set of notice files copied.
Inseob Kim1f086e22019-05-09 13:29:15 +0900599 noticeBuilt := make(map[string]bool)
600
Inseob Kim242ef0c2019-10-22 20:15:20 +0900601 // paths of VNDK modules for GPL license checking
602 modulePaths := make(map[string]string)
603
604 // actual module names of .so files
605 // e.g. moduleNames["libprotobuf-cpp-full-3.9.1.so"] = "libprotobuf-cpp-full"
606 moduleNames := make(map[string]string)
607
Inseob Kim8471cda2019-11-15 09:59:12 +0900608 var headers android.Paths
Inseob Kim242ef0c2019-10-22 20:15:20 +0900609
Inseob Kim8471cda2019-11-15 09:59:12 +0900610 installVndkSnapshotLib := func(m *Module, l snapshotLibraryInterface, vndkType string) (android.Paths, bool) {
Inseob Kim242ef0c2019-10-22 20:15:20 +0900611 var ret android.Paths
612
Inseob Kim8471cda2019-11-15 09:59:12 +0900613 targetArch := "arch-" + m.Target().Arch.ArchType.String()
614 if m.Target().Arch.ArchVariant != "" {
615 targetArch += "-" + m.Target().Arch.ArchVariant
Inseob Kim242ef0c2019-10-22 20:15:20 +0900616 }
Inseob Kimae553032019-05-14 18:52:49 +0900617
Inseob Kim8471cda2019-11-15 09:59:12 +0900618 libPath := m.outputFile.Path()
619 snapshotLibOut := filepath.Join(snapshotArchDir, targetArch, "shared", vndkType, libPath.Base())
620 ret = append(ret, copyFile(ctx, libPath, snapshotLibOut))
621
Inseob Kimae553032019-05-14 18:52:49 +0900622 if ctx.Config().VndkSnapshotBuildArtifacts() {
623 prop := struct {
624 ExportedDirs []string `json:",omitempty"`
625 ExportedSystemDirs []string `json:",omitempty"`
626 ExportedFlags []string `json:",omitempty"`
627 RelativeInstallPath string `json:",omitempty"`
628 }{}
629 prop.ExportedFlags = l.exportedFlags()
Jiyong Park74955042019-10-22 20:19:51 +0900630 prop.ExportedDirs = l.exportedDirs().Strings()
631 prop.ExportedSystemDirs = l.exportedSystemDirs().Strings()
Inseob Kimae553032019-05-14 18:52:49 +0900632 prop.RelativeInstallPath = m.RelativeInstallPath()
633
Inseob Kim242ef0c2019-10-22 20:15:20 +0900634 propOut := snapshotLibOut + ".json"
Inseob Kimae553032019-05-14 18:52:49 +0900635
636 j, err := json.Marshal(prop)
637 if err != nil {
638 ctx.Errorf("json marshal to %q failed: %#v", propOut, err)
Inseob Kim242ef0c2019-10-22 20:15:20 +0900639 return nil, false
Inseob Kimae553032019-05-14 18:52:49 +0900640 }
Inseob Kim8471cda2019-11-15 09:59:12 +0900641 ret = append(ret, writeStringToFile(ctx, string(j), propOut))
Inseob Kimae553032019-05-14 18:52:49 +0900642 }
Inseob Kim242ef0c2019-10-22 20:15:20 +0900643 return ret, true
Inseob Kimae553032019-05-14 18:52:49 +0900644 }
645
Inseob Kim1f086e22019-05-09 13:29:15 +0900646 ctx.VisitAllModules(func(module android.Module) {
647 m, ok := module.(*Module)
Inseob Kimae553032019-05-14 18:52:49 +0900648 if !ok || !m.Enabled() {
Inseob Kim1f086e22019-05-09 13:29:15 +0900649 return
650 }
651
Inseob Kimeda2e9c2020-03-03 22:06:32 +0900652 l, vndkType, ok := isVndkSnapshotLibrary(ctx.DeviceConfig(), m)
Inseob Kimae553032019-05-14 18:52:49 +0900653 if !ok {
dimitry51ea18a2019-05-20 10:39:52 +0200654 return
655 }
656
Inseob Kim8471cda2019-11-15 09:59:12 +0900657 // install .so files for appropriate modules.
658 // Also install .json files if VNDK_SNAPSHOT_BUILD_ARTIFACTS
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 }
Inseob Kim242ef0c2019-10-22 20:15:20 +0900663 snapshotOutputs = append(snapshotOutputs, libs...)
Inseob Kim1f086e22019-05-09 13:29:15 +0900664
Inseob Kim8471cda2019-11-15 09:59:12 +0900665 // These are for generating module_names.txt and module_paths.txt
666 stem := m.outputFile.Path().Base()
667 moduleNames[stem] = ctx.ModuleName(m)
668 modulePaths[stem] = ctx.ModuleDir(m)
669
Bob Badoura75b0572020-02-18 20:21:55 -0800670 if len(m.NoticeFiles()) > 0 {
Inseob Kim8471cda2019-11-15 09:59:12 +0900671 noticeName := stem + ".txt"
672 // skip already copied notice file
673 if _, ok := noticeBuilt[noticeName]; !ok {
674 noticeBuilt[noticeName] = true
Bob Badoura75b0572020-02-18 20:21:55 -0800675 snapshotOutputs = append(snapshotOutputs, combineNotices(
676 ctx, m.NoticeFiles(), filepath.Join(noticeDir, noticeName)))
Inseob Kim8471cda2019-11-15 09:59:12 +0900677 }
678 }
679
680 if ctx.Config().VndkSnapshotBuildArtifacts() {
Inseob Kimeda2e9c2020-03-03 22:06:32 +0900681 headers = append(headers, l.snapshotHeaders()...)
Inseob Kimae553032019-05-14 18:52:49 +0900682 }
683 })
Inseob Kim1f086e22019-05-09 13:29:15 +0900684
Inseob Kim8471cda2019-11-15 09:59:12 +0900685 // install all headers after removing duplicates
686 for _, header := range android.FirstUniquePaths(headers) {
687 snapshotOutputs = append(snapshotOutputs, copyFile(
688 ctx, header, filepath.Join(includeDir, header.String())))
Inseob Kimae553032019-05-14 18:52:49 +0900689 }
690
Jooyung Han39edb6c2019-11-06 16:53:07 +0900691 // install *.libraries.txt except vndkcorevariant.libraries.txt
692 ctx.VisitAllModules(func(module android.Module) {
693 m, ok := module.(*vndkLibrariesTxt)
694 if !ok || !m.Enabled() || m.Name() == vndkUsingCoreVariantLibrariesTxt {
695 return
696 }
Inseob Kim8471cda2019-11-15 09:59:12 +0900697 snapshotOutputs = append(snapshotOutputs, copyFile(
698 ctx, m.OutputFile(), filepath.Join(configsDir, m.Name())))
Jooyung Han39edb6c2019-11-06 16:53:07 +0900699 })
Inseob Kim1f086e22019-05-09 13:29:15 +0900700
Inseob Kim242ef0c2019-10-22 20:15:20 +0900701 /*
702 Dump a map to a list file as:
Inseob Kim1f086e22019-05-09 13:29:15 +0900703
Inseob Kim242ef0c2019-10-22 20:15:20 +0900704 {key1} {value1}
705 {key2} {value2}
706 ...
707 */
708 installMapListFile := func(m map[string]string, path string) android.OutputPath {
709 var txtBuilder strings.Builder
710 for idx, k := range android.SortedStringKeys(m) {
711 if idx > 0 {
712 txtBuilder.WriteString("\\n")
713 }
714 txtBuilder.WriteString(k)
715 txtBuilder.WriteString(" ")
716 txtBuilder.WriteString(m[k])
Inseob Kim1f086e22019-05-09 13:29:15 +0900717 }
Inseob Kim8471cda2019-11-15 09:59:12 +0900718 return writeStringToFile(ctx, txtBuilder.String(), path)
Inseob Kim1f086e22019-05-09 13:29:15 +0900719 }
720
Inseob Kim242ef0c2019-10-22 20:15:20 +0900721 /*
722 module_paths.txt contains paths on which VNDK modules are defined.
723 e.g.,
724 libbase.so system/core/base
725 libc.so bionic/libc
726 ...
727 */
728 snapshotOutputs = append(snapshotOutputs, installMapListFile(modulePaths, filepath.Join(configsDir, "module_paths.txt")))
729
730 /*
731 module_names.txt contains names as which VNDK modules are defined,
732 because output filename and module name can be different with stem and suffix properties.
733
734 e.g.,
735 libcutils.so libcutils
736 libprotobuf-cpp-full-3.9.2.so libprotobuf-cpp-full
737 ...
738 */
739 snapshotOutputs = append(snapshotOutputs, installMapListFile(moduleNames, filepath.Join(configsDir, "module_names.txt")))
740
741 // All artifacts are ready. Sort them to normalize ninja and then zip.
742 sort.Slice(snapshotOutputs, func(i, j int) bool {
743 return snapshotOutputs[i].String() < snapshotOutputs[j].String()
744 })
745
746 zipPath := android.PathForOutput(ctx, snapshotDir, "android-vndk-"+ctx.DeviceConfig().DeviceArch()+".zip")
747 zipRule := android.NewRuleBuilder()
748
Inseob Kim8471cda2019-11-15 09:59:12 +0900749 // filenames in rspfile from FlagWithRspFileInputList might be single-quoted. Remove it with xargs
Inseob Kim242ef0c2019-10-22 20:15:20 +0900750 snapshotOutputList := android.PathForOutput(ctx, snapshotDir, "android-vndk-"+ctx.DeviceConfig().DeviceArch()+"_list")
751 zipRule.Command().
Inseob Kim8471cda2019-11-15 09:59:12 +0900752 Text("tr").
753 FlagWithArg("-d ", "\\'").
754 FlagWithRspFileInputList("< ", snapshotOutputs).
755 FlagWithOutput("> ", snapshotOutputList)
Inseob Kim242ef0c2019-10-22 20:15:20 +0900756
757 zipRule.Temporary(snapshotOutputList)
758
759 zipRule.Command().
760 BuiltTool(ctx, "soong_zip").
761 FlagWithOutput("-o ", zipPath).
762 FlagWithArg("-C ", android.PathForOutput(ctx, snapshotDir).String()).
763 FlagWithInput("-l ", snapshotOutputList)
764
765 zipRule.Build(pctx, ctx, zipPath.String(), "vndk snapshot "+zipPath.String())
Inseob Kim8471cda2019-11-15 09:59:12 +0900766 zipRule.DeleteTemporaryFiles()
Inseob Kim242ef0c2019-10-22 20:15:20 +0900767 c.vndkSnapshotZipFile = android.OptionalPathForPath(zipPath)
Inseob Kim1f086e22019-05-09 13:29:15 +0900768}
Jooyung Han097087b2019-10-22 19:32:18 +0900769
Jooyung Han0302a842019-10-30 18:43:49 +0900770func getVndkFileName(m *Module) (string, error) {
771 if library, ok := m.linker.(*libraryDecorator); ok {
772 return library.getLibNameHelper(m.BaseModuleName(), true) + ".so", nil
773 }
774 if prebuilt, ok := m.linker.(*prebuiltLibraryLinker); ok {
775 return prebuilt.libraryDecorator.getLibNameHelper(m.BaseModuleName(), true) + ".so", nil
776 }
777 return "", fmt.Errorf("VNDK library should have libraryDecorator or prebuiltLibraryLinker as linker: %T", m.linker)
Jooyung Han097087b2019-10-22 19:32:18 +0900778}
779
780func (c *vndkSnapshotSingleton) buildVndkLibrariesTxtFiles(ctx android.SingletonContext) {
Jooyung Han39edb6c2019-11-06 16:53:07 +0900781 llndk := android.SortedStringMapValues(llndkLibraries(ctx.Config()))
Jooyung Han0302a842019-10-30 18:43:49 +0900782 vndkcore := android.SortedStringMapValues(vndkCoreLibraries(ctx.Config()))
783 vndksp := android.SortedStringMapValues(vndkSpLibraries(ctx.Config()))
784 vndkprivate := android.SortedStringMapValues(vndkPrivateLibraries(ctx.Config()))
Jooyung Han0302a842019-10-30 18:43:49 +0900785
Jooyung Han2216fb12019-11-06 16:46:15 +0900786 // Build list of vndk libs as merged & tagged & filter-out(libclang_rt):
Jooyung Han0302a842019-10-30 18:43:49 +0900787 // Since each target have different set of libclang_rt.* files,
788 // keep the common set of files in vndk.libraries.txt
789 var merged []string
Jooyung Han097087b2019-10-22 19:32:18 +0900790 filterOutLibClangRt := func(libList []string) (filtered []string) {
791 for _, lib := range libList {
792 if !strings.HasPrefix(lib, "libclang_rt.") {
793 filtered = append(filtered, lib)
794 }
795 }
796 return
797 }
798 merged = append(merged, addPrefix(filterOutLibClangRt(llndk), "LLNDK: ")...)
799 merged = append(merged, addPrefix(vndksp, "VNDK-SP: ")...)
800 merged = append(merged, addPrefix(filterOutLibClangRt(vndkcore), "VNDK-core: ")...)
801 merged = append(merged, addPrefix(vndkprivate, "VNDK-private: ")...)
Jooyung Han39edb6c2019-11-06 16:53:07 +0900802 c.vndkLibrariesFile = android.PathForOutput(ctx, "vndk", "vndk.libraries.txt")
803 ctx.Build(pctx, android.BuildParams{
804 Rule: android.WriteFile,
805 Output: c.vndkLibrariesFile,
806 Description: "Writing " + c.vndkLibrariesFile.String(),
807 Args: map[string]string{
808 "content": strings.Join(merged, "\\n"),
809 },
810 })
Jooyung Han0302a842019-10-30 18:43:49 +0900811}
Jooyung Han097087b2019-10-22 19:32:18 +0900812
Jooyung Han0302a842019-10-30 18:43:49 +0900813func (c *vndkSnapshotSingleton) MakeVars(ctx android.MakeVarsContext) {
814 // Make uses LLNDK_MOVED_TO_APEX_LIBRARIES to avoid installing libraries on /system if
815 // they been moved to an apex.
816 movedToApexLlndkLibraries := []string{}
Jooyung Han39edb6c2019-11-06 16:53:07 +0900817 for lib := range llndkLibraries(ctx.Config()) {
Jooyung Han0302a842019-10-30 18:43:49 +0900818 // Skip bionic libs, they are handled in different manner
819 if android.DirectlyInAnyApex(&notOnHostContext{}, lib) && !isBionic(lib) {
820 movedToApexLlndkLibraries = append(movedToApexLlndkLibraries, lib)
821 }
822 }
823 ctx.Strict("LLNDK_MOVED_TO_APEX_LIBRARIES", strings.Join(movedToApexLlndkLibraries, " "))
Jooyung Han39edb6c2019-11-06 16:53:07 +0900824
825 // Make uses LLNDK_LIBRARIES to determine which libraries to install.
826 // HWASAN is only part of the LL-NDK in builds in which libc depends on HWASAN.
827 // Therefore, by removing the library here, we cause it to only be installed if libc
828 // depends on it.
829 installedLlndkLibraries := []string{}
830 for lib := range llndkLibraries(ctx.Config()) {
831 if strings.HasPrefix(lib, "libclang_rt.hwasan-") {
832 continue
833 }
834 installedLlndkLibraries = append(installedLlndkLibraries, lib)
835 }
836 sort.Strings(installedLlndkLibraries)
837 ctx.Strict("LLNDK_LIBRARIES", strings.Join(installedLlndkLibraries, " "))
838
Jooyung Han0302a842019-10-30 18:43:49 +0900839 ctx.Strict("VNDK_CORE_LIBRARIES", strings.Join(android.SortedStringKeys(vndkCoreLibraries(ctx.Config())), " "))
840 ctx.Strict("VNDK_SAMEPROCESS_LIBRARIES", strings.Join(android.SortedStringKeys(vndkSpLibraries(ctx.Config())), " "))
841 ctx.Strict("VNDK_PRIVATE_LIBRARIES", strings.Join(android.SortedStringKeys(vndkPrivateLibraries(ctx.Config())), " "))
842 ctx.Strict("VNDK_USING_CORE_VARIANT_LIBRARIES", strings.Join(android.SortedStringKeys(vndkUsingCoreVariantLibraries(ctx.Config())), " "))
843
Jooyung Han0302a842019-10-30 18:43:49 +0900844 ctx.Strict("VNDK_LIBRARIES_FILE", c.vndkLibrariesFile.String())
Inseob Kim242ef0c2019-10-22 20:15:20 +0900845 ctx.Strict("SOONG_VNDK_SNAPSHOT_ZIP", c.vndkSnapshotZipFile.String())
Jooyung Han097087b2019-10-22 19:32:18 +0900846}