blob: eb94806193a6c5a80c5c322a741f2646cff7bc4b [file] [log] [blame]
Colin Cross2fe66872015-03-30 17:20:39 -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 Java for Android, and converts the properties
Colin Cross46c9b8b2017-06-22 16:51:17 -070018// into the flags and filenames necessary to pass to the Module. The final creation of the rules
Colin Cross2fe66872015-03-30 17:20:39 -070019// is handled in builder.go
20
21import (
22 "fmt"
Colin Crossfc3674a2017-09-18 17:41:52 -070023 "path/filepath"
Colin Cross74d73e22017-08-02 11:05:49 -070024 "strconv"
Colin Cross2fe66872015-03-30 17:20:39 -070025 "strings"
26
27 "github.com/google/blueprint"
Colin Cross76b5f0c2017-08-29 16:02:06 -070028 "github.com/google/blueprint/proptools"
Colin Cross2fe66872015-03-30 17:20:39 -070029
Colin Cross635c3b02016-05-18 15:37:25 -070030 "android/soong/android"
Colin Cross0607cf72015-04-28 13:28:51 -070031 "android/soong/genrule"
Colin Cross3e3e72d2017-06-22 17:20:19 -070032 "android/soong/java/config"
Colin Cross2fe66872015-03-30 17:20:39 -070033)
34
Colin Cross463a90e2015-06-17 14:20:06 -070035func init() {
Colin Cross89536d42017-07-07 14:35:50 -070036 android.RegisterModuleType("java_defaults", defaultsFactory)
37
Colin Crossa60ead82017-10-02 18:10:21 -070038 android.RegisterModuleType("java_library", LibraryFactory(true))
39 android.RegisterModuleType("java_library_static", LibraryFactory(false))
Colin Crossf506d872017-07-19 15:53:04 -070040 android.RegisterModuleType("java_library_host", LibraryHostFactory)
41 android.RegisterModuleType("java_binary", BinaryFactory)
42 android.RegisterModuleType("java_binary_host", BinaryHostFactory)
Colin Cross74d73e22017-08-02 11:05:49 -070043 android.RegisterModuleType("java_import", ImportFactory)
44 android.RegisterModuleType("java_import_host", ImportFactoryHost)
Colin Cross798bfce2016-10-12 14:28:16 -070045 android.RegisterModuleType("android_app", AndroidAppFactory)
Colin Cross463a90e2015-06-17 14:20:06 -070046
Colin Cross798bfce2016-10-12 14:28:16 -070047 android.RegisterSingletonType("logtags", LogtagsSingleton)
Colin Cross463a90e2015-06-17 14:20:06 -070048}
49
Colin Cross2fe66872015-03-30 17:20:39 -070050// TODO:
51// Autogenerated files:
Colin Cross2fe66872015-03-30 17:20:39 -070052// Renderscript
53// Post-jar passes:
54// Proguard
Colin Crossba211132017-06-22 15:36:39 -070055// Jacoco
Colin Cross2fe66872015-03-30 17:20:39 -070056// Jarjar
57// Dex
58// Rmtypedefs
Colin Cross2fe66872015-03-30 17:20:39 -070059// DroidDoc
60// Findbugs
61
Colin Cross89536d42017-07-07 14:35:50 -070062type CompilerProperties struct {
Colin Cross7d5136f2015-05-11 13:39:40 -070063 // list of source files used to compile the Java module. May be .java, .logtags, .proto,
64 // or .aidl files.
Dan Willemsen2ef08f42015-06-30 18:15:24 -070065 Srcs []string `android:"arch_variant"`
66
67 // list of source files that should not be used to build the Java module.
68 // This is most useful in the arch/multilib variants to remove non-common files
69 Exclude_srcs []string `android:"arch_variant"`
Colin Cross7d5136f2015-05-11 13:39:40 -070070
71 // list of directories containing Java resources
Colin Cross86a63ff2017-09-27 17:33:10 -070072 Java_resource_dirs []string `android:"arch_variant"`
Colin Cross7d5136f2015-05-11 13:39:40 -070073
Colin Cross86a63ff2017-09-27 17:33:10 -070074 // list of directories that should be excluded from java_resource_dirs
75 Exclude_java_resource_dirs []string `android:"arch_variant"`
Dan Willemsen2ef08f42015-06-30 18:15:24 -070076
Colin Cross0f37af02017-09-27 17:42:05 -070077 // list of files to use as Java resources
78 Java_resources []string `android:"arch_variant"`
79
80 // list of files that should be excluded from java_resources
81 Exclude_java_resources []string `android:"arch_variant"`
82
Colin Crossfa5eb232017-10-01 20:33:03 -070083 // don't build against the default libraries (bootclasspath, legacy-test, core-junit,
Colin Cross7d5136f2015-05-11 13:39:40 -070084 // ext, and framework for device targets)
Colin Cross76b5f0c2017-08-29 16:02:06 -070085 No_standard_libs *bool
Colin Cross7d5136f2015-05-11 13:39:40 -070086
Colin Crossfa5eb232017-10-01 20:33:03 -070087 // don't build against the framework libraries (legacy-test, core-junit,
88 // ext, and framework for device targets)
89 No_framework_libs *bool
90
Colin Cross7d5136f2015-05-11 13:39:40 -070091 // list of module-specific flags that will be used for javac compiles
92 Javacflags []string `android:"arch_variant"`
93
Colin Cross7d5136f2015-05-11 13:39:40 -070094 // list of of java libraries that will be in the classpath
Colin Crosse8dc34a2017-07-19 11:22:16 -070095 Libs []string `android:"arch_variant"`
Colin Cross7d5136f2015-05-11 13:39:40 -070096
97 // list of java libraries that will be compiled into the resulting jar
Colin Crosse8dc34a2017-07-19 11:22:16 -070098 Static_libs []string `android:"arch_variant"`
Colin Cross7d5136f2015-05-11 13:39:40 -070099
100 // manifest file to be included in resulting jar
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700101 Manifest *string
Colin Cross7d5136f2015-05-11 13:39:40 -0700102
Colin Cross540eff82017-06-22 17:01:52 -0700103 // if not blank, run jarjar using the specified rules file
104 Jarjar_rules *string
Colin Cross64162712017-08-08 13:17:59 -0700105
106 // If not blank, set the java version passed to javac as -source and -target
107 Java_version *string
Colin Cross2c429dc2017-08-31 16:45:16 -0700108
109 // If set to false, don't allow this module to be installed. Defaults to true.
110 Installable *bool
Colin Cross32f676a2017-09-06 13:41:06 -0700111
Colin Cross0f37af02017-09-27 17:42:05 -0700112 // If set to true, include sources used to compile the module in to the final jar
113 Include_srcs *bool
114
Colin Cross32f676a2017-09-06 13:41:06 -0700115 // List of modules to use as annotation processors
116 Annotation_processors []string
117
118 // List of classes to pass to javac to use as annotation processors
119 Annotation_processor_classes []string
Colin Cross540eff82017-06-22 17:01:52 -0700120}
121
Colin Cross89536d42017-07-07 14:35:50 -0700122type CompilerDeviceProperties struct {
Colin Cross540eff82017-06-22 17:01:52 -0700123 // list of module-specific flags that will be used for dex compiles
124 Dxflags []string `android:"arch_variant"`
125
Colin Cross7d5136f2015-05-11 13:39:40 -0700126 // if not blank, set to the version of the sdk to compile against
127 Sdk_version string
128
129 // Set for device java libraries, and for host versions of device java libraries
130 // built for testing
131 Dex bool `blueprint:"mutated"`
132
Colin Cross7d5136f2015-05-11 13:39:40 -0700133 // directories to pass to aidl tool
134 Aidl_includes []string
135
136 // directories that should be added as include directories
137 // for any aidl sources of modules that depend on this module
138 Export_aidl_include_dirs []string
139}
140
Colin Cross46c9b8b2017-06-22 16:51:17 -0700141// Module contains the properties and members used by all java module types
142type Module struct {
Colin Cross635c3b02016-05-18 15:37:25 -0700143 android.ModuleBase
Colin Cross89536d42017-07-07 14:35:50 -0700144 android.DefaultableModuleBase
Colin Cross2fe66872015-03-30 17:20:39 -0700145
Colin Cross89536d42017-07-07 14:35:50 -0700146 properties CompilerProperties
Colin Cross6af17aa2017-09-20 12:59:05 -0700147 protoProperties android.ProtoProperties
Colin Cross89536d42017-07-07 14:35:50 -0700148 deviceProperties CompilerDeviceProperties
Colin Cross2fe66872015-03-30 17:20:39 -0700149
150 // output file suitable for inserting into the classpath of another compile
Colin Cross635c3b02016-05-18 15:37:25 -0700151 classpathFile android.Path
Colin Cross2fe66872015-03-30 17:20:39 -0700152
Colin Cross6ade34f2017-09-15 13:00:47 -0700153 // output file containing classes.dex
154 dexJarFile android.Path
155
156 // output files containing resources
157 resourceJarFiles android.Paths
158
Colin Crossb7a63242015-04-16 14:09:14 -0700159 // output file suitable for installing or running
Colin Cross635c3b02016-05-18 15:37:25 -0700160 outputFile android.Path
Colin Crossb7a63242015-04-16 14:09:14 -0700161
Colin Cross635c3b02016-05-18 15:37:25 -0700162 exportAidlIncludeDirs android.Paths
Colin Crossc0b06f12015-04-08 13:03:43 -0700163
Colin Cross635c3b02016-05-18 15:37:25 -0700164 logtagsSrcs android.Paths
Colin Crossf05fe972015-04-10 17:45:20 -0700165
Colin Crossb7a63242015-04-16 14:09:14 -0700166 // filelists of extra source files that should be included in the javac command line,
167 // for example R.java generated by aapt for android apps
Colin Cross635c3b02016-05-18 15:37:25 -0700168 ExtraSrcLists android.Paths
Colin Crossb7a63242015-04-16 14:09:14 -0700169
Colin Cross2fe66872015-03-30 17:20:39 -0700170 // installed file for binary dependency
Colin Cross635c3b02016-05-18 15:37:25 -0700171 installFile android.Path
Colin Cross2fe66872015-03-30 17:20:39 -0700172}
173
Colin Crossf506d872017-07-19 15:53:04 -0700174type Dependency interface {
Colin Cross74d73e22017-08-02 11:05:49 -0700175 ClasspathFiles() android.Paths
Colin Cross6ade34f2017-09-15 13:00:47 -0700176 ResourceJarFiles() android.Paths
Colin Cross635c3b02016-05-18 15:37:25 -0700177 AidlIncludeDirs() android.Paths
Colin Cross2fe66872015-03-30 17:20:39 -0700178}
179
Colin Cross89536d42017-07-07 14:35:50 -0700180func InitJavaModule(module android.DefaultableModule, hod android.HostOrDeviceSupported) {
181 android.InitAndroidArchModule(module, hod, android.MultilibCommon)
182 android.InitDefaultableModule(module)
183}
184
Colin Crossbe1da472017-07-07 15:59:46 -0700185type dependencyTag struct {
186 blueprint.BaseDependencyTag
187 name string
Colin Cross2fe66872015-03-30 17:20:39 -0700188}
189
Colin Crossbe1da472017-07-07 15:59:46 -0700190var (
Colin Cross6ade34f2017-09-15 13:00:47 -0700191 staticLibTag = dependencyTag{name: "staticlib"}
192 libTag = dependencyTag{name: "javalib"}
193 bootClasspathTag = dependencyTag{name: "bootclasspath"}
194 frameworkResTag = dependencyTag{name: "framework-res"}
Colin Crossbe1da472017-07-07 15:59:46 -0700195)
Colin Cross2fe66872015-03-30 17:20:39 -0700196
Colin Crossfc3674a2017-09-18 17:41:52 -0700197type sdkDep struct {
Colin Cross47ff2522017-10-02 14:22:08 -0700198 useModule, useFiles, useDefaultLibs, invalidVersion bool
199
200 module string
201 jar android.Path
202 aidl android.Path
Colin Crossfc3674a2017-09-18 17:41:52 -0700203}
204
205func decodeSdkDep(ctx android.BaseContext, v string) sdkDep {
206 switch v {
207 case "", "current", "system_current", "test_current":
208 // OK
209 default:
210 if _, err := strconv.Atoi(v); err != nil {
211 ctx.PropertyErrorf("sdk_version", "invalid sdk version")
212 return sdkDep{}
213 }
214 }
215
216 toFile := func(v string) sdkDep {
217 dir := filepath.Join("prebuilts/sdk", v)
218 jar := filepath.Join(dir, "android.jar")
219 aidl := filepath.Join(dir, "framework.aidl")
220 jarPath := android.ExistentPathForSource(ctx, "sdkdir", jar)
221 aidlPath := android.ExistentPathForSource(ctx, "sdkdir", aidl)
Colin Cross47ff2522017-10-02 14:22:08 -0700222
223 if (!jarPath.Valid() || !aidlPath.Valid()) && ctx.AConfig().AllowMissingDependencies() {
224 return sdkDep{
225 invalidVersion: true,
226 module: "sdk_v" + v,
227 }
228 }
229
Colin Crossfc3674a2017-09-18 17:41:52 -0700230 if !jarPath.Valid() {
231 ctx.PropertyErrorf("sdk_version", "invalid sdk version %q, %q does not exist", v, jar)
232 return sdkDep{}
233 }
Colin Cross47ff2522017-10-02 14:22:08 -0700234
Colin Crossfc3674a2017-09-18 17:41:52 -0700235 if !aidlPath.Valid() {
236 ctx.PropertyErrorf("sdk_version", "invalid sdk version %q, %q does not exist", v, aidl)
237 return sdkDep{}
238 }
Colin Cross47ff2522017-10-02 14:22:08 -0700239
Colin Crossfc3674a2017-09-18 17:41:52 -0700240 return sdkDep{
241 useFiles: true,
242 jar: jarPath.Path(),
243 aidl: aidlPath.Path(),
244 }
245 }
246
247 toModule := func(m string) sdkDep {
248 return sdkDep{
249 useModule: true,
250 module: m,
251 }
252 }
253
Colin Cross8b9d37b2017-09-22 15:30:06 -0700254 if ctx.AConfig().UnbundledBuild() && v != "" {
Colin Crossfc3674a2017-09-18 17:41:52 -0700255 return toFile(v)
256 }
257
258 switch v {
259 case "":
260 return sdkDep{
261 useDefaultLibs: true,
262 }
263 case "current":
264 return toModule("android_stubs_current")
265 case "system_current":
266 return toModule("android_system_stubs_current")
267 case "test_current":
268 return toModule("android_test_stubs_current")
269 default:
270 return toFile(v)
271 }
272}
273
Colin Crossbe1da472017-07-07 15:59:46 -0700274func (j *Module) deps(ctx android.BottomUpMutatorContext) {
Colin Cross76b5f0c2017-08-29 16:02:06 -0700275 if !proptools.Bool(j.properties.No_standard_libs) {
Colin Crossbe1da472017-07-07 15:59:46 -0700276 if ctx.Device() {
Colin Crossfc3674a2017-09-18 17:41:52 -0700277 sdkDep := decodeSdkDep(ctx, j.deviceProperties.Sdk_version)
278 if sdkDep.useDefaultLibs {
Colin Crosscb2c9292017-09-23 19:57:16 -0700279 ctx.AddDependency(ctx.Module(), bootClasspathTag, config.DefaultBootclasspathLibraries...)
Colin Crossfa5eb232017-10-01 20:33:03 -0700280 if !proptools.Bool(j.properties.No_framework_libs) {
281 ctx.AddDependency(ctx.Module(), libTag, config.DefaultLibraries...)
282 }
Colin Crossfc3674a2017-09-18 17:41:52 -0700283 }
284 if sdkDep.useModule {
285 ctx.AddDependency(ctx.Module(), bootClasspathTag, sdkDep.module)
Colin Crossbe1da472017-07-07 15:59:46 -0700286 }
287 } else {
288 if j.deviceProperties.Dex {
Colin Crosscb2c9292017-09-23 19:57:16 -0700289 ctx.AddDependency(ctx.Module(), bootClasspathTag, config.DefaultBootclasspathLibraries...)
Colin Crossbe1da472017-07-07 15:59:46 -0700290 }
Colin Cross2fe66872015-03-30 17:20:39 -0700291 }
292 }
Colin Crossf506d872017-07-19 15:53:04 -0700293 ctx.AddDependency(ctx.Module(), libTag, j.properties.Libs...)
294 ctx.AddDependency(ctx.Module(), staticLibTag, j.properties.Static_libs...)
Colin Cross6ade34f2017-09-15 13:00:47 -0700295 ctx.AddDependency(ctx.Module(), libTag, j.properties.Annotation_processors...)
Colin Cross7f9036c2017-08-30 13:27:57 -0700296
297 android.ExtractSourcesDeps(ctx, j.properties.Srcs)
Colin Cross0f37af02017-09-27 17:42:05 -0700298 android.ExtractSourcesDeps(ctx, j.properties.Java_resources)
Colin Cross6af17aa2017-09-20 12:59:05 -0700299
300 if j.hasSrcExt(".proto") {
301 protoDeps(ctx, &j.protoProperties)
302 }
303}
304
305func hasSrcExt(srcs []string, ext string) bool {
306 for _, src := range srcs {
307 if filepath.Ext(src) == ext {
308 return true
309 }
310 }
311
312 return false
313}
314
315func (j *Module) hasSrcExt(ext string) bool {
316 return hasSrcExt(j.properties.Srcs, ext)
Colin Cross2fe66872015-03-30 17:20:39 -0700317}
318
Colin Cross46c9b8b2017-06-22 16:51:17 -0700319func (j *Module) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.OptionalPath,
Colin Cross635c3b02016-05-18 15:37:25 -0700320 aidlIncludeDirs android.Paths) []string {
Colin Crossc0b06f12015-04-08 13:03:43 -0700321
Colin Cross540eff82017-06-22 17:01:52 -0700322 localAidlIncludes := android.PathsForModuleSrc(ctx, j.deviceProperties.Aidl_includes)
Colin Crossc0b06f12015-04-08 13:03:43 -0700323
324 var flags []string
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700325 if aidlPreprocess.Valid() {
326 flags = append(flags, "-p"+aidlPreprocess.String())
Colin Crossc0b06f12015-04-08 13:03:43 -0700327 } else {
Colin Cross635c3b02016-05-18 15:37:25 -0700328 flags = append(flags, android.JoinWithPrefix(aidlIncludeDirs.Strings(), "-I"))
Colin Crossc0b06f12015-04-08 13:03:43 -0700329 }
330
Colin Cross635c3b02016-05-18 15:37:25 -0700331 flags = append(flags, android.JoinWithPrefix(j.exportAidlIncludeDirs.Strings(), "-I"))
332 flags = append(flags, android.JoinWithPrefix(localAidlIncludes.Strings(), "-I"))
333 flags = append(flags, "-I"+android.PathForModuleSrc(ctx).String())
Colin Crossd48633a2017-07-13 14:41:17 -0700334 if src := android.ExistentPathForSource(ctx, "", "src"); src.Valid() {
335 flags = append(flags, "-I"+src.String())
336 }
Colin Crossc0b06f12015-04-08 13:03:43 -0700337
Colin Crossf03c82b2015-04-13 13:53:40 -0700338 return flags
Colin Crossc0b06f12015-04-08 13:03:43 -0700339}
340
Colin Cross32f676a2017-09-06 13:41:06 -0700341type deps struct {
Colin Cross6ade34f2017-09-15 13:00:47 -0700342 classpath android.Paths
343 bootClasspath android.Paths
344 staticJars android.Paths
345 staticJarResources android.Paths
346 aidlIncludeDirs android.Paths
347 srcFileLists android.Paths
348 aidlPreprocess android.OptionalPath
Colin Cross32f676a2017-09-06 13:41:06 -0700349}
Colin Cross2fe66872015-03-30 17:20:39 -0700350
Colin Cross32f676a2017-09-06 13:41:06 -0700351func (j *Module) collectDeps(ctx android.ModuleContext) deps {
352 var deps deps
Colin Crossfc3674a2017-09-18 17:41:52 -0700353
354 sdkDep := decodeSdkDep(ctx, j.deviceProperties.Sdk_version)
Colin Cross47ff2522017-10-02 14:22:08 -0700355 if sdkDep.invalidVersion {
356 ctx.AddMissingDependencies([]string{sdkDep.module})
357 } else if sdkDep.useFiles {
Colin Crossfc3674a2017-09-18 17:41:52 -0700358 deps.classpath = append(deps.classpath, sdkDep.jar)
359 deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, sdkDep.aidl)
360 }
361
Colin Cross2fe66872015-03-30 17:20:39 -0700362 ctx.VisitDirectDeps(func(module blueprint.Module) {
363 otherName := ctx.OtherModuleName(module)
Colin Crossec7a0422017-07-07 14:47:12 -0700364 tag := ctx.OtherModuleDependencyTag(module)
365
Colin Crossf506d872017-07-19 15:53:04 -0700366 dep, _ := module.(Dependency)
367 if dep == nil {
Colin Crossec7a0422017-07-07 14:47:12 -0700368 switch tag {
369 case android.DefaultsDepTag, android.SourceDepTag:
Dan Willemsend6ba0d52017-09-13 15:46:47 -0700370 // Nothing to do
Colin Crossec7a0422017-07-07 14:47:12 -0700371 default:
372 ctx.ModuleErrorf("depends on non-java module %q", otherName)
Colin Cross2fe66872015-03-30 17:20:39 -0700373 }
Colin Crossec7a0422017-07-07 14:47:12 -0700374 return
375 }
376
Colin Crossbe1da472017-07-07 15:59:46 -0700377 switch tag {
378 case bootClasspathTag:
Colin Cross32f676a2017-09-06 13:41:06 -0700379 deps.bootClasspath = append(deps.bootClasspath, dep.ClasspathFiles()...)
Colin Crossf506d872017-07-19 15:53:04 -0700380 case libTag:
Colin Cross32f676a2017-09-06 13:41:06 -0700381 deps.classpath = append(deps.classpath, dep.ClasspathFiles()...)
Colin Crossf506d872017-07-19 15:53:04 -0700382 case staticLibTag:
Colin Cross32f676a2017-09-06 13:41:06 -0700383 deps.classpath = append(deps.classpath, dep.ClasspathFiles()...)
384 deps.staticJars = append(deps.staticJars, dep.ClasspathFiles()...)
Colin Cross6ade34f2017-09-15 13:00:47 -0700385 deps.staticJarResources = append(deps.staticJarResources, dep.ResourceJarFiles()...)
Colin Crossbe1da472017-07-07 15:59:46 -0700386 case frameworkResTag:
Colin Crossec7a0422017-07-07 14:47:12 -0700387 if ctx.ModuleName() == "framework" {
388 // framework.jar has a one-off dependency on the R.java and Manifest.java files
389 // generated by framework-res.apk
Colin Cross32f676a2017-09-06 13:41:06 -0700390 deps.srcFileLists = append(deps.srcFileLists, module.(*AndroidApp).aaptJavaFileList)
Colin Crossec7a0422017-07-07 14:47:12 -0700391 }
Colin Crossbe1da472017-07-07 15:59:46 -0700392 default:
393 panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName()))
Colin Cross2fe66872015-03-30 17:20:39 -0700394 }
Colin Crossbe1da472017-07-07 15:59:46 -0700395
Colin Cross32f676a2017-09-06 13:41:06 -0700396 deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...)
Colin Cross2fe66872015-03-30 17:20:39 -0700397 })
398
Colin Cross32f676a2017-09-06 13:41:06 -0700399 return deps
Colin Cross2fe66872015-03-30 17:20:39 -0700400}
401
Colin Cross46c9b8b2017-06-22 16:51:17 -0700402func (j *Module) compile(ctx android.ModuleContext) {
Colin Crossc0b06f12015-04-08 13:03:43 -0700403
Colin Cross540eff82017-06-22 17:01:52 -0700404 j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.deviceProperties.Export_aidl_include_dirs)
Colin Crossc0b06f12015-04-08 13:03:43 -0700405
Colin Cross32f676a2017-09-06 13:41:06 -0700406 deps := j.collectDeps(ctx)
Colin Crossc0b06f12015-04-08 13:03:43 -0700407
Colin Crossf03c82b2015-04-13 13:53:40 -0700408 var flags javaBuilderFlags
409
410 javacFlags := j.properties.Javacflags
Colin Cross4f26bc02017-09-06 12:52:16 -0700411 if ctx.AConfig().Getenv("EXPERIMENTAL_USE_OPENJDK9") == "" {
412 javacFlags = config.StripJavac9Flags(javacFlags)
413 }
Colin Cross64162712017-08-08 13:17:59 -0700414
415 if j.properties.Java_version != nil {
416 flags.javaVersion = *j.properties.Java_version
417 } else {
418 flags.javaVersion = "${config.DefaultJavaVersion}"
419 }
420
Colin Cross6ade34f2017-09-15 13:00:47 -0700421 flags.bootClasspath.AddPaths(deps.bootClasspath)
422 flags.classpath.AddPaths(deps.classpath)
423
Colin Crossf03c82b2015-04-13 13:53:40 -0700424 if len(javacFlags) > 0 {
425 ctx.Variable(pctx, "javacFlags", strings.Join(javacFlags, " "))
426 flags.javacFlags = "$javacFlags"
427 }
428
Colin Cross32f676a2017-09-06 13:41:06 -0700429 aidlFlags := j.aidlFlags(ctx, deps.aidlPreprocess, deps.aidlIncludeDirs)
Colin Crossf03c82b2015-04-13 13:53:40 -0700430 if len(aidlFlags) > 0 {
431 ctx.Variable(pctx, "aidlFlags", strings.Join(aidlFlags, " "))
432 flags.aidlFlags = "$aidlFlags"
Colin Cross2fe66872015-03-30 17:20:39 -0700433 }
434
Dan Willemsen2ef08f42015-06-30 18:15:24 -0700435 srcFiles := ctx.ExpandSources(j.properties.Srcs, j.properties.Exclude_srcs)
Colin Crossc0b06f12015-04-08 13:03:43 -0700436
Colin Cross6af17aa2017-09-20 12:59:05 -0700437 if hasSrcExt(srcFiles.Strings(), ".proto") {
438 flags = protoFlags(ctx, &j.protoProperties, flags)
439 }
440
441 var srcFileLists android.Paths
442
443 srcFiles, srcFileLists = j.genSources(ctx, srcFiles, flags)
444
445 srcFileLists = append(srcFileLists, deps.srcFileLists...)
Colin Crossc0b06f12015-04-08 13:03:43 -0700446
Colin Cross0607cf72015-04-28 13:28:51 -0700447 ctx.VisitDirectDeps(func(module blueprint.Module) {
448 if gen, ok := module.(genrule.SourceFileGenerator); ok {
449 srcFiles = append(srcFiles, gen.GeneratedSourceFiles()...)
450 }
451 })
452
Colin Cross6af17aa2017-09-20 12:59:05 -0700453 srcFileLists = append(srcFileLists, j.ExtraSrcLists...)
Colin Crossb7a63242015-04-16 14:09:14 -0700454
Colin Cross0a6e0072017-08-30 14:24:55 -0700455 var jars android.Paths
456
Colin Cross8cf13342015-04-10 15:41:49 -0700457 if len(srcFiles) > 0 {
Colin Crossd6891432017-09-27 17:39:56 -0700458 var extraJarDeps android.Paths
Colin Crossc6bbef32017-08-14 14:16:06 -0700459 if ctx.AConfig().IsEnvTrue("RUN_ERROR_PRONE") {
460 // If error-prone is enabled, add an additional rule to compile the java files into
461 // a separate set of classes (so that they don't overwrite the normal ones and require
Colin Crossd6891432017-09-27 17:39:56 -0700462 // a rebuild when error-prone is turned off).
Colin Crossc6bbef32017-08-14 14:16:06 -0700463 // TODO(ccross): Once we always compile with javac9 we may be able to conditionally
464 // enable error-prone without affecting the output class files.
Colin Cross6af17aa2017-09-20 12:59:05 -0700465 errorprone := RunErrorProne(ctx, srcFiles, srcFileLists, flags)
Colin Crossc6bbef32017-08-14 14:16:06 -0700466 extraJarDeps = append(extraJarDeps, errorprone)
467 }
468
Colin Crossd6891432017-09-27 17:39:56 -0700469 // Compile java sources into .class files
Colin Cross6af17aa2017-09-20 12:59:05 -0700470 classes := TransformJavaToClasses(ctx, srcFiles, srcFileLists, flags, extraJarDeps)
Colin Crossd6891432017-09-27 17:39:56 -0700471 if ctx.Failed() {
472 return
473 }
474
Colin Cross0a6e0072017-08-30 14:24:55 -0700475 jars = append(jars, classes)
Colin Cross2fe66872015-03-30 17:20:39 -0700476 }
477
Colin Cross0f37af02017-09-27 17:42:05 -0700478 dirArgs, dirDeps := ResourceDirsToJarArgs(ctx, j.properties.Java_resource_dirs, j.properties.Exclude_java_resource_dirs)
479 fileArgs, fileDeps := ResourceFilesToJarArgs(ctx, j.properties.Java_resources, j.properties.Exclude_java_resources)
480
481 var resArgs []string
482 var resDeps android.Paths
483
484 resArgs = append(resArgs, dirArgs...)
485 resDeps = append(resDeps, dirDeps...)
486
487 resArgs = append(resArgs, fileArgs...)
488 resDeps = append(resDeps, fileDeps...)
489
490 if proptools.Bool(j.properties.Include_srcs) {
491 srcArgs, srcDeps := ResourceFilesToJarArgs(ctx, j.properties.Srcs, j.properties.Exclude_srcs)
492 resArgs = append(resArgs, srcArgs...)
493 resDeps = append(resDeps, srcDeps...)
494 }
Colin Cross40a36712017-09-27 17:41:35 -0700495
496 if len(resArgs) > 0 {
Colin Cross0a6e0072017-08-30 14:24:55 -0700497 // Combine classes + resources into classes-full-debug.jar
Colin Cross40a36712017-09-27 17:41:35 -0700498 resourceJar := TransformResourcesToJar(ctx, resArgs, resDeps)
Colin Cross65bf4f22015-04-03 16:54:17 -0700499 if ctx.Failed() {
500 return
501 }
Colin Cross20978302015-04-10 17:05:07 -0700502
Colin Cross6ade34f2017-09-15 13:00:47 -0700503 j.resourceJarFiles = append(j.resourceJarFiles, resourceJar)
Colin Cross0a6e0072017-08-30 14:24:55 -0700504 jars = append(jars, resourceJar)
Colin Cross65bf4f22015-04-03 16:54:17 -0700505 }
506
Colin Cross6ade34f2017-09-15 13:00:47 -0700507 // Propagate the resources from the transitive closure of static dependencies for copying
508 // into dex jars
509 j.resourceJarFiles = append(j.resourceJarFiles, deps.staticJarResources...)
510
511 // static classpath jars have the resources in them, so the resource jars aren't necessary here
Colin Cross32f676a2017-09-06 13:41:06 -0700512 jars = append(jars, deps.staticJars...)
Colin Cross0a6e0072017-08-30 14:24:55 -0700513
Colin Cross635acc92017-09-12 22:50:46 -0700514 manifest := android.OptionalPathForModuleSrc(ctx, j.properties.Manifest)
515
Colin Cross0a6e0072017-08-30 14:24:55 -0700516 // Combine the classes built from sources, any manifests, and any static libraries into
Colin Cross8649b262017-09-27 18:03:17 -0700517 // classes.jar. If there is only one input jar this step will be skipped.
Colin Cross635acc92017-09-12 22:50:46 -0700518 outputFile := TransformJarsToJar(ctx, "classes.jar", jars, manifest, false)
Colin Cross0a6e0072017-08-30 14:24:55 -0700519
520 if j.properties.Jarjar_rules != nil {
521 jarjar_rules := android.PathForModuleSrc(ctx, *j.properties.Jarjar_rules)
Colin Cross8649b262017-09-27 18:03:17 -0700522 // Transform classes.jar into classes-jarjar.jar
Colin Cross0a6e0072017-08-30 14:24:55 -0700523 outputFile = TransformJarJar(ctx, outputFile, jarjar_rules)
524 if ctx.Failed() {
525 return
526 }
527 }
528
Colin Cross2fe66872015-03-30 17:20:39 -0700529 j.classpathFile = outputFile
530
Colin Crossa713a6f2017-09-20 18:04:44 -0700531 // TODO(ccross): handle hostdex
Colin Cross59f1bb62017-09-27 17:59:10 -0700532 if ctx.Device() && len(srcFiles) > 0 && j.installable() {
Colin Cross540eff82017-06-22 17:01:52 -0700533 dxFlags := j.deviceProperties.Dxflags
Colin Cross2fe66872015-03-30 17:20:39 -0700534 if false /* emma enabled */ {
535 // If you instrument class files that have local variable debug information in
536 // them emma does not correctly maintain the local variable table.
537 // This will cause an error when you try to convert the class files for Android.
538 // The workaround here is to build different dex file here based on emma switch
539 // then later copy into classes.dex. When emma is on, dx is run with --no-locals
540 // option to remove local variable information
541 dxFlags = append(dxFlags, "--no-locals")
542 }
543
Colin Cross1332b002015-04-07 17:11:30 -0700544 if ctx.AConfig().Getenv("NO_OPTIMIZE_DX") != "" {
Colin Cross2fe66872015-03-30 17:20:39 -0700545 dxFlags = append(dxFlags, "--no-optimize")
546 }
547
Colin Cross1332b002015-04-07 17:11:30 -0700548 if ctx.AConfig().Getenv("GENERATE_DEX_DEBUG") != "" {
Colin Cross2fe66872015-03-30 17:20:39 -0700549 dxFlags = append(dxFlags,
550 "--debug",
551 "--verbose",
Colin Cross635c3b02016-05-18 15:37:25 -0700552 "--dump-to="+android.PathForModuleOut(ctx, "classes.lst").String(),
Colin Cross2fe66872015-03-30 17:20:39 -0700553 "--dump-width=1000")
554 }
555
Colin Cross595a4062017-08-31 12:30:37 -0700556 var minSdkVersion string
557 switch j.deviceProperties.Sdk_version {
558 case "", "current", "test_current", "system_current":
559 minSdkVersion = strconv.Itoa(ctx.AConfig().DefaultAppTargetSdkInt())
560 default:
561 minSdkVersion = j.deviceProperties.Sdk_version
562 }
563
564 dxFlags = append(dxFlags, "--min-sdk-version="+minSdkVersion)
565
Colin Cross2fe66872015-03-30 17:20:39 -0700566 flags.dxFlags = strings.Join(dxFlags, " ")
567
Colin Cross6ade34f2017-09-15 13:00:47 -0700568 desugarFlags := []string{
569 "--min_sdk_version " + minSdkVersion,
570 "--desugar_try_with_resources_if_needed=false",
571 "--allow_empty_bootclasspath",
572 }
573
574 if inList("--core-library", dxFlags) {
575 desugarFlags = append(desugarFlags, "--core_library")
576 }
577
578 flags.desugarFlags = strings.Join(desugarFlags, " ")
579
580 desugarJar := TransformDesugar(ctx, outputFile, flags)
Colin Cross2fe66872015-03-30 17:20:39 -0700581 if ctx.Failed() {
582 return
583 }
584
Colin Cross6ade34f2017-09-15 13:00:47 -0700585 // Compile classes.jar into classes.dex
586 dexJarFile := TransformClassesJarToDexJar(ctx, desugarJar, flags)
587 if ctx.Failed() {
588 return
589 }
590
591 jars := android.Paths{dexJarFile}
592 jars = append(jars, j.resourceJarFiles...)
593
594 outputFile = TransformJarsToJar(ctx, "javalib.jar", jars, android.OptionalPath{}, true)
595
596 j.dexJarFile = outputFile
Colin Cross2fe66872015-03-30 17:20:39 -0700597 }
Colin Crossb7a63242015-04-16 14:09:14 -0700598 ctx.CheckbuildFile(outputFile)
599 j.outputFile = outputFile
Colin Cross2fe66872015-03-30 17:20:39 -0700600}
601
Colin Cross59f1bb62017-09-27 17:59:10 -0700602func (j *Module) installable() bool {
603 return j.properties.Installable == nil || *j.properties.Installable
604}
605
Colin Crossf506d872017-07-19 15:53:04 -0700606var _ Dependency = (*Library)(nil)
Colin Cross2fe66872015-03-30 17:20:39 -0700607
Colin Cross74d73e22017-08-02 11:05:49 -0700608func (j *Module) ClasspathFiles() android.Paths {
609 return android.Paths{j.classpathFile}
Colin Cross2fe66872015-03-30 17:20:39 -0700610}
611
Colin Cross6ade34f2017-09-15 13:00:47 -0700612func (j *Module) ResourceJarFiles() android.Paths {
613 return j.resourceJarFiles
614}
615
Colin Cross46c9b8b2017-06-22 16:51:17 -0700616func (j *Module) AidlIncludeDirs() android.Paths {
Colin Crossc0b06f12015-04-08 13:03:43 -0700617 return j.exportAidlIncludeDirs
618}
619
Colin Cross46c9b8b2017-06-22 16:51:17 -0700620var _ logtagsProducer = (*Module)(nil)
Colin Crossf05fe972015-04-10 17:45:20 -0700621
Colin Cross46c9b8b2017-06-22 16:51:17 -0700622func (j *Module) logtags() android.Paths {
Colin Crossf05fe972015-04-10 17:45:20 -0700623 return j.logtagsSrcs
624}
625
Colin Cross2fe66872015-03-30 17:20:39 -0700626//
627// Java libraries (.jar file)
628//
629
Colin Crossf506d872017-07-19 15:53:04 -0700630type Library struct {
Colin Cross46c9b8b2017-06-22 16:51:17 -0700631 Module
Colin Cross2fe66872015-03-30 17:20:39 -0700632}
633
Colin Crossf506d872017-07-19 15:53:04 -0700634func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Colin Cross46c9b8b2017-06-22 16:51:17 -0700635 j.compile(ctx)
Colin Crossb7a63242015-04-16 14:09:14 -0700636
Colin Cross59f1bb62017-09-27 17:59:10 -0700637 if j.installable() {
Colin Cross2c429dc2017-08-31 16:45:16 -0700638 j.installFile = ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"),
639 ctx.ModuleName()+".jar", j.outputFile)
640 }
Colin Crossb7a63242015-04-16 14:09:14 -0700641}
642
Colin Crossf506d872017-07-19 15:53:04 -0700643func (j *Library) DepsMutator(ctx android.BottomUpMutatorContext) {
Colin Cross46c9b8b2017-06-22 16:51:17 -0700644 j.deps(ctx)
645}
646
Colin Crossa60ead82017-10-02 18:10:21 -0700647func LibraryFactory(installable bool) func() android.Module {
648 return func() android.Module {
649 module := &Library{}
Colin Cross2fe66872015-03-30 17:20:39 -0700650
Colin Crossa60ead82017-10-02 18:10:21 -0700651 if !installable {
652 module.properties.Installable = proptools.BoolPtr(false)
653 }
654 module.deviceProperties.Dex = true
Colin Cross2fe66872015-03-30 17:20:39 -0700655
Colin Crossa60ead82017-10-02 18:10:21 -0700656 module.AddProperties(
657 &module.Module.properties,
Colin Cross6af17aa2017-09-20 12:59:05 -0700658 &module.Module.deviceProperties,
659 &module.Module.protoProperties)
Colin Cross36242852017-06-23 15:06:31 -0700660
Colin Crossa60ead82017-10-02 18:10:21 -0700661 InitJavaModule(module, android.HostAndDeviceSupported)
662 return module
663 }
Colin Cross2fe66872015-03-30 17:20:39 -0700664}
665
Colin Crossf506d872017-07-19 15:53:04 -0700666func LibraryHostFactory() android.Module {
667 module := &Library{}
Colin Cross2fe66872015-03-30 17:20:39 -0700668
Colin Cross6af17aa2017-09-20 12:59:05 -0700669 module.AddProperties(
670 &module.Module.properties,
671 &module.Module.protoProperties)
Colin Cross36242852017-06-23 15:06:31 -0700672
Colin Cross89536d42017-07-07 14:35:50 -0700673 InitJavaModule(module, android.HostSupported)
Colin Cross36242852017-06-23 15:06:31 -0700674 return module
Colin Cross2fe66872015-03-30 17:20:39 -0700675}
676
677//
678// Java Binaries (.jar file plus wrapper script)
679//
680
Colin Crossf506d872017-07-19 15:53:04 -0700681type binaryProperties struct {
Colin Cross7d5136f2015-05-11 13:39:40 -0700682 // installable script to execute the resulting jar
683 Wrapper string
684}
685
Colin Crossf506d872017-07-19 15:53:04 -0700686type Binary struct {
687 Library
Colin Cross2fe66872015-03-30 17:20:39 -0700688
Colin Crossf506d872017-07-19 15:53:04 -0700689 binaryProperties binaryProperties
Colin Cross10a03492017-08-10 17:09:43 -0700690
691 wrapperFile android.ModuleSrcPath
692 binaryFile android.OutputPath
Colin Cross2fe66872015-03-30 17:20:39 -0700693}
694
Colin Crossf506d872017-07-19 15:53:04 -0700695func (j *Binary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
696 j.Library.GenerateAndroidBuildActions(ctx)
Colin Cross2fe66872015-03-30 17:20:39 -0700697
698 // Depend on the installed jar (j.installFile) so that the wrapper doesn't get executed by
699 // another build rule before the jar has been installed.
Colin Cross10a03492017-08-10 17:09:43 -0700700 j.wrapperFile = android.PathForModuleSrc(ctx, j.binaryProperties.Wrapper)
Colin Cross5c517922017-08-31 12:29:17 -0700701 j.binaryFile = ctx.InstallExecutable(android.PathForModuleInstall(ctx, "bin"),
702 ctx.ModuleName(), j.wrapperFile, j.installFile)
Colin Cross2fe66872015-03-30 17:20:39 -0700703}
704
Colin Crossf506d872017-07-19 15:53:04 -0700705func (j *Binary) DepsMutator(ctx android.BottomUpMutatorContext) {
Colin Cross46c9b8b2017-06-22 16:51:17 -0700706 j.deps(ctx)
707}
708
Colin Crossf506d872017-07-19 15:53:04 -0700709func BinaryFactory() android.Module {
710 module := &Binary{}
Colin Cross2fe66872015-03-30 17:20:39 -0700711
Colin Cross540eff82017-06-22 17:01:52 -0700712 module.deviceProperties.Dex = true
Colin Cross2fe66872015-03-30 17:20:39 -0700713
Colin Cross36242852017-06-23 15:06:31 -0700714 module.AddProperties(
Colin Cross540eff82017-06-22 17:01:52 -0700715 &module.Module.properties,
716 &module.Module.deviceProperties,
Colin Cross6af17aa2017-09-20 12:59:05 -0700717 &module.Module.protoProperties,
Colin Cross540eff82017-06-22 17:01:52 -0700718 &module.binaryProperties)
Colin Cross36242852017-06-23 15:06:31 -0700719
Colin Cross89536d42017-07-07 14:35:50 -0700720 InitJavaModule(module, android.HostAndDeviceSupported)
Colin Cross36242852017-06-23 15:06:31 -0700721 return module
Colin Cross2fe66872015-03-30 17:20:39 -0700722}
723
Colin Crossf506d872017-07-19 15:53:04 -0700724func BinaryHostFactory() android.Module {
725 module := &Binary{}
Colin Cross2fe66872015-03-30 17:20:39 -0700726
Colin Cross36242852017-06-23 15:06:31 -0700727 module.AddProperties(
Colin Cross540eff82017-06-22 17:01:52 -0700728 &module.Module.properties,
729 &module.Module.deviceProperties,
Colin Cross6af17aa2017-09-20 12:59:05 -0700730 &module.Module.protoProperties,
Colin Cross540eff82017-06-22 17:01:52 -0700731 &module.binaryProperties)
Colin Cross36242852017-06-23 15:06:31 -0700732
Colin Cross89536d42017-07-07 14:35:50 -0700733 InitJavaModule(module, android.HostSupported)
Colin Cross36242852017-06-23 15:06:31 -0700734 return module
Colin Cross2fe66872015-03-30 17:20:39 -0700735}
736
737//
738// Java prebuilts
739//
740
Colin Cross74d73e22017-08-02 11:05:49 -0700741type ImportProperties struct {
742 Jars []string
743}
744
745type Import struct {
Colin Cross635c3b02016-05-18 15:37:25 -0700746 android.ModuleBase
Colin Crossec7a0422017-07-07 14:47:12 -0700747 prebuilt android.Prebuilt
Colin Cross2fe66872015-03-30 17:20:39 -0700748
Colin Cross74d73e22017-08-02 11:05:49 -0700749 properties ImportProperties
750
Colin Cross0a6e0072017-08-30 14:24:55 -0700751 classpathFiles android.Paths
752 combinedClasspathFile android.Path
Colin Cross2fe66872015-03-30 17:20:39 -0700753}
754
Colin Cross74d73e22017-08-02 11:05:49 -0700755func (j *Import) Prebuilt() *android.Prebuilt {
Colin Crossec7a0422017-07-07 14:47:12 -0700756 return &j.prebuilt
757}
758
Colin Cross74d73e22017-08-02 11:05:49 -0700759func (j *Import) PrebuiltSrcs() []string {
760 return j.properties.Jars
761}
762
763func (j *Import) Name() string {
Colin Cross5ea9bcc2017-07-27 15:41:32 -0700764 return j.prebuilt.Name(j.ModuleBase.Name())
765}
766
Colin Cross74d73e22017-08-02 11:05:49 -0700767func (j *Import) DepsMutator(ctx android.BottomUpMutatorContext) {
Colin Cross1e676be2016-10-12 14:38:15 -0700768}
769
Colin Cross74d73e22017-08-02 11:05:49 -0700770func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
771 j.classpathFiles = android.PathsForModuleSrc(ctx, j.properties.Jars)
Colin Crosse1d62a82015-04-03 16:53:05 -0700772
Colin Cross635acc92017-09-12 22:50:46 -0700773 j.combinedClasspathFile = TransformJarsToJar(ctx, "classes.jar", j.classpathFiles, android.OptionalPath{}, false)
Colin Cross2fe66872015-03-30 17:20:39 -0700774}
775
Colin Cross74d73e22017-08-02 11:05:49 -0700776var _ Dependency = (*Import)(nil)
Colin Cross2fe66872015-03-30 17:20:39 -0700777
Colin Cross74d73e22017-08-02 11:05:49 -0700778func (j *Import) ClasspathFiles() android.Paths {
779 return j.classpathFiles
Colin Cross2fe66872015-03-30 17:20:39 -0700780}
781
Colin Cross6ade34f2017-09-15 13:00:47 -0700782func (j *Import) ResourceJarFiles() android.Paths {
783 // resources are in the ClasspathFiles
784 return nil
785}
786
Colin Cross74d73e22017-08-02 11:05:49 -0700787func (j *Import) AidlIncludeDirs() android.Paths {
Colin Crossc0b06f12015-04-08 13:03:43 -0700788 return nil
789}
790
Colin Cross74d73e22017-08-02 11:05:49 -0700791var _ android.PrebuiltInterface = (*Import)(nil)
Colin Cross2fe66872015-03-30 17:20:39 -0700792
Colin Cross74d73e22017-08-02 11:05:49 -0700793func ImportFactory() android.Module {
794 module := &Import{}
Colin Cross36242852017-06-23 15:06:31 -0700795
Colin Cross74d73e22017-08-02 11:05:49 -0700796 module.AddProperties(&module.properties)
797
798 android.InitPrebuiltModule(module, &module.properties.Jars)
Colin Cross36242852017-06-23 15:06:31 -0700799 android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon)
800 return module
Colin Cross2fe66872015-03-30 17:20:39 -0700801}
802
Colin Cross74d73e22017-08-02 11:05:49 -0700803func ImportFactoryHost() android.Module {
804 module := &Import{}
805
806 module.AddProperties(&module.properties)
807
808 android.InitPrebuiltModule(module, &module.properties.Jars)
809 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
810 return module
811}
812
Colin Cross2fe66872015-03-30 17:20:39 -0700813func inList(s string, l []string) bool {
814 for _, e := range l {
815 if e == s {
816 return true
817 }
818 }
819 return false
820}
Colin Cross89536d42017-07-07 14:35:50 -0700821
822//
823// Defaults
824//
825type Defaults struct {
826 android.ModuleBase
827 android.DefaultsModuleBase
828}
829
830func (*Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
831}
832
833func (d *Defaults) DepsMutator(ctx android.BottomUpMutatorContext) {
834}
835
836func defaultsFactory() android.Module {
837 return DefaultsFactory()
838}
839
840func DefaultsFactory(props ...interface{}) android.Module {
841 module := &Defaults{}
842
843 module.AddProperties(props...)
844 module.AddProperties(
845 &CompilerProperties{},
846 &CompilerDeviceProperties{},
847 )
848
849 android.InitDefaultsModule(module)
850
851 return module
852}