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 | be1da47 | 2017-07-07 15:59:46 -0700 | [diff] [blame^] | 150 | type dependencyTag struct { |
| 151 | blueprint.BaseDependencyTag |
| 152 | name string |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 153 | } |
| 154 | |
Colin Cross | be1da47 | 2017-07-07 15:59:46 -0700 | [diff] [blame^] | 155 | var ( |
| 156 | javaStaticLibTag = dependencyTag{name: "staticlib"} |
| 157 | javaLibTag = dependencyTag{name: "javalib"} |
| 158 | bootClasspathTag = dependencyTag{name: "bootclasspath"} |
| 159 | frameworkResTag = dependencyTag{name: "framework-res"} |
| 160 | sdkDependencyTag = dependencyTag{name: "sdk"} |
| 161 | ) |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 162 | |
Colin Cross | be1da47 | 2017-07-07 15:59:46 -0700 | [diff] [blame^] | 163 | func (j *Module) deps(ctx android.BottomUpMutatorContext) { |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 164 | if !j.properties.No_standard_libraries { |
Colin Cross | be1da47 | 2017-07-07 15:59:46 -0700 | [diff] [blame^] | 165 | if ctx.Device() { |
| 166 | switch j.deviceProperties.Sdk_version { |
| 167 | case "": |
| 168 | ctx.AddDependency(ctx.Module(), bootClasspathTag, "core-libart") |
| 169 | case "current": |
| 170 | // TODO: !TARGET_BUILD_APPS |
| 171 | // TODO: export preprocessed framework.aidl from android_stubs_current |
| 172 | ctx.AddDependency(ctx.Module(), bootClasspathTag, "android_stubs_current") |
| 173 | case "system_current": |
| 174 | ctx.AddDependency(ctx.Module(), bootClasspathTag, "android_system_stubs_current") |
| 175 | default: |
| 176 | ctx.AddDependency(ctx.Module(), sdkDependencyTag, "sdk_v"+j.deviceProperties.Sdk_version) |
| 177 | } |
| 178 | } else { |
| 179 | if j.deviceProperties.Dex { |
| 180 | ctx.AddDependency(ctx.Module(), bootClasspathTag, "core-libart") |
| 181 | } |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 182 | } |
Colin Cross | be1da47 | 2017-07-07 15:59:46 -0700 | [diff] [blame^] | 183 | |
Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame] | 184 | if ctx.Device() && j.deviceProperties.Sdk_version == "" { |
Colin Cross | be1da47 | 2017-07-07 15:59:46 -0700 | [diff] [blame^] | 185 | ctx.AddDependency(ctx.Module(), javaLibTag, config.DefaultLibraries...) |
Colin Cross | efb9ebe | 2015-04-16 14:08:06 -0700 | [diff] [blame] | 186 | } |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 187 | } |
Colin Cross | be1da47 | 2017-07-07 15:59:46 -0700 | [diff] [blame^] | 188 | ctx.AddDependency(ctx.Module(), javaLibTag, j.properties.Java_libs...) |
| 189 | ctx.AddDependency(ctx.Module(), javaStaticLibTag, j.properties.Java_static_libs...) |
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()) |
Colin Cross | d48633a | 2017-07-13 14:41:17 -0700 | [diff] [blame] | 207 | if src := android.ExistentPathForSource(ctx, "", "src"); src.Valid() { |
| 208 | flags = append(flags, "-I"+src.String()) |
| 209 | } |
Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 210 | |
Colin Cross | f03c82b | 2015-04-13 13:53:40 -0700 | [diff] [blame] | 211 | return flags |
Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 212 | } |
| 213 | |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 214 | func (j *Module) collectDeps(ctx android.ModuleContext) (classpath android.Paths, |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 215 | bootClasspath android.OptionalPath, classJarSpecs, resourceJarSpecs []jarSpec, aidlPreprocess android.OptionalPath, |
| 216 | aidlIncludeDirs android.Paths, srcFileLists android.Paths) { |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 217 | |
| 218 | ctx.VisitDirectDeps(func(module blueprint.Module) { |
| 219 | otherName := ctx.OtherModuleName(module) |
Colin Cross | ec7a042 | 2017-07-07 14:47:12 -0700 | [diff] [blame] | 220 | tag := ctx.OtherModuleDependencyTag(module) |
| 221 | |
| 222 | javaDep, _ := module.(JavaDependency) |
| 223 | if javaDep == nil { |
| 224 | switch tag { |
| 225 | case android.DefaultsDepTag, android.SourceDepTag: |
| 226 | default: |
| 227 | ctx.ModuleErrorf("depends on non-java module %q", otherName) |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 228 | } |
Colin Cross | ec7a042 | 2017-07-07 14:47:12 -0700 | [diff] [blame] | 229 | return |
| 230 | } |
| 231 | |
Colin Cross | be1da47 | 2017-07-07 15:59:46 -0700 | [diff] [blame^] | 232 | switch tag { |
| 233 | case bootClasspathTag: |
Colin Cross | ec7a042 | 2017-07-07 14:47:12 -0700 | [diff] [blame] | 234 | bootClasspath = android.OptionalPathForPath(javaDep.ClasspathFile()) |
Colin Cross | be1da47 | 2017-07-07 15:59:46 -0700 | [diff] [blame^] | 235 | case javaLibTag: |
Colin Cross | ec7a042 | 2017-07-07 14:47:12 -0700 | [diff] [blame] | 236 | classpath = append(classpath, javaDep.ClasspathFile()) |
Colin Cross | be1da47 | 2017-07-07 15:59:46 -0700 | [diff] [blame^] | 237 | case javaStaticLibTag: |
Colin Cross | ec7a042 | 2017-07-07 14:47:12 -0700 | [diff] [blame] | 238 | classpath = append(classpath, javaDep.ClasspathFile()) |
| 239 | classJarSpecs = append(classJarSpecs, javaDep.ClassJarSpecs()...) |
| 240 | resourceJarSpecs = append(resourceJarSpecs, javaDep.ResourceJarSpecs()...) |
Colin Cross | be1da47 | 2017-07-07 15:59:46 -0700 | [diff] [blame^] | 241 | case frameworkResTag: |
Colin Cross | ec7a042 | 2017-07-07 14:47:12 -0700 | [diff] [blame] | 242 | if ctx.ModuleName() == "framework" { |
| 243 | // framework.jar has a one-off dependency on the R.java and Manifest.java files |
| 244 | // generated by framework-res.apk |
| 245 | srcFileLists = append(srcFileLists, module.(*AndroidApp).aaptJavaFileList) |
| 246 | } |
Colin Cross | be1da47 | 2017-07-07 15:59:46 -0700 | [diff] [blame^] | 247 | case sdkDependencyTag: |
| 248 | sdkDep := module.(sdkDependency) |
Colin Cross | ec7a042 | 2017-07-07 14:47:12 -0700 | [diff] [blame] | 249 | if sdkDep.AidlPreprocessed().Valid() { |
| 250 | if aidlPreprocess.Valid() { |
| 251 | ctx.ModuleErrorf("multiple dependencies with preprocessed aidls:\n %q\n %q", |
| 252 | aidlPreprocess, sdkDep.AidlPreprocessed()) |
| 253 | } else { |
| 254 | aidlPreprocess = sdkDep.AidlPreprocessed() |
Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 255 | } |
| 256 | } |
Colin Cross | be1da47 | 2017-07-07 15:59:46 -0700 | [diff] [blame^] | 257 | default: |
| 258 | panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName())) |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 259 | } |
Colin Cross | be1da47 | 2017-07-07 15:59:46 -0700 | [diff] [blame^] | 260 | |
| 261 | aidlIncludeDirs = append(aidlIncludeDirs, javaDep.AidlIncludeDirs()...) |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 262 | }) |
| 263 | |
Colin Cross | e7a9f3f | 2015-04-13 14:02:52 -0700 | [diff] [blame] | 264 | return classpath, bootClasspath, classJarSpecs, resourceJarSpecs, aidlPreprocess, |
| 265 | aidlIncludeDirs, srcFileLists |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 266 | } |
| 267 | |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 268 | func (j *Module) compile(ctx android.ModuleContext) { |
Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 269 | |
Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame] | 270 | j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.deviceProperties.Export_aidl_include_dirs) |
Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 271 | |
| 272 | classpath, bootClasspath, classJarSpecs, resourceJarSpecs, aidlPreprocess, |
Colin Cross | e7a9f3f | 2015-04-13 14:02:52 -0700 | [diff] [blame] | 273 | aidlIncludeDirs, srcFileLists := j.collectDeps(ctx) |
Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 274 | |
Colin Cross | f03c82b | 2015-04-13 13:53:40 -0700 | [diff] [blame] | 275 | var flags javaBuilderFlags |
| 276 | |
| 277 | javacFlags := j.properties.Javacflags |
| 278 | if len(javacFlags) > 0 { |
| 279 | ctx.Variable(pctx, "javacFlags", strings.Join(javacFlags, " ")) |
| 280 | flags.javacFlags = "$javacFlags" |
| 281 | } |
| 282 | |
| 283 | aidlFlags := j.aidlFlags(ctx, aidlPreprocess, aidlIncludeDirs) |
| 284 | if len(aidlFlags) > 0 { |
| 285 | ctx.Variable(pctx, "aidlFlags", strings.Join(aidlFlags, " ")) |
| 286 | flags.aidlFlags = "$aidlFlags" |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 287 | } |
| 288 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 289 | var javacDeps android.Paths |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 290 | |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 291 | if bootClasspath.Valid() { |
| 292 | flags.bootClasspath = "-bootclasspath " + bootClasspath.String() |
| 293 | javacDeps = append(javacDeps, bootClasspath.Path()) |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 294 | } |
| 295 | |
| 296 | if len(classpath) > 0 { |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 297 | flags.classpath = "-classpath " + strings.Join(classpath.Strings(), ":") |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 298 | javacDeps = append(javacDeps, classpath...) |
| 299 | } |
| 300 | |
Dan Willemsen | 2ef08f4 | 2015-06-30 18:15:24 -0700 | [diff] [blame] | 301 | srcFiles := ctx.ExpandSources(j.properties.Srcs, j.properties.Exclude_srcs) |
Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 302 | |
Colin Cross | f05fe97 | 2015-04-10 17:45:20 -0700 | [diff] [blame] | 303 | srcFiles = j.genSources(ctx, srcFiles, flags) |
Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 304 | |
Colin Cross | 0607cf7 | 2015-04-28 13:28:51 -0700 | [diff] [blame] | 305 | ctx.VisitDirectDeps(func(module blueprint.Module) { |
| 306 | if gen, ok := module.(genrule.SourceFileGenerator); ok { |
| 307 | srcFiles = append(srcFiles, gen.GeneratedSourceFiles()...) |
| 308 | } |
| 309 | }) |
| 310 | |
Colin Cross | b7a6324 | 2015-04-16 14:09:14 -0700 | [diff] [blame] | 311 | srcFileLists = append(srcFileLists, j.ExtraSrcLists...) |
| 312 | |
Colin Cross | 8cf1334 | 2015-04-10 15:41:49 -0700 | [diff] [blame] | 313 | if len(srcFiles) > 0 { |
| 314 | // Compile java sources into .class files |
Colin Cross | e7a9f3f | 2015-04-13 14:02:52 -0700 | [diff] [blame] | 315 | classes := TransformJavaToClasses(ctx, srcFiles, srcFileLists, flags, javacDeps) |
Colin Cross | 8cf1334 | 2015-04-10 15:41:49 -0700 | [diff] [blame] | 316 | if ctx.Failed() { |
| 317 | return |
| 318 | } |
| 319 | |
| 320 | classJarSpecs = append([]jarSpec{classes}, classJarSpecs...) |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 321 | } |
| 322 | |
Dan Willemsen | 2ef08f4 | 2015-06-30 18:15:24 -0700 | [diff] [blame] | 323 | 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] | 324 | resourceJarSpecs...) |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 325 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 326 | manifest := android.OptionalPathForModuleSrc(ctx, j.properties.Manifest) |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 327 | |
| 328 | allJarSpecs := append([]jarSpec(nil), classJarSpecs...) |
| 329 | allJarSpecs = append(allJarSpecs, resourceJarSpecs...) |
| 330 | |
| 331 | // Combine classes + resources into classes-full-debug.jar |
| 332 | outputFile := TransformClassesToJar(ctx, allJarSpecs, manifest) |
| 333 | if ctx.Failed() { |
| 334 | return |
| 335 | } |
Colin Cross | 65bf4f2 | 2015-04-03 16:54:17 -0700 | [diff] [blame] | 336 | |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 337 | if j.properties.Jarjar_rules != nil { |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 338 | jarjar_rules := android.PathForModuleSrc(ctx, *j.properties.Jarjar_rules) |
Colin Cross | 65bf4f2 | 2015-04-03 16:54:17 -0700 | [diff] [blame] | 339 | // Transform classes-full-debug.jar into classes-jarjar.jar |
| 340 | outputFile = TransformJarJar(ctx, outputFile, jarjar_rules) |
| 341 | if ctx.Failed() { |
| 342 | return |
| 343 | } |
Colin Cross | 2097830 | 2015-04-10 17:05:07 -0700 | [diff] [blame] | 344 | |
| 345 | classes, _ := TransformPrebuiltJarToClasses(ctx, outputFile) |
| 346 | classJarSpecs = []jarSpec{classes} |
Colin Cross | 65bf4f2 | 2015-04-03 16:54:17 -0700 | [diff] [blame] | 347 | } |
| 348 | |
Colin Cross | 2097830 | 2015-04-10 17:05:07 -0700 | [diff] [blame] | 349 | j.resourceJarSpecs = resourceJarSpecs |
| 350 | j.classJarSpecs = classJarSpecs |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 351 | j.classpathFile = outputFile |
| 352 | |
Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame] | 353 | if j.deviceProperties.Dex && len(srcFiles) > 0 { |
| 354 | dxFlags := j.deviceProperties.Dxflags |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 355 | if false /* emma enabled */ { |
| 356 | // If you instrument class files that have local variable debug information in |
| 357 | // them emma does not correctly maintain the local variable table. |
| 358 | // This will cause an error when you try to convert the class files for Android. |
| 359 | // The workaround here is to build different dex file here based on emma switch |
| 360 | // then later copy into classes.dex. When emma is on, dx is run with --no-locals |
| 361 | // option to remove local variable information |
| 362 | dxFlags = append(dxFlags, "--no-locals") |
| 363 | } |
| 364 | |
Colin Cross | 1332b00 | 2015-04-07 17:11:30 -0700 | [diff] [blame] | 365 | if ctx.AConfig().Getenv("NO_OPTIMIZE_DX") != "" { |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 366 | dxFlags = append(dxFlags, "--no-optimize") |
| 367 | } |
| 368 | |
Colin Cross | 1332b00 | 2015-04-07 17:11:30 -0700 | [diff] [blame] | 369 | if ctx.AConfig().Getenv("GENERATE_DEX_DEBUG") != "" { |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 370 | dxFlags = append(dxFlags, |
| 371 | "--debug", |
| 372 | "--verbose", |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 373 | "--dump-to="+android.PathForModuleOut(ctx, "classes.lst").String(), |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 374 | "--dump-width=1000") |
| 375 | } |
| 376 | |
| 377 | flags.dxFlags = strings.Join(dxFlags, " ") |
| 378 | |
| 379 | // Compile classes.jar into classes.dex |
Colin Cross | 6d1e72d | 2015-04-10 17:44:24 -0700 | [diff] [blame] | 380 | dexJarSpec := TransformClassesJarToDex(ctx, outputFile, flags) |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 381 | if ctx.Failed() { |
| 382 | return |
| 383 | } |
| 384 | |
| 385 | // Combine classes.dex + resources into javalib.jar |
Colin Cross | 6d1e72d | 2015-04-10 17:44:24 -0700 | [diff] [blame] | 386 | outputFile = TransformDexToJavaLib(ctx, resourceJarSpecs, dexJarSpec) |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 387 | } |
Colin Cross | b7a6324 | 2015-04-16 14:09:14 -0700 | [diff] [blame] | 388 | ctx.CheckbuildFile(outputFile) |
| 389 | j.outputFile = outputFile |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 390 | } |
| 391 | |
| 392 | var _ JavaDependency = (*JavaLibrary)(nil) |
| 393 | |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 394 | func (j *Module) ClasspathFile() android.Path { |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 395 | return j.classpathFile |
| 396 | } |
| 397 | |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 398 | func (j *Module) ClassJarSpecs() []jarSpec { |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 399 | return j.classJarSpecs |
| 400 | } |
| 401 | |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 402 | func (j *Module) ResourceJarSpecs() []jarSpec { |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 403 | return j.resourceJarSpecs |
| 404 | } |
| 405 | |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 406 | func (j *Module) AidlIncludeDirs() android.Paths { |
Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 407 | return j.exportAidlIncludeDirs |
| 408 | } |
| 409 | |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 410 | var _ logtagsProducer = (*Module)(nil) |
Colin Cross | f05fe97 | 2015-04-10 17:45:20 -0700 | [diff] [blame] | 411 | |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 412 | func (j *Module) logtags() android.Paths { |
Colin Cross | f05fe97 | 2015-04-10 17:45:20 -0700 | [diff] [blame] | 413 | return j.logtagsSrcs |
| 414 | } |
| 415 | |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 416 | // |
| 417 | // Java libraries (.jar file) |
| 418 | // |
| 419 | |
| 420 | type JavaLibrary struct { |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 421 | Module |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 422 | } |
| 423 | |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 424 | func (j *JavaLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
| 425 | j.compile(ctx) |
Colin Cross | b7a6324 | 2015-04-16 14:09:14 -0700 | [diff] [blame] | 426 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 427 | 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] | 428 | } |
| 429 | |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 430 | func (j *JavaLibrary) DepsMutator(ctx android.BottomUpMutatorContext) { |
| 431 | j.deps(ctx) |
| 432 | } |
| 433 | |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 434 | func JavaLibraryFactory() android.Module { |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 435 | module := &JavaLibrary{} |
| 436 | |
Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame] | 437 | module.deviceProperties.Dex = true |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 438 | |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 439 | module.AddProperties( |
Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame] | 440 | &module.Module.properties, |
| 441 | &module.Module.deviceProperties) |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 442 | |
| 443 | android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon) |
| 444 | return module |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 445 | } |
| 446 | |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 447 | func JavaLibraryHostFactory() android.Module { |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 448 | module := &JavaLibrary{} |
| 449 | |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 450 | module.AddProperties(&module.Module.properties) |
| 451 | |
| 452 | android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon) |
| 453 | return module |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 454 | } |
| 455 | |
| 456 | // |
| 457 | // Java Binaries (.jar file plus wrapper script) |
| 458 | // |
| 459 | |
Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 460 | type javaBinaryProperties struct { |
| 461 | // installable script to execute the resulting jar |
| 462 | Wrapper string |
| 463 | } |
| 464 | |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 465 | type JavaBinary struct { |
| 466 | JavaLibrary |
| 467 | |
Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 468 | binaryProperties javaBinaryProperties |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 469 | } |
| 470 | |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 471 | func (j *JavaBinary) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
| 472 | j.JavaLibrary.GenerateAndroidBuildActions(ctx) |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 473 | |
| 474 | // Depend on the installed jar (j.installFile) so that the wrapper doesn't get executed by |
| 475 | // another build rule before the jar has been installed. |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 476 | ctx.InstallFile(android.PathForModuleInstall(ctx, "bin"), android.PathForModuleSrc(ctx, j.binaryProperties.Wrapper), |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 477 | j.installFile) |
| 478 | } |
| 479 | |
Colin Cross | 46c9b8b | 2017-06-22 16:51:17 -0700 | [diff] [blame] | 480 | func (j *JavaBinary) DepsMutator(ctx android.BottomUpMutatorContext) { |
| 481 | j.deps(ctx) |
| 482 | } |
| 483 | |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 484 | func JavaBinaryFactory() android.Module { |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 485 | module := &JavaBinary{} |
| 486 | |
Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame] | 487 | module.deviceProperties.Dex = true |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 488 | |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 489 | module.AddProperties( |
Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame] | 490 | &module.Module.properties, |
| 491 | &module.Module.deviceProperties, |
| 492 | &module.binaryProperties) |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 493 | |
| 494 | android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon) |
| 495 | return module |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 496 | } |
| 497 | |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 498 | func JavaBinaryHostFactory() android.Module { |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 499 | module := &JavaBinary{} |
| 500 | |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 501 | module.AddProperties( |
Colin Cross | 540eff8 | 2017-06-22 17:01:52 -0700 | [diff] [blame] | 502 | &module.Module.properties, |
| 503 | &module.Module.deviceProperties, |
| 504 | &module.binaryProperties) |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 505 | |
| 506 | android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon) |
| 507 | return module |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 508 | } |
| 509 | |
| 510 | // |
| 511 | // Java prebuilts |
| 512 | // |
| 513 | |
| 514 | type JavaPrebuilt struct { |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 515 | android.ModuleBase |
Colin Cross | ec7a042 | 2017-07-07 14:47:12 -0700 | [diff] [blame] | 516 | prebuilt android.Prebuilt |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 517 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 518 | classpathFile android.Path |
Colin Cross | e1d62a8 | 2015-04-03 16:53:05 -0700 | [diff] [blame] | 519 | classJarSpecs, resourceJarSpecs []jarSpec |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 520 | } |
| 521 | |
Colin Cross | ec7a042 | 2017-07-07 14:47:12 -0700 | [diff] [blame] | 522 | func (j *JavaPrebuilt) Prebuilt() *android.Prebuilt { |
| 523 | return &j.prebuilt |
| 524 | } |
| 525 | |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 526 | func (j *JavaPrebuilt) DepsMutator(ctx android.BottomUpMutatorContext) { |
| 527 | } |
| 528 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 529 | func (j *JavaPrebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Colin Cross | be1da47 | 2017-07-07 15:59:46 -0700 | [diff] [blame^] | 530 | prebuilt := j.prebuilt.Path(ctx) |
Colin Cross | e1d62a8 | 2015-04-03 16:53:05 -0700 | [diff] [blame] | 531 | |
| 532 | classJarSpec, resourceJarSpec := TransformPrebuiltJarToClasses(ctx, prebuilt) |
| 533 | |
| 534 | j.classpathFile = prebuilt |
| 535 | j.classJarSpecs = []jarSpec{classJarSpec} |
| 536 | j.resourceJarSpecs = []jarSpec{resourceJarSpec} |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 537 | ctx.InstallFileName(android.PathForModuleInstall(ctx, "framework"), ctx.ModuleName()+".jar", j.classpathFile) |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 538 | } |
| 539 | |
| 540 | var _ JavaDependency = (*JavaPrebuilt)(nil) |
| 541 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 542 | func (j *JavaPrebuilt) ClasspathFile() android.Path { |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 543 | return j.classpathFile |
| 544 | } |
| 545 | |
| 546 | func (j *JavaPrebuilt) ClassJarSpecs() []jarSpec { |
Colin Cross | e1d62a8 | 2015-04-03 16:53:05 -0700 | [diff] [blame] | 547 | return j.classJarSpecs |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 548 | } |
| 549 | |
| 550 | func (j *JavaPrebuilt) ResourceJarSpecs() []jarSpec { |
Colin Cross | e1d62a8 | 2015-04-03 16:53:05 -0700 | [diff] [blame] | 551 | return j.resourceJarSpecs |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 552 | } |
| 553 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 554 | func (j *JavaPrebuilt) AidlIncludeDirs() android.Paths { |
Colin Cross | c0b06f1 | 2015-04-08 13:03:43 -0700 | [diff] [blame] | 555 | return nil |
| 556 | } |
| 557 | |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 558 | func JavaPrebuiltFactory() android.Module { |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 559 | module := &JavaPrebuilt{} |
| 560 | |
Colin Cross | be1da47 | 2017-07-07 15:59:46 -0700 | [diff] [blame^] | 561 | module.AddProperties(&module.prebuilt.Properties) |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 562 | |
| 563 | android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon) |
| 564 | return module |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 565 | } |
| 566 | |
Colin Cross | aa8630b | 2015-04-13 13:52:22 -0700 | [diff] [blame] | 567 | // |
| 568 | // SDK java prebuilts (.jar containing resources plus framework.aidl) |
| 569 | // |
| 570 | |
| 571 | type sdkDependency interface { |
| 572 | JavaDependency |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 573 | AidlPreprocessed() android.OptionalPath |
Colin Cross | aa8630b | 2015-04-13 13:52:22 -0700 | [diff] [blame] | 574 | } |
| 575 | |
| 576 | var _ sdkDependency = (*sdkPrebuilt)(nil) |
| 577 | |
Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 578 | type sdkPrebuiltProperties struct { |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 579 | Aidl_preprocessed *string |
Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 580 | } |
| 581 | |
Colin Cross | aa8630b | 2015-04-13 13:52:22 -0700 | [diff] [blame] | 582 | type sdkPrebuilt struct { |
| 583 | JavaPrebuilt |
| 584 | |
Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 585 | sdkProperties sdkPrebuiltProperties |
Colin Cross | aa8630b | 2015-04-13 13:52:22 -0700 | [diff] [blame] | 586 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 587 | aidlPreprocessed android.OptionalPath |
Colin Cross | aa8630b | 2015-04-13 13:52:22 -0700 | [diff] [blame] | 588 | } |
| 589 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 590 | func (j *sdkPrebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Colin Cross | aa8630b | 2015-04-13 13:52:22 -0700 | [diff] [blame] | 591 | j.JavaPrebuilt.GenerateAndroidBuildActions(ctx) |
| 592 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 593 | j.aidlPreprocessed = android.OptionalPathForModuleSrc(ctx, j.sdkProperties.Aidl_preprocessed) |
Colin Cross | aa8630b | 2015-04-13 13:52:22 -0700 | [diff] [blame] | 594 | } |
| 595 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 596 | func (j *sdkPrebuilt) AidlPreprocessed() android.OptionalPath { |
Colin Cross | aa8630b | 2015-04-13 13:52:22 -0700 | [diff] [blame] | 597 | return j.aidlPreprocessed |
| 598 | } |
| 599 | |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 600 | func SdkPrebuiltFactory() android.Module { |
Colin Cross | aa8630b | 2015-04-13 13:52:22 -0700 | [diff] [blame] | 601 | module := &sdkPrebuilt{} |
| 602 | |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 603 | module.AddProperties( |
Colin Cross | be1da47 | 2017-07-07 15:59:46 -0700 | [diff] [blame^] | 604 | &module.prebuilt.Properties, |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 605 | &module.sdkProperties) |
| 606 | |
| 607 | android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon) |
| 608 | return module |
Colin Cross | aa8630b | 2015-04-13 13:52:22 -0700 | [diff] [blame] | 609 | } |
| 610 | |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 611 | func inList(s string, l []string) bool { |
| 612 | for _, e := range l { |
| 613 | if e == s { |
| 614 | return true |
| 615 | } |
| 616 | } |
| 617 | return false |
| 618 | } |