blob: 292e258fda9b6c658877bde6faad7241824d6638 [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
18// into the flags and filenames necessary to pass to the compiler. The final creation of the rules
19// is handled in builder.go
20
21import (
22 "fmt"
23 "path/filepath"
24 "strings"
25
26 "github.com/google/blueprint"
Colin Crossc0b06f12015-04-08 13:03:43 -070027 "github.com/google/blueprint/pathtools"
Colin Cross2fe66872015-03-30 17:20:39 -070028
29 "android/soong/common"
30)
31
Colin Cross2fe66872015-03-30 17:20:39 -070032// TODO:
33// Autogenerated files:
Colin Cross2fe66872015-03-30 17:20:39 -070034// Proto
35// Renderscript
36// Post-jar passes:
37// Proguard
38// Emma
39// Jarjar
40// Dex
41// Rmtypedefs
42// Jack
43// DroidDoc
44// Findbugs
45
46// javaBase contains the properties and members used by all java module types, and implements
47// the blueprint.Module interface.
48type javaBase struct {
49 common.AndroidModuleBase
50 module JavaModuleType
51
52 properties struct {
53 // srcs: list of source files used to compile the Java module. May be .java, .logtags, .proto,
54 // or .aidl files.
55 Srcs []string `android:"arch_variant,arch_subtract"`
56
Colin Cross276284f2015-04-20 13:51:48 -070057 // java_resource_dirs: list of directories containing Java resources
58 Java_resource_dirs []string `android:"arch_variant"`
Colin Cross2fe66872015-03-30 17:20:39 -070059
60 // no_standard_libraries: don't build against the default libraries (core-libart, core-junit,
61 // ext, and framework for device targets)
62 No_standard_libraries bool
63
64 // javacflags: list of module-specific flags that will be used for javac compiles
65 Javacflags []string `android:"arch_variant"`
66
67 // dxflags: list of module-specific flags that will be used for dex compiles
68 Dxflags []string `android:"arch_variant"`
69
70 // java_libs: list of of java libraries that will be in the classpath
71 Java_libs []string `android:"arch_variant"`
72
73 // java_static_libs: list of java libraries that will be compiled into the resulting jar
74 Java_static_libs []string `android:"arch_variant"`
75
76 // manifest: manifest file to be included in resulting jar
77 Manifest string
78
79 // sdk_version: if not blank, set to the version of the sdk to compile against
80 Sdk_version string
81
82 // Set for device java libraries, and for host versions of device java libraries
83 // built for testing
84 Dex bool `blueprint:"mutated"`
Colin Cross65bf4f22015-04-03 16:54:17 -070085
86 // jarjar_rules: if not blank, run jarjar using the specified rules file
87 Jarjar_rules string
Colin Crossc0b06f12015-04-08 13:03:43 -070088
89 // aidl_includes: directories to pass to aidl tool
90 Aidl_includes []string
91
92 // aidl_export_include_dirs: directories that should be added as include directories
93 // for any aidl sources of modules that depend on this module
94 Export_aidl_include_dirs []string
Colin Cross2fe66872015-03-30 17:20:39 -070095 }
96
97 // output file suitable for inserting into the classpath of another compile
98 classpathFile string
99
Colin Crossb7a63242015-04-16 14:09:14 -0700100 // output file suitable for installing or running
101 outputFile string
102
Colin Cross2fe66872015-03-30 17:20:39 -0700103 // jarSpecs suitable for inserting classes from a static library into another jar
104 classJarSpecs []jarSpec
105
106 // jarSpecs suitable for inserting resources from a static library into another jar
107 resourceJarSpecs []jarSpec
108
Colin Crossc0b06f12015-04-08 13:03:43 -0700109 exportAidlIncludeDirs []string
110
Colin Crossf05fe972015-04-10 17:45:20 -0700111 logtagsSrcs []string
112
Colin Crossb7a63242015-04-16 14:09:14 -0700113 // filelists of extra source files that should be included in the javac command line,
114 // for example R.java generated by aapt for android apps
115 ExtraSrcLists []string
116
Colin Cross2fe66872015-03-30 17:20:39 -0700117 // installed file for binary dependency
118 installFile string
119}
120
121type JavaModuleType interface {
122 GenerateJavaBuildActions(ctx common.AndroidModuleContext)
Colin Crossb7a63242015-04-16 14:09:14 -0700123 JavaDynamicDependencies(ctx common.AndroidDynamicDependerModuleContext) []string
Colin Cross2fe66872015-03-30 17:20:39 -0700124}
125
126type JavaDependency interface {
127 ClasspathFile() string
128 ClassJarSpecs() []jarSpec
129 ResourceJarSpecs() []jarSpec
Colin Crossc0b06f12015-04-08 13:03:43 -0700130 AidlIncludeDirs() []string
Colin Cross2fe66872015-03-30 17:20:39 -0700131}
132
133func NewJavaBase(base *javaBase, module JavaModuleType, hod common.HostOrDeviceSupported,
134 props ...interface{}) (blueprint.Module, []interface{}) {
135
136 base.module = module
137
138 props = append(props, &base.properties)
139
140 return common.InitAndroidArchModule(base, hod, common.MultilibCommon, props...)
141}
142
143func (j *javaBase) BootClasspath(ctx common.AndroidBaseContext) string {
144 if ctx.Device() {
145 if j.properties.Sdk_version == "" {
146 return "core-libart"
147 } else if j.properties.Sdk_version == "current" {
148 // TODO: !TARGET_BUILD_APPS
Colin Crossc0b06f12015-04-08 13:03:43 -0700149 // TODO: export preprocessed framework.aidl from android_stubs_current
Colin Cross2fe66872015-03-30 17:20:39 -0700150 return "android_stubs_current"
151 } else if j.properties.Sdk_version == "system_current" {
152 return "android_system_stubs_current"
153 } else {
154 return "sdk_v" + j.properties.Sdk_version
155 }
156 } else {
157 if j.properties.Dex {
158 return "core-libart"
159 } else {
160 return ""
161 }
162 }
163}
164
Colin Crossefb9ebe2015-04-16 14:08:06 -0700165var defaultJavaLibraries = []string{"core-libart", "core-junit", "ext", "framework"}
166
Colin Cross2fe66872015-03-30 17:20:39 -0700167func (j *javaBase) AndroidDynamicDependencies(ctx common.AndroidDynamicDependerModuleContext) []string {
Colin Crossb7a63242015-04-16 14:09:14 -0700168 return j.module.JavaDynamicDependencies(ctx)
169}
170
171func (j *javaBase) JavaDynamicDependencies(ctx common.AndroidDynamicDependerModuleContext) []string {
Colin Cross2fe66872015-03-30 17:20:39 -0700172 var deps []string
173
174 if !j.properties.No_standard_libraries {
175 bootClasspath := j.BootClasspath(ctx)
176 if bootClasspath != "" {
177 deps = append(deps, bootClasspath)
178 }
Colin Crossefb9ebe2015-04-16 14:08:06 -0700179 if ctx.Device() && j.properties.Sdk_version == "" {
180 deps = append(deps, defaultJavaLibraries...)
181 }
Colin Cross2fe66872015-03-30 17:20:39 -0700182 }
183 deps = append(deps, j.properties.Java_libs...)
184 deps = append(deps, j.properties.Java_static_libs...)
185
186 return deps
187}
188
Colin Crossc0b06f12015-04-08 13:03:43 -0700189func (j *javaBase) aidlFlags(ctx common.AndroidModuleContext, aidlPreprocess string,
Colin Crossf03c82b2015-04-13 13:53:40 -0700190 aidlIncludeDirs []string) []string {
Colin Crossc0b06f12015-04-08 13:03:43 -0700191
192 localAidlIncludes := pathtools.PrefixPaths(j.properties.Aidl_includes, common.ModuleSrcDir(ctx))
193
194 var flags []string
195 if aidlPreprocess != "" {
196 flags = append(flags, "-p"+aidlPreprocess)
197 } else {
198 flags = append(flags, common.JoinWithPrefix(aidlIncludeDirs, "-I"))
199 }
200
201 flags = append(flags, common.JoinWithPrefix(j.exportAidlIncludeDirs, "-I"))
202 flags = append(flags, common.JoinWithPrefix(localAidlIncludes, "-I"))
203 flags = append(flags, "-I"+common.ModuleSrcDir(ctx))
204 flags = append(flags, "-I"+filepath.Join(common.ModuleSrcDir(ctx), "src"))
205
Colin Crossf03c82b2015-04-13 13:53:40 -0700206 return flags
Colin Crossc0b06f12015-04-08 13:03:43 -0700207}
208
Colin Cross2fe66872015-03-30 17:20:39 -0700209func (j *javaBase) collectDeps(ctx common.AndroidModuleContext) (classpath []string,
Colin Crossc0b06f12015-04-08 13:03:43 -0700210 bootClasspath string, classJarSpecs, resourceJarSpecs []jarSpec, aidlPreprocess string,
Colin Crosse7a9f3f2015-04-13 14:02:52 -0700211 aidlIncludeDirs []string, srcFileLists []string) {
Colin Cross2fe66872015-03-30 17:20:39 -0700212
213 ctx.VisitDirectDeps(func(module blueprint.Module) {
214 otherName := ctx.OtherModuleName(module)
215 if javaDep, ok := module.(JavaDependency); ok {
Colin Cross6cbb1272015-04-08 11:23:01 -0700216 if otherName == j.BootClasspath(ctx) {
217 bootClasspath = javaDep.ClasspathFile()
Colin Crossb7a63242015-04-16 14:09:14 -0700218 } else if inList(otherName, defaultJavaLibraries) {
219 classpath = append(classpath, javaDep.ClasspathFile())
Colin Cross6cbb1272015-04-08 11:23:01 -0700220 } else if inList(otherName, j.properties.Java_libs) {
Colin Cross2fe66872015-03-30 17:20:39 -0700221 classpath = append(classpath, javaDep.ClasspathFile())
222 } else if inList(otherName, j.properties.Java_static_libs) {
223 classpath = append(classpath, javaDep.ClasspathFile())
224 classJarSpecs = append(classJarSpecs, javaDep.ClassJarSpecs()...)
225 resourceJarSpecs = append(resourceJarSpecs, javaDep.ResourceJarSpecs()...)
Colin Crossb7a63242015-04-16 14:09:14 -0700226 } else if otherName == "framework-res" {
227 if ctx.ModuleName() == "framework" {
228 // framework.jar has a one-off dependency on the R.java and Manifest.java files
229 // generated by framework-res.apk
230 srcFileLists = append(srcFileLists, module.(*javaBase).module.(*AndroidApp).aaptJavaFileList)
231 }
Colin Cross2fe66872015-03-30 17:20:39 -0700232 } else {
233 panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName()))
234 }
Colin Crossaa8630b2015-04-13 13:52:22 -0700235 aidlIncludeDirs = append(aidlIncludeDirs, javaDep.AidlIncludeDirs()...)
236 if sdkDep, ok := module.(sdkDependency); ok {
237 if sdkDep.AidlPreprocessed() != "" {
238 if aidlPreprocess != "" {
239 ctx.ModuleErrorf("multiple dependencies with preprocessed aidls:\n %q\n %q",
240 aidlPreprocess, sdkDep.AidlPreprocessed())
241 } else {
242 aidlPreprocess = sdkDep.AidlPreprocessed()
243 }
Colin Crossc0b06f12015-04-08 13:03:43 -0700244 }
245 }
Colin Cross2fe66872015-03-30 17:20:39 -0700246 } else {
247 ctx.ModuleErrorf("unknown dependency module type for %q", otherName)
248 }
249 })
250
Colin Crosse7a9f3f2015-04-13 14:02:52 -0700251 return classpath, bootClasspath, classJarSpecs, resourceJarSpecs, aidlPreprocess,
252 aidlIncludeDirs, srcFileLists
Colin Cross2fe66872015-03-30 17:20:39 -0700253}
254
255func (j *javaBase) GenerateAndroidBuildActions(ctx common.AndroidModuleContext) {
256 j.module.GenerateJavaBuildActions(ctx)
257}
258
259func (j *javaBase) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
Colin Crossc0b06f12015-04-08 13:03:43 -0700260
261 j.exportAidlIncludeDirs = pathtools.PrefixPaths(j.properties.Export_aidl_include_dirs,
262 common.ModuleSrcDir(ctx))
263
264 classpath, bootClasspath, classJarSpecs, resourceJarSpecs, aidlPreprocess,
Colin Crosse7a9f3f2015-04-13 14:02:52 -0700265 aidlIncludeDirs, srcFileLists := j.collectDeps(ctx)
Colin Crossc0b06f12015-04-08 13:03:43 -0700266
Colin Crossf03c82b2015-04-13 13:53:40 -0700267 var flags javaBuilderFlags
268
269 javacFlags := j.properties.Javacflags
270 if len(javacFlags) > 0 {
271 ctx.Variable(pctx, "javacFlags", strings.Join(javacFlags, " "))
272 flags.javacFlags = "$javacFlags"
273 }
274
275 aidlFlags := j.aidlFlags(ctx, aidlPreprocess, aidlIncludeDirs)
276 if len(aidlFlags) > 0 {
277 ctx.Variable(pctx, "aidlFlags", strings.Join(aidlFlags, " "))
278 flags.aidlFlags = "$aidlFlags"
Colin Cross2fe66872015-03-30 17:20:39 -0700279 }
280
281 var javacDeps []string
282
Colin Cross2fe66872015-03-30 17:20:39 -0700283 if bootClasspath != "" {
284 flags.bootClasspath = "-bootclasspath " + bootClasspath
285 javacDeps = append(javacDeps, bootClasspath)
286 }
287
288 if len(classpath) > 0 {
289 flags.classpath = "-classpath " + strings.Join(classpath, ":")
290 javacDeps = append(javacDeps, classpath...)
291 }
292
Colin Crossc0b06f12015-04-08 13:03:43 -0700293 srcFiles := common.ExpandSources(ctx, j.properties.Srcs)
294
Colin Crossf05fe972015-04-10 17:45:20 -0700295 srcFiles = j.genSources(ctx, srcFiles, flags)
Colin Crossc0b06f12015-04-08 13:03:43 -0700296
Colin Crossb7a63242015-04-16 14:09:14 -0700297 srcFileLists = append(srcFileLists, j.ExtraSrcLists...)
298
Colin Cross8cf13342015-04-10 15:41:49 -0700299 if len(srcFiles) > 0 {
300 // Compile java sources into .class files
Colin Crosse7a9f3f2015-04-13 14:02:52 -0700301 classes := TransformJavaToClasses(ctx, srcFiles, srcFileLists, flags, javacDeps)
Colin Cross8cf13342015-04-10 15:41:49 -0700302 if ctx.Failed() {
303 return
304 }
305
306 classJarSpecs = append([]jarSpec{classes}, classJarSpecs...)
Colin Cross2fe66872015-03-30 17:20:39 -0700307 }
308
Colin Cross276284f2015-04-20 13:51:48 -0700309 resourceJarSpecs = append(ResourceDirsToJarSpecs(ctx, j.properties.Java_resource_dirs),
310 resourceJarSpecs...)
Colin Cross2fe66872015-03-30 17:20:39 -0700311
312 manifest := j.properties.Manifest
313 if manifest != "" {
314 manifest = filepath.Join(common.ModuleSrcDir(ctx), manifest)
315 }
316
317 allJarSpecs := append([]jarSpec(nil), classJarSpecs...)
318 allJarSpecs = append(allJarSpecs, resourceJarSpecs...)
319
320 // Combine classes + resources into classes-full-debug.jar
321 outputFile := TransformClassesToJar(ctx, allJarSpecs, manifest)
322 if ctx.Failed() {
323 return
324 }
Colin Cross65bf4f22015-04-03 16:54:17 -0700325
Colin Cross65bf4f22015-04-03 16:54:17 -0700326 if j.properties.Jarjar_rules != "" {
327 jarjar_rules := filepath.Join(common.ModuleSrcDir(ctx), j.properties.Jarjar_rules)
328 // Transform classes-full-debug.jar into classes-jarjar.jar
329 outputFile = TransformJarJar(ctx, outputFile, jarjar_rules)
330 if ctx.Failed() {
331 return
332 }
Colin Cross20978302015-04-10 17:05:07 -0700333
334 classes, _ := TransformPrebuiltJarToClasses(ctx, outputFile)
335 classJarSpecs = []jarSpec{classes}
Colin Cross65bf4f22015-04-03 16:54:17 -0700336 }
337
Colin Cross20978302015-04-10 17:05:07 -0700338 j.resourceJarSpecs = resourceJarSpecs
339 j.classJarSpecs = classJarSpecs
Colin Cross2fe66872015-03-30 17:20:39 -0700340 j.classpathFile = outputFile
341
Colin Cross8cf13342015-04-10 15:41:49 -0700342 if j.properties.Dex && len(srcFiles) > 0 {
Colin Cross2fe66872015-03-30 17:20:39 -0700343 dxFlags := j.properties.Dxflags
344 if false /* emma enabled */ {
345 // If you instrument class files that have local variable debug information in
346 // them emma does not correctly maintain the local variable table.
347 // This will cause an error when you try to convert the class files for Android.
348 // The workaround here is to build different dex file here based on emma switch
349 // then later copy into classes.dex. When emma is on, dx is run with --no-locals
350 // option to remove local variable information
351 dxFlags = append(dxFlags, "--no-locals")
352 }
353
Colin Cross1332b002015-04-07 17:11:30 -0700354 if ctx.AConfig().Getenv("NO_OPTIMIZE_DX") != "" {
Colin Cross2fe66872015-03-30 17:20:39 -0700355 dxFlags = append(dxFlags, "--no-optimize")
356 }
357
Colin Cross1332b002015-04-07 17:11:30 -0700358 if ctx.AConfig().Getenv("GENERATE_DEX_DEBUG") != "" {
Colin Cross2fe66872015-03-30 17:20:39 -0700359 dxFlags = append(dxFlags,
360 "--debug",
361 "--verbose",
362 "--dump-to="+filepath.Join(common.ModuleOutDir(ctx), "classes.lst"),
363 "--dump-width=1000")
364 }
365
366 flags.dxFlags = strings.Join(dxFlags, " ")
367
368 // Compile classes.jar into classes.dex
Colin Cross6d1e72d2015-04-10 17:44:24 -0700369 dexJarSpec := TransformClassesJarToDex(ctx, outputFile, flags)
Colin Cross2fe66872015-03-30 17:20:39 -0700370 if ctx.Failed() {
371 return
372 }
373
374 // Combine classes.dex + resources into javalib.jar
Colin Cross6d1e72d2015-04-10 17:44:24 -0700375 outputFile = TransformDexToJavaLib(ctx, resourceJarSpecs, dexJarSpec)
Colin Cross2fe66872015-03-30 17:20:39 -0700376 }
Colin Crossb7a63242015-04-16 14:09:14 -0700377 ctx.CheckbuildFile(outputFile)
378 j.outputFile = outputFile
Colin Cross2fe66872015-03-30 17:20:39 -0700379}
380
381var _ JavaDependency = (*JavaLibrary)(nil)
382
383func (j *javaBase) ClasspathFile() string {
384 return j.classpathFile
385}
386
387func (j *javaBase) ClassJarSpecs() []jarSpec {
388 return j.classJarSpecs
389}
390
391func (j *javaBase) ResourceJarSpecs() []jarSpec {
392 return j.resourceJarSpecs
393}
394
Colin Crossc0b06f12015-04-08 13:03:43 -0700395func (j *javaBase) AidlIncludeDirs() []string {
396 return j.exportAidlIncludeDirs
397}
398
Colin Crossf05fe972015-04-10 17:45:20 -0700399var _ logtagsProducer = (*javaBase)(nil)
400
401func (j *javaBase) logtags() []string {
402 return j.logtagsSrcs
403}
404
Colin Cross2fe66872015-03-30 17:20:39 -0700405//
406// Java libraries (.jar file)
407//
408
409type JavaLibrary struct {
410 javaBase
411}
412
Colin Crossb7a63242015-04-16 14:09:14 -0700413func (j *JavaLibrary) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
414 j.javaBase.GenerateJavaBuildActions(ctx)
415
416 j.installFile = ctx.InstallFileName("framework", ctx.ModuleName()+".jar", j.outputFile)
417}
418
Colin Cross2fe66872015-03-30 17:20:39 -0700419func JavaLibraryFactory() (blueprint.Module, []interface{}) {
420 module := &JavaLibrary{}
421
422 module.properties.Dex = true
423
424 return NewJavaBase(&module.javaBase, module, common.HostAndDeviceSupported)
425}
426
427func JavaLibraryHostFactory() (blueprint.Module, []interface{}) {
428 module := &JavaLibrary{}
429
430 return NewJavaBase(&module.javaBase, module, common.HostSupported)
431}
432
433//
434// Java Binaries (.jar file plus wrapper script)
435//
436
437type JavaBinary struct {
438 JavaLibrary
439
440 binaryProperties struct {
441 // wrapper: installable script to execute the resulting jar
442 Wrapper string
443 }
444}
445
446func (j *JavaBinary) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
447 j.JavaLibrary.GenerateJavaBuildActions(ctx)
448
449 // Depend on the installed jar (j.installFile) so that the wrapper doesn't get executed by
450 // another build rule before the jar has been installed.
451 ctx.InstallFile("bin", filepath.Join(common.ModuleSrcDir(ctx), j.binaryProperties.Wrapper),
452 j.installFile)
453}
454
455func JavaBinaryFactory() (blueprint.Module, []interface{}) {
456 module := &JavaBinary{}
457
458 module.properties.Dex = true
459
460 return NewJavaBase(&module.javaBase, module, common.HostAndDeviceSupported, &module.binaryProperties)
461}
462
463func JavaBinaryHostFactory() (blueprint.Module, []interface{}) {
464 module := &JavaBinary{}
465
466 return NewJavaBase(&module.javaBase, module, common.HostSupported, &module.binaryProperties)
467}
468
469//
470// Java prebuilts
471//
472
473type JavaPrebuilt struct {
474 common.AndroidModuleBase
475
476 properties struct {
Colin Crossaa8630b2015-04-13 13:52:22 -0700477 Srcs []string
Colin Cross2fe66872015-03-30 17:20:39 -0700478 }
479
Colin Crosse1d62a82015-04-03 16:53:05 -0700480 classpathFile string
481 classJarSpecs, resourceJarSpecs []jarSpec
Colin Cross2fe66872015-03-30 17:20:39 -0700482}
483
484func (j *JavaPrebuilt) GenerateAndroidBuildActions(ctx common.AndroidModuleContext) {
485 if len(j.properties.Srcs) != 1 {
486 ctx.ModuleErrorf("expected exactly one jar in srcs")
487 return
488 }
Colin Crosse1d62a82015-04-03 16:53:05 -0700489 prebuilt := filepath.Join(common.ModuleSrcDir(ctx), j.properties.Srcs[0])
490
491 classJarSpec, resourceJarSpec := TransformPrebuiltJarToClasses(ctx, prebuilt)
492
493 j.classpathFile = prebuilt
494 j.classJarSpecs = []jarSpec{classJarSpec}
495 j.resourceJarSpecs = []jarSpec{resourceJarSpec}
Colin Crosse1d62a82015-04-03 16:53:05 -0700496 ctx.InstallFileName("framework", ctx.ModuleName()+".jar", j.classpathFile)
Colin Cross2fe66872015-03-30 17:20:39 -0700497}
498
499var _ JavaDependency = (*JavaPrebuilt)(nil)
500
501func (j *JavaPrebuilt) ClasspathFile() string {
502 return j.classpathFile
503}
504
505func (j *JavaPrebuilt) ClassJarSpecs() []jarSpec {
Colin Crosse1d62a82015-04-03 16:53:05 -0700506 return j.classJarSpecs
Colin Cross2fe66872015-03-30 17:20:39 -0700507}
508
509func (j *JavaPrebuilt) ResourceJarSpecs() []jarSpec {
Colin Crosse1d62a82015-04-03 16:53:05 -0700510 return j.resourceJarSpecs
Colin Cross2fe66872015-03-30 17:20:39 -0700511}
512
Colin Crossc0b06f12015-04-08 13:03:43 -0700513func (j *JavaPrebuilt) AidlIncludeDirs() []string {
514 return nil
515}
516
Colin Cross2fe66872015-03-30 17:20:39 -0700517func JavaPrebuiltFactory() (blueprint.Module, []interface{}) {
518 module := &JavaPrebuilt{}
519
520 return common.InitAndroidArchModule(module, common.HostAndDeviceSupported,
521 common.MultilibCommon, &module.properties)
522}
523
Colin Crossaa8630b2015-04-13 13:52:22 -0700524//
525// SDK java prebuilts (.jar containing resources plus framework.aidl)
526//
527
528type sdkDependency interface {
529 JavaDependency
530 AidlPreprocessed() string
531}
532
533var _ sdkDependency = (*sdkPrebuilt)(nil)
534
535type sdkPrebuilt struct {
536 JavaPrebuilt
537
538 sdkProperties struct {
539 Aidl_preprocessed string
540 }
541
542 aidlPreprocessed string
543}
544
545func (j *sdkPrebuilt) GenerateAndroidBuildActions(ctx common.AndroidModuleContext) {
546 j.JavaPrebuilt.GenerateAndroidBuildActions(ctx)
547
548 if j.sdkProperties.Aidl_preprocessed != "" {
549 j.aidlPreprocessed = filepath.Join(common.ModuleSrcDir(ctx), j.sdkProperties.Aidl_preprocessed)
550 }
551}
552
553func (j *sdkPrebuilt) AidlPreprocessed() string {
554 return j.aidlPreprocessed
555}
556
557func SdkPrebuiltFactory() (blueprint.Module, []interface{}) {
558 module := &sdkPrebuilt{}
559
560 return common.InitAndroidArchModule(module, common.HostAndDeviceSupported,
561 common.MultilibCommon, &module.properties, &module.sdkProperties)
562}
563
Colin Cross2fe66872015-03-30 17:20:39 -0700564func inList(s string, l []string) bool {
565 for _, e := range l {
566 if e == s {
567 return true
568 }
569 }
570 return false
571}