blob: db6c15ce5f6b981e29c40650fbdfe862fcca3b98 [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 "strings"
21
Colin Crossa4f08812018-10-02 22:03:40 -070022 "github.com/google/blueprint"
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 Crossa4f08812018-10-02 22:03:40 -070026 "android/soong/cc"
Colin Cross303e21f2018-08-07 16:49:25 -070027 "android/soong/tradefed"
Colin Cross30e076a2015-04-13 13:58:27 -070028)
29
Colin Cross3bc7ffa2017-11-22 16:19:37 -080030func init() {
Colin Cross5ab4e6d2017-11-22 16:20:45 -080031 android.RegisterModuleType("android_app", AndroidAppFactory)
Colin Crossae5caf52018-05-22 11:11:52 -070032 android.RegisterModuleType("android_test", AndroidTestFactory)
Colin Cross252fc6f2018-10-04 15:22:03 -070033 android.RegisterModuleType("android_test_helper_app", AndroidTestHelperAppFactory)
Colin Crossbd01e2a2018-10-04 15:21:03 -070034 android.RegisterModuleType("android_app_certificate", AndroidAppCertificateFactory)
Colin Cross3bc7ffa2017-11-22 16:19:37 -080035}
36
Colin Cross30e076a2015-04-13 13:58:27 -070037// AndroidManifest.xml merging
38// package splits
39
Colin Crossfabb6082018-02-20 17:22:23 -080040type appProperties struct {
Colin Crossbd01e2a2018-10-04 15:21:03 -070041 // The name of a certificate in the default certificate directory, blank to use the default product certificate,
42 // or an android_app_certificate module name in the form ":module".
Nan Zhangea568a42017-11-08 21:20:04 -080043 Certificate *string
Colin Cross7d5136f2015-05-11 13:39:40 -070044
Colin Crossbd01e2a2018-10-04 15:21:03 -070045 // Names of extra android_app_certificate modules to sign the apk with in the form ":module".
Colin Cross7d5136f2015-05-11 13:39:40 -070046 Additional_certificates []string
47
48 // If set, create package-export.apk, which other packages can
49 // use to get PRODUCT-agnostic resource data like IDs and type definitions.
Nan Zhangea568a42017-11-08 21:20:04 -080050 Export_package_resources *bool
Colin Cross7d5136f2015-05-11 13:39:40 -070051
Colin Cross16056062017-12-13 22:46:28 -080052 // Specifies that this app should be installed to the priv-app directory,
53 // where the system will grant it additional privileges not available to
54 // normal apps.
55 Privileged *bool
Colin Crossa97c5d32018-03-28 14:58:31 -070056
57 // list of resource labels to generate individual resource packages
58 Package_splits []string
Jason Monkd4122be2018-08-10 09:33:36 -040059
60 // Names of modules to be overridden. Listed modules can only be other binaries
61 // (in Make or Soong).
62 // This does not completely prevent installation of the overridden binaries, but if both
63 // binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will be removed
64 // from PRODUCT_PACKAGES.
65 Overrides []string
Colin Crossa4f08812018-10-02 22:03:40 -070066
67 // list of native libraries that will be provided in or alongside the resulting jar
68 Jni_libs []string `android:"arch_variant"`
69
Colin Cross5a0dcd52018-10-05 14:20:06 -070070 AllowDexPreopt bool `blueprint:"mutated"`
71 EmbedJNI bool `blueprint:"mutated"`
72 StripDex bool `blueprint:"mutated"`
Colin Cross7d5136f2015-05-11 13:39:40 -070073}
74
Colin Cross30e076a2015-04-13 13:58:27 -070075type AndroidApp struct {
Colin Crossa97c5d32018-03-28 14:58:31 -070076 Library
77 aapt
78
79 certificate certificate
Colin Cross30e076a2015-04-13 13:58:27 -070080
Colin Crossfabb6082018-02-20 17:22:23 -080081 appProperties appProperties
Colin Crossae5caf52018-05-22 11:11:52 -070082
83 extraLinkFlags []string
Colin Crossa4f08812018-10-02 22:03:40 -070084
85 installJniLibs []jniLib
Colin Crosse1731a52017-12-14 11:22:55 -080086}
87
Colin Cross89c31582018-04-30 15:55:11 -070088func (a *AndroidApp) ExportedProguardFlagFiles() android.Paths {
89 return nil
90}
91
Colin Cross66f78822018-05-02 12:58:28 -070092func (a *AndroidApp) ExportedStaticPackages() android.Paths {
93 return nil
94}
95
Colin Cross31656952018-05-24 16:11:20 -070096func (a *AndroidApp) ExportedManifest() android.Path {
97 return a.manifestPath
98}
99
Colin Crossa97c5d32018-03-28 14:58:31 -0700100var _ AndroidLibraryDependency = (*AndroidApp)(nil)
101
Colin Crosse1731a52017-12-14 11:22:55 -0800102type certificate struct {
103 pem, key android.Path
Colin Cross30e076a2015-04-13 13:58:27 -0700104}
105
Colin Cross46c9b8b2017-06-22 16:51:17 -0700106func (a *AndroidApp) DepsMutator(ctx android.BottomUpMutatorContext) {
107 a.Module.deps(ctx)
Colin Crossa4f08812018-10-02 22:03:40 -0700108
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800109 if !Bool(a.properties.No_framework_libs) && !Bool(a.properties.No_standard_libs) {
Colin Cross83bb3162018-06-25 15:48:06 -0700110 a.aapt.deps(ctx, sdkContext(a))
Colin Cross30e076a2015-04-13 13:58:27 -0700111 }
Colin Crossa4f08812018-10-02 22:03:40 -0700112
113 for _, jniTarget := range ctx.MultiTargets() {
114 variation := []blueprint.Variation{
115 {Mutator: "arch", Variation: jniTarget.String()},
116 {Mutator: "link", Variation: "shared"},
117 }
118 tag := &jniDependencyTag{
119 target: jniTarget,
120 }
121 ctx.AddFarVariationDependencies(variation, tag, a.appProperties.Jni_libs...)
122 }
Colin Crossbd01e2a2018-10-04 15:21:03 -0700123
124 cert := android.SrcIsModule(String(a.appProperties.Certificate))
125 if cert != "" {
126 ctx.AddDependency(ctx.Module(), certificateTag, cert)
127 }
128
129 for _, cert := range a.appProperties.Additional_certificates {
130 cert = android.SrcIsModule(cert)
131 if cert != "" {
132 ctx.AddDependency(ctx.Module(), certificateTag, cert)
133 } else {
134 ctx.PropertyErrorf("additional_certificates",
135 `must be names of android_app_certificate modules in the form ":module"`)
136 }
137 }
Colin Cross30e076a2015-04-13 13:58:27 -0700138}
139
Colin Cross46c9b8b2017-06-22 16:51:17 -0700140func (a *AndroidApp) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Colin Crossae5caf52018-05-22 11:11:52 -0700141 a.generateAndroidBuildActions(ctx)
142}
143
Colin Cross5a0dcd52018-10-05 14:20:06 -0700144// Returns whether this module should have the dex file stored uncompressed in the APK, or stripped completely. If
145// stripped, the code will still be present on the device in the dexpreopted files.
146// This is only necessary for APKs, and not jars, because APKs are signed and the dex file should not be uncompressed
147// or removed after the signature has been generated. For jars, which are not signed, the dex file is uncompressed
148// or removed at installation time in Make.
149func (a *AndroidApp) uncompressOrStripDex(ctx android.ModuleContext) (uncompress, strip bool) {
150 if ctx.Config().UnbundledBuild() {
151 return false, false
152 }
153
154 strip = ctx.Config().DefaultStripDex()
155 // TODO(ccross): don't strip dex installed on partitions that may be updated separately (like vendor)
156 // TODO(ccross): don't strip dex on modules with LOCAL_APK_LIBRARIES equivalent
Colin Cross5a0dcd52018-10-05 14:20:06 -0700157
158 // Uncompress dex in APKs of privileged apps, and modules used by privileged apps.
159 if ctx.Config().UncompressPrivAppDex() &&
160 (Bool(a.appProperties.Privileged) ||
161 inList(ctx.ModuleName(), ctx.Config().ModulesLoadedByPrivilegedModules())) {
162
163 uncompress = true
164 // If the dex files is store uncompressed, don't strip it, we will reuse the uncompressed dex from the APK
165 // instead of copying it into the odex file.
166 strip = false
167 }
168
169 // If dexpreopt is disabled, don't strip the dex file
170 if !a.appProperties.AllowDexPreopt ||
171 !BoolDefault(a.deviceProperties.Dex_preopt.Enabled, true) ||
172 ctx.Config().DisableDexPreopt(ctx.ModuleName()) {
173 strip = false
174 }
175
Colin Cross762fbfb2018-10-29 12:58:06 -0700176 // TODO(ccross): strip dexpropted modules that are not propted to system_other
177 strip = false
178
Colin Cross5a0dcd52018-10-05 14:20:06 -0700179 return uncompress, strip
180}
181
Colin Crossae5caf52018-05-22 11:11:52 -0700182func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
183 linkFlags := append([]string(nil), a.extraLinkFlags...)
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800184
Colin Crosse78dcd32018-04-19 15:25:19 -0700185 hasProduct := false
186 for _, f := range a.aaptProperties.Aaptflags {
187 if strings.HasPrefix(f, "--product") {
188 hasProduct = true
189 }
190 }
191
192 // Product characteristics
193 if !hasProduct && len(ctx.Config().ProductAAPTCharacteristics()) > 0 {
194 linkFlags = append(linkFlags, "--product", ctx.Config().ProductAAPTCharacteristics())
195 }
196
Dan Willemsen72be5902018-10-24 20:24:57 -0700197 if !Bool(a.aaptProperties.Aapt_include_all_resources) {
198 // Product AAPT config
199 for _, aaptConfig := range ctx.Config().ProductAAPTConfig() {
200 linkFlags = append(linkFlags, "-c", aaptConfig)
201 }
Colin Crosse78dcd32018-04-19 15:25:19 -0700202
Dan Willemsen72be5902018-10-24 20:24:57 -0700203 // Product AAPT preferred config
204 if len(ctx.Config().ProductAAPTPreferredConfig()) > 0 {
205 linkFlags = append(linkFlags, "--preferred-density", ctx.Config().ProductAAPTPreferredConfig())
206 }
Colin Crosse78dcd32018-04-19 15:25:19 -0700207 }
208
Colin Crossa97c5d32018-03-28 14:58:31 -0700209 // TODO: LOCAL_PACKAGE_OVERRIDES
210 // $(addprefix --rename-manifest-package , $(PRIVATE_MANIFEST_PACKAGE_NAME)) \
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800211
Colin Cross83bb3162018-06-25 15:48:06 -0700212 a.aapt.buildActions(ctx, sdkContext(a), linkFlags...)
Colin Cross30e076a2015-04-13 13:58:27 -0700213
Colin Cross46c9b8b2017-06-22 16:51:17 -0700214 // apps manifests are handled by aapt, don't let Module see them
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700215 a.properties.Manifest = nil
Colin Cross30e076a2015-04-13 13:58:27 -0700216
Colin Cross89c31582018-04-30 15:55:11 -0700217 var staticLibProguardFlagFiles android.Paths
218 ctx.VisitDirectDeps(func(m android.Module) {
219 if lib, ok := m.(AndroidLibraryDependency); ok && ctx.OtherModuleDependencyTag(m) == staticLibTag {
220 staticLibProguardFlagFiles = append(staticLibProguardFlagFiles, lib.ExportedProguardFlagFiles()...)
221 }
222 })
223
224 staticLibProguardFlagFiles = android.FirstUniquePaths(staticLibProguardFlagFiles)
225
226 a.Module.extraProguardFlagFiles = append(a.Module.extraProguardFlagFiles, staticLibProguardFlagFiles...)
227 a.Module.extraProguardFlagFiles = append(a.Module.extraProguardFlagFiles, a.proguardOptionsFile)
Colin Cross66dbc0b2017-12-28 12:23:20 -0800228
Colin Cross5a0dcd52018-10-05 14:20:06 -0700229 a.deviceProperties.UncompressDex, a.appProperties.StripDex = a.uncompressOrStripDex(ctx)
230
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800231 if ctx.ModuleName() != "framework-res" {
232 a.Module.compile(ctx, a.aaptSrcJar)
233 }
Colin Cross5a0dcd52018-10-05 14:20:06 -0700234 dexJarFile := a.dexJarFile
Colin Cross30e076a2015-04-13 13:58:27 -0700235
Colin Cross5a0dcd52018-10-05 14:20:06 -0700236 if a.appProperties.StripDex {
237 dexJarFile = nil
238 }
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800239
Colin Crossbd01e2a2018-10-04 15:21:03 -0700240 var certificates []certificate
241
Colin Crossa4f08812018-10-02 22:03:40 -0700242 var jniJarFile android.WritablePath
Colin Crossbd01e2a2018-10-04 15:21:03 -0700243 jniLibs, certificateDeps := a.collectAppDeps(ctx)
Colin Crossa4f08812018-10-02 22:03:40 -0700244 if len(jniLibs) > 0 {
245 embedJni := ctx.Config().UnbundledBuild() || a.appProperties.EmbedJNI
246 if embedJni {
247 jniJarFile = android.PathForModuleOut(ctx, "jnilibs.zip")
248 TransformJniLibsToJar(ctx, jniJarFile, jniLibs)
249 } else {
250 a.installJniLibs = jniLibs
251 }
252 }
253
Colin Crossbd01e2a2018-10-04 15:21:03 -0700254 if ctx.Failed() {
255 return
256 }
257
258 cert := String(a.appProperties.Certificate)
259 certModule := android.SrcIsModule(cert)
260 if certModule != "" {
261 a.certificate = certificateDeps[0]
262 certificateDeps = certificateDeps[1:]
263 } else if cert != "" {
264 defaultDir := ctx.Config().DefaultAppCertificateDir(ctx)
265 a.certificate = certificate{
266 defaultDir.Join(ctx, cert+".x509.pem"),
267 defaultDir.Join(ctx, cert+".pk8"),
268 }
269 } else {
270 pem, key := ctx.Config().DefaultAppCertificate(ctx)
271 a.certificate = certificate{pem, key}
272 }
273
274 certificates = append([]certificate{a.certificate}, certificateDeps...)
275
Colin Cross5a0dcd52018-10-05 14:20:06 -0700276 packageFile := android.PathForModuleOut(ctx, "package.apk")
277 CreateAppPackage(ctx, packageFile, a.exportPackage, jniJarFile, dexJarFile, certificates)
Colin Cross3bc7ffa2017-11-22 16:19:37 -0800278 a.outputFile = packageFile
279
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800280 if ctx.ModuleName() == "framework-res" {
281 // framework-res.apk is installed as system/framework/framework-res.apk
282 ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"), ctx.ModuleName()+".apk", a.outputFile)
Colin Cross16056062017-12-13 22:46:28 -0800283 } else if Bool(a.appProperties.Privileged) {
284 ctx.InstallFile(android.PathForModuleInstall(ctx, "priv-app"), ctx.ModuleName()+".apk", a.outputFile)
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800285 } else {
286 ctx.InstallFile(android.PathForModuleInstall(ctx, "app"), ctx.ModuleName()+".apk", a.outputFile)
287 }
Colin Cross30e076a2015-04-13 13:58:27 -0700288}
289
Colin Crossbd01e2a2018-10-04 15:21:03 -0700290func (a *AndroidApp) collectAppDeps(ctx android.ModuleContext) ([]jniLib, []certificate) {
Colin Crossa4f08812018-10-02 22:03:40 -0700291 var jniLibs []jniLib
Colin Crossbd01e2a2018-10-04 15:21:03 -0700292 var certificates []certificate
Colin Crossa4f08812018-10-02 22:03:40 -0700293
294 ctx.VisitDirectDeps(func(module android.Module) {
295 otherName := ctx.OtherModuleName(module)
296 tag := ctx.OtherModuleDependencyTag(module)
297
298 if jniTag, ok := tag.(*jniDependencyTag); ok {
299 if dep, ok := module.(*cc.Module); ok {
300 lib := dep.OutputFile()
301 if lib.Valid() {
302 jniLibs = append(jniLibs, jniLib{
303 name: ctx.OtherModuleName(module),
304 path: lib.Path(),
305 target: jniTag.target,
306 })
307 } else {
308 ctx.ModuleErrorf("dependency %q missing output file", otherName)
309 }
310 } else {
311 ctx.ModuleErrorf("jni_libs dependency %q must be a cc library", otherName)
312
313 }
Colin Crossbd01e2a2018-10-04 15:21:03 -0700314 } else if tag == certificateTag {
315 if dep, ok := module.(*AndroidAppCertificate); ok {
316 certificates = append(certificates, dep.certificate)
317 } else {
318 ctx.ModuleErrorf("certificate dependency %q must be an android_app_certificate module", otherName)
319 }
Colin Crossa4f08812018-10-02 22:03:40 -0700320 }
321 })
322
Colin Crossbd01e2a2018-10-04 15:21:03 -0700323 return jniLibs, certificates
Colin Crossa4f08812018-10-02 22:03:40 -0700324}
325
Colin Cross36242852017-06-23 15:06:31 -0700326func AndroidAppFactory() android.Module {
Colin Cross30e076a2015-04-13 13:58:27 -0700327 module := &AndroidApp{}
328
Colin Cross66dbc0b2017-12-28 12:23:20 -0800329 module.Module.deviceProperties.Optimize.Enabled = proptools.BoolPtr(true)
330 module.Module.deviceProperties.Optimize.Shrink = proptools.BoolPtr(true)
331
Colin Crossae5caf52018-05-22 11:11:52 -0700332 module.Module.properties.Instrument = true
Colin Cross9ae1b922018-06-26 17:59:05 -0700333 module.Module.properties.Installable = proptools.BoolPtr(true)
Colin Cross5a0dcd52018-10-05 14:20:06 -0700334 module.appProperties.AllowDexPreopt = true
Colin Crossae5caf52018-05-22 11:11:52 -0700335
Colin Cross36242852017-06-23 15:06:31 -0700336 module.AddProperties(
Colin Cross540eff82017-06-22 17:01:52 -0700337 &module.Module.properties,
338 &module.Module.deviceProperties,
Colin Crossa97c5d32018-03-28 14:58:31 -0700339 &module.Module.protoProperties,
340 &module.aaptProperties,
Colin Cross540eff82017-06-22 17:01:52 -0700341 &module.appProperties)
Colin Cross36242852017-06-23 15:06:31 -0700342
Colin Crossa9d8bee2018-10-02 13:59:46 -0700343 module.Prefer32(func(ctx android.BaseModuleContext, base *android.ModuleBase, class android.OsClass) bool {
344 return class == android.Device && ctx.Config().DevicePrefer32BitApps()
345 })
346
Colin Crossa4f08812018-10-02 22:03:40 -0700347 android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
348 android.InitDefaultableModule(module)
349
Colin Cross36242852017-06-23 15:06:31 -0700350 return module
Colin Cross30e076a2015-04-13 13:58:27 -0700351}
Colin Crossae5caf52018-05-22 11:11:52 -0700352
353type appTestProperties struct {
354 Instrumentation_for *string
355}
356
357type AndroidTest struct {
358 AndroidApp
359
360 appTestProperties appTestProperties
361
362 testProperties testProperties
Colin Cross303e21f2018-08-07 16:49:25 -0700363
364 testConfig android.Path
Colin Crossd96ca352018-08-10 16:06:24 -0700365 data android.Paths
Colin Crossae5caf52018-05-22 11:11:52 -0700366}
367
368func (a *AndroidTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Colin Crossae5caf52018-05-22 11:11:52 -0700369 a.generateAndroidBuildActions(ctx)
Colin Cross303e21f2018-08-07 16:49:25 -0700370
Jack He33338892018-09-19 02:21:28 -0700371 a.testConfig = tradefed.AutoGenInstrumentationTestConfig(ctx, a.testProperties.Test_config, a.testProperties.Test_config_template, a.manifestPath)
Colin Crossd96ca352018-08-10 16:06:24 -0700372 a.data = ctx.ExpandSources(a.testProperties.Data, nil)
Colin Cross303e21f2018-08-07 16:49:25 -0700373}
374
375func (a *AndroidTest) DepsMutator(ctx android.BottomUpMutatorContext) {
376 android.ExtractSourceDeps(ctx, a.testProperties.Test_config)
Jack He33338892018-09-19 02:21:28 -0700377 android.ExtractSourceDeps(ctx, a.testProperties.Test_config_template)
Colin Crossd96ca352018-08-10 16:06:24 -0700378 android.ExtractSourcesDeps(ctx, a.testProperties.Data)
Colin Cross303e21f2018-08-07 16:49:25 -0700379 a.AndroidApp.DepsMutator(ctx)
Colin Cross4b964c02018-10-15 16:18:06 -0700380 if a.appTestProperties.Instrumentation_for != nil {
381 // The android_app dependency listed in instrumentation_for needs to be added to the classpath for javac,
382 // but not added to the aapt2 link includes like a normal android_app or android_library dependency, so
383 // use instrumentationForTag instead of libTag.
384 ctx.AddVariationDependencies(nil, instrumentationForTag, String(a.appTestProperties.Instrumentation_for))
385 }
Colin Crossae5caf52018-05-22 11:11:52 -0700386}
387
388func AndroidTestFactory() android.Module {
389 module := &AndroidTest{}
390
391 module.Module.deviceProperties.Optimize.Enabled = proptools.BoolPtr(true)
Colin Cross5067db92018-09-17 16:46:35 -0700392
393 module.Module.properties.Instrument = true
Colin Cross9ae1b922018-06-26 17:59:05 -0700394 module.Module.properties.Installable = proptools.BoolPtr(true)
Colin Crossa4f08812018-10-02 22:03:40 -0700395 module.appProperties.EmbedJNI = true
Colin Cross5a0dcd52018-10-05 14:20:06 -0700396 module.appProperties.AllowDexPreopt = false
Colin Crossae5caf52018-05-22 11:11:52 -0700397
398 module.AddProperties(
399 &module.Module.properties,
400 &module.Module.deviceProperties,
401 &module.Module.protoProperties,
402 &module.aaptProperties,
403 &module.appProperties,
Dan Willemsenf5531d22018-07-16 17:21:19 -0700404 &module.appTestProperties,
405 &module.testProperties)
Colin Crossae5caf52018-05-22 11:11:52 -0700406
Colin Crossa4f08812018-10-02 22:03:40 -0700407 android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
408 android.InitDefaultableModule(module)
Colin Crossae5caf52018-05-22 11:11:52 -0700409 return module
410}
Colin Crossbd01e2a2018-10-04 15:21:03 -0700411
Colin Cross252fc6f2018-10-04 15:22:03 -0700412type appTestHelperAppProperties struct {
413 // list of compatibility suites (for example "cts", "vts") that the module should be
414 // installed into.
415 Test_suites []string `android:"arch_variant"`
416}
417
418type AndroidTestHelperApp struct {
419 AndroidApp
420
421 appTestHelperAppProperties appTestHelperAppProperties
422}
423
424func AndroidTestHelperAppFactory() android.Module {
425 module := &AndroidTestHelperApp{}
426
427 module.Module.deviceProperties.Optimize.Enabled = proptools.BoolPtr(true)
428
429 module.Module.properties.Installable = proptools.BoolPtr(true)
430 module.appProperties.EmbedJNI = true
Colin Cross5a0dcd52018-10-05 14:20:06 -0700431 module.appProperties.AllowDexPreopt = false
Colin Cross252fc6f2018-10-04 15:22:03 -0700432
433 module.AddProperties(
434 &module.Module.properties,
435 &module.Module.deviceProperties,
436 &module.Module.protoProperties,
437 &module.aaptProperties,
438 &module.appProperties,
439 &module.appTestHelperAppProperties)
440
441 android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
442 android.InitDefaultableModule(module)
443 return module
444}
445
Colin Crossbd01e2a2018-10-04 15:21:03 -0700446type AndroidAppCertificate struct {
447 android.ModuleBase
448 properties AndroidAppCertificateProperties
449 certificate certificate
450}
451
452type AndroidAppCertificateProperties struct {
453 // Name of the certificate files. Extensions .x509.pem and .pk8 will be added to the name.
454 Certificate *string
455}
456
457func AndroidAppCertificateFactory() android.Module {
458 module := &AndroidAppCertificate{}
459 module.AddProperties(&module.properties)
460 android.InitAndroidModule(module)
461 return module
462}
463
464func (c *AndroidAppCertificate) DepsMutator(ctx android.BottomUpMutatorContext) {
465}
466
467func (c *AndroidAppCertificate) GenerateAndroidBuildActions(ctx android.ModuleContext) {
468 cert := String(c.properties.Certificate)
469 c.certificate = certificate{
470 android.PathForModuleSrc(ctx, cert+".x509.pem"),
471 android.PathForModuleSrc(ctx, cert+".pk8"),
472 }
473}