Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 1 | // 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 | |
| 15 | package java |
| 16 | |
| 17 | // This file contains the module types for compiling Java for Android, and converts the properties |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 18 | // into the flags and filenames necessary to pass to the Module. The final creation of the rules |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 19 | // is handled in builder.go |
| 20 | |
| 21 | import ( |
| 22 | "fmt" |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 23 | "strings" |
| 24 | |
| 25 | "github.com/google/blueprint" |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 26 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 27 | "android/soong/android" |
Colin Cross | 0607cf7 | 2015-04-28 13:28:51 -0700 | [diff] [blame] | 28 | "android/soong/genrule" |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 29 | ) |
| 30 | |
Colin Cross | 463a90e | 2015-06-17 14:20:06 -0700 | [diff] [blame] | 31 | func init() { |
Colin Cross | 798bfce | 2016-10-12 14:28:16 -0700 | [diff] [blame] | 32 | android.RegisterModuleType("java_library", JavaLibraryFactory) |
| 33 | android.RegisterModuleType("java_library_static", JavaLibraryFactory) |
| 34 | android.RegisterModuleType("java_library_host", JavaLibraryHostFactory) |
| 35 | android.RegisterModuleType("java_binary", JavaBinaryFactory) |
| 36 | android.RegisterModuleType("java_binary_host", JavaBinaryHostFactory) |
| 37 | android.RegisterModuleType("prebuilt_java_library", JavaPrebuiltFactory) |
| 38 | android.RegisterModuleType("prebuilt_sdk", SdkPrebuiltFactory) |
| 39 | android.RegisterModuleType("android_app", AndroidAppFactory) |
Colin Cross | 463a90e | 2015-06-17 14:20:06 -0700 | [diff] [blame] | 40 | |
Colin Cross | 798bfce | 2016-10-12 14:28:16 -0700 | [diff] [blame] | 41 | android.RegisterSingletonType("logtags", LogtagsSingleton) |
Colin Cross | 463a90e | 2015-06-17 14:20:06 -0700 | [diff] [blame] | 42 | } |
| 43 | |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 44 | // TODO: |
| 45 | // Autogenerated files: |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 46 | // Proto |
| 47 | // Renderscript |
| 48 | // Post-jar passes: |
| 49 | // Proguard |
Colin Cross | ba21113 | 2017-06-22 15:36:39 -0700 | [diff] [blame] | 50 | // Jacoco |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 51 | // Jarjar |
| 52 | // Dex |
| 53 | // Rmtypedefs |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 54 | // DroidDoc |
| 55 | // Findbugs |
| 56 | |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 57 | type compilerProperties struct { |
Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 58 | // list of source files used to compile the Java module. May be .java, .logtags, .proto, |
| 59 | // or .aidl files. |
Dan Willemsen | 2ef08f4 | 2015-06-30 18:15:24 -0700 | [diff] [blame] | 60 | Srcs []string `android:"arch_variant"` |
| 61 | |
| 62 | // list of source files that should not be used to build the Java module. |
| 63 | // This is most useful in the arch/multilib variants to remove non-common files |
| 64 | Exclude_srcs []string `android:"arch_variant"` |
Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 65 | |
| 66 | // list of directories containing Java resources |
| 67 | Java_resource_dirs []string `android:"arch_variant"` |
| 68 | |
Dan Willemsen | 2ef08f4 | 2015-06-30 18:15:24 -0700 | [diff] [blame] | 69 | // list of directories that should be excluded from java_resource_dirs |
| 70 | Exclude_java_resource_dirs []string `android:"arch_variant"` |
| 71 | |
Paul Duffin | 2b67e3b | 2016-11-30 16:13:09 +0000 | [diff] [blame] | 72 | // don't build against the default libraries (legacy-test, core-junit, |
Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 73 | // ext, and framework for device targets) |
| 74 | No_standard_libraries bool |
| 75 | |
| 76 | // list of module-specific flags that will be used for javac compiles |
| 77 | Javacflags []string `android:"arch_variant"` |
| 78 | |
Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 79 | // list of of java libraries that will be in the classpath |
| 80 | Java_libs []string `android:"arch_variant"` |
| 81 | |
| 82 | // list of java libraries that will be compiled into the resulting jar |
| 83 | Java_static_libs []string `android:"arch_variant"` |
| 84 | |
| 85 | // manifest file to be included in resulting jar |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 86 | Manifest *string |
Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 87 | |
Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame^] | 88 | // if not blank, run jarjar using the specified rules file |
| 89 | Jarjar_rules *string |
| 90 | } |
| 91 | |
| 92 | type compilerDeviceProperties struct { |
| 93 | // list of module-specific flags that will be used for dex compiles |
| 94 | Dxflags []string `android:"arch_variant"` |
| 95 | |
Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 96 | // if not blank, set to the version of the sdk to compile against |
| 97 | Sdk_version string |
| 98 | |
| 99 | // Set for device java libraries, and for host versions of device java libraries |
| 100 | // built for testing |
| 101 | Dex bool `blueprint:"mutated"` |
| 102 | |
Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 103 | // directories to pass to aidl tool |
| 104 | Aidl_includes []string |
| 105 | |
| 106 | // directories that should be added as include directories |
| 107 | // for any aidl sources of modules that depend on this module |
| 108 | Export_aidl_include_dirs []string |
| 109 | } |
| 110 | |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 111 | // Module contains the properties and members used by all java module types |
| 112 | type Module struct { |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 113 | android.ModuleBase |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 114 | |
Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame^] | 115 | properties compilerProperties |
| 116 | deviceProperties compilerDeviceProperties |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 117 | |
| 118 | // output file suitable for inserting into the classpath of another compile |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 119 | classpathFile android.Path |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 120 | |
Colin Cross | b7a6324 | 2015-04-16 14:09:14 -0700 | [diff] [blame] | 121 | // output file suitable for installing or running |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 122 | outputFile android.Path |
Colin Cross | b7a6324 | 2015-04-16 14:09:14 -0700 | [diff] [blame] | 123 | |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 124 | // jarSpecs suitable for inserting classes from a static library into another jar |
| 125 | classJarSpecs []jarSpec |
| 126 | |
| 127 | // jarSpecs suitable for inserting resources from a static library into another jar |
| 128 | resourceJarSpecs []jarSpec |
| 129 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 130 | exportAidlIncludeDirs android.Paths |
Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 131 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 132 | logtagsSrcs android.Paths |
Colin Cross | f05fe97 | 2015-04-10 17:45:20 -0700 | [diff] [blame] | 133 | |
Colin Cross | b7a6324 | 2015-04-16 14:09:14 -0700 | [diff] [blame] | 134 | // filelists of extra source files that should be included in the javac command line, |
| 135 | // for example R.java generated by aapt for android apps |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 136 | ExtraSrcLists android.Paths |
Colin Cross | b7a6324 | 2015-04-16 14:09:14 -0700 | [diff] [blame] | 137 | |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 138 | // installed file for binary dependency |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 139 | installFile android.Path |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 140 | } |
| 141 | |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 142 | type JavaDependency interface { |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 143 | ClasspathFile() android.Path |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 144 | ClassJarSpecs() []jarSpec |
| 145 | ResourceJarSpecs() []jarSpec |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 146 | AidlIncludeDirs() android.Paths |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 147 | } |
| 148 | |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 149 | func (j *Module) BootClasspath(ctx android.BaseContext) string { |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 150 | if ctx.Device() { |
Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame^] | 151 | switch j.deviceProperties.Sdk_version { |
| 152 | case "": |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 153 | return "core-libart" |
Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame^] | 154 | case "current": |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 155 | // TODO: !TARGET_BUILD_APPS |
Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 156 | // TODO: export preprocessed framework.aidl from android_stubs_current |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 157 | return "android_stubs_current" |
Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame^] | 158 | case "system_current": |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 159 | return "android_system_stubs_current" |
Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame^] | 160 | default: |
| 161 | return "sdk_v" + j.deviceProperties.Sdk_version |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 162 | } |
| 163 | } else { |
Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame^] | 164 | if j.deviceProperties.Dex { |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 165 | return "core-libart" |
| 166 | } else { |
| 167 | return "" |
| 168 | } |
| 169 | } |
| 170 | } |
| 171 | |
Paul Duffin | 2b67e3b | 2016-11-30 16:13:09 +0000 | [diff] [blame] | 172 | var defaultJavaLibraries = []string{"core-libart", "legacy-test", "ext", "framework"} |
Colin Cross | efb9ebe | 2015-04-16 14:08:06 -0700 | [diff] [blame] | 173 | |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 174 | func (j *Module) deps(ctx android.BottomUpMutatorContext) { |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 175 | var deps []string |
| 176 | |
| 177 | if !j.properties.No_standard_libraries { |
| 178 | bootClasspath := j.BootClasspath(ctx) |
| 179 | if bootClasspath != "" { |
| 180 | deps = append(deps, bootClasspath) |
| 181 | } |
Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame^] | 182 | if ctx.Device() && j.deviceProperties.Sdk_version == "" { |
Colin Cross | efb9ebe | 2015-04-16 14:08:06 -0700 | [diff] [blame] | 183 | deps = append(deps, defaultJavaLibraries...) |
| 184 | } |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 185 | } |
| 186 | deps = append(deps, j.properties.Java_libs...) |
| 187 | deps = append(deps, j.properties.Java_static_libs...) |
| 188 | |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 189 | ctx.AddDependency(ctx.Module(), nil, deps...) |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 190 | } |
| 191 | |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 192 | func (j *Module) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.OptionalPath, |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 193 | aidlIncludeDirs android.Paths) []string { |
Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 194 | |
Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame^] | 195 | localAidlIncludes := android.PathsForModuleSrc(ctx, j.deviceProperties.Aidl_includes) |
Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 196 | |
| 197 | var flags []string |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 198 | if aidlPreprocess.Valid() { |
| 199 | flags = append(flags, "-p"+aidlPreprocess.String()) |
Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 200 | } else { |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 201 | flags = append(flags, android.JoinWithPrefix(aidlIncludeDirs.Strings(), "-I")) |
Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 202 | } |
| 203 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 204 | flags = append(flags, android.JoinWithPrefix(j.exportAidlIncludeDirs.Strings(), "-I")) |
| 205 | flags = append(flags, android.JoinWithPrefix(localAidlIncludes.Strings(), "-I")) |
| 206 | flags = append(flags, "-I"+android.PathForModuleSrc(ctx).String()) |
| 207 | flags = append(flags, "-I"+android.PathForModuleSrc(ctx, "src").String()) |
Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 208 | |
Colin Cross | f03c82b | 2015-04-13 13:53:40 -0700 | [diff] [blame] | 209 | return flags |
Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 210 | } |
| 211 | |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 212 | func (j *Module) collectDeps(ctx android.ModuleContext) (classpath android.Paths, |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 213 | bootClasspath android.OptionalPath, classJarSpecs, resourceJarSpecs []jarSpec, aidlPreprocess android.OptionalPath, |
| 214 | aidlIncludeDirs android.Paths, srcFileLists android.Paths) { |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 215 | |
| 216 | ctx.VisitDirectDeps(func(module blueprint.Module) { |
| 217 | otherName := ctx.OtherModuleName(module) |
| 218 | if javaDep, ok := module.(JavaDependency); ok { |
Colin Cross | 6cbb127 | 2015-04-08 11:23:01 -0700 | [diff] [blame] | 219 | if otherName == j.BootClasspath(ctx) { |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 220 | bootClasspath = android.OptionalPathForPath(javaDep.ClasspathFile()) |
Colin Cross | b7a6324 | 2015-04-16 14:09:14 -0700 | [diff] [blame] | 221 | } else if inList(otherName, defaultJavaLibraries) { |
| 222 | classpath = append(classpath, javaDep.ClasspathFile()) |
Colin Cross | 6cbb127 | 2015-04-08 11:23:01 -0700 | [diff] [blame] | 223 | } else if inList(otherName, j.properties.Java_libs) { |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 224 | classpath = append(classpath, javaDep.ClasspathFile()) |
| 225 | } else if inList(otherName, j.properties.Java_static_libs) { |
| 226 | classpath = append(classpath, javaDep.ClasspathFile()) |
| 227 | classJarSpecs = append(classJarSpecs, javaDep.ClassJarSpecs()...) |
| 228 | resourceJarSpecs = append(resourceJarSpecs, javaDep.ResourceJarSpecs()...) |
Colin Cross | b7a6324 | 2015-04-16 14:09:14 -0700 | [diff] [blame] | 229 | } else if otherName == "framework-res" { |
| 230 | if ctx.ModuleName() == "framework" { |
| 231 | // framework.jar has a one-off dependency on the R.java and Manifest.java files |
| 232 | // generated by framework-res.apk |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 233 | srcFileLists = append(srcFileLists, module.(*AndroidApp).aaptJavaFileList) |
Colin Cross | b7a6324 | 2015-04-16 14:09:14 -0700 | [diff] [blame] | 234 | } |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 235 | } else { |
| 236 | panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName())) |
| 237 | } |
Colin Cross | aa8630b | 2015-04-13 13:52:22 -0700 | [diff] [blame] | 238 | aidlIncludeDirs = append(aidlIncludeDirs, javaDep.AidlIncludeDirs()...) |
| 239 | if sdkDep, ok := module.(sdkDependency); ok { |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 240 | if sdkDep.AidlPreprocessed().Valid() { |
| 241 | if aidlPreprocess.Valid() { |
Colin Cross | aa8630b | 2015-04-13 13:52:22 -0700 | [diff] [blame] | 242 | ctx.ModuleErrorf("multiple dependencies with preprocessed aidls:\n %q\n %q", |
| 243 | aidlPreprocess, sdkDep.AidlPreprocessed()) |
| 244 | } else { |
| 245 | aidlPreprocess = sdkDep.AidlPreprocessed() |
| 246 | } |
Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 247 | } |
| 248 | } |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 249 | } |
| 250 | }) |
| 251 | |
Colin Cross | e7a9f3f | 2015-04-13 14:02:52 -0700 | [diff] [blame] | 252 | return classpath, bootClasspath, classJarSpecs, resourceJarSpecs, aidlPreprocess, |
| 253 | aidlIncludeDirs, srcFileLists |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 254 | } |
| 255 | |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 256 | func (j *Module) compile(ctx android.ModuleContext) { |
Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 257 | |
Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame^] | 258 | j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.deviceProperties.Export_aidl_include_dirs) |
Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 259 | |
| 260 | classpath, bootClasspath, classJarSpecs, resourceJarSpecs, aidlPreprocess, |
Colin Cross | e7a9f3f | 2015-04-13 14:02:52 -0700 | [diff] [blame] | 261 | aidlIncludeDirs, srcFileLists := j.collectDeps(ctx) |
Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 262 | |
Colin Cross | f03c82b | 2015-04-13 13:53:40 -0700 | [diff] [blame] | 263 | var flags javaBuilderFlags |
| 264 | |
| 265 | javacFlags := j.properties.Javacflags |
| 266 | if len(javacFlags) > 0 { |
| 267 | ctx.Variable(pctx, "javacFlags", strings.Join(javacFlags, " ")) |
| 268 | flags.javacFlags = "$javacFlags" |
| 269 | } |
| 270 | |
| 271 | aidlFlags := j.aidlFlags(ctx, aidlPreprocess, aidlIncludeDirs) |
| 272 | if len(aidlFlags) > 0 { |
| 273 | ctx.Variable(pctx, "aidlFlags", strings.Join(aidlFlags, " ")) |
| 274 | flags.aidlFlags = "$aidlFlags" |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 275 | } |
| 276 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 277 | var javacDeps android.Paths |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 278 | |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 279 | if bootClasspath.Valid() { |
| 280 | flags.bootClasspath = "-bootclasspath " + bootClasspath.String() |
| 281 | javacDeps = append(javacDeps, bootClasspath.Path()) |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | if len(classpath) > 0 { |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 285 | flags.classpath = "-classpath " + strings.Join(classpath.Strings(), ":") |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 286 | javacDeps = append(javacDeps, classpath...) |
| 287 | } |
| 288 | |
Dan Willemsen | 2ef08f4 | 2015-06-30 18:15:24 -0700 | [diff] [blame] | 289 | srcFiles := ctx.ExpandSources(j.properties.Srcs, j.properties.Exclude_srcs) |
Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 290 | |
Colin Cross | f05fe97 | 2015-04-10 17:45:20 -0700 | [diff] [blame] | 291 | srcFiles = j.genSources(ctx, srcFiles, flags) |
Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 292 | |
Colin Cross | 0607cf7 | 2015-04-28 13:28:51 -0700 | [diff] [blame] | 293 | ctx.VisitDirectDeps(func(module blueprint.Module) { |
| 294 | if gen, ok := module.(genrule.SourceFileGenerator); ok { |
| 295 | srcFiles = append(srcFiles, gen.GeneratedSourceFiles()...) |
| 296 | } |
| 297 | }) |
| 298 | |
Colin Cross | b7a6324 | 2015-04-16 14:09:14 -0700 | [diff] [blame] | 299 | srcFileLists = append(srcFileLists, j.ExtraSrcLists...) |
| 300 | |
Colin Cross | 8cf1334 | 2015-04-10 15:41:49 -0700 | [diff] [blame] | 301 | if len(srcFiles) > 0 { |
| 302 | // Compile java sources into .class files |
Colin Cross | e7a9f3f | 2015-04-13 14:02:52 -0700 | [diff] [blame] | 303 | classes := TransformJavaToClasses(ctx, srcFiles, srcFileLists, flags, javacDeps) |
Colin Cross | 8cf1334 | 2015-04-10 15:41:49 -0700 | [diff] [blame] | 304 | if ctx.Failed() { |
| 305 | return |
| 306 | } |
| 307 | |
| 308 | classJarSpecs = append([]jarSpec{classes}, classJarSpecs...) |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 309 | } |
| 310 | |
Dan Willemsen | 2ef08f4 | 2015-06-30 18:15:24 -0700 | [diff] [blame] | 311 | resourceJarSpecs = append(ResourceDirsToJarSpecs(ctx, j.properties.Java_resource_dirs, j.properties.Exclude_java_resource_dirs), |
Colin Cross | 276284f | 2015-04-20 13:51:48 -0700 | [diff] [blame] | 312 | resourceJarSpecs...) |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 313 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 314 | manifest := android.OptionalPathForModuleSrc(ctx, j.properties.Manifest) |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 315 | |
| 316 | allJarSpecs := append([]jarSpec(nil), classJarSpecs...) |
| 317 | allJarSpecs = append(allJarSpecs, resourceJarSpecs...) |
| 318 | |
| 319 | // Combine classes + resources into classes-full-debug.jar |
| 320 | outputFile := TransformClassesToJar(ctx, allJarSpecs, manifest) |
| 321 | if ctx.Failed() { |
| 322 | return |
| 323 | } |
Colin Cross | 65bf4f2 | 2015-04-03 16:54:17 -0700 | [diff] [blame] | 324 | |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 325 | if j.properties.Jarjar_rules != nil { |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 326 | jarjar_rules := android.PathForModuleSrc(ctx, *j.properties.Jarjar_rules) |
Colin Cross | 65bf4f2 | 2015-04-03 16:54:17 -0700 | [diff] [blame] | 327 | // Transform classes-full-debug.jar into classes-jarjar.jar |
| 328 | outputFile = TransformJarJar(ctx, outputFile, jarjar_rules) |
| 329 | if ctx.Failed() { |
| 330 | return |
| 331 | } |
Colin Cross | 2097830 | 2015-04-10 17:05:07 -0700 | [diff] [blame] | 332 | |
| 333 | classes, _ := TransformPrebuiltJarToClasses(ctx, outputFile) |
| 334 | classJarSpecs = []jarSpec{classes} |
Colin Cross | 65bf4f2 | 2015-04-03 16:54:17 -0700 | [diff] [blame] | 335 | } |
| 336 | |
Colin Cross | 2097830 | 2015-04-10 17:05:07 -0700 | [diff] [blame] | 337 | j.resourceJarSpecs = resourceJarSpecs |
| 338 | j.classJarSpecs = classJarSpecs |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 339 | j.classpathFile = outputFile |
| 340 | |
Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame^] | 341 | if j.deviceProperties.Dex && len(srcFiles) > 0 { |
| 342 | dxFlags := j.deviceProperties.Dxflags |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 343 | if false /* emma enabled */ { |
| 344 | // If you instrument class files that have local variable debug information in |
| 345 | // them emma does not correctly maintain the local variable table. |
| 346 | // This will cause an error when you try to convert the class files for Android. |
| 347 | // The workaround here is to build different dex file here based on emma switch |
| 348 | // then later copy into classes.dex. When emma is on, dx is run with --no-locals |
| 349 | // option to remove local variable information |
| 350 | dxFlags = append(dxFlags, "--no-locals") |
| 351 | } |
| 352 | |
Colin Cross | 1332b00 | 2015-04-07 17:11:30 -0700 | [diff] [blame] | 353 | if ctx.AConfig().Getenv("NO_OPTIMIZE_DX") != "" { |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 354 | dxFlags = append(dxFlags, "--no-optimize") |
| 355 | } |
| 356 | |
Colin Cross | 1332b00 | 2015-04-07 17:11:30 -0700 | [diff] [blame] | 357 | if ctx.AConfig().Getenv("GENERATE_DEX_DEBUG") != "" { |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 358 | dxFlags = append(dxFlags, |
| 359 | "--debug", |
| 360 | "--verbose", |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 361 | "--dump-to="+android.PathForModuleOut(ctx, "classes.lst").String(), |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 362 | "--dump-width=1000") |
| 363 | } |
| 364 | |
| 365 | flags.dxFlags = strings.Join(dxFlags, " ") |
| 366 | |
| 367 | // Compile classes.jar into classes.dex |
Colin Cross | 6d1e72d | 2015-04-10 17:44:24 -0700 | [diff] [blame] | 368 | dexJarSpec := TransformClassesJarToDex(ctx, outputFile, flags) |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 369 | if ctx.Failed() { |
| 370 | return |
| 371 | } |
| 372 | |
| 373 | // Combine classes.dex + resources into javalib.jar |
Colin Cross | 6d1e72d | 2015-04-10 17:44:24 -0700 | [diff] [blame] | 374 | outputFile = TransformDexToJavaLib(ctx, resourceJarSpecs, dexJarSpec) |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 375 | } |
Colin Cross | b7a6324 | 2015-04-16 14:09:14 -0700 | [diff] [blame] | 376 | ctx.CheckbuildFile(outputFile) |
| 377 | j.outputFile = outputFile |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 378 | } |
| 379 | |
| 380 | var _ JavaDependency = (*JavaLibrary)(nil) |
| 381 | |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 382 | func (j *Module) ClasspathFile() android.Path { |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 383 | return j.classpathFile |
| 384 | } |
| 385 | |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 386 | func (j *Module) ClassJarSpecs() []jarSpec { |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 387 | return j.classJarSpecs |
| 388 | } |
| 389 | |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 390 | func (j *Module) ResourceJarSpecs() []jarSpec { |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 391 | return j.resourceJarSpecs |
| 392 | } |
| 393 | |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 394 | func (j *Module) AidlIncludeDirs() android.Paths { |
Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 395 | return j.exportAidlIncludeDirs |
| 396 | } |
| 397 | |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 398 | var _ logtagsProducer = (*Module)(nil) |
Colin Cross | f05fe97 | 2015-04-10 17:45:20 -0700 | [diff] [blame] | 399 | |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 400 | func (j *Module) logtags() android.Paths { |
Colin Cross | f05fe97 | 2015-04-10 17:45:20 -0700 | [diff] [blame] | 401 | return j.logtagsSrcs |
| 402 | } |
| 403 | |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 404 | // |
| 405 | // Java libraries (.jar file) |
| 406 | // |
| 407 | |
| 408 | type JavaLibrary struct { |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 409 | Module |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 410 | } |
| 411 | |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 412 | func (j *JavaLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
| 413 | j.compile(ctx) |
Colin Cross | b7a6324 | 2015-04-16 14:09:14 -0700 | [diff] [blame] | 414 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 415 | j.installFile = ctx.InstallFileName(android.PathForModuleInstall(ctx, "framework"), ctx.ModuleName()+".jar", j.outputFile) |
Colin Cross | b7a6324 | 2015-04-16 14:09:14 -0700 | [diff] [blame] | 416 | } |
| 417 | |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 418 | func (j *JavaLibrary) DepsMutator(ctx android.BottomUpMutatorContext) { |
| 419 | j.deps(ctx) |
| 420 | } |
| 421 | |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 422 | func JavaLibraryFactory() (blueprint.Module, []interface{}) { |
| 423 | module := &JavaLibrary{} |
| 424 | |
Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame^] | 425 | module.deviceProperties.Dex = true |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 426 | |
Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame^] | 427 | return android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon, |
| 428 | &module.Module.properties, |
| 429 | &module.Module.deviceProperties) |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 430 | } |
| 431 | |
| 432 | func JavaLibraryHostFactory() (blueprint.Module, []interface{}) { |
| 433 | module := &JavaLibrary{} |
| 434 | |
Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame^] | 435 | return android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon, |
| 436 | &module.Module.properties) |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 437 | } |
| 438 | |
| 439 | // |
| 440 | // Java Binaries (.jar file plus wrapper script) |
| 441 | // |
| 442 | |
Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 443 | type javaBinaryProperties struct { |
| 444 | // installable script to execute the resulting jar |
| 445 | Wrapper string |
| 446 | } |
| 447 | |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 448 | type JavaBinary struct { |
| 449 | JavaLibrary |
| 450 | |
Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 451 | binaryProperties javaBinaryProperties |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 452 | } |
| 453 | |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 454 | func (j *JavaBinary) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
| 455 | j.JavaLibrary.GenerateAndroidBuildActions(ctx) |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 456 | |
| 457 | // Depend on the installed jar (j.installFile) so that the wrapper doesn't get executed by |
| 458 | // another build rule before the jar has been installed. |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 459 | ctx.InstallFile(android.PathForModuleInstall(ctx, "bin"), android.PathForModuleSrc(ctx, j.binaryProperties.Wrapper), |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 460 | j.installFile) |
| 461 | } |
| 462 | |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 463 | func (j *JavaBinary) DepsMutator(ctx android.BottomUpMutatorContext) { |
| 464 | j.deps(ctx) |
| 465 | } |
| 466 | |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 467 | func JavaBinaryFactory() (blueprint.Module, []interface{}) { |
| 468 | module := &JavaBinary{} |
| 469 | |
Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame^] | 470 | module.deviceProperties.Dex = true |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 471 | |
Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame^] | 472 | return android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon, |
| 473 | &module.Module.properties, |
| 474 | &module.Module.deviceProperties, |
| 475 | &module.binaryProperties) |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 476 | } |
| 477 | |
| 478 | func JavaBinaryHostFactory() (blueprint.Module, []interface{}) { |
| 479 | module := &JavaBinary{} |
| 480 | |
Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame^] | 481 | return android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon, |
| 482 | &module.Module.properties, |
| 483 | &module.Module.deviceProperties, |
| 484 | &module.binaryProperties) |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 485 | } |
| 486 | |
| 487 | // |
| 488 | // Java prebuilts |
| 489 | // |
| 490 | |
Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 491 | type javaPrebuiltProperties struct { |
| 492 | Srcs []string |
| 493 | } |
| 494 | |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 495 | type JavaPrebuilt struct { |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 496 | android.ModuleBase |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 497 | |
Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 498 | properties javaPrebuiltProperties |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 499 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 500 | classpathFile android.Path |
Colin Cross | e1d62a8 | 2015-04-03 16:53:05 -0700 | [diff] [blame] | 501 | classJarSpecs, resourceJarSpecs []jarSpec |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 502 | } |
| 503 | |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 504 | func (j *JavaPrebuilt) DepsMutator(ctx android.BottomUpMutatorContext) { |
| 505 | } |
| 506 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 507 | func (j *JavaPrebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 508 | if len(j.properties.Srcs) != 1 { |
| 509 | ctx.ModuleErrorf("expected exactly one jar in srcs") |
| 510 | return |
| 511 | } |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 512 | prebuilt := android.PathForModuleSrc(ctx, j.properties.Srcs[0]) |
Colin Cross | e1d62a8 | 2015-04-03 16:53:05 -0700 | [diff] [blame] | 513 | |
| 514 | classJarSpec, resourceJarSpec := TransformPrebuiltJarToClasses(ctx, prebuilt) |
| 515 | |
| 516 | j.classpathFile = prebuilt |
| 517 | j.classJarSpecs = []jarSpec{classJarSpec} |
| 518 | j.resourceJarSpecs = []jarSpec{resourceJarSpec} |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 519 | ctx.InstallFileName(android.PathForModuleInstall(ctx, "framework"), ctx.ModuleName()+".jar", j.classpathFile) |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 520 | } |
| 521 | |
| 522 | var _ JavaDependency = (*JavaPrebuilt)(nil) |
| 523 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 524 | func (j *JavaPrebuilt) ClasspathFile() android.Path { |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 525 | return j.classpathFile |
| 526 | } |
| 527 | |
| 528 | func (j *JavaPrebuilt) ClassJarSpecs() []jarSpec { |
Colin Cross | e1d62a8 | 2015-04-03 16:53:05 -0700 | [diff] [blame] | 529 | return j.classJarSpecs |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 530 | } |
| 531 | |
| 532 | func (j *JavaPrebuilt) ResourceJarSpecs() []jarSpec { |
Colin Cross | e1d62a8 | 2015-04-03 16:53:05 -0700 | [diff] [blame] | 533 | return j.resourceJarSpecs |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 534 | } |
| 535 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 536 | func (j *JavaPrebuilt) AidlIncludeDirs() android.Paths { |
Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 537 | return nil |
| 538 | } |
| 539 | |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 540 | func JavaPrebuiltFactory() (blueprint.Module, []interface{}) { |
| 541 | module := &JavaPrebuilt{} |
| 542 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 543 | return android.InitAndroidArchModule(module, android.HostAndDeviceSupported, |
| 544 | android.MultilibCommon, &module.properties) |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 545 | } |
| 546 | |
Colin Cross | aa8630b | 2015-04-13 13:52:22 -0700 | [diff] [blame] | 547 | // |
| 548 | // SDK java prebuilts (.jar containing resources plus framework.aidl) |
| 549 | // |
| 550 | |
| 551 | type sdkDependency interface { |
| 552 | JavaDependency |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 553 | AidlPreprocessed() android.OptionalPath |
Colin Cross | aa8630b | 2015-04-13 13:52:22 -0700 | [diff] [blame] | 554 | } |
| 555 | |
| 556 | var _ sdkDependency = (*sdkPrebuilt)(nil) |
| 557 | |
Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 558 | type sdkPrebuiltProperties struct { |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 559 | Aidl_preprocessed *string |
Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 560 | } |
| 561 | |
Colin Cross | aa8630b | 2015-04-13 13:52:22 -0700 | [diff] [blame] | 562 | type sdkPrebuilt struct { |
| 563 | JavaPrebuilt |
| 564 | |
Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 565 | sdkProperties sdkPrebuiltProperties |
Colin Cross | aa8630b | 2015-04-13 13:52:22 -0700 | [diff] [blame] | 566 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 567 | aidlPreprocessed android.OptionalPath |
Colin Cross | aa8630b | 2015-04-13 13:52:22 -0700 | [diff] [blame] | 568 | } |
| 569 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 570 | func (j *sdkPrebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Colin Cross | aa8630b | 2015-04-13 13:52:22 -0700 | [diff] [blame] | 571 | j.JavaPrebuilt.GenerateAndroidBuildActions(ctx) |
| 572 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 573 | j.aidlPreprocessed = android.OptionalPathForModuleSrc(ctx, j.sdkProperties.Aidl_preprocessed) |
Colin Cross | aa8630b | 2015-04-13 13:52:22 -0700 | [diff] [blame] | 574 | } |
| 575 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 576 | func (j *sdkPrebuilt) AidlPreprocessed() android.OptionalPath { |
Colin Cross | aa8630b | 2015-04-13 13:52:22 -0700 | [diff] [blame] | 577 | return j.aidlPreprocessed |
| 578 | } |
| 579 | |
| 580 | func SdkPrebuiltFactory() (blueprint.Module, []interface{}) { |
| 581 | module := &sdkPrebuilt{} |
| 582 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 583 | return android.InitAndroidArchModule(module, android.HostAndDeviceSupported, |
| 584 | android.MultilibCommon, &module.properties, &module.sdkProperties) |
Colin Cross | aa8630b | 2015-04-13 13:52:22 -0700 | [diff] [blame] | 585 | } |
| 586 | |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 587 | func inList(s string, l []string) bool { |
| 588 | for _, e := range l { |
| 589 | if e == s { |
| 590 | return true |
| 591 | } |
| 592 | } |
| 593 | return false |
| 594 | } |