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