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