Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 1 | // 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 | |
| 15 | package cc |
| 16 | |
| 17 | import ( |
Martin Stjernholm | 257eb0c | 2018-10-15 13:05:27 +0100 | [diff] [blame] | 18 | "errors" |
Jooyung Han | 0302a84 | 2019-10-30 18:43:49 +0900 | [diff] [blame] | 19 | "fmt" |
Jiyong Park | d5b18a5 | 2017-08-03 21:22:50 +0900 | [diff] [blame] | 20 | "strings" |
Jiyong Park | d5b18a5 | 2017-08-03 21:22:50 +0900 | [diff] [blame] | 21 | |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 22 | "android/soong/android" |
Vic Yang | efd249e | 2018-11-12 20:19:56 -0800 | [diff] [blame] | 23 | "android/soong/cc/config" |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 24 | "android/soong/etc" |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 25 | |
| 26 | "github.com/google/blueprint" |
Justin Yun | d578412 | 2023-10-25 13:25:32 +0900 | [diff] [blame] | 27 | "github.com/google/blueprint/proptools" |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 28 | ) |
| 29 | |
Jooyung Han | 39edb6c | 2019-11-06 16:53:07 +0900 | [diff] [blame] | 30 | const ( |
| 31 | llndkLibrariesTxt = "llndk.libraries.txt" |
Justin Yun | d578412 | 2023-10-25 13:25:32 +0900 | [diff] [blame] | 32 | llndkLibrariesTxtForApex = "llndk.libraries.txt.apex" |
Jooyung Han | 39edb6c | 2019-11-06 16:53:07 +0900 | [diff] [blame] | 33 | vndkCoreLibrariesTxt = "vndkcore.libraries.txt" |
| 34 | vndkSpLibrariesTxt = "vndksp.libraries.txt" |
| 35 | vndkPrivateLibrariesTxt = "vndkprivate.libraries.txt" |
Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 36 | vndkProductLibrariesTxt = "vndkproduct.libraries.txt" |
Jooyung Han | 39edb6c | 2019-11-06 16:53:07 +0900 | [diff] [blame] | 37 | vndkUsingCoreVariantLibrariesTxt = "vndkcorevariant.libraries.txt" |
| 38 | ) |
| 39 | |
Kiyoung Kim | a2d6dee | 2023-08-11 10:14:43 +0900 | [diff] [blame] | 40 | func VndkLibrariesTxtModules(vndkVersion string, ctx android.BaseModuleContext) []string { |
Jooyung Han | 39edb6c | 2019-11-06 16:53:07 +0900 | [diff] [blame] | 41 | // Snapshot vndks have their own *.libraries.VER.txt files. |
| 42 | // Note that snapshots don't have "vndkcorevariant.libraries.VER.txt" |
Kiyoung Kim | a2d6dee | 2023-08-11 10:14:43 +0900 | [diff] [blame] | 43 | result := []string{ |
Jooyung Han | 39edb6c | 2019-11-06 16:53:07 +0900 | [diff] [blame] | 44 | insertVndkVersion(vndkCoreLibrariesTxt, vndkVersion), |
| 45 | insertVndkVersion(vndkSpLibrariesTxt, vndkVersion), |
| 46 | insertVndkVersion(vndkPrivateLibrariesTxt, vndkVersion), |
Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 47 | insertVndkVersion(vndkProductLibrariesTxt, vndkVersion), |
Kiyoung Kim | a2d6dee | 2023-08-11 10:14:43 +0900 | [diff] [blame] | 48 | insertVndkVersion(llndkLibrariesTxt, vndkVersion), |
Jooyung Han | 39edb6c | 2019-11-06 16:53:07 +0900 | [diff] [blame] | 49 | } |
Kiyoung Kim | a2d6dee | 2023-08-11 10:14:43 +0900 | [diff] [blame] | 50 | |
| 51 | return result |
Jooyung Han | 39edb6c | 2019-11-06 16:53:07 +0900 | [diff] [blame] | 52 | } |
| 53 | |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 54 | type VndkProperties struct { |
| 55 | Vndk struct { |
| 56 | // declared as a VNDK or VNDK-SP module. The vendor variant |
| 57 | // will be installed in /system instead of /vendor partition. |
| 58 | // |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 59 | // `vendor_available` and `product_available` must be explicitly |
| 60 | // set to either true or false together with `vndk: {enabled: true}`. |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 61 | Enabled *bool |
| 62 | |
| 63 | // declared as a VNDK-SP module, which is a subset of VNDK. |
| 64 | // |
| 65 | // `vndk: { enabled: true }` must set together. |
| 66 | // |
| 67 | // All these modules are allowed to link to VNDK-SP or LL-NDK |
| 68 | // modules only. Other dependency will cause link-type errors. |
| 69 | // |
| 70 | // If `support_system_process` is not set or set to false, |
| 71 | // the module is VNDK-core and can link to other VNDK-core, |
| 72 | // VNDK-SP or LL-NDK modules only. |
| 73 | Support_system_process *bool |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 74 | |
Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 75 | // declared as a VNDK-private module. |
| 76 | // This module still creates the vendor and product variants refering |
| 77 | // to the `vendor_available: true` and `product_available: true` |
| 78 | // properties. However, it is only available to the other VNDK modules |
| 79 | // but not to the non-VNDK vendor or product modules. |
| 80 | Private *bool |
| 81 | |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 82 | // Extending another module |
| 83 | Extends *string |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 84 | } |
| 85 | } |
| 86 | |
| 87 | type vndkdep struct { |
| 88 | Properties VndkProperties |
| 89 | } |
| 90 | |
| 91 | func (vndk *vndkdep) props() []interface{} { |
| 92 | return []interface{}{&vndk.Properties} |
| 93 | } |
| 94 | |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 95 | func (vndk *vndkdep) isVndk() bool { |
| 96 | return Bool(vndk.Properties.Vndk.Enabled) |
| 97 | } |
| 98 | |
| 99 | func (vndk *vndkdep) isVndkSp() bool { |
| 100 | return Bool(vndk.Properties.Vndk.Support_system_process) |
| 101 | } |
| 102 | |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 103 | func (vndk *vndkdep) isVndkExt() bool { |
| 104 | return vndk.Properties.Vndk.Extends != nil |
| 105 | } |
| 106 | |
| 107 | func (vndk *vndkdep) getVndkExtendsModuleName() string { |
| 108 | return String(vndk.Properties.Vndk.Extends) |
| 109 | } |
| 110 | |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 111 | func (vndk *vndkdep) typeName() string { |
| 112 | if !vndk.isVndk() { |
| 113 | return "native:vendor" |
| 114 | } |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 115 | if !vndk.isVndkExt() { |
| 116 | if !vndk.isVndkSp() { |
| 117 | return "native:vendor:vndk" |
| 118 | } |
| 119 | return "native:vendor:vndksp" |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 120 | } |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 121 | if !vndk.isVndkSp() { |
| 122 | return "native:vendor:vndkext" |
| 123 | } |
| 124 | return "native:vendor:vndkspext" |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 125 | } |
| 126 | |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 127 | // VNDK link type check from a module with UseVndk() == true. |
Jooyung Han | 479ca17 | 2020-10-19 18:51:07 +0900 | [diff] [blame] | 128 | func (vndk *vndkdep) vndkCheckLinkType(ctx android.BaseModuleContext, to *Module, tag blueprint.DependencyTag) { |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 129 | if to.linker == nil { |
| 130 | return |
| 131 | } |
Jiyong Park | 82e2bf3 | 2017-08-16 14:05:54 +0900 | [diff] [blame] | 132 | if !vndk.isVndk() { |
Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 133 | // Non-VNDK modules those installed to /vendor, /system/vendor, |
| 134 | // /product or /system/product cannot depend on VNDK-private modules |
| 135 | // that include VNDK-core-private, VNDK-SP-private and LLNDK-private. |
| 136 | if to.IsVndkPrivate() { |
| 137 | ctx.ModuleErrorf("non-VNDK module should not link to %q which has `private: true`", to.Name()) |
Jiyong Park | 82e2bf3 | 2017-08-16 14:05:54 +0900 | [diff] [blame] | 138 | } |
| 139 | } |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 140 | if lib, ok := to.linker.(*libraryDecorator); !ok || !lib.shared() { |
| 141 | // Check only shared libraries. |
Colin Cross | 127bb8b | 2020-12-16 16:46:01 -0800 | [diff] [blame] | 142 | // Other (static) libraries are allowed to link. |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 143 | return |
| 144 | } |
Colin Cross | 127bb8b | 2020-12-16 16:46:01 -0800 | [diff] [blame] | 145 | |
| 146 | if to.IsLlndk() { |
| 147 | // LL-NDK libraries are allowed to link |
| 148 | return |
| 149 | } |
| 150 | |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 151 | if !to.UseVndk() { |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 152 | ctx.ModuleErrorf("(%s) should not link to %q which is not a vendor-available library", |
| 153 | vndk.typeName(), to.Name()) |
| 154 | return |
| 155 | } |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 156 | if tag == vndkExtDepTag { |
| 157 | // Ensure `extends: "name"` property refers a vndk module that has vendor_available |
| 158 | // and has identical vndk properties. |
| 159 | if to.vndkdep == nil || !to.vndkdep.isVndk() { |
| 160 | ctx.ModuleErrorf("`extends` refers a non-vndk module %q", to.Name()) |
| 161 | return |
| 162 | } |
| 163 | if vndk.isVndkSp() != to.vndkdep.isVndkSp() { |
| 164 | ctx.ModuleErrorf( |
| 165 | "`extends` refers a module %q with mismatched support_system_process", |
| 166 | to.Name()) |
| 167 | return |
| 168 | } |
Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 169 | if to.IsVndkPrivate() { |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 170 | ctx.ModuleErrorf( |
Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 171 | "`extends` refers module %q which has `private: true`", |
Justin Yun | 6977e8a | 2020-10-29 18:24:11 +0900 | [diff] [blame] | 172 | to.Name()) |
| 173 | return |
| 174 | } |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 175 | } |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 176 | if to.vndkdep == nil { |
| 177 | return |
| 178 | } |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 179 | |
Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 180 | // Check the dependencies of VNDK shared libraries. |
Martin Stjernholm | 257eb0c | 2018-10-15 13:05:27 +0100 | [diff] [blame] | 181 | if err := vndkIsVndkDepAllowed(vndk, to.vndkdep); err != nil { |
| 182 | ctx.ModuleErrorf("(%s) should not link to %q (%s): %v", |
| 183 | vndk.typeName(), to.Name(), to.vndkdep.typeName(), err) |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 184 | return |
| 185 | } |
Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 186 | } |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 187 | |
Martin Stjernholm | 257eb0c | 2018-10-15 13:05:27 +0100 | [diff] [blame] | 188 | func vndkIsVndkDepAllowed(from *vndkdep, to *vndkdep) error { |
Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 189 | // Check the dependencies of VNDK, VNDK-Ext, VNDK-SP, VNDK-SP-Ext and vendor modules. |
| 190 | if from.isVndkExt() { |
| 191 | if from.isVndkSp() { |
Martin Stjernholm | 257eb0c | 2018-10-15 13:05:27 +0100 | [diff] [blame] | 192 | if to.isVndk() && !to.isVndkSp() { |
| 193 | return errors.New("VNDK-SP extensions must not depend on VNDK or VNDK extensions") |
| 194 | } |
| 195 | return nil |
Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 196 | } |
| 197 | // VNDK-Ext may depend on VNDK, VNDK-Ext, VNDK-SP, VNDK-SP-Ext, or vendor libs. |
Martin Stjernholm | 257eb0c | 2018-10-15 13:05:27 +0100 | [diff] [blame] | 198 | return nil |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 199 | } |
Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 200 | if from.isVndk() { |
| 201 | if to.isVndkExt() { |
Martin Stjernholm | 257eb0c | 2018-10-15 13:05:27 +0100 | [diff] [blame] | 202 | return errors.New("VNDK-core and VNDK-SP must not depend on VNDK extensions") |
Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 203 | } |
| 204 | if from.isVndkSp() { |
Martin Stjernholm | 257eb0c | 2018-10-15 13:05:27 +0100 | [diff] [blame] | 205 | if !to.isVndkSp() { |
| 206 | return errors.New("VNDK-SP must only depend on VNDK-SP") |
| 207 | } |
| 208 | return nil |
Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 209 | } |
Martin Stjernholm | 257eb0c | 2018-10-15 13:05:27 +0100 | [diff] [blame] | 210 | if !to.isVndk() { |
| 211 | return errors.New("VNDK-core must only depend on VNDK-core or VNDK-SP") |
| 212 | } |
| 213 | return nil |
Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 214 | } |
| 215 | // Vendor modules may depend on VNDK, VNDK-Ext, VNDK-SP, VNDK-SP-Ext, or vendor libs. |
Martin Stjernholm | 257eb0c | 2018-10-15 13:05:27 +0100 | [diff] [blame] | 216 | return nil |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 217 | } |
Jiyong Park | d5b18a5 | 2017-08-03 21:22:50 +0900 | [diff] [blame] | 218 | |
Colin Cross | 7821224 | 2021-01-06 14:51:30 -0800 | [diff] [blame] | 219 | type moduleListerFunc func(ctx android.SingletonContext) (moduleNames, fileNames []string) |
| 220 | |
Jiyong Park | d5b18a5 | 2017-08-03 21:22:50 +0900 | [diff] [blame] | 221 | var ( |
Colin Cross | 203b421 | 2021-04-26 17:19:41 -0700 | [diff] [blame] | 222 | llndkLibraries = vndkModuleLister(func(m *Module) bool { return m.VendorProperties.IsLLNDK && !m.Header() }) |
Colin Cross | 7821224 | 2021-01-06 14:51:30 -0800 | [diff] [blame] | 223 | vndkSPLibraries = vndkModuleLister(func(m *Module) bool { return m.VendorProperties.IsVNDKSP }) |
| 224 | vndkCoreLibraries = vndkModuleLister(func(m *Module) bool { return m.VendorProperties.IsVNDKCore }) |
Colin Cross | 203b421 | 2021-04-26 17:19:41 -0700 | [diff] [blame] | 225 | vndkPrivateLibraries = vndkModuleLister(func(m *Module) bool { return m.VendorProperties.IsVNDKPrivate }) |
Colin Cross | 7821224 | 2021-01-06 14:51:30 -0800 | [diff] [blame] | 226 | vndkProductLibraries = vndkModuleLister(func(m *Module) bool { return m.VendorProperties.IsVNDKProduct }) |
| 227 | vndkUsingCoreVariantLibraries = vndkModuleLister(func(m *Module) bool { return m.VendorProperties.IsVNDKUsingCoreVariant }) |
Inseob Kim | ae55303 | 2019-05-14 18:52:49 +0900 | [diff] [blame] | 228 | ) |
Inseob Kim | 1f086e2 | 2019-05-09 13:29:15 +0900 | [diff] [blame] | 229 | |
Colin Cross | 7821224 | 2021-01-06 14:51:30 -0800 | [diff] [blame] | 230 | // vndkModuleLister takes a predicate that operates on a Module and returns a moduleListerFunc |
| 231 | // that produces a list of module names and output file names for which the predicate returns true. |
| 232 | func vndkModuleLister(predicate func(*Module) bool) moduleListerFunc { |
| 233 | return func(ctx android.SingletonContext) (moduleNames, fileNames []string) { |
| 234 | ctx.VisitAllModules(func(m android.Module) { |
Jooyung Han | e3f0281 | 2023-05-08 13:54:50 +0900 | [diff] [blame] | 235 | if c, ok := m.(*Module); ok && predicate(c) && !c.IsVndkPrebuiltLibrary() { |
Colin Cross | 7821224 | 2021-01-06 14:51:30 -0800 | [diff] [blame] | 236 | filename, err := getVndkFileName(c) |
| 237 | if err != nil { |
| 238 | ctx.ModuleErrorf(m, "%s", err) |
| 239 | } |
| 240 | moduleNames = append(moduleNames, ctx.ModuleName(m)) |
| 241 | fileNames = append(fileNames, filename) |
| 242 | } |
| 243 | }) |
| 244 | moduleNames = android.SortedUniqueStrings(moduleNames) |
| 245 | fileNames = android.SortedUniqueStrings(fileNames) |
| 246 | return |
| 247 | } |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 248 | } |
| 249 | |
Colin Cross | 7821224 | 2021-01-06 14:51:30 -0800 | [diff] [blame] | 250 | // vndkModuleListRemover takes a moduleListerFunc and a prefix and returns a moduleListerFunc |
| 251 | // that returns the same lists as the input moduleListerFunc, but with modules with the |
| 252 | // given prefix removed. |
| 253 | func vndkModuleListRemover(lister moduleListerFunc, prefix string) moduleListerFunc { |
| 254 | return func(ctx android.SingletonContext) (moduleNames, fileNames []string) { |
| 255 | moduleNames, fileNames = lister(ctx) |
| 256 | filter := func(in []string) []string { |
| 257 | out := make([]string, 0, len(in)) |
| 258 | for _, lib := range in { |
| 259 | if strings.HasPrefix(lib, prefix) { |
| 260 | continue |
| 261 | } |
| 262 | out = append(out, lib) |
| 263 | } |
| 264 | return out |
| 265 | } |
| 266 | return filter(moduleNames), filter(fileNames) |
| 267 | } |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 268 | } |
| 269 | |
Colin Cross | 7821224 | 2021-01-06 14:51:30 -0800 | [diff] [blame] | 270 | var vndkMustUseVendorVariantListKey = android.NewOnceKey("vndkMustUseVendorVariantListKey") |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 271 | |
Jooyung Han | 097087b | 2019-10-22 19:32:18 +0900 | [diff] [blame] | 272 | func vndkMustUseVendorVariantList(cfg android.Config) []string { |
| 273 | return cfg.Once(vndkMustUseVendorVariantListKey, func() interface{} { |
Jooyung Han | 097087b | 2019-10-22 19:32:18 +0900 | [diff] [blame] | 274 | return config.VndkMustUseVendorVariantList |
| 275 | }).([]string) |
| 276 | } |
| 277 | |
| 278 | // test may call this to override global configuration(config.VndkMustUseVendorVariantList) |
| 279 | // when it is called, it must be before the first call to vndkMustUseVendorVariantList() |
| 280 | func setVndkMustUseVendorVariantListForTest(config android.Config, mustUseVendorVariantList []string) { |
Jooyung Han | a463f72 | 2019-11-01 08:45:59 +0900 | [diff] [blame] | 281 | config.Once(vndkMustUseVendorVariantListKey, func() interface{} { |
Jooyung Han | 097087b | 2019-10-22 19:32:18 +0900 | [diff] [blame] | 282 | return mustUseVendorVariantList |
| 283 | }) |
| 284 | } |
| 285 | |
Inseob Kim | 1f086e2 | 2019-05-09 13:29:15 +0900 | [diff] [blame] | 286 | func processVndkLibrary(mctx android.BottomUpMutatorContext, m *Module) { |
Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 287 | if m.InProduct() { |
| 288 | // We may skip the steps for the product variants because they |
| 289 | // are already covered by the vendor variants. |
| 290 | return |
| 291 | } |
| 292 | |
Jooyung Han | 0302a84 | 2019-10-30 18:43:49 +0900 | [diff] [blame] | 293 | name := m.BaseModuleName() |
Inseob Kim | 1f086e2 | 2019-05-09 13:29:15 +0900 | [diff] [blame] | 294 | |
Colin Cross | 31076b3 | 2020-10-23 17:22:06 -0700 | [diff] [blame] | 295 | if lib := m.library; lib != nil && lib.hasStubsVariants() && name != "libz" { |
Jiyong Park | 2478e4e | 2020-05-18 09:30:14 +0000 | [diff] [blame] | 296 | // b/155456180 libz is the ONLY exception here. We don't want to make |
| 297 | // libz an LLNDK library because we in general can't guarantee that |
| 298 | // libz will behave consistently especially about the compression. |
| 299 | // i.e. the compressed output might be different across releases. |
| 300 | // As the library is an external one, it's risky to keep the compatibility |
| 301 | // promise if it becomes an LLNDK. |
Jiyong Park | ea97f51 | 2020-03-31 15:31:17 +0900 | [diff] [blame] | 302 | mctx.PropertyErrorf("vndk.enabled", "This library provides stubs. Shouldn't be VNDK. Consider making it as LLNDK") |
| 303 | } |
| 304 | |
Jooyung Han | 097087b | 2019-10-22 19:32:18 +0900 | [diff] [blame] | 305 | if inList(name, vndkMustUseVendorVariantList(mctx.Config())) { |
| 306 | m.Properties.MustUseVendorVariant = true |
| 307 | } |
Jooyung Han | 0302a84 | 2019-10-30 18:43:49 +0900 | [diff] [blame] | 308 | if mctx.DeviceConfig().VndkUseCoreVariant() && !m.Properties.MustUseVendorVariant { |
Colin Cross | 7821224 | 2021-01-06 14:51:30 -0800 | [diff] [blame] | 309 | m.VendorProperties.IsVNDKUsingCoreVariant = true |
Inseob Kim | 1f086e2 | 2019-05-09 13:29:15 +0900 | [diff] [blame] | 310 | } |
Jooyung Han | 0302a84 | 2019-10-30 18:43:49 +0900 | [diff] [blame] | 311 | |
Inseob Kim | 1f086e2 | 2019-05-09 13:29:15 +0900 | [diff] [blame] | 312 | if m.vndkdep.isVndkSp() { |
Colin Cross | 7821224 | 2021-01-06 14:51:30 -0800 | [diff] [blame] | 313 | m.VendorProperties.IsVNDKSP = true |
Inseob Kim | 1f086e2 | 2019-05-09 13:29:15 +0900 | [diff] [blame] | 314 | } else { |
Colin Cross | 7821224 | 2021-01-06 14:51:30 -0800 | [diff] [blame] | 315 | m.VendorProperties.IsVNDKCore = true |
Inseob Kim | 1f086e2 | 2019-05-09 13:29:15 +0900 | [diff] [blame] | 316 | } |
Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 317 | if m.IsVndkPrivate() { |
Colin Cross | 7821224 | 2021-01-06 14:51:30 -0800 | [diff] [blame] | 318 | m.VendorProperties.IsVNDKPrivate = true |
Inseob Kim | 1f086e2 | 2019-05-09 13:29:15 +0900 | [diff] [blame] | 319 | } |
Justin Yun | c0d8c49 | 2021-01-07 17:45:31 +0900 | [diff] [blame] | 320 | if Bool(m.VendorProperties.Product_available) { |
Colin Cross | 7821224 | 2021-01-06 14:51:30 -0800 | [diff] [blame] | 321 | m.VendorProperties.IsVNDKProduct = true |
Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 322 | } |
Inseob Kim | 1f086e2 | 2019-05-09 13:29:15 +0900 | [diff] [blame] | 323 | } |
| 324 | |
Yo Chiang | 08fac0c | 2020-07-29 01:08:20 +0800 | [diff] [blame] | 325 | // Check for modules that mustn't be VNDK |
Yo Chiang | bba545e | 2020-06-09 16:15:37 +0800 | [diff] [blame] | 326 | func shouldSkipVndkMutator(m *Module) bool { |
Jooyung Han | 31c470b | 2019-10-18 16:26:59 +0900 | [diff] [blame] | 327 | if !m.Enabled() { |
Yo Chiang | bba545e | 2020-06-09 16:15:37 +0800 | [diff] [blame] | 328 | return true |
Jooyung Han | 31c470b | 2019-10-18 16:26:59 +0900 | [diff] [blame] | 329 | } |
Yo Chiang | bba545e | 2020-06-09 16:15:37 +0800 | [diff] [blame] | 330 | if !m.Device() { |
| 331 | // Skip non-device modules |
| 332 | return true |
Jooyung Han | 87a7f30 | 2019-10-29 05:18:21 +0900 | [diff] [blame] | 333 | } |
Jooyung Han | 31c470b | 2019-10-18 16:26:59 +0900 | [diff] [blame] | 334 | if m.Target().NativeBridge == android.NativeBridgeEnabled { |
Yo Chiang | bba545e | 2020-06-09 16:15:37 +0800 | [diff] [blame] | 335 | // Skip native_bridge modules |
| 336 | return true |
| 337 | } |
| 338 | return false |
| 339 | } |
| 340 | |
| 341 | func IsForVndkApex(mctx android.BottomUpMutatorContext, m *Module) bool { |
| 342 | if shouldSkipVndkMutator(m) { |
Jooyung Han | 31c470b | 2019-10-18 16:26:59 +0900 | [diff] [blame] | 343 | return false |
| 344 | } |
| 345 | |
Jooyung Han | 31c470b | 2019-10-18 16:26:59 +0900 | [diff] [blame] | 346 | // TODO(b/142675459): Use enabled: to select target device in vndk_prebuilt_shared |
| 347 | // When b/142675459 is landed, remove following check |
Justin Yun | f14beaf | 2023-08-18 17:51:14 +0900 | [diff] [blame] | 348 | if p, ok := m.linker.(*vndkPrebuiltLibraryDecorator); ok { |
| 349 | // prebuilt vndk modules should match with device |
| 350 | if !p.MatchesWithDevice(mctx.DeviceConfig()) { |
| 351 | return false |
| 352 | } |
Jooyung Han | 31c470b | 2019-10-18 16:26:59 +0900 | [diff] [blame] | 353 | } |
| 354 | |
| 355 | if lib, ok := m.linker.(libraryInterface); ok { |
Jooyung Han | 1724d58 | 2022-12-21 10:17:44 +0900 | [diff] [blame] | 356 | // VNDK APEX doesn't need stub variants |
| 357 | if lib.buildStubs() { |
| 358 | return false |
| 359 | } |
Kiyoung Kim | fa13ff1 | 2024-03-18 16:01:19 +0900 | [diff] [blame] | 360 | useCoreVariant := mctx.DeviceConfig().VndkUseCoreVariant() && !m.MustUseVendorVariant() |
Ivan Lozano | 3968d8f | 2020-12-14 11:27:52 -0500 | [diff] [blame] | 361 | return lib.shared() && m.InVendor() && m.IsVndk() && !m.IsVndkExt() && !useCoreVariant |
Jooyung Han | 31c470b | 2019-10-18 16:26:59 +0900 | [diff] [blame] | 362 | } |
| 363 | return false |
| 364 | } |
| 365 | |
Inseob Kim | 1f086e2 | 2019-05-09 13:29:15 +0900 | [diff] [blame] | 366 | // gather list of vndk-core, vndk-sp, and ll-ndk libs |
| 367 | func VndkMutator(mctx android.BottomUpMutatorContext) { |
| 368 | m, ok := mctx.Module().(*Module) |
| 369 | if !ok { |
| 370 | return |
| 371 | } |
Yo Chiang | bba545e | 2020-06-09 16:15:37 +0800 | [diff] [blame] | 372 | |
| 373 | if shouldSkipVndkMutator(m) { |
Justin Yun | 7390ea3 | 2019-09-08 11:34:06 +0900 | [diff] [blame] | 374 | return |
| 375 | } |
Inseob Kim | 1f086e2 | 2019-05-09 13:29:15 +0900 | [diff] [blame] | 376 | |
Jaewoong Jung | 18aefc1 | 2020-12-21 09:11:10 -0800 | [diff] [blame] | 377 | lib, isLib := m.linker.(*libraryDecorator) |
| 378 | prebuiltLib, isPrebuiltLib := m.linker.(*prebuiltLibraryLinker) |
Inseob Kim | 1f086e2 | 2019-05-09 13:29:15 +0900 | [diff] [blame] | 379 | |
Kiyoung Kim | aa39480 | 2024-01-08 12:55:45 +0900 | [diff] [blame] | 380 | if m.InVendorOrProduct() && isLib && lib.hasLLNDKStubs() { |
Colin Cross | 0fb7fcd | 2021-03-02 11:00:07 -0800 | [diff] [blame] | 381 | m.VendorProperties.IsLLNDK = true |
| 382 | m.VendorProperties.IsVNDKPrivate = Bool(lib.Properties.Llndk.Private) |
| 383 | } |
Kiyoung Kim | aa39480 | 2024-01-08 12:55:45 +0900 | [diff] [blame] | 384 | if m.InVendorOrProduct() && isPrebuiltLib && prebuiltLib.hasLLNDKStubs() { |
Colin Cross | 0fb7fcd | 2021-03-02 11:00:07 -0800 | [diff] [blame] | 385 | m.VendorProperties.IsLLNDK = true |
| 386 | m.VendorProperties.IsVNDKPrivate = Bool(prebuiltLib.Properties.Llndk.Private) |
| 387 | } |
| 388 | |
Jooyung Han | e3f0281 | 2023-05-08 13:54:50 +0900 | [diff] [blame] | 389 | if m.IsVndkPrebuiltLibrary() && !m.IsVndk() { |
| 390 | m.VendorProperties.IsLLNDK = true |
| 391 | // TODO(b/280697209): copy "llndk.private" flag to vndk_prebuilt_shared |
| 392 | } |
| 393 | |
Jaewoong Jung | 18aefc1 | 2020-12-21 09:11:10 -0800 | [diff] [blame] | 394 | if (isLib && lib.buildShared()) || (isPrebuiltLib && prebuiltLib.buildShared()) { |
Inseob Kim | 64c4395 | 2019-08-26 16:52:35 +0900 | [diff] [blame] | 395 | if m.vndkdep != nil && m.vndkdep.isVndk() && !m.vndkdep.isVndkExt() { |
Inseob Kim | 1f086e2 | 2019-05-09 13:29:15 +0900 | [diff] [blame] | 396 | processVndkLibrary(mctx, m) |
| 397 | return |
| 398 | } |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | func init() { |
Colin Cross | e4e44bc | 2020-12-28 13:50:21 -0800 | [diff] [blame] | 403 | RegisterVndkLibraryTxtTypes(android.InitRegistrationContext) |
Inseob Kim | 1f086e2 | 2019-05-09 13:29:15 +0900 | [diff] [blame] | 404 | } |
| 405 | |
Colin Cross | e4e44bc | 2020-12-28 13:50:21 -0800 | [diff] [blame] | 406 | func RegisterVndkLibraryTxtTypes(ctx android.RegistrationContext) { |
LaMont Jones | 0c10e4d | 2023-05-16 00:58:37 +0000 | [diff] [blame] | 407 | ctx.RegisterParallelSingletonModuleType("llndk_libraries_txt", llndkLibrariesTxtFactory) |
Justin Yun | d578412 | 2023-10-25 13:25:32 +0900 | [diff] [blame] | 408 | ctx.RegisterParallelSingletonModuleType("llndk_libraries_txt_for_apex", llndkLibrariesTxtApexOnlyFactory) |
LaMont Jones | 0c10e4d | 2023-05-16 00:58:37 +0000 | [diff] [blame] | 409 | ctx.RegisterParallelSingletonModuleType("vndksp_libraries_txt", vndkSPLibrariesTxtFactory) |
| 410 | ctx.RegisterParallelSingletonModuleType("vndkcore_libraries_txt", vndkCoreLibrariesTxtFactory) |
| 411 | ctx.RegisterParallelSingletonModuleType("vndkprivate_libraries_txt", vndkPrivateLibrariesTxtFactory) |
| 412 | ctx.RegisterParallelSingletonModuleType("vndkproduct_libraries_txt", vndkProductLibrariesTxtFactory) |
| 413 | ctx.RegisterParallelSingletonModuleType("vndkcorevariant_libraries_txt", vndkUsingCoreVariantLibrariesTxtFactory) |
Colin Cross | e4e44bc | 2020-12-28 13:50:21 -0800 | [diff] [blame] | 414 | } |
| 415 | |
Jooyung Han | 2216fb1 | 2019-11-06 16:46:15 +0900 | [diff] [blame] | 416 | type vndkLibrariesTxt struct { |
Colin Cross | 7821224 | 2021-01-06 14:51:30 -0800 | [diff] [blame] | 417 | android.SingletonModuleBase |
Colin Cross | e4e44bc | 2020-12-28 13:50:21 -0800 | [diff] [blame] | 418 | |
Justin Yun | 611e886 | 2021-05-24 18:17:33 +0900 | [diff] [blame] | 419 | lister moduleListerFunc |
| 420 | makeVarName string |
| 421 | filterOutFromMakeVar string |
Colin Cross | 7821224 | 2021-01-06 14:51:30 -0800 | [diff] [blame] | 422 | |
Colin Cross | e4e44bc | 2020-12-28 13:50:21 -0800 | [diff] [blame] | 423 | properties VndkLibrariesTxtProperties |
| 424 | |
Colin Cross | 7821224 | 2021-01-06 14:51:30 -0800 | [diff] [blame] | 425 | outputFile android.OutputPath |
| 426 | moduleNames []string |
| 427 | fileNames []string |
Jooyung Han | 2216fb1 | 2019-11-06 16:46:15 +0900 | [diff] [blame] | 428 | } |
| 429 | |
Colin Cross | e4e44bc | 2020-12-28 13:50:21 -0800 | [diff] [blame] | 430 | type VndkLibrariesTxtProperties struct { |
| 431 | Insert_vndk_version *bool |
Justin Yun | d578412 | 2023-10-25 13:25:32 +0900 | [diff] [blame] | 432 | Stem *string |
Colin Cross | e4e44bc | 2020-12-28 13:50:21 -0800 | [diff] [blame] | 433 | } |
| 434 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 435 | var _ etc.PrebuiltEtcModule = &vndkLibrariesTxt{} |
Jooyung Han | 39edb6c | 2019-11-06 16:53:07 +0900 | [diff] [blame] | 436 | var _ android.OutputFileProducer = &vndkLibrariesTxt{} |
| 437 | |
Colin Cross | 7821224 | 2021-01-06 14:51:30 -0800 | [diff] [blame] | 438 | // llndk_libraries_txt is a singleton module whose content is a list of LLNDK libraries |
Justin Yun | d578412 | 2023-10-25 13:25:32 +0900 | [diff] [blame] | 439 | // generated by Soong. |
Justin Yun | 611e886 | 2021-05-24 18:17:33 +0900 | [diff] [blame] | 440 | // Make uses LLNDK_LIBRARIES to determine which libraries to install. |
Justin Yun | d578412 | 2023-10-25 13:25:32 +0900 | [diff] [blame] | 441 | // HWASAN is only part of the LLNDK in builds in which libc depends on HWASAN. |
Justin Yun | 611e886 | 2021-05-24 18:17:33 +0900 | [diff] [blame] | 442 | // Therefore, by removing the library here, we cause it to only be installed if libc |
| 443 | // depends on it. |
Colin Cross | 7821224 | 2021-01-06 14:51:30 -0800 | [diff] [blame] | 444 | func llndkLibrariesTxtFactory() android.SingletonModule { |
Colin Cross | 4c4c1be | 2022-02-10 11:41:18 -0800 | [diff] [blame] | 445 | return newVndkLibrariesWithMakeVarFilter(llndkLibraries, "LLNDK_LIBRARIES", "libclang_rt.hwasan") |
Colin Cross | 7821224 | 2021-01-06 14:51:30 -0800 | [diff] [blame] | 446 | } |
| 447 | |
Justin Yun | d578412 | 2023-10-25 13:25:32 +0900 | [diff] [blame] | 448 | // llndk_libraries_txt_for_apex is a singleton module that provide the same LLNDK libraries list |
| 449 | // with the llndk_libraries_txt, but skips setting make variable LLNDK_LIBRARIES. So, it must not |
| 450 | // be used without installing llndk_libraries_txt singleton. |
| 451 | // We include llndk_libraries_txt by default to install the llndk.libraries.txt file to system/etc. |
| 452 | // This singleton module is to install the llndk.libraries.<ver>.txt file to vndk apex. |
| 453 | func llndkLibrariesTxtApexOnlyFactory() android.SingletonModule { |
| 454 | return newVndkLibrariesWithMakeVarFilter(llndkLibraries, "", "libclang_rt.hwasan") |
| 455 | } |
| 456 | |
Colin Cross | 7821224 | 2021-01-06 14:51:30 -0800 | [diff] [blame] | 457 | // vndksp_libraries_txt is a singleton module whose content is a list of VNDKSP libraries |
| 458 | // generated by Soong but can be referenced by other modules. |
| 459 | // For example, apex_vndk can depend on these files as prebuilt. |
| 460 | func vndkSPLibrariesTxtFactory() android.SingletonModule { |
| 461 | return newVndkLibrariesTxt(vndkSPLibraries, "VNDK_SAMEPROCESS_LIBRARIES") |
| 462 | } |
| 463 | |
| 464 | // vndkcore_libraries_txt is a singleton module whose content is a list of VNDK core libraries |
| 465 | // generated by Soong but can be referenced by other modules. |
| 466 | // For example, apex_vndk can depend on these files as prebuilt. |
| 467 | func vndkCoreLibrariesTxtFactory() android.SingletonModule { |
| 468 | return newVndkLibrariesTxt(vndkCoreLibraries, "VNDK_CORE_LIBRARIES") |
| 469 | } |
| 470 | |
| 471 | // vndkprivate_libraries_txt is a singleton module whose content is a list of VNDK private libraries |
| 472 | // generated by Soong but can be referenced by other modules. |
| 473 | // For example, apex_vndk can depend on these files as prebuilt. |
| 474 | func vndkPrivateLibrariesTxtFactory() android.SingletonModule { |
| 475 | return newVndkLibrariesTxt(vndkPrivateLibraries, "VNDK_PRIVATE_LIBRARIES") |
| 476 | } |
| 477 | |
| 478 | // vndkproduct_libraries_txt is a singleton module whose content is a list of VNDK product libraries |
| 479 | // generated by Soong but can be referenced by other modules. |
| 480 | // For example, apex_vndk can depend on these files as prebuilt. |
| 481 | func vndkProductLibrariesTxtFactory() android.SingletonModule { |
| 482 | return newVndkLibrariesTxt(vndkProductLibraries, "VNDK_PRODUCT_LIBRARIES") |
| 483 | } |
| 484 | |
| 485 | // vndkcorevariant_libraries_txt is a singleton module whose content is a list of VNDK libraries |
| 486 | // that are using the core variant, generated by Soong but can be referenced by other modules. |
| 487 | // For example, apex_vndk can depend on these files as prebuilt. |
| 488 | func vndkUsingCoreVariantLibrariesTxtFactory() android.SingletonModule { |
| 489 | return newVndkLibrariesTxt(vndkUsingCoreVariantLibraries, "VNDK_USING_CORE_VARIANT_LIBRARIES") |
| 490 | } |
| 491 | |
Justin Yun | 611e886 | 2021-05-24 18:17:33 +0900 | [diff] [blame] | 492 | func newVndkLibrariesWithMakeVarFilter(lister moduleListerFunc, makeVarName string, filter string) android.SingletonModule { |
Colin Cross | 7821224 | 2021-01-06 14:51:30 -0800 | [diff] [blame] | 493 | m := &vndkLibrariesTxt{ |
Justin Yun | 611e886 | 2021-05-24 18:17:33 +0900 | [diff] [blame] | 494 | lister: lister, |
| 495 | makeVarName: makeVarName, |
| 496 | filterOutFromMakeVar: filter, |
Colin Cross | e4e44bc | 2020-12-28 13:50:21 -0800 | [diff] [blame] | 497 | } |
Colin Cross | 7821224 | 2021-01-06 14:51:30 -0800 | [diff] [blame] | 498 | m.AddProperties(&m.properties) |
Colin Cross | 45bce85 | 2021-11-11 22:47:54 -0800 | [diff] [blame] | 499 | android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon) |
Colin Cross | 7821224 | 2021-01-06 14:51:30 -0800 | [diff] [blame] | 500 | return m |
Jooyung Han | 2216fb1 | 2019-11-06 16:46:15 +0900 | [diff] [blame] | 501 | } |
| 502 | |
Justin Yun | 611e886 | 2021-05-24 18:17:33 +0900 | [diff] [blame] | 503 | func newVndkLibrariesTxt(lister moduleListerFunc, makeVarName string) android.SingletonModule { |
| 504 | return newVndkLibrariesWithMakeVarFilter(lister, makeVarName, "") |
| 505 | } |
| 506 | |
Jooyung Han | 2216fb1 | 2019-11-06 16:46:15 +0900 | [diff] [blame] | 507 | func insertVndkVersion(filename string, vndkVersion string) string { |
| 508 | if index := strings.LastIndex(filename, "."); index != -1 { |
| 509 | return filename[:index] + "." + vndkVersion + filename[index:] |
| 510 | } |
| 511 | return filename |
| 512 | } |
| 513 | |
Colin Cross | e4e44bc | 2020-12-28 13:50:21 -0800 | [diff] [blame] | 514 | func (txt *vndkLibrariesTxt) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Justin Yun | d578412 | 2023-10-25 13:25:32 +0900 | [diff] [blame] | 515 | filename := proptools.StringDefault(txt.properties.Stem, txt.Name()) |
Kiyoung Kim | a2d6dee | 2023-08-11 10:14:43 +0900 | [diff] [blame] | 516 | |
Jooyung Han | 2216fb1 | 2019-11-06 16:46:15 +0900 | [diff] [blame] | 517 | txt.outputFile = android.PathForModuleOut(ctx, filename).OutputPath |
Jooyung Han | 2216fb1 | 2019-11-06 16:46:15 +0900 | [diff] [blame] | 518 | |
| 519 | installPath := android.PathForModuleInstall(ctx, "etc") |
| 520 | ctx.InstallFile(installPath, filename, txt.outputFile) |
| 521 | } |
| 522 | |
Colin Cross | 7821224 | 2021-01-06 14:51:30 -0800 | [diff] [blame] | 523 | func (txt *vndkLibrariesTxt) GenerateSingletonBuildActions(ctx android.SingletonContext) { |
| 524 | txt.moduleNames, txt.fileNames = txt.lister(ctx) |
| 525 | android.WriteFileRule(ctx, txt.outputFile, strings.Join(txt.fileNames, "\n")) |
| 526 | } |
| 527 | |
Jiyong Park | 0b0e1b9 | 2019-12-03 13:24:29 +0900 | [diff] [blame] | 528 | func (txt *vndkLibrariesTxt) AndroidMkEntries() []android.AndroidMkEntries { |
| 529 | return []android.AndroidMkEntries{android.AndroidMkEntries{ |
Jooyung Han | 2216fb1 | 2019-11-06 16:46:15 +0900 | [diff] [blame] | 530 | Class: "ETC", |
| 531 | OutputFile: android.OptionalPathForPath(txt.outputFile), |
| 532 | ExtraEntries: []android.AndroidMkExtraEntriesFunc{ |
Colin Cross | aa25553 | 2020-07-03 13:18:24 -0700 | [diff] [blame] | 533 | func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { |
Jooyung Han | 2216fb1 | 2019-11-06 16:46:15 +0900 | [diff] [blame] | 534 | entries.SetString("LOCAL_MODULE_STEM", txt.outputFile.Base()) |
| 535 | }, |
| 536 | }, |
Jiyong Park | 0b0e1b9 | 2019-12-03 13:24:29 +0900 | [diff] [blame] | 537 | }} |
Jooyung Han | 2216fb1 | 2019-11-06 16:46:15 +0900 | [diff] [blame] | 538 | } |
| 539 | |
Colin Cross | 7821224 | 2021-01-06 14:51:30 -0800 | [diff] [blame] | 540 | func (txt *vndkLibrariesTxt) MakeVars(ctx android.MakeVarsContext) { |
Justin Yun | d578412 | 2023-10-25 13:25:32 +0900 | [diff] [blame] | 541 | if txt.makeVarName == "" { |
| 542 | return |
| 543 | } |
| 544 | |
Justin Yun | 611e886 | 2021-05-24 18:17:33 +0900 | [diff] [blame] | 545 | filter := func(modules []string, prefix string) []string { |
| 546 | if prefix == "" { |
| 547 | return modules |
| 548 | } |
| 549 | var result []string |
| 550 | for _, module := range modules { |
| 551 | if strings.HasPrefix(module, prefix) { |
| 552 | continue |
| 553 | } else { |
| 554 | result = append(result, module) |
| 555 | } |
| 556 | } |
| 557 | return result |
| 558 | } |
| 559 | ctx.Strict(txt.makeVarName, strings.Join(filter(txt.moduleNames, txt.filterOutFromMakeVar), " ")) |
Colin Cross | 7821224 | 2021-01-06 14:51:30 -0800 | [diff] [blame] | 560 | } |
| 561 | |
Jooyung Han | 0703fd8 | 2020-08-26 22:11:53 +0900 | [diff] [blame] | 562 | // PrebuiltEtcModule interface |
Jooyung Han | 39edb6c | 2019-11-06 16:53:07 +0900 | [diff] [blame] | 563 | func (txt *vndkLibrariesTxt) OutputFile() android.OutputPath { |
| 564 | return txt.outputFile |
| 565 | } |
| 566 | |
Jooyung Han | 0703fd8 | 2020-08-26 22:11:53 +0900 | [diff] [blame] | 567 | // PrebuiltEtcModule interface |
| 568 | func (txt *vndkLibrariesTxt) BaseDir() string { |
| 569 | return "etc" |
Jooyung Han | 39edb6c | 2019-11-06 16:53:07 +0900 | [diff] [blame] | 570 | } |
| 571 | |
Jooyung Han | 0703fd8 | 2020-08-26 22:11:53 +0900 | [diff] [blame] | 572 | // PrebuiltEtcModule interface |
Jooyung Han | 39edb6c | 2019-11-06 16:53:07 +0900 | [diff] [blame] | 573 | func (txt *vndkLibrariesTxt) SubDir() string { |
| 574 | return "" |
| 575 | } |
| 576 | |
Jooyung Han | 0703fd8 | 2020-08-26 22:11:53 +0900 | [diff] [blame] | 577 | func (txt *vndkLibrariesTxt) OutputFiles(tag string) (android.Paths, error) { |
| 578 | return android.Paths{txt.outputFile}, nil |
| 579 | } |
Jooyung Han | 0302a84 | 2019-10-30 18:43:49 +0900 | [diff] [blame] | 580 | func getVndkFileName(m *Module) (string, error) { |
| 581 | if library, ok := m.linker.(*libraryDecorator); ok { |
Justin Yun | 6977e8a | 2020-10-29 18:24:11 +0900 | [diff] [blame] | 582 | return library.getLibNameHelper(m.BaseModuleName(), true, false) + ".so", nil |
Jooyung Han | 0302a84 | 2019-10-30 18:43:49 +0900 | [diff] [blame] | 583 | } |
| 584 | if prebuilt, ok := m.linker.(*prebuiltLibraryLinker); ok { |
Justin Yun | 6977e8a | 2020-10-29 18:24:11 +0900 | [diff] [blame] | 585 | return prebuilt.libraryDecorator.getLibNameHelper(m.BaseModuleName(), true, false) + ".so", nil |
Jooyung Han | 0302a84 | 2019-10-30 18:43:49 +0900 | [diff] [blame] | 586 | } |
| 587 | return "", fmt.Errorf("VNDK library should have libraryDecorator or prebuiltLibraryLinker as linker: %T", m.linker) |
Jooyung Han | 097087b | 2019-10-22 19:32:18 +0900 | [diff] [blame] | 588 | } |