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