blob: 6866e2a8330b80cf7e1e75ee96ce4acd71ccea03 [file] [log] [blame]
Colin Cross30e076a2015-04-13 13:58:27 -07001// 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
15package java
16
17// This file contains the module types for compiling Android apps.
18
19import (
Colin Cross30e076a2015-04-13 13:58:27 -070020 "path/filepath"
21 "strings"
22
Colin Cross76b5f0c2017-08-29 16:02:06 -070023 "github.com/google/blueprint/proptools"
Colin Cross30e076a2015-04-13 13:58:27 -070024
Colin Cross635c3b02016-05-18 15:37:25 -070025 "android/soong/android"
Colin Cross30e076a2015-04-13 13:58:27 -070026)
27
Colin Cross3bc7ffa2017-11-22 16:19:37 -080028func init() {
29 android.RegisterPreSingletonType("overlay", OverlaySingletonFactory)
Colin Cross5ab4e6d2017-11-22 16:20:45 -080030 android.RegisterModuleType("android_app", AndroidAppFactory)
Colin Cross3bc7ffa2017-11-22 16:19:37 -080031}
32
Colin Cross30e076a2015-04-13 13:58:27 -070033// AAR prebuilts
34// AndroidManifest.xml merging
35// package splits
36
Colin Cross7d5136f2015-05-11 13:39:40 -070037type androidAppProperties struct {
38 // path to a certificate, or the name of a certificate in the default
39 // certificate directory, or blank to use the default product certificate
Nan Zhangea568a42017-11-08 21:20:04 -080040 Certificate *string
Colin Cross7d5136f2015-05-11 13:39:40 -070041
42 // paths to extra certificates to sign the apk with
43 Additional_certificates []string
44
45 // If set, create package-export.apk, which other packages can
46 // use to get PRODUCT-agnostic resource data like IDs and type definitions.
Nan Zhangea568a42017-11-08 21:20:04 -080047 Export_package_resources *bool
Colin Cross7d5136f2015-05-11 13:39:40 -070048
49 // flags passed to aapt when creating the apk
50 Aaptflags []string
51
52 // list of resource labels to generate individual resource packages
53 Package_splits []string
54
55 // list of directories relative to the Blueprints file containing assets.
56 // Defaults to "assets"
57 Asset_dirs []string
58
59 // list of directories relative to the Blueprints file containing
Colin Cross86a63ff2017-09-27 17:33:10 -070060 // Android resources
61 Resource_dirs []string
Colin Crosscb933592017-11-22 13:49:43 -080062
63 Instrumentation_for *string
Colin Cross7d5136f2015-05-11 13:39:40 -070064}
65
Colin Cross30e076a2015-04-13 13:58:27 -070066type AndroidApp struct {
Colin Cross46c9b8b2017-06-22 16:51:17 -070067 Module
Colin Cross30e076a2015-04-13 13:58:27 -070068
Colin Cross7d5136f2015-05-11 13:39:40 -070069 appProperties androidAppProperties
Colin Cross30e076a2015-04-13 13:58:27 -070070
Colin Cross3bc7ffa2017-11-22 16:19:37 -080071 aaptSrcJar android.Path
72 exportPackage android.Path
Colin Cross890ff552017-11-30 20:13:19 -080073 rroDirs android.Paths
74 manifestPath android.Path
Colin Cross30e076a2015-04-13 13:58:27 -070075}
76
Colin Cross46c9b8b2017-06-22 16:51:17 -070077func (a *AndroidApp) DepsMutator(ctx android.BottomUpMutatorContext) {
78 a.Module.deps(ctx)
Colin Cross30e076a2015-04-13 13:58:27 -070079
Colin Cross3bc7ffa2017-11-22 16:19:37 -080080 if !Bool(a.properties.No_framework_libs) && !Bool(a.properties.No_standard_libs) {
Nan Zhangea568a42017-11-08 21:20:04 -080081 switch String(a.deviceProperties.Sdk_version) { // TODO: Res_sdk_version?
Colin Cross5ab4e6d2017-11-22 16:20:45 -080082 case "current", "system_current", "test_current", "":
Colin Crossbe1da472017-07-07 15:59:46 -070083 ctx.AddDependency(ctx.Module(), frameworkResTag, "framework-res")
Colin Cross30e076a2015-04-13 13:58:27 -070084 default:
85 // We'll already have a dependency on an sdk prebuilt android.jar
86 }
87 }
Colin Cross30e076a2015-04-13 13:58:27 -070088}
89
Colin Cross46c9b8b2017-06-22 16:51:17 -070090func (a *AndroidApp) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Colin Cross890ff552017-11-30 20:13:19 -080091 linkFlags, linkDeps, resDirs, overlayDirs, rroDirs, manifestPath := a.aapt2Flags(ctx)
Colin Cross30e076a2015-04-13 13:58:27 -070092
Colin Cross3bc7ffa2017-11-22 16:19:37 -080093 packageRes := android.PathForModuleOut(ctx, "package-res.apk")
94 srcJar := android.PathForModuleGen(ctx, "R.jar")
95 proguardOptionsFile := android.PathForModuleGen(ctx, "proguard.options")
Colin Cross30e076a2015-04-13 13:58:27 -070096
Colin Cross3bc7ffa2017-11-22 16:19:37 -080097 var compiledRes, compiledOverlay android.Paths
98 for _, dir := range resDirs {
99 compiledRes = append(compiledRes, aapt2Compile(ctx, dir.dir, dir.files).Paths()...)
Colin Cross30e076a2015-04-13 13:58:27 -0700100 }
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800101 for _, dir := range overlayDirs {
102 compiledOverlay = append(compiledOverlay, aapt2Compile(ctx, dir.dir, dir.files).Paths()...)
103 }
104
105 aapt2Link(ctx, packageRes, srcJar, proguardOptionsFile,
106 linkFlags, linkDeps, compiledRes, compiledOverlay)
107
108 a.exportPackage = packageRes
109 a.aaptSrcJar = srcJar
110
111 ctx.CheckbuildFile(proguardOptionsFile)
112 ctx.CheckbuildFile(a.exportPackage)
113 ctx.CheckbuildFile(a.aaptSrcJar)
Colin Cross30e076a2015-04-13 13:58:27 -0700114
Colin Cross46c9b8b2017-06-22 16:51:17 -0700115 // apps manifests are handled by aapt, don't let Module see them
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700116 a.properties.Manifest = nil
Colin Cross30e076a2015-04-13 13:58:27 -0700117
118 //if !ctx.ContainsProperty("proguard.enabled") {
119 // a.properties.Proguard.Enabled = true
120 //}
121
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800122 if String(a.appProperties.Instrumentation_for) == "" {
123 a.properties.Instrument = true
124 }
125
126 if ctx.ModuleName() != "framework-res" {
127 a.Module.compile(ctx, a.aaptSrcJar)
128 }
Colin Cross30e076a2015-04-13 13:58:27 -0700129
Nan Zhangea568a42017-11-08 21:20:04 -0800130 certificate := String(a.appProperties.Certificate)
Colin Cross30e076a2015-04-13 13:58:27 -0700131 if certificate == "" {
Colin Cross6510f912017-11-29 00:27:14 -0800132 certificate = ctx.Config().DefaultAppCertificate(ctx).String()
Colin Cross30e076a2015-04-13 13:58:27 -0700133 } else if dir, _ := filepath.Split(certificate); dir == "" {
Colin Cross6510f912017-11-29 00:27:14 -0800134 certificate = filepath.Join(ctx.Config().DefaultAppCertificateDir(ctx).String(), certificate)
Colin Cross30e076a2015-04-13 13:58:27 -0700135 } else {
Colin Cross635c3b02016-05-18 15:37:25 -0700136 certificate = filepath.Join(android.PathForSource(ctx).String(), certificate)
Colin Cross30e076a2015-04-13 13:58:27 -0700137 }
138
139 certificates := []string{certificate}
140 for _, c := range a.appProperties.Additional_certificates {
Colin Cross635c3b02016-05-18 15:37:25 -0700141 certificates = append(certificates, filepath.Join(android.PathForSource(ctx).String(), c))
Colin Cross30e076a2015-04-13 13:58:27 -0700142 }
143
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800144 packageFile := android.PathForModuleOut(ctx, "package.apk")
145
146 CreateAppPackage(ctx, packageFile, a.exportPackage, a.outputFile, certificates)
147
148 a.outputFile = packageFile
Colin Cross890ff552017-11-30 20:13:19 -0800149 a.rroDirs = rroDirs
150 a.manifestPath = manifestPath
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800151
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800152 if ctx.ModuleName() == "framework-res" {
153 // framework-res.apk is installed as system/framework/framework-res.apk
154 ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"), ctx.ModuleName()+".apk", a.outputFile)
155 } else {
156 ctx.InstallFile(android.PathForModuleInstall(ctx, "app"), ctx.ModuleName()+".apk", a.outputFile)
157 }
Colin Cross30e076a2015-04-13 13:58:27 -0700158}
159
160var aaptIgnoreFilenames = []string{
161 ".svn",
162 ".git",
163 ".ds_store",
164 "*.scc",
165 ".*",
166 "CVS",
167 "thumbs.db",
168 "picasa.ini",
169 "*~",
170}
171
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800172type globbedResourceDir struct {
173 dir android.Path
174 files android.Paths
175}
176
177func (a *AndroidApp) aapt2Flags(ctx android.ModuleContext) (flags []string, deps android.Paths,
Colin Cross890ff552017-11-30 20:13:19 -0800178 resDirs, overlayDirs []globbedResourceDir, rroDirs android.Paths, manifestPath android.Path) {
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800179
Colin Cross30e076a2015-04-13 13:58:27 -0700180 hasVersionCode := false
181 hasVersionName := false
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800182 hasProduct := false
183 for _, f := range a.appProperties.Aaptflags {
Colin Cross30e076a2015-04-13 13:58:27 -0700184 if strings.HasPrefix(f, "--version-code") {
185 hasVersionCode = true
186 } else if strings.HasPrefix(f, "--version-name") {
187 hasVersionName = true
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800188 } else if strings.HasPrefix(f, "--product") {
189 hasProduct = true
Colin Cross30e076a2015-04-13 13:58:27 -0700190 }
191 }
192
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800193 var linkFlags []string
Colin Cross30e076a2015-04-13 13:58:27 -0700194
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800195 // Flags specified in Android.bp
196 linkFlags = append(linkFlags, a.appProperties.Aaptflags...)
197
198 linkFlags = append(linkFlags, "--no-static-lib-packages")
199
200 // Find implicit or explicit asset and resource dirs
Colin Cross635c3b02016-05-18 15:37:25 -0700201 assetDirs := android.PathsWithOptionalDefaultForModuleSrc(ctx, a.appProperties.Asset_dirs, "assets")
Colin Cross86a63ff2017-09-27 17:33:10 -0700202 resourceDirs := android.PathsWithOptionalDefaultForModuleSrc(ctx, a.appProperties.Resource_dirs, "res")
Colin Cross30e076a2015-04-13 13:58:27 -0700203
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800204 var linkDeps android.Paths
205
206 // Glob directories into lists of paths
207 for _, dir := range resourceDirs {
208 resDirs = append(resDirs, globbedResourceDir{
209 dir: dir,
210 files: resourceGlob(ctx, dir),
211 })
Colin Cross890ff552017-11-30 20:13:19 -0800212 resOverlayDirs, resRRODirs := overlayResourceGlob(ctx, dir)
213 overlayDirs = append(overlayDirs, resOverlayDirs...)
214 rroDirs = append(rroDirs, resRRODirs...)
Colin Cross30e076a2015-04-13 13:58:27 -0700215 }
216
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800217 var assetFiles android.Paths
218 for _, dir := range assetDirs {
219 assetFiles = append(assetFiles, resourceGlob(ctx, dir)...)
Colin Cross30e076a2015-04-13 13:58:27 -0700220 }
221
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800222 // App manifest file
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700223 var manifestFile string
224 if a.properties.Manifest == nil {
Colin Cross30e076a2015-04-13 13:58:27 -0700225 manifestFile = "AndroidManifest.xml"
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700226 } else {
227 manifestFile = *a.properties.Manifest
Colin Cross30e076a2015-04-13 13:58:27 -0700228 }
229
Colin Cross890ff552017-11-30 20:13:19 -0800230 manifestPath = android.PathForModuleSrc(ctx, manifestFile)
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800231 linkFlags = append(linkFlags, "--manifest "+manifestPath.String())
232 linkDeps = append(linkDeps, manifestPath)
Colin Cross30e076a2015-04-13 13:58:27 -0700233
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800234 linkFlags = append(linkFlags, android.JoinWithPrefix(assetDirs.Strings(), "-A "))
235 linkDeps = append(linkDeps, assetFiles...)
Colin Cross30e076a2015-04-13 13:58:27 -0700236
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800237 // Include dirs
Colin Crossd11fcda2017-10-23 17:59:01 -0700238 ctx.VisitDirectDeps(func(module android.Module) {
Colin Cross74d73e22017-08-02 11:05:49 -0700239 var depFiles android.Paths
Colin Crossfc3674a2017-09-18 17:41:52 -0700240 if javaDep, ok := module.(Dependency); ok {
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800241 // TODO: shared android libraries
Colin Cross30e076a2015-04-13 13:58:27 -0700242 if ctx.OtherModuleName(module) == "framework-res" {
Colin Cross74d73e22017-08-02 11:05:49 -0700243 depFiles = android.Paths{javaDep.(*AndroidApp).exportPackage}
Colin Cross30e076a2015-04-13 13:58:27 -0700244 }
245 }
Colin Cross74d73e22017-08-02 11:05:49 -0700246
247 for _, dep := range depFiles {
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800248 linkFlags = append(linkFlags, "-I "+dep.String())
Colin Cross30e076a2015-04-13 13:58:27 -0700249 }
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800250 linkDeps = append(linkDeps, depFiles...)
Colin Cross30e076a2015-04-13 13:58:27 -0700251 })
252
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800253 // SDK version flags
Nan Zhangea568a42017-11-08 21:20:04 -0800254 sdkVersion := String(a.deviceProperties.Sdk_version)
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800255 switch sdkVersion {
256 case "", "current", "system_current", "test_current":
Colin Cross6510f912017-11-29 00:27:14 -0800257 sdkVersion = ctx.Config().AppsDefaultVersionName()
Colin Cross30e076a2015-04-13 13:58:27 -0700258 }
259
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800260 linkFlags = append(linkFlags, "--min-sdk-version "+sdkVersion)
261 linkFlags = append(linkFlags, "--target-sdk-version "+sdkVersion)
Colin Cross30e076a2015-04-13 13:58:27 -0700262
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800263 // Product characteristics
Colin Cross6510f912017-11-29 00:27:14 -0800264 if !hasProduct && len(ctx.Config().ProductAAPTCharacteristics()) > 0 {
265 linkFlags = append(linkFlags, "--product", ctx.Config().ProductAAPTCharacteristics())
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800266 }
267
268 // Product AAPT config
Colin Cross6510f912017-11-29 00:27:14 -0800269 for _, aaptConfig := range ctx.Config().ProductAAPTConfig() {
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800270 linkFlags = append(linkFlags, "-c", aaptConfig)
271 }
272
273 // Product AAPT preferred config
Colin Cross6510f912017-11-29 00:27:14 -0800274 if len(ctx.Config().ProductAAPTPreferredConfig()) > 0 {
275 linkFlags = append(linkFlags, "--preferred-density", ctx.Config().ProductAAPTPreferredConfig())
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800276 }
277
278 // Version code
Colin Cross30e076a2015-04-13 13:58:27 -0700279 if !hasVersionCode {
Colin Cross6510f912017-11-29 00:27:14 -0800280 linkFlags = append(linkFlags, "--version-code", ctx.Config().PlatformSdkVersion())
Colin Cross30e076a2015-04-13 13:58:27 -0700281 }
282
283 if !hasVersionName {
Colin Cross6510f912017-11-29 00:27:14 -0800284 versionName := proptools.NinjaEscape([]string{ctx.Config().AppsDefaultVersionName()})[0]
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800285 linkFlags = append(linkFlags, "--version-name ", versionName)
286 }
287
288 if String(a.appProperties.Instrumentation_for) != "" {
289 linkFlags = append(linkFlags,
290 "--rename-instrumentation-target-package",
291 String(a.appProperties.Instrumentation_for))
Colin Cross30e076a2015-04-13 13:58:27 -0700292 }
293
294 // TODO: LOCAL_PACKAGE_OVERRIDES
295 // $(addprefix --rename-manifest-package , $(PRIVATE_MANIFEST_PACKAGE_NAME)) \
296
Colin Cross890ff552017-11-30 20:13:19 -0800297 return linkFlags, linkDeps, resDirs, overlayDirs, rroDirs, manifestPath
Colin Cross30e076a2015-04-13 13:58:27 -0700298}
299
Colin Cross36242852017-06-23 15:06:31 -0700300func AndroidAppFactory() android.Module {
Colin Cross30e076a2015-04-13 13:58:27 -0700301 module := &AndroidApp{}
302
Colin Cross36242852017-06-23 15:06:31 -0700303 module.AddProperties(
Colin Cross540eff82017-06-22 17:01:52 -0700304 &module.Module.properties,
305 &module.Module.deviceProperties,
306 &module.appProperties)
Colin Cross36242852017-06-23 15:06:31 -0700307
308 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
309 return module
Colin Cross30e076a2015-04-13 13:58:27 -0700310}
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800311
312func resourceGlob(ctx android.ModuleContext, dir android.Path) android.Paths {
313 var ret android.Paths
314 files := ctx.Glob(filepath.Join(dir.String(), "**/*"), aaptIgnoreFilenames)
315 for _, f := range files {
316 if isDir, err := ctx.Fs().IsDir(f.String()); err != nil {
317 ctx.ModuleErrorf("error in IsDir(%s): %s", f.String(), err.Error())
318 return nil
319 } else if !isDir {
320 ret = append(ret, f)
321 }
322 }
323 return ret
324}
325
326type overlayGlobResult struct {
327 dir string
328 paths android.DirectorySortedPaths
Colin Cross890ff552017-11-30 20:13:19 -0800329
330 // Set to true of the product has selected that values in this overlay should not be moved to
331 // Runtime Resource Overlay (RRO) packages.
332 excludeFromRRO bool
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800333}
334
335const overlayDataKey = "overlayDataKey"
336
Colin Cross890ff552017-11-30 20:13:19 -0800337func overlayResourceGlob(ctx android.ModuleContext, dir android.Path) (res []globbedResourceDir,
338 rroDirs android.Paths) {
339
Colin Cross6510f912017-11-29 00:27:14 -0800340 overlayData := ctx.Config().Get(overlayDataKey).([]overlayGlobResult)
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800341
Colin Cross890ff552017-11-30 20:13:19 -0800342 // Runtime resource overlays (RRO) may be turned on by the product config for some modules
343 rroEnabled := false
344 enforceRROTargets := ctx.Config().ProductVariables.EnforceRROTargets
345 if enforceRROTargets != nil {
346 if len(*enforceRROTargets) == 1 && (*enforceRROTargets)[0] == "*" {
347 rroEnabled = true
348 } else if inList(ctx.ModuleName(), *enforceRROTargets) {
349 rroEnabled = true
350 }
351 }
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800352
353 for _, data := range overlayData {
354 files := data.paths.PathsInDirectory(filepath.Join(data.dir, dir.String()))
355 if len(files) > 0 {
Colin Cross890ff552017-11-30 20:13:19 -0800356 overlayModuleDir := android.PathForSource(ctx, data.dir, dir.String())
357 // If enforce RRO is enabled for this module and this overlay is not in the
358 // exclusion list, ignore the overlay. The list of ignored overlays will be
359 // passed to Make to be turned into an RRO package.
360 if rroEnabled && !data.excludeFromRRO {
361 rroDirs = append(rroDirs, overlayModuleDir)
362 } else {
363 res = append(res, globbedResourceDir{
364 dir: overlayModuleDir,
365 files: files,
366 })
367 }
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800368 }
369 }
370
Colin Cross890ff552017-11-30 20:13:19 -0800371 return res, rroDirs
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800372}
373
374func OverlaySingletonFactory() android.Singleton {
375 return overlaySingleton{}
376}
377
378type overlaySingleton struct{}
379
380func (overlaySingleton) GenerateBuildActions(ctx android.SingletonContext) {
Colin Cross890ff552017-11-30 20:13:19 -0800381
382 // Specific overlays may be excluded from Runtime Resource Overlays by the product config
383 var rroExcludedOverlays []string
384 if ctx.Config().ProductVariables.EnforceRROExcludedOverlays != nil {
385 rroExcludedOverlays = *ctx.Config().ProductVariables.EnforceRROExcludedOverlays
386 }
387
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800388 var overlayData []overlayGlobResult
Colin Crossaabf6792017-11-29 00:27:14 -0800389 for _, overlay := range ctx.Config().ResourceOverlays() {
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800390 var result overlayGlobResult
391 result.dir = overlay
Colin Cross890ff552017-11-30 20:13:19 -0800392
393 // Mark overlays that will not have Runtime Resource Overlays enforced on them
394 for _, exclude := range rroExcludedOverlays {
395 if strings.HasPrefix(overlay, exclude) {
396 result.excludeFromRRO = true
397 }
398 }
399
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800400 files, err := ctx.GlobWithDeps(filepath.Join(overlay, "**/*"), aaptIgnoreFilenames)
401 if err != nil {
402 ctx.Errorf("failed to glob resource dir %q: %s", overlay, err.Error())
403 continue
404 }
405 var paths android.Paths
406 for _, f := range files {
407 if isDir, err := ctx.Fs().IsDir(f); err != nil {
408 ctx.Errorf("error in IsDir(%s): %s", f, err.Error())
409 return
410 } else if !isDir {
411 paths = append(paths, android.PathForSource(ctx, f))
412 }
413 }
414 result.paths = android.PathsToDirectorySortedPaths(paths)
415 overlayData = append(overlayData, result)
416 }
417
Colin Crossaabf6792017-11-29 00:27:14 -0800418 ctx.Config().Once(overlayDataKey, func() interface{} {
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800419 return overlayData
420 })
421}