| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 1 | // Copyright 2015 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 | |
| Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 15 | package android |
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 16 | |
| 17 | import ( |
| 18 | "bytes" |
| Dan Willemsen | 9775052 | 2016-02-09 17:43:51 -0800 | [diff] [blame] | 19 | "fmt" |
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 20 | "io" |
| 21 | "io/ioutil" |
| 22 | "os" |
| 23 | "path/filepath" |
| Bob Badour | 987f33c | 2021-01-07 03:34:31 +0000 | [diff] [blame] | 24 | "reflect" |
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 25 | "sort" |
| Dan Willemsen | 0fda89f | 2016-06-01 15:25:32 -0700 | [diff] [blame] | 26 | "strings" |
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 27 | |
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 28 | "github.com/google/blueprint" |
| Colin Cross | 2465c3d | 2018-09-28 10:19:18 -0700 | [diff] [blame] | 29 | "github.com/google/blueprint/bootstrap" |
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 30 | ) |
| 31 | |
| 32 | func init() { |
| Paul Duffin | 22595f9 | 2020-03-04 20:15:08 +0000 | [diff] [blame] | 33 | RegisterAndroidMkBuildComponents(InitRegistrationContext) |
| 34 | } |
| 35 | |
| 36 | func RegisterAndroidMkBuildComponents(ctx RegistrationContext) { |
| 37 | ctx.RegisterSingletonType("androidmk", AndroidMkSingleton) |
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 38 | } |
| 39 | |
| Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 40 | // Deprecated: consider using AndroidMkEntriesProvider instead, especially if you're not going to |
| 41 | // use the Custom function. |
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 42 | type AndroidMkDataProvider interface { |
| Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 43 | AndroidMk() AndroidMkData |
| Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 44 | BaseModuleName() string |
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | type AndroidMkData struct { |
| Sasha Smundak | b6d2305 | 2019-04-01 18:37:36 -0700 | [diff] [blame] | 48 | Class string |
| 49 | SubName string |
| Jingwen Chen | 803474e | 2020-06-15 05:24:19 +0000 | [diff] [blame] | 50 | DistFiles TaggedDistFiles |
| Sasha Smundak | b6d2305 | 2019-04-01 18:37:36 -0700 | [diff] [blame] | 51 | OutputFile OptionalPath |
| 52 | Disabled bool |
| 53 | Include string |
| 54 | Required []string |
| 55 | Host_required []string |
| 56 | Target_required []string |
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 57 | |
| Colin Cross | 0f86d18 | 2017-08-10 17:07:28 -0700 | [diff] [blame] | 58 | Custom func(w io.Writer, name, prefix, moduleDir string, data AndroidMkData) |
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 59 | |
| Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 60 | Extra []AndroidMkExtraFunc |
| Colin Cross | 0f86d18 | 2017-08-10 17:07:28 -0700 | [diff] [blame] | 61 | |
| 62 | preamble bytes.Buffer |
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 63 | } |
| 64 | |
| Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 65 | type AndroidMkExtraFunc func(w io.Writer, outputFile Path) |
| 66 | |
| Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 67 | // Allows modules to customize their Android*.mk output. |
| 68 | type AndroidMkEntriesProvider interface { |
| Jiyong Park | 0b0e1b9 | 2019-12-03 13:24:29 +0900 | [diff] [blame] | 69 | AndroidMkEntries() []AndroidMkEntries |
| Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 70 | BaseModuleName() string |
| 71 | } |
| 72 | |
| 73 | type AndroidMkEntries struct { |
| 74 | Class string |
| 75 | SubName string |
| Jingwen Chen | 803474e | 2020-06-15 05:24:19 +0000 | [diff] [blame] | 76 | DistFiles TaggedDistFiles |
| Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 77 | OutputFile OptionalPath |
| 78 | Disabled bool |
| 79 | Include string |
| 80 | Required []string |
| 81 | Host_required []string |
| 82 | Target_required []string |
| 83 | |
| 84 | header bytes.Buffer |
| 85 | footer bytes.Buffer |
| 86 | |
| Jaewoong Jung | e0dc8df | 2019-08-27 17:33:16 -0700 | [diff] [blame] | 87 | ExtraEntries []AndroidMkExtraEntriesFunc |
| Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 88 | ExtraFooters []AndroidMkExtraFootersFunc |
| Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 89 | |
| 90 | EntryMap map[string][]string |
| 91 | entryOrder []string |
| 92 | } |
| 93 | |
| Jaewoong Jung | e0dc8df | 2019-08-27 17:33:16 -0700 | [diff] [blame] | 94 | type AndroidMkExtraEntriesFunc func(entries *AndroidMkEntries) |
| Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 95 | type AndroidMkExtraFootersFunc func(w io.Writer, name, prefix, moduleDir string, entries *AndroidMkEntries) |
| Jaewoong Jung | e0dc8df | 2019-08-27 17:33:16 -0700 | [diff] [blame] | 96 | |
| Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 97 | func (a *AndroidMkEntries) SetString(name, value string) { |
| 98 | if _, ok := a.EntryMap[name]; !ok { |
| 99 | a.entryOrder = append(a.entryOrder, name) |
| 100 | } |
| 101 | a.EntryMap[name] = []string{value} |
| 102 | } |
| 103 | |
| Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 104 | func (a *AndroidMkEntries) SetPath(name string, path Path) { |
| 105 | if _, ok := a.EntryMap[name]; !ok { |
| 106 | a.entryOrder = append(a.entryOrder, name) |
| 107 | } |
| 108 | a.EntryMap[name] = []string{path.String()} |
| 109 | } |
| 110 | |
| Colin Cross | 1d11c87 | 2020-07-03 11:56:24 -0700 | [diff] [blame] | 111 | func (a *AndroidMkEntries) SetOptionalPath(name string, path OptionalPath) { |
| 112 | if path.Valid() { |
| 113 | a.SetPath(name, path.Path()) |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | func (a *AndroidMkEntries) AddPath(name string, path Path) { |
| 118 | if _, ok := a.EntryMap[name]; !ok { |
| 119 | a.entryOrder = append(a.entryOrder, name) |
| 120 | } |
| 121 | a.EntryMap[name] = append(a.EntryMap[name], path.String()) |
| 122 | } |
| 123 | |
| 124 | func (a *AndroidMkEntries) AddOptionalPath(name string, path OptionalPath) { |
| 125 | if path.Valid() { |
| 126 | a.AddPath(name, path.Path()) |
| 127 | } |
| 128 | } |
| 129 | |
| Colin Cross | 5bc1744 | 2020-07-21 20:31:17 -0700 | [diff] [blame] | 130 | func (a *AndroidMkEntries) SetPaths(name string, paths Paths) { |
| 131 | if _, ok := a.EntryMap[name]; !ok { |
| 132 | a.entryOrder = append(a.entryOrder, name) |
| 133 | } |
| 134 | a.EntryMap[name] = paths.Strings() |
| 135 | } |
| 136 | |
| 137 | func (a *AndroidMkEntries) SetOptionalPaths(name string, paths Paths) { |
| 138 | if len(paths) > 0 { |
| 139 | a.SetPaths(name, paths) |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | func (a *AndroidMkEntries) AddPaths(name string, paths Paths) { |
| 144 | if _, ok := a.EntryMap[name]; !ok { |
| 145 | a.entryOrder = append(a.entryOrder, name) |
| 146 | } |
| 147 | a.EntryMap[name] = append(a.EntryMap[name], paths.Strings()...) |
| 148 | } |
| 149 | |
| Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 150 | func (a *AndroidMkEntries) SetBoolIfTrue(name string, flag bool) { |
| 151 | if flag { |
| 152 | if _, ok := a.EntryMap[name]; !ok { |
| 153 | a.entryOrder = append(a.entryOrder, name) |
| 154 | } |
| 155 | a.EntryMap[name] = []string{"true"} |
| 156 | } |
| 157 | } |
| 158 | |
| Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 159 | func (a *AndroidMkEntries) SetBool(name string, flag bool) { |
| 160 | if _, ok := a.EntryMap[name]; !ok { |
| 161 | a.entryOrder = append(a.entryOrder, name) |
| 162 | } |
| 163 | if flag { |
| 164 | a.EntryMap[name] = []string{"true"} |
| 165 | } else { |
| 166 | a.EntryMap[name] = []string{"false"} |
| 167 | } |
| 168 | } |
| 169 | |
| Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 170 | func (a *AndroidMkEntries) AddStrings(name string, value ...string) { |
| 171 | if len(value) == 0 { |
| 172 | return |
| 173 | } |
| 174 | if _, ok := a.EntryMap[name]; !ok { |
| 175 | a.entryOrder = append(a.entryOrder, name) |
| 176 | } |
| 177 | a.EntryMap[name] = append(a.EntryMap[name], value...) |
| 178 | } |
| 179 | |
| Treehugger Robot | 6a421b3 | 2020-12-01 22:37:46 +0000 | [diff] [blame] | 180 | // AddCompatibilityTestSuites adds the supplied test suites to the EntryMap, with special handling |
| 181 | // for partial MTS test suites. |
| 182 | func (a *AndroidMkEntries) AddCompatibilityTestSuites(suites ...string) { |
| 183 | // MTS supports a full test suite and partial per-module MTS test suites, with naming mts-${MODULE}. |
| 184 | // To reduce repetition, if we find a partial MTS test suite without an full MTS test suite, |
| 185 | // we add the full test suite to our list. |
| 186 | if PrefixInList(suites, "mts-") && !InList("mts", suites) { |
| 187 | suites = append(suites, "mts") |
| 188 | } |
| 189 | a.AddStrings("LOCAL_COMPATIBILITY_SUITE", suites...) |
| 190 | } |
| 191 | |
| Jingwen Chen | 803474e | 2020-06-15 05:24:19 +0000 | [diff] [blame] | 192 | // Compute the list of Make strings to declare phone goals and dist-for-goals |
| 193 | // calls from the module's dist and dists properties. |
| 194 | func (a *AndroidMkEntries) GetDistForGoals(mod blueprint.Module) []string { |
| 195 | amod := mod.(Module).base() |
| 196 | name := amod.BaseModuleName() |
| 197 | |
| 198 | var ret []string |
| Jingwen Chen | e80262a | 2020-07-24 09:13:49 +0000 | [diff] [blame] | 199 | var availableTaggedDists TaggedDistFiles |
| Jingwen Chen | 803474e | 2020-06-15 05:24:19 +0000 | [diff] [blame] | 200 | |
| Jingwen Chen | 06c3b41 | 2020-07-21 11:32:19 +0000 | [diff] [blame] | 201 | if a.DistFiles != nil { |
| Jingwen Chen | 803474e | 2020-06-15 05:24:19 +0000 | [diff] [blame] | 202 | availableTaggedDists = a.DistFiles |
| 203 | } else if a.OutputFile.Valid() { |
| 204 | availableTaggedDists = MakeDefaultDistFiles(a.OutputFile.Path()) |
| Jingwen Chen | e80262a | 2020-07-24 09:13:49 +0000 | [diff] [blame] | 205 | } else { |
| 206 | // Nothing dist-able for this module. |
| 207 | return nil |
| Jingwen Chen | 803474e | 2020-06-15 05:24:19 +0000 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | // Iterate over this module's dist structs, merged from the dist and dists properties. |
| 211 | for _, dist := range amod.Dists() { |
| 212 | // Get the list of goals this dist should be enabled for. e.g. sdk, droidcore |
| 213 | goals := strings.Join(dist.Targets, " ") |
| 214 | |
| 215 | // Get the tag representing the output files to be dist'd. e.g. ".jar", ".proguard_map" |
| 216 | var tag string |
| 217 | if dist.Tag == nil { |
| 218 | // If the dist struct does not specify a tag, use the default output files tag. |
| 219 | tag = "" |
| 220 | } else { |
| 221 | tag = *dist.Tag |
| 222 | } |
| 223 | |
| 224 | // Get the paths of the output files to be dist'd, represented by the tag. |
| 225 | // Can be an empty list. |
| 226 | tagPaths := availableTaggedDists[tag] |
| 227 | if len(tagPaths) == 0 { |
| 228 | // Nothing to dist for this tag, continue to the next dist. |
| 229 | continue |
| 230 | } |
| 231 | |
| 232 | if len(tagPaths) > 1 && (dist.Dest != nil || dist.Suffix != nil) { |
| 233 | errorMessage := "Cannot apply dest/suffix for more than one dist " + |
| 234 | "file for %s goals in module %s. The list of dist files, " + |
| 235 | "which should have a single element, is:\n%s" |
| 236 | panic(fmt.Errorf(errorMessage, goals, name, tagPaths)) |
| 237 | } |
| 238 | |
| 239 | ret = append(ret, fmt.Sprintf(".PHONY: %s\n", goals)) |
| 240 | |
| 241 | // Create dist-for-goals calls for each path in the dist'd files. |
| 242 | for _, path := range tagPaths { |
| 243 | // It's possible that the Path is nil from errant modules. Be defensive here. |
| 244 | if path == nil { |
| 245 | tagName := "default" // for error message readability |
| 246 | if dist.Tag != nil { |
| 247 | tagName = *dist.Tag |
| 248 | } |
| 249 | panic(fmt.Errorf("Dist file should not be nil for the %s tag in %s", tagName, name)) |
| 250 | } |
| 251 | |
| 252 | dest := filepath.Base(path.String()) |
| 253 | |
| 254 | if dist.Dest != nil { |
| 255 | var err error |
| 256 | if dest, err = validateSafePath(*dist.Dest); err != nil { |
| 257 | // This was checked in ModuleBase.GenerateBuildActions |
| 258 | panic(err) |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | if dist.Suffix != nil { |
| 263 | ext := filepath.Ext(dest) |
| 264 | suffix := *dist.Suffix |
| 265 | dest = strings.TrimSuffix(dest, ext) + suffix + ext |
| 266 | } |
| 267 | |
| 268 | if dist.Dir != nil { |
| 269 | var err error |
| 270 | if dest, err = validateSafePath(*dist.Dir, dest); err != nil { |
| 271 | // This was checked in ModuleBase.GenerateBuildActions |
| 272 | panic(err) |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | ret = append( |
| 277 | ret, |
| 278 | fmt.Sprintf("$(call dist-for-goals,%s,%s:%s)\n", goals, path.String(), dest)) |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | return ret |
| 283 | } |
| 284 | |
| Bob Badour | 987f33c | 2021-01-07 03:34:31 +0000 | [diff] [blame] | 285 | // Write the license variables to Make for AndroidMkData.Custom(..) methods that do not call WriteAndroidMkData(..) |
| 286 | // It's required to propagate the license metadata even for module types that have non-standard interfaces to Make. |
| 287 | func (a *AndroidMkEntries) WriteLicenseVariables(w io.Writer) { |
| 288 | fmt.Fprintln(w, "LOCAL_LICENSE_KINDS :=", strings.Join(a.EntryMap["LOCAL_LICENSE_KINDS"], " ")) |
| 289 | fmt.Fprintln(w, "LOCAL_LICENSE_CONDITIONS :=", strings.Join(a.EntryMap["LOCAL_LICENSE_CONDITIONS"], " ")) |
| 290 | fmt.Fprintln(w, "LOCAL_NOTICE_FILE :=", strings.Join(a.EntryMap["LOCAL_NOTICE_FILE"], " ")) |
| 291 | if pn, ok := a.EntryMap["LOCAL_LICENSE_PACKAGE_NAME"]; ok { |
| 292 | fmt.Fprintln(w, "LOCAL_LICENSE_PACKAGE_NAME :=", strings.Join(pn, " ")) |
| 293 | } |
| 294 | } |
| 295 | |
| Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 296 | func (a *AndroidMkEntries) fillInEntries(config Config, bpPath string, mod blueprint.Module) { |
| 297 | a.EntryMap = make(map[string][]string) |
| 298 | amod := mod.(Module).base() |
| 299 | name := amod.BaseModuleName() |
| 300 | |
| 301 | if a.Include == "" { |
| 302 | a.Include = "$(BUILD_PREBUILT)" |
| 303 | } |
| 304 | a.Required = append(a.Required, amod.commonProperties.Required...) |
| 305 | a.Host_required = append(a.Host_required, amod.commonProperties.Host_required...) |
| 306 | a.Target_required = append(a.Target_required, amod.commonProperties.Target_required...) |
| 307 | |
| Jingwen Chen | 803474e | 2020-06-15 05:24:19 +0000 | [diff] [blame] | 308 | for _, distString := range a.GetDistForGoals(mod) { |
| 309 | fmt.Fprintf(&a.header, distString) |
| Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 310 | } |
| 311 | |
| 312 | fmt.Fprintln(&a.header, "\ninclude $(CLEAR_VARS)") |
| 313 | |
| 314 | // Collect make variable assignment entries. |
| 315 | a.SetString("LOCAL_PATH", filepath.Dir(bpPath)) |
| 316 | a.SetString("LOCAL_MODULE", name+a.SubName) |
| Bob Badour | 987f33c | 2021-01-07 03:34:31 +0000 | [diff] [blame] | 317 | a.AddStrings("LOCAL_LICENSE_KINDS", amod.commonProperties.Effective_license_kinds...) |
| 318 | a.AddStrings("LOCAL_LICENSE_CONDITIONS", amod.commonProperties.Effective_license_conditions...) |
| 319 | a.AddStrings("LOCAL_NOTICE_FILE", amod.commonProperties.Effective_license_text...) |
| 320 | // TODO(b/151177513): Does this code need to set LOCAL_MODULE_IS_CONTAINER ? |
| 321 | if amod.commonProperties.Effective_package_name != nil { |
| 322 | a.SetString("LOCAL_LICENSE_PACKAGE_NAME", *amod.commonProperties.Effective_package_name) |
| 323 | } |
| Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 324 | a.SetString("LOCAL_MODULE_CLASS", a.Class) |
| 325 | a.SetString("LOCAL_PREBUILT_MODULE_FILE", a.OutputFile.String()) |
| 326 | a.AddStrings("LOCAL_REQUIRED_MODULES", a.Required...) |
| 327 | a.AddStrings("LOCAL_HOST_REQUIRED_MODULES", a.Host_required...) |
| 328 | a.AddStrings("LOCAL_TARGET_REQUIRED_MODULES", a.Target_required...) |
| 329 | |
| Jiyong Park | 6a9ddc3 | 2020-04-07 16:37:39 +0900 | [diff] [blame] | 330 | if am, ok := mod.(ApexModule); ok { |
| 331 | a.SetBoolIfTrue("LOCAL_NOT_AVAILABLE_FOR_PLATFORM", am.NotAvailableForPlatform()) |
| 332 | } |
| 333 | |
| Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 334 | archStr := amod.Arch().ArchType.String() |
| 335 | host := false |
| 336 | switch amod.Os().Class { |
| 337 | case Host: |
| 338 | // Make cannot identify LOCAL_MODULE_HOST_ARCH:= common. |
| Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 339 | if amod.Arch().ArchType != Common { |
| Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 340 | a.SetString("LOCAL_MODULE_HOST_ARCH", archStr) |
| 341 | } |
| 342 | host = true |
| 343 | case HostCross: |
| 344 | // Make cannot identify LOCAL_MODULE_HOST_CROSS_ARCH:= common. |
| Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 345 | if amod.Arch().ArchType != Common { |
| Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 346 | a.SetString("LOCAL_MODULE_HOST_CROSS_ARCH", archStr) |
| 347 | } |
| 348 | host = true |
| 349 | case Device: |
| 350 | // Make cannot identify LOCAL_MODULE_TARGET_ARCH:= common. |
| Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 351 | if amod.Arch().ArchType != Common { |
| dimitry | 1f33e40 | 2019-03-26 12:39:31 +0100 | [diff] [blame] | 352 | if amod.Target().NativeBridge { |
| dimitry | 8d6dde8 | 2019-07-11 10:23:53 +0200 | [diff] [blame] | 353 | hostArchStr := amod.Target().NativeBridgeHostArchName |
| dimitry | 1f33e40 | 2019-03-26 12:39:31 +0100 | [diff] [blame] | 354 | if hostArchStr != "" { |
| 355 | a.SetString("LOCAL_MODULE_TARGET_ARCH", hostArchStr) |
| 356 | } |
| 357 | } else { |
| 358 | a.SetString("LOCAL_MODULE_TARGET_ARCH", archStr) |
| 359 | } |
| Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 360 | } |
| 361 | |
| 362 | a.AddStrings("LOCAL_INIT_RC", amod.commonProperties.Init_rc...) |
| 363 | a.AddStrings("LOCAL_VINTF_FRAGMENTS", amod.commonProperties.Vintf_fragments...) |
| 364 | a.SetBoolIfTrue("LOCAL_PROPRIETARY_MODULE", Bool(amod.commonProperties.Proprietary)) |
| 365 | if Bool(amod.commonProperties.Vendor) || Bool(amod.commonProperties.Soc_specific) { |
| 366 | a.SetString("LOCAL_VENDOR_MODULE", "true") |
| 367 | } |
| 368 | a.SetBoolIfTrue("LOCAL_ODM_MODULE", Bool(amod.commonProperties.Device_specific)) |
| 369 | a.SetBoolIfTrue("LOCAL_PRODUCT_MODULE", Bool(amod.commonProperties.Product_specific)) |
| Justin Yun | d5f6c82 | 2019-06-25 16:47:17 +0900 | [diff] [blame] | 370 | a.SetBoolIfTrue("LOCAL_SYSTEM_EXT_MODULE", Bool(amod.commonProperties.System_ext_specific)) |
| Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 371 | if amod.commonProperties.Owner != nil { |
| 372 | a.SetString("LOCAL_MODULE_OWNER", *amod.commonProperties.Owner) |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | if amod.noticeFile.Valid() { |
| 377 | a.SetString("LOCAL_NOTICE_FILE", amod.noticeFile.String()) |
| 378 | } |
| 379 | |
| 380 | if host { |
| 381 | makeOs := amod.Os().String() |
| 382 | if amod.Os() == Linux || amod.Os() == LinuxBionic { |
| 383 | makeOs = "linux" |
| 384 | } |
| 385 | a.SetString("LOCAL_MODULE_HOST_OS", makeOs) |
| 386 | a.SetString("LOCAL_IS_HOST_MODULE", "true") |
| 387 | } |
| 388 | |
| 389 | prefix := "" |
| 390 | if amod.ArchSpecific() { |
| 391 | switch amod.Os().Class { |
| 392 | case Host: |
| 393 | prefix = "HOST_" |
| 394 | case HostCross: |
| 395 | prefix = "HOST_CROSS_" |
| 396 | case Device: |
| 397 | prefix = "TARGET_" |
| 398 | |
| 399 | } |
| 400 | |
| 401 | if amod.Arch().ArchType != config.Targets[amod.Os()][0].Arch.ArchType { |
| 402 | prefix = "2ND_" + prefix |
| 403 | } |
| 404 | } |
| Jaewoong Jung | e0dc8df | 2019-08-27 17:33:16 -0700 | [diff] [blame] | 405 | for _, extra := range a.ExtraEntries { |
| 406 | extra(a) |
| Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 407 | } |
| 408 | |
| 409 | // Write to footer. |
| 410 | fmt.Fprintln(&a.footer, "include "+a.Include) |
| Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 411 | blueprintDir := filepath.Dir(bpPath) |
| 412 | for _, footerFunc := range a.ExtraFooters { |
| 413 | footerFunc(&a.footer, name, prefix, blueprintDir, a) |
| 414 | } |
| Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 415 | } |
| 416 | |
| 417 | func (a *AndroidMkEntries) write(w io.Writer) { |
| Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 418 | if a.Disabled { |
| 419 | return |
| 420 | } |
| 421 | |
| 422 | if !a.OutputFile.Valid() { |
| 423 | return |
| 424 | } |
| 425 | |
| Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 426 | w.Write(a.header.Bytes()) |
| 427 | for _, name := range a.entryOrder { |
| 428 | fmt.Fprintln(w, name+" := "+strings.Join(a.EntryMap[name], " ")) |
| 429 | } |
| 430 | w.Write(a.footer.Bytes()) |
| 431 | } |
| 432 | |
| Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 433 | func (a *AndroidMkEntries) FooterLinesForTests() []string { |
| 434 | return strings.Split(string(a.footer.Bytes()), "\n") |
| 435 | } |
| 436 | |
| Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 437 | func AndroidMkSingleton() Singleton { |
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 438 | return &androidMkSingleton{} |
| 439 | } |
| 440 | |
| 441 | type androidMkSingleton struct{} |
| 442 | |
| Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 443 | func (c *androidMkSingleton) GenerateBuildActions(ctx SingletonContext) { |
| Colin Cross | aabf679 | 2017-11-29 00:27:14 -0800 | [diff] [blame] | 444 | if !ctx.Config().EmbeddedInMake() { |
| Dan Willemsen | 5ba07e8 | 2015-12-11 13:51:06 -0800 | [diff] [blame] | 445 | return |
| 446 | } |
| 447 | |
| Colin Cross | 2465c3d | 2018-09-28 10:19:18 -0700 | [diff] [blame] | 448 | var androidMkModulesList []blueprint.Module |
| Colin Cross | 4f6e4e6 | 2016-01-11 12:55:55 -0800 | [diff] [blame] | 449 | |
| Colin Cross | 2465c3d | 2018-09-28 10:19:18 -0700 | [diff] [blame] | 450 | ctx.VisitAllModulesBlueprint(func(module blueprint.Module) { |
| Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 451 | androidMkModulesList = append(androidMkModulesList, module) |
| Colin Cross | 4f6e4e6 | 2016-01-11 12:55:55 -0800 | [diff] [blame] | 452 | }) |
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 453 | |
| Colin Cross | 1ad8142 | 2019-01-14 12:47:35 -0800 | [diff] [blame] | 454 | sort.SliceStable(androidMkModulesList, func(i, j int) bool { |
| 455 | return ctx.ModuleName(androidMkModulesList[i]) < ctx.ModuleName(androidMkModulesList[j]) |
| 456 | }) |
| Colin Cross | d779da4 | 2015-12-17 18:00:23 -0800 | [diff] [blame] | 457 | |
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 458 | transMk := PathForOutput(ctx, "Android"+String(ctx.Config().productVariables.Make_suffix)+".mk") |
| Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 459 | if ctx.Failed() { |
| 460 | return |
| 461 | } |
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 462 | |
| Colin Cross | 988414c | 2020-01-11 01:11:46 +0000 | [diff] [blame] | 463 | err := translateAndroidMk(ctx, absolutePath(transMk.String()), androidMkModulesList) |
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 464 | if err != nil { |
| 465 | ctx.Errorf(err.Error()) |
| 466 | } |
| 467 | |
| Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 468 | ctx.Build(pctx, BuildParams{ |
| 469 | Rule: blueprint.Phony, |
| 470 | Output: transMk, |
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 471 | }) |
| 472 | } |
| 473 | |
| Colin Cross | 2465c3d | 2018-09-28 10:19:18 -0700 | [diff] [blame] | 474 | func translateAndroidMk(ctx SingletonContext, mkFile string, mods []blueprint.Module) error { |
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 475 | buf := &bytes.Buffer{} |
| 476 | |
| Dan Willemsen | 9775052 | 2016-02-09 17:43:51 -0800 | [diff] [blame] | 477 | fmt.Fprintln(buf, "LOCAL_MODULE_MAKEFILE := $(lastword $(MAKEFILE_LIST))") |
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 478 | |
| Dan Willemsen | 70e17fa | 2016-07-25 16:00:20 -0700 | [diff] [blame] | 479 | type_stats := make(map[string]int) |
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 480 | for _, mod := range mods { |
| 481 | err := translateAndroidMkModule(ctx, buf, mod) |
| 482 | if err != nil { |
| 483 | os.Remove(mkFile) |
| 484 | return err |
| 485 | } |
| Dan Willemsen | 70e17fa | 2016-07-25 16:00:20 -0700 | [diff] [blame] | 486 | |
| Colin Cross | 2465c3d | 2018-09-28 10:19:18 -0700 | [diff] [blame] | 487 | if amod, ok := mod.(Module); ok && ctx.PrimaryModule(amod) == amod { |
| 488 | type_stats[ctx.ModuleType(amod)] += 1 |
| Dan Willemsen | 70e17fa | 2016-07-25 16:00:20 -0700 | [diff] [blame] | 489 | } |
| 490 | } |
| 491 | |
| 492 | keys := []string{} |
| 493 | fmt.Fprintln(buf, "\nSTATS.SOONG_MODULE_TYPE :=") |
| 494 | for k := range type_stats { |
| 495 | keys = append(keys, k) |
| 496 | } |
| 497 | sort.Strings(keys) |
| 498 | for _, mod_type := range keys { |
| 499 | fmt.Fprintln(buf, "STATS.SOONG_MODULE_TYPE +=", mod_type) |
| 500 | fmt.Fprintf(buf, "STATS.SOONG_MODULE_TYPE.%s := %d\n", mod_type, type_stats[mod_type]) |
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 501 | } |
| 502 | |
| 503 | // Don't write to the file if it hasn't changed |
| Colin Cross | 988414c | 2020-01-11 01:11:46 +0000 | [diff] [blame] | 504 | if _, err := os.Stat(absolutePath(mkFile)); !os.IsNotExist(err) { |
| 505 | if data, err := ioutil.ReadFile(absolutePath(mkFile)); err == nil { |
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 506 | matches := buf.Len() == len(data) |
| 507 | |
| 508 | if matches { |
| 509 | for i, value := range buf.Bytes() { |
| 510 | if value != data[i] { |
| 511 | matches = false |
| 512 | break |
| 513 | } |
| 514 | } |
| 515 | } |
| 516 | |
| 517 | if matches { |
| 518 | return nil |
| 519 | } |
| 520 | } |
| 521 | } |
| 522 | |
| Colin Cross | 988414c | 2020-01-11 01:11:46 +0000 | [diff] [blame] | 523 | return ioutil.WriteFile(absolutePath(mkFile), buf.Bytes(), 0666) |
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 524 | } |
| 525 | |
| Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 526 | func translateAndroidMkModule(ctx SingletonContext, w io.Writer, mod blueprint.Module) error { |
| Colin Cross | 953d3a2 | 2018-09-05 16:23:54 -0700 | [diff] [blame] | 527 | defer func() { |
| 528 | if r := recover(); r != nil { |
| 529 | panic(fmt.Errorf("%s in translateAndroidMkModule for module %s variant %s", |
| 530 | r, ctx.ModuleName(mod), ctx.ModuleSubDir(mod))) |
| 531 | } |
| 532 | }() |
| 533 | |
| Bob Badour | 987f33c | 2021-01-07 03:34:31 +0000 | [diff] [blame] | 534 | // Additional cases here require review for correct license propagation to make. |
| Colin Cross | 2465c3d | 2018-09-28 10:19:18 -0700 | [diff] [blame] | 535 | switch x := mod.(type) { |
| 536 | case AndroidMkDataProvider: |
| 537 | return translateAndroidModule(ctx, w, mod, x) |
| 538 | case bootstrap.GoBinaryTool: |
| 539 | return translateGoBinaryModule(ctx, w, mod, x) |
| Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 540 | case AndroidMkEntriesProvider: |
| 541 | return translateAndroidMkEntriesModule(ctx, w, mod, x) |
| Colin Cross | 2465c3d | 2018-09-28 10:19:18 -0700 | [diff] [blame] | 542 | default: |
| Bob Badour | 987f33c | 2021-01-07 03:34:31 +0000 | [diff] [blame] | 543 | // Not exported to make so no make variables to set. |
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 544 | return nil |
| 545 | } |
| Colin Cross | 2465c3d | 2018-09-28 10:19:18 -0700 | [diff] [blame] | 546 | } |
| 547 | |
| 548 | func translateGoBinaryModule(ctx SingletonContext, w io.Writer, mod blueprint.Module, |
| 549 | goBinary bootstrap.GoBinaryTool) error { |
| 550 | |
| 551 | name := ctx.ModuleName(mod) |
| 552 | fmt.Fprintln(w, ".PHONY:", name) |
| 553 | fmt.Fprintln(w, name+":", goBinary.InstallPath()) |
| 554 | fmt.Fprintln(w, "") |
| Bob Badour | 987f33c | 2021-01-07 03:34:31 +0000 | [diff] [blame] | 555 | // Assuming no rules in make include go binaries in distributables. |
| 556 | // If the assumption is wrong, make will fail to build without the necessary .meta_lic and .meta_module files. |
| 557 | // In that case, add the targets and rules here to build a .meta_lic file for `name` and a .meta_module for |
| 558 | // `goBinary.InstallPath()` pointing to the `name`.meta_lic file. |
| Colin Cross | 2465c3d | 2018-09-28 10:19:18 -0700 | [diff] [blame] | 559 | |
| 560 | return nil |
| 561 | } |
| 562 | |
| Jooyung Han | 12df5fb | 2019-07-11 16:18:47 +0900 | [diff] [blame] | 563 | func (data *AndroidMkData) fillInData(config Config, bpPath string, mod blueprint.Module) { |
| 564 | // Get the preamble content through AndroidMkEntries logic. |
| 565 | entries := AndroidMkEntries{ |
| 566 | Class: data.Class, |
| 567 | SubName: data.SubName, |
| Jingwen Chen | 803474e | 2020-06-15 05:24:19 +0000 | [diff] [blame] | 568 | DistFiles: data.DistFiles, |
| Jooyung Han | 12df5fb | 2019-07-11 16:18:47 +0900 | [diff] [blame] | 569 | OutputFile: data.OutputFile, |
| 570 | Disabled: data.Disabled, |
| 571 | Include: data.Include, |
| 572 | Required: data.Required, |
| 573 | Host_required: data.Host_required, |
| 574 | Target_required: data.Target_required, |
| 575 | } |
| 576 | entries.fillInEntries(config, bpPath, mod) |
| 577 | |
| 578 | // preamble doesn't need the footer content. |
| 579 | entries.footer = bytes.Buffer{} |
| 580 | entries.write(&data.preamble) |
| 581 | |
| 582 | // copy entries back to data since it is used in Custom |
| 583 | data.Required = entries.Required |
| 584 | data.Host_required = entries.Host_required |
| 585 | data.Target_required = entries.Target_required |
| 586 | } |
| 587 | |
| Colin Cross | 2465c3d | 2018-09-28 10:19:18 -0700 | [diff] [blame] | 588 | func translateAndroidModule(ctx SingletonContext, w io.Writer, mod blueprint.Module, |
| 589 | provider AndroidMkDataProvider) error { |
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 590 | |
| Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 591 | amod := mod.(Module).base() |
| Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 592 | if shouldSkipAndroidMkProcessing(amod) { |
| Jeff Gaston | 088e29e | 2017-11-29 16:47:17 -0800 | [diff] [blame] | 593 | return nil |
| 594 | } |
| 595 | |
| Colin Cross | 91825d2 | 2017-08-10 16:59:47 -0700 | [diff] [blame] | 596 | data := provider.AndroidMk() |
| Colin Cross | 5349941 | 2017-09-07 13:20:25 -0700 | [diff] [blame] | 597 | if data.Include == "" { |
| 598 | data.Include = "$(BUILD_PREBUILT)" |
| 599 | } |
| 600 | |
| Jooyung Han | 12df5fb | 2019-07-11 16:18:47 +0900 | [diff] [blame] | 601 | data.fillInData(ctx.Config(), ctx.BlueprintFile(mod), mod) |
| Dan Willemsen | 01a405a | 2016-06-13 17:19:03 -0700 | [diff] [blame] | 602 | |
| Colin Cross | 0f86d18 | 2017-08-10 17:07:28 -0700 | [diff] [blame] | 603 | prefix := "" |
| 604 | if amod.ArchSpecific() { |
| 605 | switch amod.Os().Class { |
| 606 | case Host: |
| 607 | prefix = "HOST_" |
| 608 | case HostCross: |
| 609 | prefix = "HOST_CROSS_" |
| 610 | case Device: |
| 611 | prefix = "TARGET_" |
| Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 612 | |
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 613 | } |
| 614 | |
| Dan Willemsen | 0ef639b | 2018-10-10 17:02:29 -0700 | [diff] [blame] | 615 | if amod.Arch().ArchType != ctx.Config().Targets[amod.Os()][0].Arch.ArchType { |
| Colin Cross | 0f86d18 | 2017-08-10 17:07:28 -0700 | [diff] [blame] | 616 | prefix = "2ND_" + prefix |
| 617 | } |
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 618 | } |
| 619 | |
| Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 620 | name := provider.BaseModuleName() |
| Colin Cross | 0f86d18 | 2017-08-10 17:07:28 -0700 | [diff] [blame] | 621 | blueprintDir := filepath.Dir(ctx.BlueprintFile(mod)) |
| 622 | |
| 623 | if data.Custom != nil { |
| Bob Badour | 987f33c | 2021-01-07 03:34:31 +0000 | [diff] [blame] | 624 | // List of module types allowed to use .Custom(...) |
| 625 | // Additions to the list require careful review for proper license handling. |
| 626 | switch reflect.TypeOf(mod).String() { // ctx.ModuleType(mod) doesn't work: aidl_interface creates phony without type |
| 627 | case "*aidl.aidlApi": // writes non-custom before adding .phony |
| 628 | case "*aidl.aidlMapping": // writes non-custom before adding .phony |
| 629 | case "*android.customModule": // appears in tests only |
| 630 | case "*apex.apexBundle": // license properties written |
| 631 | case "*bpf.bpf": // license properties written (both for module and objs) |
| 632 | case "*genrule.Module": // writes non-custom before adding .phony |
| 633 | case "*java.SystemModules": // doesn't go through base_rules |
| 634 | case "*java.systemModulesImport": // doesn't go through base_rules |
| 635 | case "*phony.phony": // license properties written |
| 636 | case "*selinux.selinuxContextsModule": // license properties written |
| 637 | case "*sysprop.syspropLibrary": // license properties written |
| 638 | default: |
| 639 | if ctx.Config().IsEnvTrue("ANDROID_REQUIRE_LICENSES") { |
| 640 | return fmt.Errorf("custom make rules not allowed for %q (%q) module %q", ctx.ModuleType(mod), reflect.TypeOf(mod), ctx.ModuleName(mod)) |
| 641 | } |
| 642 | } |
| Colin Cross | 0f86d18 | 2017-08-10 17:07:28 -0700 | [diff] [blame] | 643 | data.Custom(w, name, prefix, blueprintDir, data) |
| 644 | } else { |
| 645 | WriteAndroidMkData(w, data) |
| 646 | } |
| 647 | |
| 648 | return nil |
| 649 | } |
| 650 | |
| 651 | func WriteAndroidMkData(w io.Writer, data AndroidMkData) { |
| 652 | if data.Disabled { |
| 653 | return |
| 654 | } |
| 655 | |
| 656 | if !data.OutputFile.Valid() { |
| 657 | return |
| 658 | } |
| 659 | |
| 660 | w.Write(data.preamble.Bytes()) |
| 661 | |
| Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 662 | for _, extra := range data.Extra { |
| Colin Cross | 27a4b05 | 2017-08-10 16:32:23 -0700 | [diff] [blame] | 663 | extra(w, data.OutputFile.Path()) |
| Dan Willemsen | 9775052 | 2016-02-09 17:43:51 -0800 | [diff] [blame] | 664 | } |
| 665 | |
| Colin Cross | 5349941 | 2017-09-07 13:20:25 -0700 | [diff] [blame] | 666 | fmt.Fprintln(w, "include "+data.Include) |
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 667 | } |
| Sasha Smundak | b6d2305 | 2019-04-01 18:37:36 -0700 | [diff] [blame] | 668 | |
| Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 669 | func translateAndroidMkEntriesModule(ctx SingletonContext, w io.Writer, mod blueprint.Module, |
| 670 | provider AndroidMkEntriesProvider) error { |
| 671 | if shouldSkipAndroidMkProcessing(mod.(Module).base()) { |
| 672 | return nil |
| Sasha Smundak | b6d2305 | 2019-04-01 18:37:36 -0700 | [diff] [blame] | 673 | } |
| Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 674 | |
| Bob Badour | 987f33c | 2021-01-07 03:34:31 +0000 | [diff] [blame] | 675 | // Any new or special cases here need review to verify correct propagation of license information. |
| Jiyong Park | 0b0e1b9 | 2019-12-03 13:24:29 +0900 | [diff] [blame] | 676 | for _, entries := range provider.AndroidMkEntries() { |
| 677 | entries.fillInEntries(ctx.Config(), ctx.BlueprintFile(mod), mod) |
| 678 | entries.write(w) |
| 679 | } |
| Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 680 | |
| 681 | return nil |
| 682 | } |
| 683 | |
| 684 | func shouldSkipAndroidMkProcessing(module *ModuleBase) bool { |
| 685 | if !module.commonProperties.NamespaceExportedToMake { |
| 686 | // TODO(jeffrygaston) do we want to validate that there are no modules being |
| 687 | // exported to Kati that depend on this module? |
| 688 | return true |
| Sasha Smundak | b6d2305 | 2019-04-01 18:37:36 -0700 | [diff] [blame] | 689 | } |
| Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 690 | |
| 691 | return !module.Enabled() || |
| 692 | module.commonProperties.SkipInstall || |
| 693 | // Make does not understand LinuxBionic |
| 694 | module.Os() == LinuxBionic |
| Sasha Smundak | b6d2305 | 2019-04-01 18:37:36 -0700 | [diff] [blame] | 695 | } |