blob: 506f39f8ae7ba3c138e85e79f2883fdf59dd129e [file] [log] [blame]
Colin Crossfabb6082018-02-20 17:22:23 -08001// Copyright 2018 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
17import (
18 "android/soong/android"
Colin Crossa97c5d32018-03-28 14:58:31 -070019 "strings"
Colin Crossfabb6082018-02-20 17:22:23 -080020
21 "github.com/google/blueprint"
Colin Crossa97c5d32018-03-28 14:58:31 -070022 "github.com/google/blueprint/proptools"
Colin Crossfabb6082018-02-20 17:22:23 -080023)
24
Colin Crossa97c5d32018-03-28 14:58:31 -070025type AndroidLibraryDependency interface {
26 Dependency
27 ExportPackage() android.Path
Colin Cross89c31582018-04-30 15:55:11 -070028 ExportedProguardFlagFiles() android.Paths
Colin Cross66f78822018-05-02 12:58:28 -070029 ExportedStaticPackages() android.Paths
Colin Crossa97c5d32018-03-28 14:58:31 -070030}
31
32func init() {
33 android.RegisterModuleType("android_library_import", AARImportFactory)
34 android.RegisterModuleType("android_library", AndroidLibraryFactory)
35}
36
37//
38// AAR (android library)
39//
40
41type androidLibraryProperties struct {
42 BuildAAR bool `blueprint:"mutated"`
43}
44
45type aaptProperties struct {
46 // flags passed to aapt when creating the apk
47 Aaptflags []string
48
49 // list of directories relative to the Blueprints file containing assets.
50 // Defaults to "assets"
51 Asset_dirs []string
52
53 // list of directories relative to the Blueprints file containing
54 // Android resources
55 Resource_dirs []string
56
57 // path to AndroidManifest.xml. If unset, defaults to "AndroidManifest.xml".
58 Manifest *string
59}
60
61type aapt struct {
Colin Cross66f78822018-05-02 12:58:28 -070062 aaptSrcJar android.Path
63 exportPackage android.Path
64 manifestPath android.Path
65 proguardOptionsFile android.Path
66 rroDirs android.Paths
67 rTxt android.Path
68 extraAaptPackagesFile android.Path
Colin Crossa97c5d32018-03-28 14:58:31 -070069
70 aaptProperties aaptProperties
71}
72
73func (a *aapt) ExportPackage() android.Path {
74 return a.exportPackage
75}
76
Colin Cross83bb3162018-06-25 15:48:06 -070077func (a *aapt) aapt2Flags(ctx android.ModuleContext, sdkContext sdkContext) (flags []string, deps android.Paths,
Colin Crossa97c5d32018-03-28 14:58:31 -070078 resDirs, overlayDirs []globbedResourceDir, overlayFiles, rroDirs android.Paths, manifestPath android.Path) {
79
80 hasVersionCode := false
81 hasVersionName := false
Colin Crossa97c5d32018-03-28 14:58:31 -070082 for _, f := range a.aaptProperties.Aaptflags {
83 if strings.HasPrefix(f, "--version-code") {
84 hasVersionCode = true
85 } else if strings.HasPrefix(f, "--version-name") {
86 hasVersionName = true
Colin Crossa97c5d32018-03-28 14:58:31 -070087 }
88 }
89
90 var linkFlags []string
91
92 // Flags specified in Android.bp
93 linkFlags = append(linkFlags, a.aaptProperties.Aaptflags...)
94
95 linkFlags = append(linkFlags, "--no-static-lib-packages")
96
97 // Find implicit or explicit asset and resource dirs
98 assetDirs := android.PathsWithOptionalDefaultForModuleSrc(ctx, a.aaptProperties.Asset_dirs, "assets")
99 resourceDirs := android.PathsWithOptionalDefaultForModuleSrc(ctx, a.aaptProperties.Resource_dirs, "res")
100
101 var linkDeps android.Paths
102
103 // Glob directories into lists of paths
104 for _, dir := range resourceDirs {
105 resDirs = append(resDirs, globbedResourceDir{
106 dir: dir,
107 files: androidResourceGlob(ctx, dir),
108 })
109 resOverlayDirs, resRRODirs := overlayResourceGlob(ctx, dir)
110 overlayDirs = append(overlayDirs, resOverlayDirs...)
111 rroDirs = append(rroDirs, resRRODirs...)
112 }
113
114 var assetFiles android.Paths
115 for _, dir := range assetDirs {
116 assetFiles = append(assetFiles, androidResourceGlob(ctx, dir)...)
117 }
118
119 // App manifest file
120 manifestFile := proptools.StringDefault(a.aaptProperties.Manifest, "AndroidManifest.xml")
121 manifestPath = android.PathForModuleSrc(ctx, manifestFile)
122 linkFlags = append(linkFlags, "--manifest "+manifestPath.String())
123 linkDeps = append(linkDeps, manifestPath)
124
125 linkFlags = append(linkFlags, android.JoinWithPrefix(assetDirs.Strings(), "-A "))
126 linkDeps = append(linkDeps, assetFiles...)
127
Colin Cross83bb3162018-06-25 15:48:06 -0700128 transitiveStaticLibs, libDeps, libFlags := aaptLibs(ctx, sdkContext)
Colin Crossa97c5d32018-03-28 14:58:31 -0700129
Colin Cross66f78822018-05-02 12:58:28 -0700130 overlayFiles = append(overlayFiles, transitiveStaticLibs...)
Colin Crossa97c5d32018-03-28 14:58:31 -0700131 linkDeps = append(linkDeps, libDeps...)
132 linkFlags = append(linkFlags, libFlags...)
133
134 // SDK version flags
Colin Cross83bb3162018-06-25 15:48:06 -0700135 minSdkVersion := sdkVersionOrDefault(ctx, sdkContext.minSdkVersion())
Colin Crossa97c5d32018-03-28 14:58:31 -0700136
Colin Cross83bb3162018-06-25 15:48:06 -0700137 linkFlags = append(linkFlags, "--min-sdk-version "+minSdkVersion)
138 linkFlags = append(linkFlags, "--target-sdk-version "+minSdkVersion)
Colin Crossa97c5d32018-03-28 14:58:31 -0700139
Colin Crossa97c5d32018-03-28 14:58:31 -0700140 // Version code
141 if !hasVersionCode {
142 linkFlags = append(linkFlags, "--version-code", ctx.Config().PlatformSdkVersion())
143 }
144
145 if !hasVersionName {
Colin Cross402d5e02018-04-25 14:54:06 -0700146 var versionName string
147 if ctx.ModuleName() == "framework-res" {
148 // Some builds set AppsDefaultVersionName() to include the build number ("O-123456"). aapt2 copies the
149 // version name of framework-res into app manifests as compileSdkVersionCodename, which confuses things
Colin Crossbfd347d2018-05-09 11:11:35 -0700150 // if it contains the build number. Use the PlatformVersionName instead.
151 versionName = ctx.Config().PlatformVersionName()
Colin Cross402d5e02018-04-25 14:54:06 -0700152 } else {
153 versionName = ctx.Config().AppsDefaultVersionName()
154 }
155 versionName = proptools.NinjaEscape([]string{versionName})[0]
Colin Crossa97c5d32018-03-28 14:58:31 -0700156 linkFlags = append(linkFlags, "--version-name ", versionName)
157 }
158
159 return linkFlags, linkDeps, resDirs, overlayDirs, overlayFiles, rroDirs, manifestPath
160}
161
Colin Cross83bb3162018-06-25 15:48:06 -0700162func (a *aapt) deps(ctx android.BottomUpMutatorContext, sdkContext sdkContext) {
Colin Crossa97c5d32018-03-28 14:58:31 -0700163 if !ctx.Config().UnbundledBuild() {
Colin Cross83bb3162018-06-25 15:48:06 -0700164 sdkDep := decodeSdkDep(ctx, sdkContext)
Colin Crossa97c5d32018-03-28 14:58:31 -0700165 if sdkDep.frameworkResModule != "" {
166 ctx.AddDependency(ctx.Module(), frameworkResTag, sdkDep.frameworkResModule)
167 }
168 }
169}
170
Colin Cross83bb3162018-06-25 15:48:06 -0700171func (a *aapt) buildActions(ctx android.ModuleContext, sdkContext sdkContext, extraLinkFlags ...string) {
172 linkFlags, linkDeps, resDirs, overlayDirs, overlayFiles, rroDirs, manifestPath := a.aapt2Flags(ctx, sdkContext)
Colin Crossa97c5d32018-03-28 14:58:31 -0700173
174 linkFlags = append(linkFlags, extraLinkFlags...)
175
176 packageRes := android.PathForModuleOut(ctx, "package-res.apk")
177 srcJar := android.PathForModuleGen(ctx, "R.jar")
178 proguardOptionsFile := android.PathForModuleGen(ctx, "proguard.options")
179 rTxt := android.PathForModuleOut(ctx, "R.txt")
Colin Cross66f78822018-05-02 12:58:28 -0700180 // This file isn't used by Soong, but is generated for exporting
181 extraPackages := android.PathForModuleOut(ctx, "extra_packages")
Colin Crossa97c5d32018-03-28 14:58:31 -0700182
183 var compiledRes, compiledOverlay android.Paths
184 for _, dir := range resDirs {
185 compiledRes = append(compiledRes, aapt2Compile(ctx, dir.dir, dir.files).Paths()...)
186 }
187 for _, dir := range overlayDirs {
188 compiledOverlay = append(compiledOverlay, aapt2Compile(ctx, dir.dir, dir.files).Paths()...)
189 }
190
191 compiledOverlay = append(compiledOverlay, overlayFiles...)
192
Colin Cross66f78822018-05-02 12:58:28 -0700193 aapt2Link(ctx, packageRes, srcJar, proguardOptionsFile, rTxt, extraPackages,
Colin Crossa97c5d32018-03-28 14:58:31 -0700194 linkFlags, linkDeps, compiledRes, compiledOverlay)
195
196 a.aaptSrcJar = srcJar
197 a.exportPackage = packageRes
198 a.manifestPath = manifestPath
199 a.proguardOptionsFile = proguardOptionsFile
200 a.rroDirs = rroDirs
Colin Cross66f78822018-05-02 12:58:28 -0700201 a.extraAaptPackagesFile = extraPackages
Colin Crossa97c5d32018-03-28 14:58:31 -0700202 a.rTxt = rTxt
203}
204
205// aaptLibs collects libraries from dependencies and sdk_version and converts them into paths
Colin Cross83bb3162018-06-25 15:48:06 -0700206func aaptLibs(ctx android.ModuleContext, sdkContext sdkContext) (transitiveStaticLibs, deps android.Paths,
Colin Cross66f78822018-05-02 12:58:28 -0700207 flags []string) {
208
Colin Crossa97c5d32018-03-28 14:58:31 -0700209 var sharedLibs android.Paths
210
Colin Cross83bb3162018-06-25 15:48:06 -0700211 sdkDep := decodeSdkDep(ctx, sdkContext)
Colin Crossa97c5d32018-03-28 14:58:31 -0700212 if sdkDep.useFiles {
Colin Cross86a60ae2018-05-29 14:44:55 -0700213 sharedLibs = append(sharedLibs, sdkDep.jars...)
Colin Crossa97c5d32018-03-28 14:58:31 -0700214 }
215
216 ctx.VisitDirectDeps(func(module android.Module) {
217 var exportPackage android.Path
Colin Cross66f78822018-05-02 12:58:28 -0700218 aarDep, _ := module.(AndroidLibraryDependency)
219 if aarDep != nil {
Colin Crossa97c5d32018-03-28 14:58:31 -0700220 exportPackage = aarDep.ExportPackage()
221 }
222
223 switch ctx.OtherModuleDependencyTag(module) {
224 case libTag, frameworkResTag:
225 if exportPackage != nil {
226 sharedLibs = append(sharedLibs, exportPackage)
227 }
228 case staticLibTag:
229 if exportPackage != nil {
Colin Cross66f78822018-05-02 12:58:28 -0700230 transitiveStaticLibs = append(transitiveStaticLibs, exportPackage)
231 transitiveStaticLibs = append(transitiveStaticLibs, aarDep.ExportedStaticPackages()...)
Colin Crossa97c5d32018-03-28 14:58:31 -0700232 }
233 }
234 })
235
236 deps = append(deps, sharedLibs...)
Colin Cross66f78822018-05-02 12:58:28 -0700237 deps = append(deps, transitiveStaticLibs...)
Colin Crossa97c5d32018-03-28 14:58:31 -0700238
Colin Cross66f78822018-05-02 12:58:28 -0700239 if len(transitiveStaticLibs) > 0 {
Colin Crossa97c5d32018-03-28 14:58:31 -0700240 flags = append(flags, "--auto-add-overlay")
241 }
242
243 for _, sharedLib := range sharedLibs {
244 flags = append(flags, "-I "+sharedLib.String())
245 }
246
Colin Cross66f78822018-05-02 12:58:28 -0700247 transitiveStaticLibs = android.FirstUniquePaths(transitiveStaticLibs)
248
249 return transitiveStaticLibs, deps, flags
Colin Crossa97c5d32018-03-28 14:58:31 -0700250}
251
252type AndroidLibrary struct {
253 Library
254 aapt
255
256 androidLibraryProperties androidLibraryProperties
257
258 aarFile android.WritablePath
Colin Cross89c31582018-04-30 15:55:11 -0700259
260 exportedProguardFlagFiles android.Paths
Colin Cross66f78822018-05-02 12:58:28 -0700261 exportedStaticPackages android.Paths
Colin Cross89c31582018-04-30 15:55:11 -0700262}
263
264func (a *AndroidLibrary) ExportedProguardFlagFiles() android.Paths {
265 return a.exportedProguardFlagFiles
Colin Crossa97c5d32018-03-28 14:58:31 -0700266}
267
Colin Cross66f78822018-05-02 12:58:28 -0700268func (a *AndroidLibrary) ExportedStaticPackages() android.Paths {
269 return a.exportedStaticPackages
270}
271
Colin Crossa97c5d32018-03-28 14:58:31 -0700272var _ AndroidLibraryDependency = (*AndroidLibrary)(nil)
273
274func (a *AndroidLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
275 a.Module.deps(ctx)
276 if !Bool(a.properties.No_framework_libs) && !Bool(a.properties.No_standard_libs) {
Colin Cross83bb3162018-06-25 15:48:06 -0700277 a.aapt.deps(ctx, sdkContext(a))
Colin Crossa97c5d32018-03-28 14:58:31 -0700278 }
279}
280
281func (a *AndroidLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Colin Cross83bb3162018-06-25 15:48:06 -0700282 a.aapt.buildActions(ctx, sdkContext(a), "--static-lib")
Colin Crossa97c5d32018-03-28 14:58:31 -0700283
284 ctx.CheckbuildFile(a.proguardOptionsFile)
285 ctx.CheckbuildFile(a.exportPackage)
286 ctx.CheckbuildFile(a.aaptSrcJar)
287
288 // apps manifests are handled by aapt, don't let Module see them
289 a.properties.Manifest = nil
290
291 a.Module.extraProguardFlagFiles = append(a.Module.extraProguardFlagFiles,
292 a.proguardOptionsFile)
293
294 a.Module.compile(ctx, a.aaptSrcJar)
295
296 a.aarFile = android.PathForOutput(ctx, ctx.ModuleName()+".aar")
297 var res android.Paths
298 if a.androidLibraryProperties.BuildAAR {
299 BuildAAR(ctx, a.aarFile, a.outputFile, a.manifestPath, a.rTxt, res)
300 ctx.CheckbuildFile(a.aarFile)
301 }
Colin Cross89c31582018-04-30 15:55:11 -0700302
303 ctx.VisitDirectDeps(func(m android.Module) {
304 if lib, ok := m.(AndroidLibraryDependency); ok && ctx.OtherModuleDependencyTag(m) == staticLibTag {
305 a.exportedProguardFlagFiles = append(a.exportedProguardFlagFiles, lib.ExportedProguardFlagFiles()...)
Colin Cross66f78822018-05-02 12:58:28 -0700306 a.exportedStaticPackages = append(a.exportedStaticPackages, lib.ExportPackage())
307 a.exportedStaticPackages = append(a.exportedStaticPackages, lib.ExportedStaticPackages()...)
Colin Cross89c31582018-04-30 15:55:11 -0700308 }
309 })
310
311 a.exportedProguardFlagFiles = android.FirstUniquePaths(a.exportedProguardFlagFiles)
Colin Cross66f78822018-05-02 12:58:28 -0700312 a.exportedStaticPackages = android.FirstUniquePaths(a.exportedStaticPackages)
Colin Crossa97c5d32018-03-28 14:58:31 -0700313}
314
315func AndroidLibraryFactory() android.Module {
316 module := &AndroidLibrary{}
317
318 module.AddProperties(
319 &module.Module.properties,
320 &module.Module.deviceProperties,
321 &module.Module.protoProperties,
322 &module.aaptProperties,
323 &module.androidLibraryProperties)
324
325 module.androidLibraryProperties.BuildAAR = true
326
327 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
328 return module
329}
330
Colin Crossfabb6082018-02-20 17:22:23 -0800331//
332// AAR (android library) prebuilts
333//
Colin Crossfabb6082018-02-20 17:22:23 -0800334
335type AARImportProperties struct {
336 Aars []string
337
338 Sdk_version *string
Colin Crossa97c5d32018-03-28 14:58:31 -0700339
340 Static_libs []string
341 Libs []string
Colin Crossfabb6082018-02-20 17:22:23 -0800342}
343
344type AARImport struct {
345 android.ModuleBase
346 prebuilt android.Prebuilt
347
348 properties AARImportProperties
349
Colin Cross66f78822018-05-02 12:58:28 -0700350 classpathFile android.WritablePath
351 proguardFlags android.WritablePath
352 exportPackage android.WritablePath
353 extraAaptPackagesFile android.WritablePath
Colin Cross10f7c4a2018-05-23 10:59:28 -0700354 manifest android.WritablePath
Colin Cross66f78822018-05-02 12:58:28 -0700355
356 exportedStaticPackages android.Paths
Colin Crossfabb6082018-02-20 17:22:23 -0800357}
358
Colin Cross83bb3162018-06-25 15:48:06 -0700359func (a *AARImport) sdkVersion() string {
360 return String(a.properties.Sdk_version)
361}
362
363func (a *AARImport) minSdkVersion() string {
364 return a.sdkVersion()
365}
366
Colin Crossa97c5d32018-03-28 14:58:31 -0700367var _ AndroidLibraryDependency = (*AARImport)(nil)
368
369func (a *AARImport) ExportPackage() android.Path {
370 return a.exportPackage
371}
372
Colin Cross89c31582018-04-30 15:55:11 -0700373func (a *AARImport) ExportedProguardFlagFiles() android.Paths {
374 return android.Paths{a.proguardFlags}
375}
376
Colin Cross66f78822018-05-02 12:58:28 -0700377func (a *AARImport) ExportedStaticPackages() android.Paths {
378 return a.exportedStaticPackages
379}
380
Colin Crossfabb6082018-02-20 17:22:23 -0800381func (a *AARImport) Prebuilt() *android.Prebuilt {
382 return &a.prebuilt
383}
384
385func (a *AARImport) Name() string {
386 return a.prebuilt.Name(a.ModuleBase.Name())
387}
388
389func (a *AARImport) DepsMutator(ctx android.BottomUpMutatorContext) {
Colin Crossfabb6082018-02-20 17:22:23 -0800390 if !ctx.Config().UnbundledBuild() {
Colin Cross83bb3162018-06-25 15:48:06 -0700391 sdkDep := decodeSdkDep(ctx, sdkContext(a))
Colin Crossa97c5d32018-03-28 14:58:31 -0700392 if sdkDep.useModule && sdkDep.frameworkResModule != "" {
393 ctx.AddDependency(ctx.Module(), frameworkResTag, sdkDep.frameworkResModule)
Colin Crossfabb6082018-02-20 17:22:23 -0800394 }
395 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700396
Colin Cross66f78822018-05-02 12:58:28 -0700397 ctx.AddDependency(ctx.Module(), libTag, a.properties.Libs...)
Colin Crossa97c5d32018-03-28 14:58:31 -0700398 ctx.AddDependency(ctx.Module(), staticLibTag, a.properties.Static_libs...)
Colin Crossfabb6082018-02-20 17:22:23 -0800399}
400
401// Unzip an AAR into its constituent files and directories. Any files in Outputs that don't exist in the AAR will be
402// touched to create an empty file, and any directories in $expectedDirs will be created.
403var unzipAAR = pctx.AndroidStaticRule("unzipAAR",
404 blueprint.RuleParams{
405 Command: `rm -rf $outDir && mkdir -p $outDir $expectedDirs && ` +
406 `unzip -qo -d $outDir $in && touch $out`,
407 },
408 "expectedDirs", "outDir")
409
410func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
411 if len(a.properties.Aars) != 1 {
412 ctx.PropertyErrorf("aars", "exactly one aar is required")
413 return
414 }
415
416 aar := android.PathForModuleSrc(ctx, a.properties.Aars[0])
417
418 extractedAARDir := android.PathForModuleOut(ctx, "aar")
419 extractedResDir := extractedAARDir.Join(ctx, "res")
420 a.classpathFile = extractedAARDir.Join(ctx, "classes.jar")
421 a.proguardFlags = extractedAARDir.Join(ctx, "proguard.txt")
Colin Cross10f7c4a2018-05-23 10:59:28 -0700422 a.manifest = extractedAARDir.Join(ctx, "AndroidManifest.xml")
Colin Crossfabb6082018-02-20 17:22:23 -0800423
424 ctx.Build(pctx, android.BuildParams{
425 Rule: unzipAAR,
426 Input: aar,
Colin Cross10f7c4a2018-05-23 10:59:28 -0700427 Outputs: android.WritablePaths{a.classpathFile, a.proguardFlags, a.manifest},
Colin Crossfabb6082018-02-20 17:22:23 -0800428 Description: "unzip AAR",
429 Args: map[string]string{
430 "expectedDirs": extractedResDir.String(),
431 "outDir": extractedAARDir.String(),
432 },
433 })
434
435 compiledResDir := android.PathForModuleOut(ctx, "flat-res")
436 aaptCompileDeps := android.Paths{a.classpathFile}
437 aaptCompileDirs := android.Paths{extractedResDir}
438 flata := compiledResDir.Join(ctx, "gen_res.flata")
439 aapt2CompileDirs(ctx, flata, aaptCompileDirs, aaptCompileDeps)
440
441 a.exportPackage = android.PathForModuleOut(ctx, "package-res.apk")
442 srcJar := android.PathForModuleGen(ctx, "R.jar")
443 proguardOptionsFile := android.PathForModuleGen(ctx, "proguard.options")
Colin Crossa97c5d32018-03-28 14:58:31 -0700444 rTxt := android.PathForModuleOut(ctx, "R.txt")
Colin Cross66f78822018-05-02 12:58:28 -0700445 a.extraAaptPackagesFile = android.PathForModuleOut(ctx, "extra_packages")
Colin Crossfabb6082018-02-20 17:22:23 -0800446
447 var linkDeps android.Paths
448
449 linkFlags := []string{
450 "--static-lib",
451 "--no-static-lib-packages",
452 "--auto-add-overlay",
453 }
454
Colin Cross10f7c4a2018-05-23 10:59:28 -0700455 linkFlags = append(linkFlags, "--manifest "+a.manifest.String())
456 linkDeps = append(linkDeps, a.manifest)
Colin Crossfabb6082018-02-20 17:22:23 -0800457
Colin Cross83bb3162018-06-25 15:48:06 -0700458 transitiveStaticLibs, libDeps, libFlags := aaptLibs(ctx, sdkContext(a))
Colin Crossfabb6082018-02-20 17:22:23 -0800459
Colin Crossa97c5d32018-03-28 14:58:31 -0700460 linkDeps = append(linkDeps, libDeps...)
461 linkFlags = append(linkFlags, libFlags...)
Colin Crossfabb6082018-02-20 17:22:23 -0800462
Colin Cross66f78822018-05-02 12:58:28 -0700463 overlayRes := append(android.Paths{flata}, transitiveStaticLibs...)
Colin Crossfabb6082018-02-20 17:22:23 -0800464
Colin Cross66f78822018-05-02 12:58:28 -0700465 aapt2Link(ctx, a.exportPackage, srcJar, proguardOptionsFile, rTxt, a.extraAaptPackagesFile,
Colin Crossa97c5d32018-03-28 14:58:31 -0700466 linkFlags, linkDeps, nil, overlayRes)
Colin Crossfabb6082018-02-20 17:22:23 -0800467}
468
469var _ Dependency = (*AARImport)(nil)
470
471func (a *AARImport) HeaderJars() android.Paths {
472 return android.Paths{a.classpathFile}
473}
474
475func (a *AARImport) ImplementationJars() android.Paths {
476 return android.Paths{a.classpathFile}
477}
478
479func (a *AARImport) AidlIncludeDirs() android.Paths {
480 return nil
481}
482
Jiyong Park1be96912018-05-28 18:02:19 +0900483func (a *AARImport) ExportedSdkLibs() []string {
484 return nil
485}
486
Colin Crossfabb6082018-02-20 17:22:23 -0800487var _ android.PrebuiltInterface = (*Import)(nil)
488
489func AARImportFactory() android.Module {
490 module := &AARImport{}
491
492 module.AddProperties(&module.properties)
493
494 android.InitPrebuiltModule(module, &module.properties.Aars)
495 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
496 return module
497}