blob: d9aad3c9cc36b374c4e851724e0cd35a848ca642 [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"
Colin Cross0607cf72015-04-28 13:28:51 -070030 "android/soong/genrule"
Colin Cross2fe66872015-03-30 17:20:39 -070031)
32
Colin Cross2fe66872015-03-30 17:20:39 -070033// TODO:
34// Autogenerated files:
Colin Cross2fe66872015-03-30 17:20:39 -070035// Proto
36// Renderscript
37// Post-jar passes:
38// Proguard
39// Emma
40// Jarjar
41// Dex
42// Rmtypedefs
43// Jack
44// DroidDoc
45// Findbugs
46
47// javaBase contains the properties and members used by all java module types, and implements
48// the blueprint.Module interface.
49type javaBase struct {
50 common.AndroidModuleBase
51 module JavaModuleType
52
53 properties struct {
54 // srcs: list of source files used to compile the Java module. May be .java, .logtags, .proto,
55 // or .aidl files.
56 Srcs []string `android:"arch_variant,arch_subtract"`
57
Colin Cross276284f2015-04-20 13:51:48 -070058 // java_resource_dirs: list of directories containing Java resources
59 Java_resource_dirs []string `android:"arch_variant"`
Colin Cross2fe66872015-03-30 17:20:39 -070060
61 // no_standard_libraries: don't build against the default libraries (core-libart, core-junit,
62 // ext, and framework for device targets)
63 No_standard_libraries bool
64
65 // javacflags: list of module-specific flags that will be used for javac compiles
66 Javacflags []string `android:"arch_variant"`
67
68 // dxflags: list of module-specific flags that will be used for dex compiles
69 Dxflags []string `android:"arch_variant"`
70
71 // java_libs: list of of java libraries that will be in the classpath
72 Java_libs []string `android:"arch_variant"`
73
74 // java_static_libs: list of java libraries that will be compiled into the resulting jar
75 Java_static_libs []string `android:"arch_variant"`
76
77 // manifest: manifest file to be included in resulting jar
78 Manifest string
79
80 // sdk_version: if not blank, set to the version of the sdk to compile against
81 Sdk_version string
82
83 // Set for device java libraries, and for host versions of device java libraries
84 // built for testing
85 Dex bool `blueprint:"mutated"`
Colin Cross65bf4f22015-04-03 16:54:17 -070086
87 // jarjar_rules: if not blank, run jarjar using the specified rules file
88 Jarjar_rules string
Colin Crossc0b06f12015-04-08 13:03:43 -070089
90 // aidl_includes: directories to pass to aidl tool
91 Aidl_includes []string
92
93 // aidl_export_include_dirs: directories that should be added as include directories
94 // for any aidl sources of modules that depend on this module
95 Export_aidl_include_dirs []string
Colin Cross2fe66872015-03-30 17:20:39 -070096 }
97
98 // output file suitable for inserting into the classpath of another compile
99 classpathFile string
100
Colin Crossb7a63242015-04-16 14:09:14 -0700101 // output file suitable for installing or running
102 outputFile string
103
Colin Cross2fe66872015-03-30 17:20:39 -0700104 // jarSpecs suitable for inserting classes from a static library into another jar
105 classJarSpecs []jarSpec
106
107 // jarSpecs suitable for inserting resources from a static library into another jar
108 resourceJarSpecs []jarSpec
109
Colin Crossc0b06f12015-04-08 13:03:43 -0700110 exportAidlIncludeDirs []string
111
Colin Crossf05fe972015-04-10 17:45:20 -0700112 logtagsSrcs []string
113
Colin Crossb7a63242015-04-16 14:09:14 -0700114 // filelists of extra source files that should be included in the javac command line,
115 // for example R.java generated by aapt for android apps
116 ExtraSrcLists []string
117
Colin Cross2fe66872015-03-30 17:20:39 -0700118 // installed file for binary dependency
119 installFile string
120}
121
122type JavaModuleType interface {
123 GenerateJavaBuildActions(ctx common.AndroidModuleContext)
Colin Crossb7a63242015-04-16 14:09:14 -0700124 JavaDynamicDependencies(ctx common.AndroidDynamicDependerModuleContext) []string
Colin Cross2fe66872015-03-30 17:20:39 -0700125}
126
127type JavaDependency interface {
128 ClasspathFile() string
129 ClassJarSpecs() []jarSpec
130 ResourceJarSpecs() []jarSpec
Colin Crossc0b06f12015-04-08 13:03:43 -0700131 AidlIncludeDirs() []string
Colin Cross2fe66872015-03-30 17:20:39 -0700132}
133
134func NewJavaBase(base *javaBase, module JavaModuleType, hod common.HostOrDeviceSupported,
135 props ...interface{}) (blueprint.Module, []interface{}) {
136
137 base.module = module
138
139 props = append(props, &base.properties)
140
141 return common.InitAndroidArchModule(base, hod, common.MultilibCommon, props...)
142}
143
144func (j *javaBase) BootClasspath(ctx common.AndroidBaseContext) string {
145 if ctx.Device() {
146 if j.properties.Sdk_version == "" {
147 return "core-libart"
148 } else if j.properties.Sdk_version == "current" {
149 // TODO: !TARGET_BUILD_APPS
Colin Crossc0b06f12015-04-08 13:03:43 -0700150 // TODO: export preprocessed framework.aidl from android_stubs_current
Colin Cross2fe66872015-03-30 17:20:39 -0700151 return "android_stubs_current"
152 } else if j.properties.Sdk_version == "system_current" {
153 return "android_system_stubs_current"
154 } else {
155 return "sdk_v" + j.properties.Sdk_version
156 }
157 } else {
158 if j.properties.Dex {
159 return "core-libart"
160 } else {
161 return ""
162 }
163 }
164}
165
Colin Crossefb9ebe2015-04-16 14:08:06 -0700166var defaultJavaLibraries = []string{"core-libart", "core-junit", "ext", "framework"}
167
Colin Cross2fe66872015-03-30 17:20:39 -0700168func (j *javaBase) AndroidDynamicDependencies(ctx common.AndroidDynamicDependerModuleContext) []string {
Colin Crossb7a63242015-04-16 14:09:14 -0700169 return j.module.JavaDynamicDependencies(ctx)
170}
171
172func (j *javaBase) JavaDynamicDependencies(ctx common.AndroidDynamicDependerModuleContext) []string {
Colin Cross2fe66872015-03-30 17:20:39 -0700173 var deps []string
174
175 if !j.properties.No_standard_libraries {
176 bootClasspath := j.BootClasspath(ctx)
177 if bootClasspath != "" {
178 deps = append(deps, bootClasspath)
179 }
Colin Crossefb9ebe2015-04-16 14:08:06 -0700180 if ctx.Device() && j.properties.Sdk_version == "" {
181 deps = append(deps, defaultJavaLibraries...)
182 }
Colin Cross2fe66872015-03-30 17:20:39 -0700183 }
184 deps = append(deps, j.properties.Java_libs...)
185 deps = append(deps, j.properties.Java_static_libs...)
186
187 return deps
188}
189
Colin Crossc0b06f12015-04-08 13:03:43 -0700190func (j *javaBase) aidlFlags(ctx common.AndroidModuleContext, aidlPreprocess string,
Colin Crossf03c82b2015-04-13 13:53:40 -0700191 aidlIncludeDirs []string) []string {
Colin Crossc0b06f12015-04-08 13:03:43 -0700192
193 localAidlIncludes := pathtools.PrefixPaths(j.properties.Aidl_includes, common.ModuleSrcDir(ctx))
194
195 var flags []string
196 if aidlPreprocess != "" {
197 flags = append(flags, "-p"+aidlPreprocess)
198 } else {
199 flags = append(flags, common.JoinWithPrefix(aidlIncludeDirs, "-I"))
200 }
201
202 flags = append(flags, common.JoinWithPrefix(j.exportAidlIncludeDirs, "-I"))
203 flags = append(flags, common.JoinWithPrefix(localAidlIncludes, "-I"))
204 flags = append(flags, "-I"+common.ModuleSrcDir(ctx))
205 flags = append(flags, "-I"+filepath.Join(common.ModuleSrcDir(ctx), "src"))
206
Colin Crossf03c82b2015-04-13 13:53:40 -0700207 return flags
Colin Crossc0b06f12015-04-08 13:03:43 -0700208}
209
Colin Cross2fe66872015-03-30 17:20:39 -0700210func (j *javaBase) collectDeps(ctx common.AndroidModuleContext) (classpath []string,
Colin Crossc0b06f12015-04-08 13:03:43 -0700211 bootClasspath string, classJarSpecs, resourceJarSpecs []jarSpec, aidlPreprocess string,
Colin Crosse7a9f3f2015-04-13 14:02:52 -0700212 aidlIncludeDirs []string, srcFileLists []string) {
Colin Cross2fe66872015-03-30 17:20:39 -0700213
214 ctx.VisitDirectDeps(func(module blueprint.Module) {
215 otherName := ctx.OtherModuleName(module)
216 if javaDep, ok := module.(JavaDependency); ok {
Colin Cross6cbb1272015-04-08 11:23:01 -0700217 if otherName == j.BootClasspath(ctx) {
218 bootClasspath = javaDep.ClasspathFile()
Colin Crossb7a63242015-04-16 14:09:14 -0700219 } else if inList(otherName, defaultJavaLibraries) {
220 classpath = append(classpath, javaDep.ClasspathFile())
Colin Cross6cbb1272015-04-08 11:23:01 -0700221 } else if inList(otherName, j.properties.Java_libs) {
Colin Cross2fe66872015-03-30 17:20:39 -0700222 classpath = append(classpath, javaDep.ClasspathFile())
223 } else if inList(otherName, j.properties.Java_static_libs) {
224 classpath = append(classpath, javaDep.ClasspathFile())
225 classJarSpecs = append(classJarSpecs, javaDep.ClassJarSpecs()...)
226 resourceJarSpecs = append(resourceJarSpecs, javaDep.ResourceJarSpecs()...)
Colin Crossb7a63242015-04-16 14:09:14 -0700227 } else if otherName == "framework-res" {
228 if ctx.ModuleName() == "framework" {
229 // framework.jar has a one-off dependency on the R.java and Manifest.java files
230 // generated by framework-res.apk
231 srcFileLists = append(srcFileLists, module.(*javaBase).module.(*AndroidApp).aaptJavaFileList)
232 }
Colin Cross2fe66872015-03-30 17:20:39 -0700233 } else {
234 panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName()))
235 }
Colin Crossaa8630b2015-04-13 13:52:22 -0700236 aidlIncludeDirs = append(aidlIncludeDirs, javaDep.AidlIncludeDirs()...)
237 if sdkDep, ok := module.(sdkDependency); ok {
238 if sdkDep.AidlPreprocessed() != "" {
239 if aidlPreprocess != "" {
240 ctx.ModuleErrorf("multiple dependencies with preprocessed aidls:\n %q\n %q",
241 aidlPreprocess, sdkDep.AidlPreprocessed())
242 } else {
243 aidlPreprocess = sdkDep.AidlPreprocessed()
244 }
Colin Crossc0b06f12015-04-08 13:03:43 -0700245 }
246 }
Colin Cross2fe66872015-03-30 17:20:39 -0700247 }
248 })
249
Colin Crosse7a9f3f2015-04-13 14:02:52 -0700250 return classpath, bootClasspath, classJarSpecs, resourceJarSpecs, aidlPreprocess,
251 aidlIncludeDirs, srcFileLists
Colin Cross2fe66872015-03-30 17:20:39 -0700252}
253
254func (j *javaBase) GenerateAndroidBuildActions(ctx common.AndroidModuleContext) {
255 j.module.GenerateJavaBuildActions(ctx)
256}
257
258func (j *javaBase) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
Colin Crossc0b06f12015-04-08 13:03:43 -0700259
260 j.exportAidlIncludeDirs = pathtools.PrefixPaths(j.properties.Export_aidl_include_dirs,
261 common.ModuleSrcDir(ctx))
262
263 classpath, bootClasspath, classJarSpecs, resourceJarSpecs, aidlPreprocess,
Colin Crosse7a9f3f2015-04-13 14:02:52 -0700264 aidlIncludeDirs, srcFileLists := j.collectDeps(ctx)
Colin Crossc0b06f12015-04-08 13:03:43 -0700265
Colin Crossf03c82b2015-04-13 13:53:40 -0700266 var flags javaBuilderFlags
267
268 javacFlags := j.properties.Javacflags
269 if len(javacFlags) > 0 {
270 ctx.Variable(pctx, "javacFlags", strings.Join(javacFlags, " "))
271 flags.javacFlags = "$javacFlags"
272 }
273
274 aidlFlags := j.aidlFlags(ctx, aidlPreprocess, aidlIncludeDirs)
275 if len(aidlFlags) > 0 {
276 ctx.Variable(pctx, "aidlFlags", strings.Join(aidlFlags, " "))
277 flags.aidlFlags = "$aidlFlags"
Colin Cross2fe66872015-03-30 17:20:39 -0700278 }
279
280 var javacDeps []string
281
Colin Cross2fe66872015-03-30 17:20:39 -0700282 if bootClasspath != "" {
283 flags.bootClasspath = "-bootclasspath " + bootClasspath
284 javacDeps = append(javacDeps, bootClasspath)
285 }
286
287 if len(classpath) > 0 {
288 flags.classpath = "-classpath " + strings.Join(classpath, ":")
289 javacDeps = append(javacDeps, classpath...)
290 }
291
Colin Crossc0b06f12015-04-08 13:03:43 -0700292 srcFiles := common.ExpandSources(ctx, j.properties.Srcs)
293
Colin Crossf05fe972015-04-10 17:45:20 -0700294 srcFiles = j.genSources(ctx, srcFiles, flags)
Colin Crossc0b06f12015-04-08 13:03:43 -0700295
Colin Cross0607cf72015-04-28 13:28:51 -0700296 ctx.VisitDirectDeps(func(module blueprint.Module) {
297 if gen, ok := module.(genrule.SourceFileGenerator); ok {
298 srcFiles = append(srcFiles, gen.GeneratedSourceFiles()...)
299 }
300 })
301
Colin Crossb7a63242015-04-16 14:09:14 -0700302 srcFileLists = append(srcFileLists, j.ExtraSrcLists...)
303
Colin Cross8cf13342015-04-10 15:41:49 -0700304 if len(srcFiles) > 0 {
305 // Compile java sources into .class files
Colin Crosse7a9f3f2015-04-13 14:02:52 -0700306 classes := TransformJavaToClasses(ctx, srcFiles, srcFileLists, flags, javacDeps)
Colin Cross8cf13342015-04-10 15:41:49 -0700307 if ctx.Failed() {
308 return
309 }
310
311 classJarSpecs = append([]jarSpec{classes}, classJarSpecs...)
Colin Cross2fe66872015-03-30 17:20:39 -0700312 }
313
Colin Cross276284f2015-04-20 13:51:48 -0700314 resourceJarSpecs = append(ResourceDirsToJarSpecs(ctx, j.properties.Java_resource_dirs),
315 resourceJarSpecs...)
Colin Cross2fe66872015-03-30 17:20:39 -0700316
317 manifest := j.properties.Manifest
318 if manifest != "" {
319 manifest = filepath.Join(common.ModuleSrcDir(ctx), manifest)
320 }
321
322 allJarSpecs := append([]jarSpec(nil), classJarSpecs...)
323 allJarSpecs = append(allJarSpecs, resourceJarSpecs...)
324
325 // Combine classes + resources into classes-full-debug.jar
326 outputFile := TransformClassesToJar(ctx, allJarSpecs, manifest)
327 if ctx.Failed() {
328 return
329 }
Colin Cross65bf4f22015-04-03 16:54:17 -0700330
Colin Cross65bf4f22015-04-03 16:54:17 -0700331 if j.properties.Jarjar_rules != "" {
332 jarjar_rules := filepath.Join(common.ModuleSrcDir(ctx), j.properties.Jarjar_rules)
333 // Transform classes-full-debug.jar into classes-jarjar.jar
334 outputFile = TransformJarJar(ctx, outputFile, jarjar_rules)
335 if ctx.Failed() {
336 return
337 }
Colin Cross20978302015-04-10 17:05:07 -0700338
339 classes, _ := TransformPrebuiltJarToClasses(ctx, outputFile)
340 classJarSpecs = []jarSpec{classes}
Colin Cross65bf4f22015-04-03 16:54:17 -0700341 }
342
Colin Cross20978302015-04-10 17:05:07 -0700343 j.resourceJarSpecs = resourceJarSpecs
344 j.classJarSpecs = classJarSpecs
Colin Cross2fe66872015-03-30 17:20:39 -0700345 j.classpathFile = outputFile
346
Colin Cross8cf13342015-04-10 15:41:49 -0700347 if j.properties.Dex && len(srcFiles) > 0 {
Colin Cross2fe66872015-03-30 17:20:39 -0700348 dxFlags := j.properties.Dxflags
349 if false /* emma enabled */ {
350 // If you instrument class files that have local variable debug information in
351 // them emma does not correctly maintain the local variable table.
352 // This will cause an error when you try to convert the class files for Android.
353 // The workaround here is to build different dex file here based on emma switch
354 // then later copy into classes.dex. When emma is on, dx is run with --no-locals
355 // option to remove local variable information
356 dxFlags = append(dxFlags, "--no-locals")
357 }
358
Colin Cross1332b002015-04-07 17:11:30 -0700359 if ctx.AConfig().Getenv("NO_OPTIMIZE_DX") != "" {
Colin Cross2fe66872015-03-30 17:20:39 -0700360 dxFlags = append(dxFlags, "--no-optimize")
361 }
362
Colin Cross1332b002015-04-07 17:11:30 -0700363 if ctx.AConfig().Getenv("GENERATE_DEX_DEBUG") != "" {
Colin Cross2fe66872015-03-30 17:20:39 -0700364 dxFlags = append(dxFlags,
365 "--debug",
366 "--verbose",
367 "--dump-to="+filepath.Join(common.ModuleOutDir(ctx), "classes.lst"),
368 "--dump-width=1000")
369 }
370
371 flags.dxFlags = strings.Join(dxFlags, " ")
372
373 // Compile classes.jar into classes.dex
Colin Cross6d1e72d2015-04-10 17:44:24 -0700374 dexJarSpec := TransformClassesJarToDex(ctx, outputFile, flags)
Colin Cross2fe66872015-03-30 17:20:39 -0700375 if ctx.Failed() {
376 return
377 }
378
379 // Combine classes.dex + resources into javalib.jar
Colin Cross6d1e72d2015-04-10 17:44:24 -0700380 outputFile = TransformDexToJavaLib(ctx, resourceJarSpecs, dexJarSpec)
Colin Cross2fe66872015-03-30 17:20:39 -0700381 }
Colin Crossb7a63242015-04-16 14:09:14 -0700382 ctx.CheckbuildFile(outputFile)
383 j.outputFile = outputFile
Colin Cross2fe66872015-03-30 17:20:39 -0700384}
385
386var _ JavaDependency = (*JavaLibrary)(nil)
387
388func (j *javaBase) ClasspathFile() string {
389 return j.classpathFile
390}
391
392func (j *javaBase) ClassJarSpecs() []jarSpec {
393 return j.classJarSpecs
394}
395
396func (j *javaBase) ResourceJarSpecs() []jarSpec {
397 return j.resourceJarSpecs
398}
399
Colin Crossc0b06f12015-04-08 13:03:43 -0700400func (j *javaBase) AidlIncludeDirs() []string {
401 return j.exportAidlIncludeDirs
402}
403
Colin Crossf05fe972015-04-10 17:45:20 -0700404var _ logtagsProducer = (*javaBase)(nil)
405
406func (j *javaBase) logtags() []string {
407 return j.logtagsSrcs
408}
409
Colin Cross2fe66872015-03-30 17:20:39 -0700410//
411// Java libraries (.jar file)
412//
413
414type JavaLibrary struct {
415 javaBase
416}
417
Colin Crossb7a63242015-04-16 14:09:14 -0700418func (j *JavaLibrary) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
419 j.javaBase.GenerateJavaBuildActions(ctx)
420
421 j.installFile = ctx.InstallFileName("framework", ctx.ModuleName()+".jar", j.outputFile)
422}
423
Colin Cross2fe66872015-03-30 17:20:39 -0700424func JavaLibraryFactory() (blueprint.Module, []interface{}) {
425 module := &JavaLibrary{}
426
427 module.properties.Dex = true
428
429 return NewJavaBase(&module.javaBase, module, common.HostAndDeviceSupported)
430}
431
432func JavaLibraryHostFactory() (blueprint.Module, []interface{}) {
433 module := &JavaLibrary{}
434
435 return NewJavaBase(&module.javaBase, module, common.HostSupported)
436}
437
438//
439// Java Binaries (.jar file plus wrapper script)
440//
441
442type JavaBinary struct {
443 JavaLibrary
444
445 binaryProperties struct {
446 // wrapper: installable script to execute the resulting jar
447 Wrapper string
448 }
449}
450
451func (j *JavaBinary) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
452 j.JavaLibrary.GenerateJavaBuildActions(ctx)
453
454 // Depend on the installed jar (j.installFile) so that the wrapper doesn't get executed by
455 // another build rule before the jar has been installed.
456 ctx.InstallFile("bin", filepath.Join(common.ModuleSrcDir(ctx), j.binaryProperties.Wrapper),
457 j.installFile)
458}
459
460func JavaBinaryFactory() (blueprint.Module, []interface{}) {
461 module := &JavaBinary{}
462
463 module.properties.Dex = true
464
465 return NewJavaBase(&module.javaBase, module, common.HostAndDeviceSupported, &module.binaryProperties)
466}
467
468func JavaBinaryHostFactory() (blueprint.Module, []interface{}) {
469 module := &JavaBinary{}
470
471 return NewJavaBase(&module.javaBase, module, common.HostSupported, &module.binaryProperties)
472}
473
474//
475// Java prebuilts
476//
477
478type JavaPrebuilt struct {
479 common.AndroidModuleBase
480
481 properties struct {
Colin Crossaa8630b2015-04-13 13:52:22 -0700482 Srcs []string
Colin Cross2fe66872015-03-30 17:20:39 -0700483 }
484
Colin Crosse1d62a82015-04-03 16:53:05 -0700485 classpathFile string
486 classJarSpecs, resourceJarSpecs []jarSpec
Colin Cross2fe66872015-03-30 17:20:39 -0700487}
488
489func (j *JavaPrebuilt) GenerateAndroidBuildActions(ctx common.AndroidModuleContext) {
490 if len(j.properties.Srcs) != 1 {
491 ctx.ModuleErrorf("expected exactly one jar in srcs")
492 return
493 }
Colin Crosse1d62a82015-04-03 16:53:05 -0700494 prebuilt := filepath.Join(common.ModuleSrcDir(ctx), j.properties.Srcs[0])
495
496 classJarSpec, resourceJarSpec := TransformPrebuiltJarToClasses(ctx, prebuilt)
497
498 j.classpathFile = prebuilt
499 j.classJarSpecs = []jarSpec{classJarSpec}
500 j.resourceJarSpecs = []jarSpec{resourceJarSpec}
Colin Crosse1d62a82015-04-03 16:53:05 -0700501 ctx.InstallFileName("framework", ctx.ModuleName()+".jar", j.classpathFile)
Colin Cross2fe66872015-03-30 17:20:39 -0700502}
503
504var _ JavaDependency = (*JavaPrebuilt)(nil)
505
506func (j *JavaPrebuilt) ClasspathFile() string {
507 return j.classpathFile
508}
509
510func (j *JavaPrebuilt) ClassJarSpecs() []jarSpec {
Colin Crosse1d62a82015-04-03 16:53:05 -0700511 return j.classJarSpecs
Colin Cross2fe66872015-03-30 17:20:39 -0700512}
513
514func (j *JavaPrebuilt) ResourceJarSpecs() []jarSpec {
Colin Crosse1d62a82015-04-03 16:53:05 -0700515 return j.resourceJarSpecs
Colin Cross2fe66872015-03-30 17:20:39 -0700516}
517
Colin Crossc0b06f12015-04-08 13:03:43 -0700518func (j *JavaPrebuilt) AidlIncludeDirs() []string {
519 return nil
520}
521
Colin Cross2fe66872015-03-30 17:20:39 -0700522func JavaPrebuiltFactory() (blueprint.Module, []interface{}) {
523 module := &JavaPrebuilt{}
524
525 return common.InitAndroidArchModule(module, common.HostAndDeviceSupported,
526 common.MultilibCommon, &module.properties)
527}
528
Colin Crossaa8630b2015-04-13 13:52:22 -0700529//
530// SDK java prebuilts (.jar containing resources plus framework.aidl)
531//
532
533type sdkDependency interface {
534 JavaDependency
535 AidlPreprocessed() string
536}
537
538var _ sdkDependency = (*sdkPrebuilt)(nil)
539
540type sdkPrebuilt struct {
541 JavaPrebuilt
542
543 sdkProperties struct {
544 Aidl_preprocessed string
545 }
546
547 aidlPreprocessed string
548}
549
550func (j *sdkPrebuilt) GenerateAndroidBuildActions(ctx common.AndroidModuleContext) {
551 j.JavaPrebuilt.GenerateAndroidBuildActions(ctx)
552
553 if j.sdkProperties.Aidl_preprocessed != "" {
554 j.aidlPreprocessed = filepath.Join(common.ModuleSrcDir(ctx), j.sdkProperties.Aidl_preprocessed)
555 }
556}
557
558func (j *sdkPrebuilt) AidlPreprocessed() string {
559 return j.aidlPreprocessed
560}
561
562func SdkPrebuiltFactory() (blueprint.Module, []interface{}) {
563 module := &sdkPrebuilt{}
564
565 return common.InitAndroidArchModule(module, common.HostAndDeviceSupported,
566 common.MultilibCommon, &module.properties, &module.sdkProperties)
567}
568
Colin Cross2fe66872015-03-30 17:20:39 -0700569func inList(s string, l []string) bool {
570 for _, e := range l {
571 if e == s {
572 return true
573 }
574 }
575 return false
576}