| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 1 | // Copyright 2018 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 | import ( | 
|  | 18 | "android/soong/android" | 
|  | 19 | "android/soong/java/config" | 
|  | 20 | "fmt" | 
| Nan Zhang | b2b33de | 2018-02-23 11:18:47 -0800 | [diff] [blame] | 21 | "path/filepath" | 
| Nan Zhang | 4613097 | 2018-06-04 11:28:01 -0700 | [diff] [blame] | 22 | "runtime" | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 23 | "strings" | 
|  | 24 |  | 
|  | 25 | "github.com/google/blueprint" | 
|  | 26 | ) | 
|  | 27 |  | 
|  | 28 | var ( | 
|  | 29 | javadoc = pctx.AndroidStaticRule("javadoc", | 
|  | 30 | blueprint.RuleParams{ | 
|  | 31 | Command: `rm -rf "$outDir" "$srcJarDir" "$stubsDir" && mkdir -p "$outDir" "$srcJarDir" "$stubsDir" && ` + | 
| Colin Cross | 436b765 | 2018-03-15 16:24:10 -0700 | [diff] [blame] | 32 | `${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` + | 
| Nan Zhang | af322cc | 2018-06-19 15:15:38 -0700 | [diff] [blame] | 33 | `${config.JavadocCmd} -encoding UTF-8 @$out.rsp @$srcJarDir/list ` + | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 34 | `$opts $bootclasspathArgs $classpathArgs $sourcepathArgs ` + | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 35 | `-d $outDir -quiet  && ` + | 
|  | 36 | `${config.SoongZipCmd} -write_if_changed -d -o $docZip -C $outDir -D $outDir && ` + | 
| Nan Zhang | e2ba5d4 | 2018-07-11 15:16:55 -0700 | [diff] [blame] | 37 | `${config.SoongZipCmd} -write_if_changed -jar -o $out -C $stubsDir -D $stubsDir $postDoclavaCmds`, | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 38 | CommandDeps: []string{ | 
| Colin Cross | 436b765 | 2018-03-15 16:24:10 -0700 | [diff] [blame] | 39 | "${config.ZipSyncCmd}", | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 40 | "${config.JavadocCmd}", | 
|  | 41 | "${config.SoongZipCmd}", | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 42 | }, | 
|  | 43 | Rspfile:        "$out.rsp", | 
|  | 44 | RspfileContent: "$in", | 
|  | 45 | Restat:         true, | 
|  | 46 | }, | 
| Nan Zhang | af322cc | 2018-06-19 15:15:38 -0700 | [diff] [blame] | 47 | "outDir", "srcJarDir", "stubsDir", "srcJars", "opts", | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 48 | "bootclasspathArgs", "classpathArgs", "sourcepathArgs", "docZip", "postDoclavaCmds") | 
| Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 49 |  | 
|  | 50 | apiCheck = pctx.AndroidStaticRule("apiCheck", | 
|  | 51 | blueprint.RuleParams{ | 
|  | 52 | Command: `( ${config.ApiCheckCmd} -JXmx1024m -J"classpath $classpath" $opts ` + | 
|  | 53 | `$apiFile $apiFileToCheck $removedApiFile $removedApiFileToCheck ` + | 
| Jiyong Park | eeb8a64 | 2018-05-12 22:21:20 +0900 | [diff] [blame] | 54 | `&& touch $out ) || (echo -e "$msg" ; exit 38)`, | 
| Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 55 | CommandDeps: []string{ | 
|  | 56 | "${config.ApiCheckCmd}", | 
|  | 57 | }, | 
|  | 58 | }, | 
|  | 59 | "classpath", "opts", "apiFile", "apiFileToCheck", "removedApiFile", "removedApiFileToCheck", "msg") | 
|  | 60 |  | 
|  | 61 | updateApi = pctx.AndroidStaticRule("updateApi", | 
|  | 62 | blueprint.RuleParams{ | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 63 | Command: `( ( cp -f $srcApiFile $destApiFile && cp -f $srcRemovedApiFile $destRemovedApiFile ) ` + | 
| Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 64 | `&& touch $out ) || (echo failed to update public API ; exit 38)`, | 
|  | 65 | }, | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 66 | "srcApiFile", "destApiFile", "srcRemovedApiFile", "destRemovedApiFile") | 
| Nan Zhang | 79614d1 | 2018-04-19 18:03:39 -0700 | [diff] [blame] | 67 |  | 
|  | 68 | metalava = pctx.AndroidStaticRule("metalava", | 
|  | 69 | blueprint.RuleParams{ | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 70 | Command: `rm -rf "$outDir" "$srcJarDir" "$stubsDir" && ` + | 
|  | 71 | `mkdir -p "$outDir" "$srcJarDir" "$stubsDir" && ` + | 
| Nan Zhang | 79614d1 | 2018-04-19 18:03:39 -0700 | [diff] [blame] | 72 | `${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` + | 
| Nan Zhang | 357466b | 2018-04-17 17:38:36 -0700 | [diff] [blame] | 73 | `${config.JavaCmd} -jar ${config.MetalavaJar} -encoding UTF-8 -source $javaVersion @$out.rsp @$srcJarDir/list ` + | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 74 | `$bootclasspathArgs $classpathArgs $sourcepathArgs --no-banner --color --quiet ` + | 
|  | 75 | `$opts && ` + | 
| Nan Zhang | 79614d1 | 2018-04-19 18:03:39 -0700 | [diff] [blame] | 76 | `${config.SoongZipCmd} -write_if_changed -jar -o $out -C $stubsDir -D $stubsDir`, | 
|  | 77 | CommandDeps: []string{ | 
|  | 78 | "${config.ZipSyncCmd}", | 
|  | 79 | "${config.JavaCmd}", | 
|  | 80 | "${config.MetalavaJar}", | 
| Nan Zhang | 79614d1 | 2018-04-19 18:03:39 -0700 | [diff] [blame] | 81 | "${config.SoongZipCmd}", | 
|  | 82 | }, | 
|  | 83 | Rspfile:        "$out.rsp", | 
|  | 84 | RspfileContent: "$in", | 
|  | 85 | Restat:         true, | 
|  | 86 | }, | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 87 | "outDir", "srcJarDir", "stubsDir", "srcJars", "javaVersion", "bootclasspathArgs", | 
|  | 88 | "classpathArgs", "sourcepathArgs", "opts") | 
| Nan Zhang | 2760dfc | 2018-08-24 17:32:54 +0000 | [diff] [blame] | 89 |  | 
|  | 90 | metalavaApiCheck = pctx.AndroidStaticRule("metalavaApiCheck", | 
|  | 91 | blueprint.RuleParams{ | 
|  | 92 | Command: `( rm -rf "$srcJarDir" && mkdir -p "$srcJarDir" && ` + | 
|  | 93 | `${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` + | 
|  | 94 | `${config.JavaCmd} -jar ${config.MetalavaJar} -encoding UTF-8 -source $javaVersion @$out.rsp @$srcJarDir/list ` + | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 95 | `$bootclasspathArgs $classpathArgs $sourcepathArgs --no-banner --color --quiet ` + | 
| Nan Zhang | 2760dfc | 2018-08-24 17:32:54 +0000 | [diff] [blame] | 96 | `$opts && touch $out ) || ` + | 
|  | 97 | `( echo -e "$msg" ; exit 38 )`, | 
|  | 98 | CommandDeps: []string{ | 
|  | 99 | "${config.ZipSyncCmd}", | 
|  | 100 | "${config.JavaCmd}", | 
|  | 101 | "${config.MetalavaJar}", | 
|  | 102 | }, | 
|  | 103 | Rspfile:        "$out.rsp", | 
|  | 104 | RspfileContent: "$in", | 
|  | 105 | }, | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 106 | "srcJarDir", "srcJars", "javaVersion", "bootclasspathArgs", "classpathArgs", "sourcepathArgs", "opts", "msg") | 
|  | 107 |  | 
|  | 108 | dokka = pctx.AndroidStaticRule("dokka", | 
|  | 109 | blueprint.RuleParams{ | 
|  | 110 | Command: `rm -rf "$outDir" "$srcJarDir" "$stubsDir" && ` + | 
|  | 111 | `mkdir -p "$outDir" "$srcJarDir" "$stubsDir" && ` + | 
|  | 112 | `${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` + | 
|  | 113 | `${config.JavaCmd} -jar ${config.DokkaJar} $srcJarDir ` + | 
|  | 114 | `$classpathArgs -format dac -dacRoot /reference/kotlin -output $outDir $opts && ` + | 
|  | 115 | `${config.SoongZipCmd} -write_if_changed -d -o $docZip -C $outDir -D $outDir && ` + | 
|  | 116 | `${config.SoongZipCmd} -write_if_changed -jar -o $out -C $stubsDir -D $stubsDir`, | 
|  | 117 | CommandDeps: []string{ | 
|  | 118 | "${config.ZipSyncCmd}", | 
|  | 119 | "${config.DokkaJar}", | 
|  | 120 | "${config.MetalavaJar}", | 
|  | 121 | "${config.SoongZipCmd}", | 
|  | 122 | }, | 
|  | 123 | Restat: true, | 
|  | 124 | }, | 
|  | 125 | "outDir", "srcJarDir", "stubsDir", "srcJars", "classpathArgs", "opts", "docZip") | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 126 | ) | 
|  | 127 |  | 
|  | 128 | func init() { | 
| Nan Zhang | b2b33de | 2018-02-23 11:18:47 -0800 | [diff] [blame] | 129 | android.RegisterModuleType("doc_defaults", DocDefaultsFactory) | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 130 | android.RegisterModuleType("stubs_defaults", StubsDefaultsFactory) | 
| Nan Zhang | b2b33de | 2018-02-23 11:18:47 -0800 | [diff] [blame] | 131 |  | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 132 | android.RegisterModuleType("droiddoc", DroiddocFactory) | 
|  | 133 | android.RegisterModuleType("droiddoc_host", DroiddocHostFactory) | 
| Nan Zhang | f4936b0 | 2018-08-01 15:00:28 -0700 | [diff] [blame] | 134 | android.RegisterModuleType("droiddoc_exported_dir", ExportedDroiddocDirFactory) | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 135 | android.RegisterModuleType("javadoc", JavadocFactory) | 
|  | 136 | android.RegisterModuleType("javadoc_host", JavadocHostFactory) | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 137 |  | 
|  | 138 | android.RegisterModuleType("droidstubs", DroidstubsFactory) | 
|  | 139 | android.RegisterModuleType("droidstubs_host", DroidstubsHostFactory) | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 140 | } | 
|  | 141 |  | 
| Colin Cross | a1ce2a0 | 2018-06-20 15:19:39 -0700 | [diff] [blame] | 142 | var ( | 
|  | 143 | srcsLibTag = dependencyTag{name: "sources from javalib"} | 
|  | 144 | ) | 
|  | 145 |  | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 146 | type JavadocProperties struct { | 
|  | 147 | // list of source files used to compile the Java module.  May be .java, .logtags, .proto, | 
|  | 148 | // or .aidl files. | 
|  | 149 | Srcs []string `android:"arch_variant"` | 
|  | 150 |  | 
|  | 151 | // list of directories rooted at the Android.bp file that will | 
|  | 152 | // be added to the search paths for finding source files when passing package names. | 
| Nan Zhang | b2b33de | 2018-02-23 11:18:47 -0800 | [diff] [blame] | 153 | Local_sourcepaths []string | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 154 |  | 
|  | 155 | // list of source files that should not be used to build the Java module. | 
|  | 156 | // This is most useful in the arch/multilib variants to remove non-common files | 
|  | 157 | // filegroup or genrule can be included within this property. | 
|  | 158 | Exclude_srcs []string `android:"arch_variant"` | 
|  | 159 |  | 
| Nan Zhang | b2b33de | 2018-02-23 11:18:47 -0800 | [diff] [blame] | 160 | // list of java libraries that will be in the classpath. | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 161 | Libs []string `android:"arch_variant"` | 
|  | 162 |  | 
| Nan Zhang | e66c727 | 2018-03-06 12:59:27 -0800 | [diff] [blame] | 163 | // don't build against the framework libraries (legacy-test, core-junit, | 
|  | 164 | // ext, and framework for device targets) | 
|  | 165 | No_framework_libs *bool | 
|  | 166 |  | 
| Nan Zhang | b2b33de | 2018-02-23 11:18:47 -0800 | [diff] [blame] | 167 | // the java library (in classpath) for documentation that provides java srcs and srcjars. | 
|  | 168 | Srcs_lib *string | 
|  | 169 |  | 
|  | 170 | // the base dirs under srcs_lib will be scanned for java srcs. | 
|  | 171 | Srcs_lib_whitelist_dirs []string | 
|  | 172 |  | 
|  | 173 | // the sub dirs under srcs_lib_whitelist_dirs will be scanned for java srcs. | 
|  | 174 | Srcs_lib_whitelist_pkgs []string | 
|  | 175 |  | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 176 | // If set to false, don't allow this module(-docs.zip) to be exported. Defaults to true. | 
| Nan Zhang | b2b33de | 2018-02-23 11:18:47 -0800 | [diff] [blame] | 177 | Installable *bool | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 178 |  | 
|  | 179 | // if not blank, set to the version of the sdk to compile against | 
|  | 180 | Sdk_version *string `android:"arch_variant"` | 
| Jiyong Park | 1e44068 | 2018-05-23 18:42:04 +0900 | [diff] [blame] | 181 |  | 
|  | 182 | Aidl struct { | 
|  | 183 | // Top level directories to pass to aidl tool | 
|  | 184 | Include_dirs []string | 
|  | 185 |  | 
|  | 186 | // Directories rooted at the Android.bp file to pass to aidl tool | 
|  | 187 | Local_include_dirs []string | 
|  | 188 | } | 
| Nan Zhang | 357466b | 2018-04-17 17:38:36 -0700 | [diff] [blame] | 189 |  | 
|  | 190 | // If not blank, set the java version passed to javadoc as -source | 
|  | 191 | Java_version *string | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 192 |  | 
|  | 193 | // local files that are used within user customized droiddoc options. | 
|  | 194 | Arg_files []string | 
|  | 195 |  | 
|  | 196 | // user customized droiddoc args. | 
|  | 197 | // Available variables for substitution: | 
|  | 198 | // | 
|  | 199 | //  $(location <label>): the path to the arg_files with name <label> | 
|  | 200 | Args *string | 
|  | 201 |  | 
|  | 202 | // names of the output files used in args that will be generated | 
|  | 203 | Out []string | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 204 | } | 
|  | 205 |  | 
| Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 206 | type ApiToCheck struct { | 
| Jiyong Park | eeb8a64 | 2018-05-12 22:21:20 +0900 | [diff] [blame] | 207 | // path to the API txt file that the new API extracted from source code is checked | 
|  | 208 | // against. The path can be local to the module or from other module (via :module syntax). | 
| Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 209 | Api_file *string | 
|  | 210 |  | 
| Jiyong Park | eeb8a64 | 2018-05-12 22:21:20 +0900 | [diff] [blame] | 211 | // path to the API txt file that the new @removed API extractd from source code is | 
|  | 212 | // checked against. The path can be local to the module or from other module (via | 
|  | 213 | // :module syntax). | 
| Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 214 | Removed_api_file *string | 
|  | 215 |  | 
| Jiyong Park | eeb8a64 | 2018-05-12 22:21:20 +0900 | [diff] [blame] | 216 | // Arguments to the apicheck tool. | 
| Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 217 | Args *string | 
|  | 218 | } | 
|  | 219 |  | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 220 | type DroiddocProperties struct { | 
|  | 221 | // directory relative to top of the source tree that contains doc templates files. | 
| Nan Zhang | b2b33de | 2018-02-23 11:18:47 -0800 | [diff] [blame] | 222 | Custom_template *string | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 223 |  | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 224 | // directories under current module source which contains html/jd files. | 
| Nan Zhang | b2b33de | 2018-02-23 11:18:47 -0800 | [diff] [blame] | 225 | Html_dirs []string | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 226 |  | 
|  | 227 | // set a value in the Clearsilver hdf namespace. | 
| Nan Zhang | b2b33de | 2018-02-23 11:18:47 -0800 | [diff] [blame] | 228 | Hdf []string | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 229 |  | 
|  | 230 | // proofread file contains all of the text content of the javadocs concatenated into one file, | 
|  | 231 | // suitable for spell-checking and other goodness. | 
| Nan Zhang | b2b33de | 2018-02-23 11:18:47 -0800 | [diff] [blame] | 232 | Proofread_file *string | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 233 |  | 
|  | 234 | // a todo file lists the program elements that are missing documentation. | 
|  | 235 | // At some point, this might be improved to show more warnings. | 
| Nan Zhang | b2b33de | 2018-02-23 11:18:47 -0800 | [diff] [blame] | 236 | Todo_file *string | 
|  | 237 |  | 
|  | 238 | // directory under current module source that provide additional resources (images). | 
|  | 239 | Resourcesdir *string | 
|  | 240 |  | 
|  | 241 | // resources output directory under out/soong/.intermediates. | 
|  | 242 | Resourcesoutdir *string | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 243 |  | 
| Nan Zhang | e2ba5d4 | 2018-07-11 15:16:55 -0700 | [diff] [blame] | 244 | // if set to true, collect the values used by the Dev tools and | 
|  | 245 | // write them in files packaged with the SDK. Defaults to false. | 
|  | 246 | Write_sdk_values *bool | 
|  | 247 |  | 
|  | 248 | // index.html under current module will be copied to docs out dir, if not null. | 
|  | 249 | Static_doc_index_redirect *string | 
|  | 250 |  | 
|  | 251 | // source.properties under current module will be copied to docs out dir, if not null. | 
|  | 252 | Static_doc_properties *string | 
|  | 253 |  | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 254 | // a list of files under current module source dir which contains known tags in Java sources. | 
|  | 255 | // filegroup or genrule can be included within this property. | 
| Nan Zhang | b2b33de | 2018-02-23 11:18:47 -0800 | [diff] [blame] | 256 | Knowntags []string | 
| Nan Zhang | 28c68b9 | 2018-03-13 16:17:01 -0700 | [diff] [blame] | 257 |  | 
|  | 258 | // the tag name used to distinguish if the API files belong to public/system/test. | 
|  | 259 | Api_tag_name *string | 
|  | 260 |  | 
|  | 261 | // the generated public API filename by Doclava. | 
|  | 262 | Api_filename *string | 
|  | 263 |  | 
| David Brazdil | fbe4cc3 | 2018-05-31 13:56:46 +0100 | [diff] [blame] | 264 | // the generated public Dex API filename by Doclava. | 
|  | 265 | Dex_api_filename *string | 
|  | 266 |  | 
| Nan Zhang | 28c68b9 | 2018-03-13 16:17:01 -0700 | [diff] [blame] | 267 | // the generated private API filename by Doclava. | 
|  | 268 | Private_api_filename *string | 
|  | 269 |  | 
|  | 270 | // the generated private Dex API filename by Doclava. | 
|  | 271 | Private_dex_api_filename *string | 
|  | 272 |  | 
|  | 273 | // the generated removed API filename by Doclava. | 
|  | 274 | Removed_api_filename *string | 
|  | 275 |  | 
| David Brazdil | aac0c3c | 2018-04-24 16:23:29 +0100 | [diff] [blame] | 276 | // the generated removed Dex API filename by Doclava. | 
|  | 277 | Removed_dex_api_filename *string | 
|  | 278 |  | 
| Mathew Inwood | 76c3de1 | 2018-06-22 15:28:11 +0100 | [diff] [blame] | 279 | // mapping of dex signatures to source file and line number. This is a temporary property and | 
|  | 280 | // will be deleted; you probably shouldn't be using it. | 
|  | 281 | Dex_mapping_filename *string | 
|  | 282 |  | 
| Nan Zhang | 28c68b9 | 2018-03-13 16:17:01 -0700 | [diff] [blame] | 283 | // the generated exact API filename by Doclava. | 
|  | 284 | Exact_api_filename *string | 
| Nan Zhang | 853f420 | 2018-04-12 16:55:56 -0700 | [diff] [blame] | 285 |  | 
| Nan Zhang | 66dc236 | 2018-08-14 20:41:04 -0700 | [diff] [blame] | 286 | // the generated proguard filename by Doclava. | 
|  | 287 | Proguard_filename *string | 
|  | 288 |  | 
| Nan Zhang | 853f420 | 2018-04-12 16:55:56 -0700 | [diff] [blame] | 289 | // if set to false, don't allow droiddoc to generate stubs source files. Defaults to true. | 
|  | 290 | Create_stubs *bool | 
| Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 291 |  | 
|  | 292 | Check_api struct { | 
|  | 293 | Last_released ApiToCheck | 
|  | 294 |  | 
|  | 295 | Current ApiToCheck | 
|  | 296 | } | 
| Nan Zhang | 79614d1 | 2018-04-19 18:03:39 -0700 | [diff] [blame] | 297 |  | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 298 | // if set to true, generate docs through Dokka instead of Doclava. | 
|  | 299 | Dokka_enabled *bool | 
|  | 300 | } | 
|  | 301 |  | 
|  | 302 | type DroidstubsProperties struct { | 
|  | 303 | // the tag name used to distinguish if the API files belong to public/system/test. | 
|  | 304 | Api_tag_name *string | 
|  | 305 |  | 
|  | 306 | // the generated public API filename by Doclava. | 
|  | 307 | Api_filename *string | 
|  | 308 |  | 
|  | 309 | // the generated public Dex API filename by Doclava. | 
|  | 310 | Dex_api_filename *string | 
|  | 311 |  | 
|  | 312 | // the generated private API filename by Doclava. | 
|  | 313 | Private_api_filename *string | 
|  | 314 |  | 
|  | 315 | // the generated private Dex API filename by Doclava. | 
|  | 316 | Private_dex_api_filename *string | 
|  | 317 |  | 
|  | 318 | // the generated removed API filename by Doclava. | 
|  | 319 | Removed_api_filename *string | 
|  | 320 |  | 
|  | 321 | // the generated removed Dex API filename by Doclava. | 
|  | 322 | Removed_dex_api_filename *string | 
|  | 323 |  | 
| Nan Zhang | 9c69a12 | 2018-08-22 10:22:08 -0700 | [diff] [blame] | 324 | // mapping of dex signatures to source file and line number. This is a temporary property and | 
|  | 325 | // will be deleted; you probably shouldn't be using it. | 
|  | 326 | Dex_mapping_filename *string | 
|  | 327 |  | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 328 | // the generated exact API filename by Doclava. | 
|  | 329 | Exact_api_filename *string | 
|  | 330 |  | 
|  | 331 | Check_api struct { | 
|  | 332 | Last_released ApiToCheck | 
|  | 333 |  | 
|  | 334 | Current ApiToCheck | 
|  | 335 | } | 
| Nan Zhang | 79614d1 | 2018-04-19 18:03:39 -0700 | [diff] [blame] | 336 |  | 
|  | 337 | // user can specify the version of previous released API file in order to do compatibility check. | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 338 | Previous_api *string | 
| Nan Zhang | 79614d1 | 2018-04-19 18:03:39 -0700 | [diff] [blame] | 339 |  | 
|  | 340 | // is set to true, Metalava will allow framework SDK to contain annotations. | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 341 | Annotations_enabled *bool | 
| Nan Zhang | 79614d1 | 2018-04-19 18:03:39 -0700 | [diff] [blame] | 342 |  | 
| Pete Gillin | 7716790 | 2018-09-19 18:16:26 +0100 | [diff] [blame] | 343 | // a list of top-level directories containing files to merge qualifier annotations (i.e. those intended to be included in the stubs written) from. | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 344 | Merge_annotations_dirs []string | 
| Nan Zhang | 86d2d55 | 2018-08-09 15:33:27 -0700 | [diff] [blame] | 345 |  | 
| Pete Gillin | 7716790 | 2018-09-19 18:16:26 +0100 | [diff] [blame] | 346 | // a list of top-level directories containing Java stub files to merge show/hide annotations from. | 
|  | 347 | Merge_inclusion_annotations_dirs []string | 
|  | 348 |  | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 349 | // if set to true, allow Metalava to generate doc_stubs source files. Defaults to false. | 
|  | 350 | Create_doc_stubs *bool | 
| Nan Zhang | 9c69a12 | 2018-08-22 10:22:08 -0700 | [diff] [blame] | 351 |  | 
|  | 352 | // is set to true, Metalava will allow framework SDK to contain API levels annotations. | 
|  | 353 | Api_levels_annotations_enabled *bool | 
|  | 354 |  | 
|  | 355 | // the dirs which Metalava extracts API levels annotations from. | 
|  | 356 | Api_levels_annotations_dirs []string | 
|  | 357 |  | 
|  | 358 | // if set to true, collect the values used by the Dev tools and | 
|  | 359 | // write them in files packaged with the SDK. Defaults to false. | 
|  | 360 | Write_sdk_values *bool | 
| Nan Zhang | 71bbe63 | 2018-09-17 14:32:21 -0700 | [diff] [blame] | 361 |  | 
|  | 362 | // If set to true, .xml based public API file will be also generated, and | 
|  | 363 | // JDiff tool will be invoked to genreate javadoc files. Defaults to false. | 
|  | 364 | Jdiff_enabled *bool | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 365 | } | 
|  | 366 |  | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 367 | // | 
|  | 368 | // Common flags passed down to build rule | 
|  | 369 | // | 
|  | 370 | type droiddocBuilderFlags struct { | 
| Nan Zhang | 86d2d55 | 2018-08-09 15:33:27 -0700 | [diff] [blame] | 371 | bootClasspathArgs  string | 
|  | 372 | classpathArgs      string | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 373 | sourcepathArgs     string | 
| Nan Zhang | 86d2d55 | 2018-08-09 15:33:27 -0700 | [diff] [blame] | 374 | dokkaClasspathArgs string | 
|  | 375 | aidlFlags          string | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 376 |  | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 377 | doclavaStubsFlags string | 
| Nan Zhang | 86d2d55 | 2018-08-09 15:33:27 -0700 | [diff] [blame] | 378 | doclavaDocsFlags  string | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 379 | postDoclavaCmds   string | 
|  | 380 |  | 
| Nan Zhang | 9c69a12 | 2018-08-22 10:22:08 -0700 | [diff] [blame] | 381 | metalavaStubsFlags                string | 
|  | 382 | metalavaAnnotationsFlags          string | 
|  | 383 | metalavaApiLevelsAnnotationsFlags string | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 384 |  | 
| Nan Zhang | 71bbe63 | 2018-09-17 14:32:21 -0700 | [diff] [blame] | 385 | metalavaApiToXmlFlags string | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 386 | } | 
|  | 387 |  | 
|  | 388 | func InitDroiddocModule(module android.DefaultableModule, hod android.HostOrDeviceSupported) { | 
|  | 389 | android.InitAndroidArchModule(module, hod, android.MultilibCommon) | 
|  | 390 | android.InitDefaultableModule(module) | 
|  | 391 | } | 
|  | 392 |  | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 393 | func apiCheckEnabled(apiToCheck ApiToCheck, apiVersionTag string) bool { | 
|  | 394 | if String(apiToCheck.Api_file) != "" && String(apiToCheck.Removed_api_file) != "" { | 
|  | 395 | return true | 
|  | 396 | } else if String(apiToCheck.Api_file) != "" { | 
|  | 397 | panic("for " + apiVersionTag + " removed_api_file has to be non-empty!") | 
|  | 398 | } else if String(apiToCheck.Removed_api_file) != "" { | 
|  | 399 | panic("for " + apiVersionTag + " api_file has to be non-empty!") | 
|  | 400 | } | 
|  | 401 |  | 
|  | 402 | return false | 
|  | 403 | } | 
|  | 404 |  | 
|  | 405 | type ApiFilePath interface { | 
|  | 406 | ApiFilePath() android.Path | 
|  | 407 | } | 
|  | 408 |  | 
|  | 409 | func transformUpdateApi(ctx android.ModuleContext, destApiFile, destRemovedApiFile, | 
|  | 410 | srcApiFile, srcRemovedApiFile android.Path, output android.WritablePath) { | 
|  | 411 | ctx.Build(pctx, android.BuildParams{ | 
|  | 412 | Rule:        updateApi, | 
|  | 413 | Description: "Update API", | 
|  | 414 | Output:      output, | 
|  | 415 | Implicits: append(android.Paths{}, srcApiFile, srcRemovedApiFile, | 
|  | 416 | destApiFile, destRemovedApiFile), | 
|  | 417 | Args: map[string]string{ | 
|  | 418 | "destApiFile":        destApiFile.String(), | 
|  | 419 | "srcApiFile":         srcApiFile.String(), | 
|  | 420 | "destRemovedApiFile": destRemovedApiFile.String(), | 
|  | 421 | "srcRemovedApiFile":  srcRemovedApiFile.String(), | 
|  | 422 | }, | 
|  | 423 | }) | 
|  | 424 | } | 
|  | 425 |  | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 426 | // | 
|  | 427 | // Javadoc | 
|  | 428 | // | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 429 | type Javadoc struct { | 
|  | 430 | android.ModuleBase | 
|  | 431 | android.DefaultableModuleBase | 
|  | 432 |  | 
|  | 433 | properties JavadocProperties | 
|  | 434 |  | 
|  | 435 | srcJars     android.Paths | 
|  | 436 | srcFiles    android.Paths | 
|  | 437 | sourcepaths android.Paths | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 438 | argFiles    android.Paths | 
|  | 439 |  | 
|  | 440 | args string | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 441 |  | 
| Nan Zhang | ccff0f7 | 2018-03-08 17:26:16 -0800 | [diff] [blame] | 442 | docZip      android.WritablePath | 
|  | 443 | stubsSrcJar android.WritablePath | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 444 | } | 
|  | 445 |  | 
| Nan Zhang | b2b33de | 2018-02-23 11:18:47 -0800 | [diff] [blame] | 446 | func (j *Javadoc) Srcs() android.Paths { | 
|  | 447 | return android.Paths{j.stubsSrcJar} | 
|  | 448 | } | 
|  | 449 |  | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 450 | func JavadocFactory() android.Module { | 
|  | 451 | module := &Javadoc{} | 
|  | 452 |  | 
|  | 453 | module.AddProperties(&module.properties) | 
|  | 454 |  | 
|  | 455 | InitDroiddocModule(module, android.HostAndDeviceSupported) | 
|  | 456 | return module | 
|  | 457 | } | 
|  | 458 |  | 
|  | 459 | func JavadocHostFactory() android.Module { | 
|  | 460 | module := &Javadoc{} | 
|  | 461 |  | 
|  | 462 | module.AddProperties(&module.properties) | 
|  | 463 |  | 
|  | 464 | InitDroiddocModule(module, android.HostSupported) | 
|  | 465 | return module | 
|  | 466 | } | 
|  | 467 |  | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 468 | var _ android.SourceFileProducer = (*Javadoc)(nil) | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 469 |  | 
| Colin Cross | 83bb316 | 2018-06-25 15:48:06 -0700 | [diff] [blame] | 470 | func (j *Javadoc) sdkVersion() string { | 
|  | 471 | return String(j.properties.Sdk_version) | 
|  | 472 | } | 
|  | 473 |  | 
|  | 474 | func (j *Javadoc) minSdkVersion() string { | 
|  | 475 | return j.sdkVersion() | 
|  | 476 | } | 
|  | 477 |  | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 478 | func (j *Javadoc) addDeps(ctx android.BottomUpMutatorContext) { | 
|  | 479 | if ctx.Device() { | 
| Colin Cross | 83bb316 | 2018-06-25 15:48:06 -0700 | [diff] [blame] | 480 | sdkDep := decodeSdkDep(ctx, sdkContext(j)) | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 481 | if sdkDep.useDefaultLibs { | 
| Colin Cross | 42d48b7 | 2018-08-29 14:10:52 -0700 | [diff] [blame] | 482 | ctx.AddVariationDependencies(nil, bootClasspathTag, config.DefaultBootclasspathLibraries...) | 
| Nan Zhang | 357466b | 2018-04-17 17:38:36 -0700 | [diff] [blame] | 483 | if ctx.Config().TargetOpenJDK9() { | 
| Colin Cross | 42d48b7 | 2018-08-29 14:10:52 -0700 | [diff] [blame] | 484 | ctx.AddVariationDependencies(nil, systemModulesTag, config.DefaultSystemModules) | 
| Nan Zhang | 357466b | 2018-04-17 17:38:36 -0700 | [diff] [blame] | 485 | } | 
| Nan Zhang | 9cbe677 | 2018-03-21 17:56:39 -0700 | [diff] [blame] | 486 | if !Bool(j.properties.No_framework_libs) { | 
| Colin Cross | 42d48b7 | 2018-08-29 14:10:52 -0700 | [diff] [blame] | 487 | ctx.AddVariationDependencies(nil, libTag, config.DefaultLibraries...) | 
| Nan Zhang | e66c727 | 2018-03-06 12:59:27 -0800 | [diff] [blame] | 488 | } | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 489 | } else if sdkDep.useModule { | 
| Nan Zhang | 357466b | 2018-04-17 17:38:36 -0700 | [diff] [blame] | 490 | if ctx.Config().TargetOpenJDK9() { | 
| Colin Cross | 42d48b7 | 2018-08-29 14:10:52 -0700 | [diff] [blame] | 491 | ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules) | 
| Nan Zhang | 357466b | 2018-04-17 17:38:36 -0700 | [diff] [blame] | 492 | } | 
| Colin Cross | 42d48b7 | 2018-08-29 14:10:52 -0700 | [diff] [blame] | 493 | ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.modules...) | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 494 | } | 
|  | 495 | } | 
|  | 496 |  | 
| Colin Cross | 42d48b7 | 2018-08-29 14:10:52 -0700 | [diff] [blame] | 497 | ctx.AddVariationDependencies(nil, libTag, j.properties.Libs...) | 
| Colin Cross | a1ce2a0 | 2018-06-20 15:19:39 -0700 | [diff] [blame] | 498 | if j.properties.Srcs_lib != nil { | 
| Colin Cross | 42d48b7 | 2018-08-29 14:10:52 -0700 | [diff] [blame] | 499 | ctx.AddVariationDependencies(nil, srcsLibTag, *j.properties.Srcs_lib) | 
| Colin Cross | a1ce2a0 | 2018-06-20 15:19:39 -0700 | [diff] [blame] | 500 | } | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 501 |  | 
|  | 502 | android.ExtractSourcesDeps(ctx, j.properties.Srcs) | 
|  | 503 |  | 
|  | 504 | // exclude_srcs may contain filegroup or genrule. | 
|  | 505 | android.ExtractSourcesDeps(ctx, j.properties.Exclude_srcs) | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 506 |  | 
|  | 507 | // arg_files may contains filegroup or genrule. | 
|  | 508 | android.ExtractSourcesDeps(ctx, j.properties.Arg_files) | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 509 | } | 
|  | 510 |  | 
| Nan Zhang | b2b33de | 2018-02-23 11:18:47 -0800 | [diff] [blame] | 511 | func (j *Javadoc) genWhitelistPathPrefixes(whitelistPathPrefixes map[string]bool) { | 
|  | 512 | for _, dir := range j.properties.Srcs_lib_whitelist_dirs { | 
|  | 513 | for _, pkg := range j.properties.Srcs_lib_whitelist_pkgs { | 
| Jiyong Park | 82484c0 | 2018-04-23 21:41:26 +0900 | [diff] [blame] | 514 | // convert foo.bar.baz to foo/bar/baz | 
|  | 515 | pkgAsPath := filepath.Join(strings.Split(pkg, ".")...) | 
|  | 516 | prefix := filepath.Join(dir, pkgAsPath) | 
| Nan Zhang | b2b33de | 2018-02-23 11:18:47 -0800 | [diff] [blame] | 517 | if _, found := whitelistPathPrefixes[prefix]; !found { | 
|  | 518 | whitelistPathPrefixes[prefix] = true | 
|  | 519 | } | 
|  | 520 | } | 
|  | 521 | } | 
|  | 522 | } | 
|  | 523 |  | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 524 | func (j *Javadoc) collectAidlFlags(ctx android.ModuleContext, deps deps) droiddocBuilderFlags { | 
|  | 525 | var flags droiddocBuilderFlags | 
| Jiyong Park | 1e44068 | 2018-05-23 18:42:04 +0900 | [diff] [blame] | 526 |  | 
|  | 527 | // aidl flags. | 
|  | 528 | aidlFlags := j.aidlFlags(ctx, deps.aidlPreprocess, deps.aidlIncludeDirs) | 
|  | 529 | if len(aidlFlags) > 0 { | 
|  | 530 | // optimization. | 
|  | 531 | ctx.Variable(pctx, "aidlFlags", strings.Join(aidlFlags, " ")) | 
|  | 532 | flags.aidlFlags = "$aidlFlags" | 
|  | 533 | } | 
|  | 534 |  | 
|  | 535 | return flags | 
|  | 536 | } | 
|  | 537 |  | 
|  | 538 | func (j *Javadoc) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.OptionalPath, | 
|  | 539 | aidlIncludeDirs android.Paths) []string { | 
|  | 540 |  | 
|  | 541 | aidlIncludes := android.PathsForModuleSrc(ctx, j.properties.Aidl.Local_include_dirs) | 
|  | 542 | aidlIncludes = append(aidlIncludes, android.PathsForSource(ctx, j.properties.Aidl.Include_dirs)...) | 
|  | 543 |  | 
|  | 544 | var flags []string | 
|  | 545 | if aidlPreprocess.Valid() { | 
|  | 546 | flags = append(flags, "-p"+aidlPreprocess.String()) | 
|  | 547 | } else { | 
|  | 548 | flags = append(flags, android.JoinWithPrefix(aidlIncludeDirs.Strings(), "-I")) | 
|  | 549 | } | 
|  | 550 |  | 
|  | 551 | flags = append(flags, android.JoinWithPrefix(aidlIncludes.Strings(), "-I")) | 
|  | 552 | flags = append(flags, "-I"+android.PathForModuleSrc(ctx).String()) | 
|  | 553 | if src := android.ExistentPathForSource(ctx, ctx.ModuleDir(), "src"); src.Valid() { | 
|  | 554 | flags = append(flags, "-I"+src.String()) | 
|  | 555 | } | 
|  | 556 |  | 
|  | 557 | return flags | 
|  | 558 | } | 
|  | 559 |  | 
|  | 560 | func (j *Javadoc) genSources(ctx android.ModuleContext, srcFiles android.Paths, | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 561 | flags droiddocBuilderFlags) android.Paths { | 
| Jiyong Park | 1e44068 | 2018-05-23 18:42:04 +0900 | [diff] [blame] | 562 |  | 
|  | 563 | outSrcFiles := make(android.Paths, 0, len(srcFiles)) | 
|  | 564 |  | 
|  | 565 | for _, srcFile := range srcFiles { | 
|  | 566 | switch srcFile.Ext() { | 
|  | 567 | case ".aidl": | 
|  | 568 | javaFile := genAidl(ctx, srcFile, flags.aidlFlags) | 
|  | 569 | outSrcFiles = append(outSrcFiles, javaFile) | 
|  | 570 | default: | 
|  | 571 | outSrcFiles = append(outSrcFiles, srcFile) | 
|  | 572 | } | 
|  | 573 | } | 
|  | 574 |  | 
|  | 575 | return outSrcFiles | 
|  | 576 | } | 
|  | 577 |  | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 578 | func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps { | 
|  | 579 | var deps deps | 
|  | 580 |  | 
| Colin Cross | 83bb316 | 2018-06-25 15:48:06 -0700 | [diff] [blame] | 581 | sdkDep := decodeSdkDep(ctx, sdkContext(j)) | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 582 | if sdkDep.invalidVersion { | 
| Colin Cross | 86a60ae | 2018-05-29 14:44:55 -0700 | [diff] [blame] | 583 | ctx.AddMissingDependencies(sdkDep.modules) | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 584 | } else if sdkDep.useFiles { | 
| Colin Cross | 86a60ae | 2018-05-29 14:44:55 -0700 | [diff] [blame] | 585 | deps.bootClasspath = append(deps.bootClasspath, sdkDep.jars...) | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 586 | } | 
|  | 587 |  | 
|  | 588 | ctx.VisitDirectDeps(func(module android.Module) { | 
|  | 589 | otherName := ctx.OtherModuleName(module) | 
|  | 590 | tag := ctx.OtherModuleDependencyTag(module) | 
|  | 591 |  | 
| Colin Cross | 2d24c1b | 2018-05-23 10:59:18 -0700 | [diff] [blame] | 592 | switch tag { | 
|  | 593 | case bootClasspathTag: | 
|  | 594 | if dep, ok := module.(Dependency); ok { | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 595 | deps.bootClasspath = append(deps.bootClasspath, dep.ImplementationJars()...) | 
| Colin Cross | 2d24c1b | 2018-05-23 10:59:18 -0700 | [diff] [blame] | 596 | } else { | 
|  | 597 | panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName())) | 
|  | 598 | } | 
|  | 599 | case libTag: | 
|  | 600 | switch dep := module.(type) { | 
|  | 601 | case Dependency: | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 602 | deps.classpath = append(deps.classpath, dep.ImplementationJars()...) | 
| Colin Cross | 2d24c1b | 2018-05-23 10:59:18 -0700 | [diff] [blame] | 603 | case SdkLibraryDependency: | 
| Colin Cross | 83bb316 | 2018-06-25 15:48:06 -0700 | [diff] [blame] | 604 | sdkVersion := j.sdkVersion() | 
| Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 605 | linkType := javaSdk | 
|  | 606 | if strings.HasPrefix(sdkVersion, "system_") || strings.HasPrefix(sdkVersion, "test_") { | 
|  | 607 | linkType = javaSystem | 
|  | 608 | } else if sdkVersion == "" { | 
|  | 609 | linkType = javaPlatform | 
|  | 610 | } | 
| Sundong Ahn | 241cd37 | 2018-07-13 16:16:44 +0900 | [diff] [blame] | 611 | deps.classpath = append(deps.classpath, dep.ImplementationJars(linkType)...) | 
| Colin Cross | 2d24c1b | 2018-05-23 10:59:18 -0700 | [diff] [blame] | 612 | case android.SourceFileProducer: | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 613 | checkProducesJars(ctx, dep) | 
|  | 614 | deps.classpath = append(deps.classpath, dep.Srcs()...) | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 615 | default: | 
|  | 616 | ctx.ModuleErrorf("depends on non-java module %q", otherName) | 
|  | 617 | } | 
| Colin Cross | a1ce2a0 | 2018-06-20 15:19:39 -0700 | [diff] [blame] | 618 | case srcsLibTag: | 
|  | 619 | switch dep := module.(type) { | 
|  | 620 | case Dependency: | 
|  | 621 | srcs := dep.(SrcDependency).CompiledSrcs() | 
|  | 622 | whitelistPathPrefixes := make(map[string]bool) | 
|  | 623 | j.genWhitelistPathPrefixes(whitelistPathPrefixes) | 
|  | 624 | for _, src := range srcs { | 
|  | 625 | if _, ok := src.(android.WritablePath); ok { // generated sources | 
|  | 626 | deps.srcs = append(deps.srcs, src) | 
|  | 627 | } else { // select source path for documentation based on whitelist path prefixs. | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 628 | for k := range whitelistPathPrefixes { | 
| Colin Cross | a1ce2a0 | 2018-06-20 15:19:39 -0700 | [diff] [blame] | 629 | if strings.HasPrefix(src.Rel(), k) { | 
|  | 630 | deps.srcs = append(deps.srcs, src) | 
|  | 631 | break | 
|  | 632 | } | 
|  | 633 | } | 
|  | 634 | } | 
|  | 635 | } | 
|  | 636 | deps.srcJars = append(deps.srcJars, dep.(SrcDependency).CompiledSrcJars()...) | 
|  | 637 | default: | 
|  | 638 | ctx.ModuleErrorf("depends on non-java module %q", otherName) | 
|  | 639 | } | 
| Nan Zhang | 357466b | 2018-04-17 17:38:36 -0700 | [diff] [blame] | 640 | case systemModulesTag: | 
|  | 641 | if deps.systemModules != nil { | 
|  | 642 | panic("Found two system module dependencies") | 
|  | 643 | } | 
|  | 644 | sm := module.(*SystemModules) | 
|  | 645 | if sm.outputFile == nil { | 
|  | 646 | panic("Missing directory for system module dependency") | 
|  | 647 | } | 
|  | 648 | deps.systemModules = sm.outputFile | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 649 | } | 
|  | 650 | }) | 
|  | 651 | // do not pass exclude_srcs directly when expanding srcFiles since exclude_srcs | 
|  | 652 | // may contain filegroup or genrule. | 
|  | 653 | srcFiles := ctx.ExpandSources(j.properties.Srcs, j.properties.Exclude_srcs) | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 654 | flags := j.collectAidlFlags(ctx, deps) | 
| Jiyong Park | 1e44068 | 2018-05-23 18:42:04 +0900 | [diff] [blame] | 655 | srcFiles = j.genSources(ctx, srcFiles, flags) | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 656 |  | 
|  | 657 | // srcs may depend on some genrule output. | 
|  | 658 | j.srcJars = srcFiles.FilterByExt(".srcjar") | 
| Nan Zhang | b2b33de | 2018-02-23 11:18:47 -0800 | [diff] [blame] | 659 | j.srcJars = append(j.srcJars, deps.srcJars...) | 
|  | 660 |  | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 661 | j.srcFiles = srcFiles.FilterOutByExt(".srcjar") | 
| Nan Zhang | b2b33de | 2018-02-23 11:18:47 -0800 | [diff] [blame] | 662 | j.srcFiles = append(j.srcFiles, deps.srcs...) | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 663 |  | 
|  | 664 | j.docZip = android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"docs.zip") | 
| Nan Zhang | ccff0f7 | 2018-03-08 17:26:16 -0800 | [diff] [blame] | 665 | j.stubsSrcJar = android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"stubs.srcjar") | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 666 |  | 
| Nan Zhang | 9c69a12 | 2018-08-22 10:22:08 -0700 | [diff] [blame] | 667 | if j.properties.Local_sourcepaths == nil && len(j.srcFiles) > 0 { | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 668 | j.properties.Local_sourcepaths = append(j.properties.Local_sourcepaths, ".") | 
|  | 669 | } | 
|  | 670 | j.sourcepaths = android.PathsForModuleSrc(ctx, j.properties.Local_sourcepaths) | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 671 |  | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 672 | j.argFiles = ctx.ExpandSources(j.properties.Arg_files, nil) | 
|  | 673 | argFilesMap := map[string]android.Path{} | 
|  | 674 |  | 
|  | 675 | for _, f := range j.argFiles { | 
|  | 676 | if _, exists := argFilesMap[f.Rel()]; !exists { | 
|  | 677 | argFilesMap[f.Rel()] = f | 
|  | 678 | } else { | 
|  | 679 | ctx.ModuleErrorf("multiple arg_files for %q, %q and %q", | 
|  | 680 | f, argFilesMap[f.Rel()], f.Rel()) | 
|  | 681 | } | 
|  | 682 | } | 
|  | 683 |  | 
|  | 684 | var err error | 
|  | 685 | j.args, err = android.Expand(String(j.properties.Args), func(name string) (string, error) { | 
|  | 686 | if strings.HasPrefix(name, "location ") { | 
|  | 687 | label := strings.TrimSpace(strings.TrimPrefix(name, "location ")) | 
|  | 688 | if f, ok := argFilesMap[label]; ok { | 
|  | 689 | return f.String(), nil | 
|  | 690 | } else { | 
|  | 691 | return "", fmt.Errorf("unknown location label %q", label) | 
|  | 692 | } | 
|  | 693 | } else if name == "genDir" { | 
|  | 694 | return android.PathForModuleGen(ctx).String(), nil | 
|  | 695 | } | 
|  | 696 | return "", fmt.Errorf("unknown variable '$(%s)'", name) | 
|  | 697 | }) | 
|  | 698 |  | 
|  | 699 | if err != nil { | 
|  | 700 | ctx.PropertyErrorf("args", "%s", err.Error()) | 
|  | 701 | } | 
|  | 702 |  | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 703 | return deps | 
|  | 704 | } | 
|  | 705 |  | 
|  | 706 | func (j *Javadoc) DepsMutator(ctx android.BottomUpMutatorContext) { | 
|  | 707 | j.addDeps(ctx) | 
|  | 708 | } | 
|  | 709 |  | 
|  | 710 | func (j *Javadoc) GenerateAndroidBuildActions(ctx android.ModuleContext) { | 
|  | 711 | deps := j.collectDeps(ctx) | 
|  | 712 |  | 
|  | 713 | var implicits android.Paths | 
|  | 714 | implicits = append(implicits, deps.bootClasspath...) | 
|  | 715 | implicits = append(implicits, deps.classpath...) | 
|  | 716 |  | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 717 | var bootClasspathArgs, classpathArgs, sourcepathArgs string | 
| Nan Zhang | 357466b | 2018-04-17 17:38:36 -0700 | [diff] [blame] | 718 |  | 
| Colin Cross | 83bb316 | 2018-06-25 15:48:06 -0700 | [diff] [blame] | 719 | javaVersion := getJavaVersion(ctx, String(j.properties.Java_version), sdkContext(j)) | 
| Colin Cross | 997262f | 2018-06-19 22:49:39 -0700 | [diff] [blame] | 720 | if len(deps.bootClasspath) > 0 { | 
|  | 721 | var systemModules classpath | 
|  | 722 | if deps.systemModules != nil { | 
|  | 723 | systemModules = append(systemModules, deps.systemModules) | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 724 | } | 
| Colin Cross | 997262f | 2018-06-19 22:49:39 -0700 | [diff] [blame] | 725 | bootClasspathArgs = systemModules.FormJavaSystemModulesPath("--system ", ctx.Device()) | 
|  | 726 | bootClasspathArgs = bootClasspathArgs + " --patch-module java.base=." | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 727 | } | 
|  | 728 | if len(deps.classpath.Strings()) > 0 { | 
|  | 729 | classpathArgs = "-classpath " + strings.Join(deps.classpath.Strings(), ":") | 
|  | 730 | } | 
|  | 731 |  | 
|  | 732 | implicits = append(implicits, j.srcJars...) | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 733 | implicits = append(implicits, j.argFiles...) | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 734 |  | 
| Nan Zhang | af322cc | 2018-06-19 15:15:38 -0700 | [diff] [blame] | 735 | opts := "-source " + javaVersion + " -J-Xmx1024m -XDignore.symbol.file -Xdoclint:none" | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 736 |  | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 737 | sourcepathArgs = "-sourcepath " + strings.Join(j.sourcepaths.Strings(), ":") | 
|  | 738 |  | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 739 | ctx.Build(pctx, android.BuildParams{ | 
|  | 740 | Rule:           javadoc, | 
|  | 741 | Description:    "Javadoc", | 
| Nan Zhang | ccff0f7 | 2018-03-08 17:26:16 -0800 | [diff] [blame] | 742 | Output:         j.stubsSrcJar, | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 743 | ImplicitOutput: j.docZip, | 
|  | 744 | Inputs:         j.srcFiles, | 
|  | 745 | Implicits:      implicits, | 
|  | 746 | Args: map[string]string{ | 
| Nan Zhang | de860a4 | 2018-08-08 16:32:21 -0700 | [diff] [blame] | 747 | "outDir":            android.PathForModuleOut(ctx, "out").String(), | 
|  | 748 | "srcJarDir":         android.PathForModuleOut(ctx, "srcjars").String(), | 
|  | 749 | "stubsDir":          android.PathForModuleOut(ctx, "stubsDir").String(), | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 750 | "srcJars":           strings.Join(j.srcJars.Strings(), " "), | 
|  | 751 | "opts":              opts, | 
| Nan Zhang | 853f420 | 2018-04-12 16:55:56 -0700 | [diff] [blame] | 752 | "bootclasspathArgs": bootClasspathArgs, | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 753 | "classpathArgs":     classpathArgs, | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 754 | "sourcepathArgs":    sourcepathArgs, | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 755 | "docZip":            j.docZip.String(), | 
|  | 756 | }, | 
|  | 757 | }) | 
|  | 758 | } | 
|  | 759 |  | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 760 | // | 
|  | 761 | // Droiddoc | 
|  | 762 | // | 
|  | 763 | type Droiddoc struct { | 
|  | 764 | Javadoc | 
|  | 765 |  | 
|  | 766 | properties        DroiddocProperties | 
|  | 767 | apiFile           android.WritablePath | 
|  | 768 | dexApiFile        android.WritablePath | 
|  | 769 | privateApiFile    android.WritablePath | 
|  | 770 | privateDexApiFile android.WritablePath | 
|  | 771 | removedApiFile    android.WritablePath | 
|  | 772 | removedDexApiFile android.WritablePath | 
|  | 773 | exactApiFile      android.WritablePath | 
|  | 774 | apiMappingFile    android.WritablePath | 
| Nan Zhang | 66dc236 | 2018-08-14 20:41:04 -0700 | [diff] [blame] | 775 | proguardFile      android.WritablePath | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 776 |  | 
|  | 777 | checkCurrentApiTimestamp      android.WritablePath | 
|  | 778 | updateCurrentApiTimestamp     android.WritablePath | 
|  | 779 | checkLastReleasedApiTimestamp android.WritablePath | 
|  | 780 |  | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 781 | apiFilePath android.Path | 
|  | 782 | } | 
|  | 783 |  | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 784 | func DroiddocFactory() android.Module { | 
|  | 785 | module := &Droiddoc{} | 
|  | 786 |  | 
|  | 787 | module.AddProperties(&module.properties, | 
|  | 788 | &module.Javadoc.properties) | 
|  | 789 |  | 
|  | 790 | InitDroiddocModule(module, android.HostAndDeviceSupported) | 
|  | 791 | return module | 
|  | 792 | } | 
|  | 793 |  | 
|  | 794 | func DroiddocHostFactory() android.Module { | 
|  | 795 | module := &Droiddoc{} | 
|  | 796 |  | 
|  | 797 | module.AddProperties(&module.properties, | 
|  | 798 | &module.Javadoc.properties) | 
|  | 799 |  | 
|  | 800 | InitDroiddocModule(module, android.HostSupported) | 
|  | 801 | return module | 
|  | 802 | } | 
|  | 803 |  | 
|  | 804 | func (d *Droiddoc) ApiFilePath() android.Path { | 
|  | 805 | return d.apiFilePath | 
|  | 806 | } | 
|  | 807 |  | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 808 | func (d *Droiddoc) DepsMutator(ctx android.BottomUpMutatorContext) { | 
|  | 809 | d.Javadoc.addDeps(ctx) | 
|  | 810 |  | 
| Nan Zhang | 79614d1 | 2018-04-19 18:03:39 -0700 | [diff] [blame] | 811 | if String(d.properties.Custom_template) != "" { | 
| Dan Willemsen | cc09097 | 2018-02-26 14:33:31 -0800 | [diff] [blame] | 812 | ctx.AddDependency(ctx.Module(), droiddocTemplateTag, String(d.properties.Custom_template)) | 
|  | 813 | } | 
|  | 814 |  | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 815 | // knowntags may contain filegroup or genrule. | 
|  | 816 | android.ExtractSourcesDeps(ctx, d.properties.Knowntags) | 
| Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 817 |  | 
| Nan Zhang | e2ba5d4 | 2018-07-11 15:16:55 -0700 | [diff] [blame] | 818 | if String(d.properties.Static_doc_index_redirect) != "" { | 
|  | 819 | android.ExtractSourceDeps(ctx, d.properties.Static_doc_index_redirect) | 
|  | 820 | } | 
|  | 821 |  | 
|  | 822 | if String(d.properties.Static_doc_properties) != "" { | 
|  | 823 | android.ExtractSourceDeps(ctx, d.properties.Static_doc_properties) | 
|  | 824 | } | 
|  | 825 |  | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 826 | if apiCheckEnabled(d.properties.Check_api.Current, "current") { | 
| Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 827 | android.ExtractSourceDeps(ctx, d.properties.Check_api.Current.Api_file) | 
|  | 828 | android.ExtractSourceDeps(ctx, d.properties.Check_api.Current.Removed_api_file) | 
|  | 829 | } | 
|  | 830 |  | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 831 | if apiCheckEnabled(d.properties.Check_api.Last_released, "last_released") { | 
| Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 832 | android.ExtractSourceDeps(ctx, d.properties.Check_api.Last_released.Api_file) | 
|  | 833 | android.ExtractSourceDeps(ctx, d.properties.Check_api.Last_released.Removed_api_file) | 
|  | 834 | } | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 835 | } | 
|  | 836 |  | 
| Nan Zhang | 66dc236 | 2018-08-14 20:41:04 -0700 | [diff] [blame] | 837 | func (d *Droiddoc) initBuilderFlags(ctx android.ModuleContext, implicits *android.Paths, | 
|  | 838 | deps deps) (droiddocBuilderFlags, error) { | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 839 | var flags droiddocBuilderFlags | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 840 |  | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 841 | *implicits = append(*implicits, deps.bootClasspath...) | 
|  | 842 | *implicits = append(*implicits, deps.classpath...) | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 843 |  | 
| Nan Zhang | c94f9d8 | 2018-06-26 10:02:26 -0700 | [diff] [blame] | 844 | if len(deps.bootClasspath.Strings()) > 0 { | 
|  | 845 | // For OpenJDK 8 we can use -bootclasspath to define the core libraries code. | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 846 | flags.bootClasspathArgs = deps.bootClasspath.FormJavaClassPath("-bootclasspath") | 
| Nan Zhang | 357466b | 2018-04-17 17:38:36 -0700 | [diff] [blame] | 847 | } | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 848 | flags.classpathArgs = deps.classpath.FormJavaClassPath("-classpath") | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 849 | // Dokka doesn't support bootClasspath, so combine these two classpath vars for Dokka. | 
| Nan Zhang | 86d2d55 | 2018-08-09 15:33:27 -0700 | [diff] [blame] | 850 | dokkaClasspath := classpath{} | 
|  | 851 | dokkaClasspath = append(dokkaClasspath, deps.bootClasspath...) | 
|  | 852 | dokkaClasspath = append(dokkaClasspath, deps.classpath...) | 
|  | 853 | flags.dokkaClasspathArgs = dokkaClasspath.FormJavaClassPath("-classpath") | 
| Nan Zhang | 79614d1 | 2018-04-19 18:03:39 -0700 | [diff] [blame] | 854 |  | 
| Nan Zhang | 9c69a12 | 2018-08-22 10:22:08 -0700 | [diff] [blame] | 855 | // TODO(nanzhang): Remove this if- statement once we finish migration for all Doclava | 
|  | 856 | // based stubs generation. | 
|  | 857 | // In the future, all the docs generation depends on Metalava stubs (droidstubs) srcjar | 
|  | 858 | // dir. We need add the srcjar dir to -sourcepath arg, so that Javadoc can figure out | 
|  | 859 | // the correct package name base path. | 
|  | 860 | if len(d.Javadoc.properties.Local_sourcepaths) > 0 { | 
|  | 861 | flags.sourcepathArgs = "-sourcepath " + strings.Join(d.Javadoc.sourcepaths.Strings(), ":") | 
|  | 862 | } else { | 
|  | 863 | flags.sourcepathArgs = "-sourcepath " + android.PathForModuleOut(ctx, "srcjars").String() | 
|  | 864 | } | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 865 |  | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 866 | return flags, nil | 
|  | 867 | } | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 868 |  | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 869 | func (d *Droiddoc) collectDoclavaDocsFlags(ctx android.ModuleContext, implicits *android.Paths, | 
| Nan Zhang | 443fa52 | 2018-08-20 20:58:28 -0700 | [diff] [blame] | 870 | jsilver, doclava android.Path) string { | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 871 |  | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 872 | *implicits = append(*implicits, jsilver) | 
|  | 873 | *implicits = append(*implicits, doclava) | 
| Nan Zhang | 3096374 | 2018-04-23 09:59:14 -0700 | [diff] [blame] | 874 |  | 
| Nan Zhang | 4613097 | 2018-06-04 11:28:01 -0700 | [diff] [blame] | 875 | var date string | 
|  | 876 | if runtime.GOOS == "darwin" { | 
|  | 877 | date = `date -r` | 
|  | 878 | } else { | 
|  | 879 | date = `date -d` | 
|  | 880 | } | 
|  | 881 |  | 
| Nan Zhang | 443fa52 | 2018-08-20 20:58:28 -0700 | [diff] [blame] | 882 | // Droiddoc always gets "-source 1.8" because it doesn't support 1.9 sources.  For modules with 1.9 | 
|  | 883 | // sources, droiddoc will get sources produced by metalava which will have already stripped out the | 
|  | 884 | // 1.9 language features. | 
|  | 885 | args := " -source 1.8 -J-Xmx1600m -J-XX:-OmitStackTraceInFastThrow -XDignore.symbol.file " + | 
| Nan Zhang | 3096374 | 2018-04-23 09:59:14 -0700 | [diff] [blame] | 886 | "-doclet com.google.doclava.Doclava -docletpath " + jsilver.String() + ":" + doclava.String() + " " + | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 887 | "-hdf page.build " + ctx.Config().BuildId() + "-" + ctx.Config().BuildNumberFromFile() + " " + | 
| Nan Zhang | 79614d1 | 2018-04-19 18:03:39 -0700 | [diff] [blame] | 888 | `-hdf page.now "$$(` + date + ` @$$(cat ` + ctx.Config().Getenv("BUILD_DATETIME_FILE") + `) "+%d %b %Y %k:%M")" ` | 
| Nan Zhang | 4613097 | 2018-06-04 11:28:01 -0700 | [diff] [blame] | 889 |  | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 890 | if String(d.properties.Custom_template) == "" { | 
|  | 891 | // TODO: This is almost always droiddoc-templates-sdk | 
|  | 892 | ctx.PropertyErrorf("custom_template", "must specify a template") | 
|  | 893 | } | 
|  | 894 |  | 
|  | 895 | ctx.VisitDirectDepsWithTag(droiddocTemplateTag, func(m android.Module) { | 
| Nan Zhang | f4936b0 | 2018-08-01 15:00:28 -0700 | [diff] [blame] | 896 | if t, ok := m.(*ExportedDroiddocDir); ok { | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 897 | *implicits = append(*implicits, t.deps...) | 
|  | 898 | args = args + " -templatedir " + t.dir.String() | 
|  | 899 | } else { | 
|  | 900 | ctx.PropertyErrorf("custom_template", "module %q is not a droiddoc_template", ctx.OtherModuleName(m)) | 
|  | 901 | } | 
|  | 902 | }) | 
|  | 903 |  | 
|  | 904 | if len(d.properties.Html_dirs) > 0 { | 
|  | 905 | htmlDir := android.PathForModuleSrc(ctx, d.properties.Html_dirs[0]) | 
|  | 906 | *implicits = append(*implicits, ctx.Glob(htmlDir.Join(ctx, "**/*").String(), nil)...) | 
|  | 907 | args = args + " -htmldir " + htmlDir.String() | 
|  | 908 | } | 
|  | 909 |  | 
|  | 910 | if len(d.properties.Html_dirs) > 1 { | 
|  | 911 | htmlDir2 := android.PathForModuleSrc(ctx, d.properties.Html_dirs[1]) | 
|  | 912 | *implicits = append(*implicits, ctx.Glob(htmlDir2.Join(ctx, "**/*").String(), nil)...) | 
|  | 913 | args = args + " -htmldir2 " + htmlDir2.String() | 
|  | 914 | } | 
|  | 915 |  | 
|  | 916 | if len(d.properties.Html_dirs) > 2 { | 
|  | 917 | ctx.PropertyErrorf("html_dirs", "Droiddoc only supports up to 2 html dirs") | 
|  | 918 | } | 
|  | 919 |  | 
|  | 920 | knownTags := ctx.ExpandSources(d.properties.Knowntags, nil) | 
|  | 921 | *implicits = append(*implicits, knownTags...) | 
|  | 922 |  | 
|  | 923 | for _, kt := range knownTags { | 
|  | 924 | args = args + " -knowntags " + kt.String() | 
|  | 925 | } | 
|  | 926 |  | 
|  | 927 | for _, hdf := range d.properties.Hdf { | 
|  | 928 | args = args + " -hdf " + hdf | 
|  | 929 | } | 
|  | 930 |  | 
|  | 931 | if String(d.properties.Proofread_file) != "" { | 
|  | 932 | proofreadFile := android.PathForModuleOut(ctx, String(d.properties.Proofread_file)) | 
|  | 933 | args = args + " -proofread " + proofreadFile.String() | 
|  | 934 | } | 
|  | 935 |  | 
|  | 936 | if String(d.properties.Todo_file) != "" { | 
|  | 937 | // tricky part: | 
|  | 938 | // we should not compute full path for todo_file through PathForModuleOut(). | 
|  | 939 | // the non-standard doclet will get the full path relative to "-o". | 
|  | 940 | args = args + " -todo " + String(d.properties.Todo_file) | 
|  | 941 | } | 
|  | 942 |  | 
|  | 943 | if String(d.properties.Resourcesdir) != "" { | 
|  | 944 | // TODO: should we add files under resourcesDir to the implicits? It seems that | 
|  | 945 | // resourcesDir is one sub dir of htmlDir | 
|  | 946 | resourcesDir := android.PathForModuleSrc(ctx, String(d.properties.Resourcesdir)) | 
|  | 947 | args = args + " -resourcesdir " + resourcesDir.String() | 
|  | 948 | } | 
|  | 949 |  | 
|  | 950 | if String(d.properties.Resourcesoutdir) != "" { | 
|  | 951 | // TODO: it seems -resourceoutdir reference/android/images/ didn't get generated anywhere. | 
|  | 952 | args = args + " -resourcesoutdir " + String(d.properties.Resourcesoutdir) | 
|  | 953 | } | 
|  | 954 | return args | 
|  | 955 | } | 
|  | 956 |  | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 957 | func (d *Droiddoc) collectStubsFlags(ctx android.ModuleContext, | 
|  | 958 | implicitOutputs *android.WritablePaths) string { | 
|  | 959 | var doclavaFlags string | 
|  | 960 | if apiCheckEnabled(d.properties.Check_api.Current, "current") || | 
|  | 961 | apiCheckEnabled(d.properties.Check_api.Last_released, "last_released") || | 
|  | 962 | String(d.properties.Api_filename) != "" { | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 963 | d.apiFile = android.PathForModuleOut(ctx, ctx.ModuleName()+"_api.txt") | 
|  | 964 | doclavaFlags += " -api " + d.apiFile.String() | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 965 | *implicitOutputs = append(*implicitOutputs, d.apiFile) | 
|  | 966 | d.apiFilePath = d.apiFile | 
|  | 967 | } | 
|  | 968 |  | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 969 | if apiCheckEnabled(d.properties.Check_api.Current, "current") || | 
|  | 970 | apiCheckEnabled(d.properties.Check_api.Last_released, "last_released") || | 
|  | 971 | String(d.properties.Removed_api_filename) != "" { | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 972 | d.removedApiFile = android.PathForModuleOut(ctx, ctx.ModuleName()+"_removed.txt") | 
|  | 973 | doclavaFlags += " -removedApi " + d.removedApiFile.String() | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 974 | *implicitOutputs = append(*implicitOutputs, d.removedApiFile) | 
|  | 975 | } | 
|  | 976 |  | 
|  | 977 | if String(d.properties.Private_api_filename) != "" { | 
|  | 978 | d.privateApiFile = android.PathForModuleOut(ctx, String(d.properties.Private_api_filename)) | 
|  | 979 | doclavaFlags += " -privateApi " + d.privateApiFile.String() | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 980 | *implicitOutputs = append(*implicitOutputs, d.privateApiFile) | 
|  | 981 | } | 
|  | 982 |  | 
|  | 983 | if String(d.properties.Dex_api_filename) != "" { | 
|  | 984 | d.dexApiFile = android.PathForModuleOut(ctx, String(d.properties.Dex_api_filename)) | 
|  | 985 | doclavaFlags += " -dexApi " + d.dexApiFile.String() | 
|  | 986 | *implicitOutputs = append(*implicitOutputs, d.dexApiFile) | 
|  | 987 | } | 
|  | 988 |  | 
|  | 989 | if String(d.properties.Private_dex_api_filename) != "" { | 
|  | 990 | d.privateDexApiFile = android.PathForModuleOut(ctx, String(d.properties.Private_dex_api_filename)) | 
|  | 991 | doclavaFlags += " -privateDexApi " + d.privateDexApiFile.String() | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 992 | *implicitOutputs = append(*implicitOutputs, d.privateDexApiFile) | 
|  | 993 | } | 
|  | 994 |  | 
|  | 995 | if String(d.properties.Removed_dex_api_filename) != "" { | 
|  | 996 | d.removedDexApiFile = android.PathForModuleOut(ctx, String(d.properties.Removed_dex_api_filename)) | 
|  | 997 | doclavaFlags += " -removedDexApi " + d.removedDexApiFile.String() | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 998 | *implicitOutputs = append(*implicitOutputs, d.removedDexApiFile) | 
|  | 999 | } | 
|  | 1000 |  | 
|  | 1001 | if String(d.properties.Exact_api_filename) != "" { | 
|  | 1002 | d.exactApiFile = android.PathForModuleOut(ctx, String(d.properties.Exact_api_filename)) | 
|  | 1003 | doclavaFlags += " -exactApi " + d.exactApiFile.String() | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 1004 | *implicitOutputs = append(*implicitOutputs, d.exactApiFile) | 
|  | 1005 | } | 
|  | 1006 |  | 
|  | 1007 | if String(d.properties.Dex_mapping_filename) != "" { | 
|  | 1008 | d.apiMappingFile = android.PathForModuleOut(ctx, String(d.properties.Dex_mapping_filename)) | 
|  | 1009 | doclavaFlags += " -apiMapping " + d.apiMappingFile.String() | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 1010 | *implicitOutputs = append(*implicitOutputs, d.apiMappingFile) | 
|  | 1011 | } | 
|  | 1012 |  | 
| Nan Zhang | 66dc236 | 2018-08-14 20:41:04 -0700 | [diff] [blame] | 1013 | if String(d.properties.Proguard_filename) != "" { | 
|  | 1014 | d.proguardFile = android.PathForModuleOut(ctx, String(d.properties.Proguard_filename)) | 
|  | 1015 | doclavaFlags += " -proguard " + d.proguardFile.String() | 
| Nan Zhang | 66dc236 | 2018-08-14 20:41:04 -0700 | [diff] [blame] | 1016 | *implicitOutputs = append(*implicitOutputs, d.proguardFile) | 
|  | 1017 | } | 
|  | 1018 |  | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 1019 | if BoolDefault(d.properties.Create_stubs, true) { | 
| Nan Zhang | de860a4 | 2018-08-08 16:32:21 -0700 | [diff] [blame] | 1020 | doclavaFlags += " -stubs " + android.PathForModuleOut(ctx, "stubsDir").String() | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 1021 | } | 
|  | 1022 |  | 
|  | 1023 | if Bool(d.properties.Write_sdk_values) { | 
| Nan Zhang | de860a4 | 2018-08-08 16:32:21 -0700 | [diff] [blame] | 1024 | doclavaFlags += " -sdkvalues " + android.PathForModuleOut(ctx, "out").String() | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 1025 | } | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 1026 |  | 
|  | 1027 | return doclavaFlags | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 1028 | } | 
|  | 1029 |  | 
|  | 1030 | func (d *Droiddoc) getPostDoclavaCmds(ctx android.ModuleContext, implicits *android.Paths) string { | 
|  | 1031 | var cmds string | 
|  | 1032 | if String(d.properties.Static_doc_index_redirect) != "" { | 
|  | 1033 | static_doc_index_redirect := ctx.ExpandSource(String(d.properties.Static_doc_index_redirect), | 
|  | 1034 | "static_doc_index_redirect") | 
|  | 1035 | *implicits = append(*implicits, static_doc_index_redirect) | 
|  | 1036 | cmds = cmds + " && cp " + static_doc_index_redirect.String() + " " + | 
| Nan Zhang | de860a4 | 2018-08-08 16:32:21 -0700 | [diff] [blame] | 1037 | android.PathForModuleOut(ctx, "out", "index.html").String() | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 1038 | } | 
|  | 1039 |  | 
|  | 1040 | if String(d.properties.Static_doc_properties) != "" { | 
|  | 1041 | static_doc_properties := ctx.ExpandSource(String(d.properties.Static_doc_properties), | 
|  | 1042 | "static_doc_properties") | 
|  | 1043 | *implicits = append(*implicits, static_doc_properties) | 
|  | 1044 | cmds = cmds + " && cp " + static_doc_properties.String() + " " + | 
| Nan Zhang | de860a4 | 2018-08-08 16:32:21 -0700 | [diff] [blame] | 1045 | android.PathForModuleOut(ctx, "out", "source.properties").String() | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 1046 | } | 
|  | 1047 | return cmds | 
|  | 1048 | } | 
|  | 1049 |  | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 1050 | func (d *Droiddoc) transformDoclava(ctx android.ModuleContext, implicits android.Paths, | 
|  | 1051 | implicitOutputs android.WritablePaths, | 
|  | 1052 | bootclasspathArgs, classpathArgs, sourcepathArgs, opts, postDoclavaCmds string) { | 
|  | 1053 | ctx.Build(pctx, android.BuildParams{ | 
|  | 1054 | Rule:            javadoc, | 
|  | 1055 | Description:     "Doclava", | 
|  | 1056 | Output:          d.Javadoc.stubsSrcJar, | 
|  | 1057 | Inputs:          d.Javadoc.srcFiles, | 
|  | 1058 | Implicits:       implicits, | 
|  | 1059 | ImplicitOutputs: implicitOutputs, | 
|  | 1060 | Args: map[string]string{ | 
|  | 1061 | "outDir":            android.PathForModuleOut(ctx, "out").String(), | 
|  | 1062 | "srcJarDir":         android.PathForModuleOut(ctx, "srcjars").String(), | 
|  | 1063 | "stubsDir":          android.PathForModuleOut(ctx, "stubsDir").String(), | 
|  | 1064 | "srcJars":           strings.Join(d.Javadoc.srcJars.Strings(), " "), | 
|  | 1065 | "opts":              opts, | 
|  | 1066 | "bootclasspathArgs": bootclasspathArgs, | 
|  | 1067 | "classpathArgs":     classpathArgs, | 
|  | 1068 | "sourcepathArgs":    sourcepathArgs, | 
|  | 1069 | "docZip":            d.Javadoc.docZip.String(), | 
|  | 1070 | "postDoclavaCmds":   postDoclavaCmds, | 
|  | 1071 | }, | 
|  | 1072 | }) | 
|  | 1073 | } | 
|  | 1074 |  | 
|  | 1075 | func (d *Droiddoc) transformCheckApi(ctx android.ModuleContext, apiFile, removedApiFile android.Path, | 
|  | 1076 | checkApiClasspath classpath, msg, opts string, output android.WritablePath) { | 
|  | 1077 | ctx.Build(pctx, android.BuildParams{ | 
|  | 1078 | Rule:        apiCheck, | 
|  | 1079 | Description: "Doclava Check API", | 
|  | 1080 | Output:      output, | 
|  | 1081 | Inputs:      nil, | 
|  | 1082 | Implicits: append(android.Paths{apiFile, removedApiFile, d.apiFile, d.removedApiFile}, | 
|  | 1083 | checkApiClasspath...), | 
|  | 1084 | Args: map[string]string{ | 
|  | 1085 | "msg":                   msg, | 
|  | 1086 | "classpath":             checkApiClasspath.FormJavaClassPath(""), | 
|  | 1087 | "opts":                  opts, | 
|  | 1088 | "apiFile":               apiFile.String(), | 
|  | 1089 | "apiFileToCheck":        d.apiFile.String(), | 
|  | 1090 | "removedApiFile":        removedApiFile.String(), | 
|  | 1091 | "removedApiFileToCheck": d.removedApiFile.String(), | 
|  | 1092 | }, | 
|  | 1093 | }) | 
|  | 1094 | } | 
|  | 1095 |  | 
|  | 1096 | func (d *Droiddoc) transformDokka(ctx android.ModuleContext, implicits android.Paths, | 
|  | 1097 | classpathArgs, opts string) { | 
|  | 1098 | ctx.Build(pctx, android.BuildParams{ | 
|  | 1099 | Rule:        dokka, | 
|  | 1100 | Description: "Dokka", | 
|  | 1101 | Output:      d.Javadoc.stubsSrcJar, | 
|  | 1102 | Inputs:      d.Javadoc.srcFiles, | 
|  | 1103 | Implicits:   implicits, | 
|  | 1104 | Args: map[string]string{ | 
|  | 1105 | "outDir":        android.PathForModuleOut(ctx, "out").String(), | 
|  | 1106 | "srcJarDir":     android.PathForModuleOut(ctx, "srcjars").String(), | 
|  | 1107 | "stubsDir":      android.PathForModuleOut(ctx, "stubsDir").String(), | 
|  | 1108 | "srcJars":       strings.Join(d.Javadoc.srcJars.Strings(), " "), | 
|  | 1109 | "classpathArgs": classpathArgs, | 
|  | 1110 | "opts":          opts, | 
|  | 1111 | "docZip":        d.Javadoc.docZip.String(), | 
|  | 1112 | }, | 
|  | 1113 | }) | 
|  | 1114 | } | 
|  | 1115 |  | 
|  | 1116 | func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) { | 
|  | 1117 | deps := d.Javadoc.collectDeps(ctx) | 
|  | 1118 |  | 
|  | 1119 | jsilver := android.PathForOutput(ctx, "host", ctx.Config().PrebuiltOS(), "framework", "jsilver.jar") | 
|  | 1120 | doclava := android.PathForOutput(ctx, "host", ctx.Config().PrebuiltOS(), "framework", "doclava.jar") | 
|  | 1121 | java8Home := ctx.Config().Getenv("ANDROID_JAVA8_HOME") | 
|  | 1122 | checkApiClasspath := classpath{jsilver, doclava, android.PathForSource(ctx, java8Home, "lib/tools.jar")} | 
|  | 1123 |  | 
|  | 1124 | var implicits android.Paths | 
|  | 1125 | implicits = append(implicits, d.Javadoc.srcJars...) | 
|  | 1126 | implicits = append(implicits, d.Javadoc.argFiles...) | 
|  | 1127 |  | 
|  | 1128 | var implicitOutputs android.WritablePaths | 
|  | 1129 | implicitOutputs = append(implicitOutputs, d.Javadoc.docZip) | 
|  | 1130 | for _, o := range d.Javadoc.properties.Out { | 
|  | 1131 | implicitOutputs = append(implicitOutputs, android.PathForModuleGen(ctx, o)) | 
|  | 1132 | } | 
|  | 1133 |  | 
|  | 1134 | flags, err := d.initBuilderFlags(ctx, &implicits, deps) | 
|  | 1135 | if err != nil { | 
|  | 1136 | return | 
|  | 1137 | } | 
|  | 1138 |  | 
|  | 1139 | flags.doclavaStubsFlags = d.collectStubsFlags(ctx, &implicitOutputs) | 
|  | 1140 | if Bool(d.properties.Dokka_enabled) { | 
|  | 1141 | d.transformDokka(ctx, implicits, flags.classpathArgs, d.Javadoc.args) | 
|  | 1142 | } else { | 
|  | 1143 | flags.doclavaDocsFlags = d.collectDoclavaDocsFlags(ctx, &implicits, jsilver, doclava) | 
|  | 1144 | flags.postDoclavaCmds = d.getPostDoclavaCmds(ctx, &implicits) | 
|  | 1145 | d.transformDoclava(ctx, implicits, implicitOutputs, flags.bootClasspathArgs, flags.classpathArgs, | 
|  | 1146 | flags.sourcepathArgs, flags.doclavaDocsFlags+flags.doclavaStubsFlags+" "+d.Javadoc.args, | 
|  | 1147 | flags.postDoclavaCmds) | 
|  | 1148 | } | 
|  | 1149 |  | 
|  | 1150 | if apiCheckEnabled(d.properties.Check_api.Current, "current") && | 
|  | 1151 | !ctx.Config().IsPdkBuild() { | 
|  | 1152 | apiFile := ctx.ExpandSource(String(d.properties.Check_api.Current.Api_file), | 
|  | 1153 | "check_api.current.api_file") | 
|  | 1154 | removedApiFile := ctx.ExpandSource(String(d.properties.Check_api.Current.Removed_api_file), | 
|  | 1155 | "check_api.current_removed_api_file") | 
|  | 1156 |  | 
|  | 1157 | d.checkCurrentApiTimestamp = android.PathForModuleOut(ctx, "check_current_api.timestamp") | 
|  | 1158 | d.transformCheckApi(ctx, apiFile, removedApiFile, checkApiClasspath, | 
|  | 1159 | fmt.Sprintf(`\n******************************\n`+ | 
|  | 1160 | `You have tried to change the API from what has been previously approved.\n\n`+ | 
|  | 1161 | `To make these errors go away, you have two choices:\n`+ | 
|  | 1162 | `   1. You can add '@hide' javadoc comments to the methods, etc. listed in the\n`+ | 
|  | 1163 | `      errors above.\n\n`+ | 
|  | 1164 | `   2. You can update current.txt by executing the following command:\n`+ | 
|  | 1165 | `         make %s-update-current-api\n\n`+ | 
|  | 1166 | `      To submit the revised current.txt to the main Android repository,\n`+ | 
|  | 1167 | `      you will need approval.\n`+ | 
|  | 1168 | `******************************\n`, ctx.ModuleName()), String(d.properties.Check_api.Current.Args), | 
|  | 1169 | d.checkCurrentApiTimestamp) | 
|  | 1170 |  | 
|  | 1171 | d.updateCurrentApiTimestamp = android.PathForModuleOut(ctx, "update_current_api.timestamp") | 
|  | 1172 | transformUpdateApi(ctx, apiFile, removedApiFile, d.apiFile, d.removedApiFile, | 
|  | 1173 | d.updateCurrentApiTimestamp) | 
|  | 1174 | } | 
|  | 1175 |  | 
|  | 1176 | if apiCheckEnabled(d.properties.Check_api.Last_released, "last_released") && | 
|  | 1177 | !ctx.Config().IsPdkBuild() { | 
|  | 1178 | apiFile := ctx.ExpandSource(String(d.properties.Check_api.Last_released.Api_file), | 
|  | 1179 | "check_api.last_released.api_file") | 
|  | 1180 | removedApiFile := ctx.ExpandSource(String(d.properties.Check_api.Last_released.Removed_api_file), | 
|  | 1181 | "check_api.last_released.removed_api_file") | 
|  | 1182 |  | 
|  | 1183 | d.checkLastReleasedApiTimestamp = android.PathForModuleOut(ctx, "check_last_released_api.timestamp") | 
|  | 1184 | d.transformCheckApi(ctx, apiFile, removedApiFile, checkApiClasspath, | 
|  | 1185 | `\n******************************\n`+ | 
|  | 1186 | `You have tried to change the API from what has been previously released in\n`+ | 
|  | 1187 | `an SDK.  Please fix the errors listed above.\n`+ | 
|  | 1188 | `******************************\n`, String(d.properties.Check_api.Last_released.Args), | 
|  | 1189 | d.checkLastReleasedApiTimestamp) | 
|  | 1190 | } | 
|  | 1191 | } | 
|  | 1192 |  | 
|  | 1193 | // | 
|  | 1194 | // Droidstubs | 
|  | 1195 | // | 
|  | 1196 | type Droidstubs struct { | 
|  | 1197 | Javadoc | 
|  | 1198 |  | 
| Nan Zhang | 71bbe63 | 2018-09-17 14:32:21 -0700 | [diff] [blame] | 1199 | properties             DroidstubsProperties | 
|  | 1200 | apiFile                android.WritablePath | 
|  | 1201 | apiXmlFile             android.WritablePath | 
|  | 1202 | lastReleasedApiXmlFile android.WritablePath | 
|  | 1203 | dexApiFile             android.WritablePath | 
|  | 1204 | privateApiFile         android.WritablePath | 
|  | 1205 | privateDexApiFile      android.WritablePath | 
|  | 1206 | removedApiFile         android.WritablePath | 
|  | 1207 | removedDexApiFile      android.WritablePath | 
|  | 1208 | apiMappingFile         android.WritablePath | 
|  | 1209 | exactApiFile           android.WritablePath | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 1210 |  | 
|  | 1211 | checkCurrentApiTimestamp      android.WritablePath | 
|  | 1212 | updateCurrentApiTimestamp     android.WritablePath | 
|  | 1213 | checkLastReleasedApiTimestamp android.WritablePath | 
|  | 1214 |  | 
|  | 1215 | annotationsZip android.WritablePath | 
| Nan Zhang | 9c69a12 | 2018-08-22 10:22:08 -0700 | [diff] [blame] | 1216 | apiVersionsXml android.WritablePath | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 1217 |  | 
|  | 1218 | apiFilePath android.Path | 
| Nan Zhang | 71bbe63 | 2018-09-17 14:32:21 -0700 | [diff] [blame] | 1219 |  | 
|  | 1220 | jdiffDocZip      android.WritablePath | 
|  | 1221 | jdiffStubsSrcJar android.WritablePath | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 1222 | } | 
|  | 1223 |  | 
|  | 1224 | func DroidstubsFactory() android.Module { | 
|  | 1225 | module := &Droidstubs{} | 
|  | 1226 |  | 
|  | 1227 | module.AddProperties(&module.properties, | 
|  | 1228 | &module.Javadoc.properties) | 
|  | 1229 |  | 
|  | 1230 | InitDroiddocModule(module, android.HostAndDeviceSupported) | 
|  | 1231 | return module | 
|  | 1232 | } | 
|  | 1233 |  | 
|  | 1234 | func DroidstubsHostFactory() android.Module { | 
|  | 1235 | module := &Droidstubs{} | 
|  | 1236 |  | 
|  | 1237 | module.AddProperties(&module.properties, | 
|  | 1238 | &module.Javadoc.properties) | 
|  | 1239 |  | 
|  | 1240 | InitDroiddocModule(module, android.HostSupported) | 
|  | 1241 | return module | 
|  | 1242 | } | 
|  | 1243 |  | 
|  | 1244 | func (d *Droidstubs) ApiFilePath() android.Path { | 
|  | 1245 | return d.apiFilePath | 
|  | 1246 | } | 
|  | 1247 |  | 
|  | 1248 | func (d *Droidstubs) DepsMutator(ctx android.BottomUpMutatorContext) { | 
|  | 1249 | d.Javadoc.addDeps(ctx) | 
|  | 1250 |  | 
|  | 1251 | if apiCheckEnabled(d.properties.Check_api.Current, "current") { | 
|  | 1252 | android.ExtractSourceDeps(ctx, d.properties.Check_api.Current.Api_file) | 
|  | 1253 | android.ExtractSourceDeps(ctx, d.properties.Check_api.Current.Removed_api_file) | 
|  | 1254 | } | 
|  | 1255 |  | 
|  | 1256 | if apiCheckEnabled(d.properties.Check_api.Last_released, "last_released") { | 
|  | 1257 | android.ExtractSourceDeps(ctx, d.properties.Check_api.Last_released.Api_file) | 
|  | 1258 | android.ExtractSourceDeps(ctx, d.properties.Check_api.Last_released.Removed_api_file) | 
|  | 1259 | } | 
|  | 1260 |  | 
|  | 1261 | if String(d.properties.Previous_api) != "" { | 
|  | 1262 | android.ExtractSourceDeps(ctx, d.properties.Previous_api) | 
|  | 1263 | } | 
|  | 1264 |  | 
|  | 1265 | if len(d.properties.Merge_annotations_dirs) != 0 { | 
|  | 1266 | for _, mergeAnnotationsDir := range d.properties.Merge_annotations_dirs { | 
|  | 1267 | ctx.AddDependency(ctx.Module(), metalavaMergeAnnotationsDirTag, mergeAnnotationsDir) | 
|  | 1268 | } | 
|  | 1269 | } | 
| Nan Zhang | 9c69a12 | 2018-08-22 10:22:08 -0700 | [diff] [blame] | 1270 |  | 
| Pete Gillin | 7716790 | 2018-09-19 18:16:26 +0100 | [diff] [blame] | 1271 | if len(d.properties.Merge_inclusion_annotations_dirs) != 0 { | 
|  | 1272 | for _, mergeInclusionAnnotationsDir := range d.properties.Merge_inclusion_annotations_dirs { | 
|  | 1273 | ctx.AddDependency(ctx.Module(), metalavaMergeInclusionAnnotationsDirTag, mergeInclusionAnnotationsDir) | 
|  | 1274 | } | 
|  | 1275 | } | 
|  | 1276 |  | 
| Nan Zhang | 9c69a12 | 2018-08-22 10:22:08 -0700 | [diff] [blame] | 1277 | if len(d.properties.Api_levels_annotations_dirs) != 0 { | 
|  | 1278 | for _, apiLevelsAnnotationsDir := range d.properties.Api_levels_annotations_dirs { | 
|  | 1279 | ctx.AddDependency(ctx.Module(), metalavaAPILevelsAnnotationsDirTag, apiLevelsAnnotationsDir) | 
|  | 1280 | } | 
|  | 1281 | } | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 1282 | } | 
|  | 1283 |  | 
|  | 1284 | func (d *Droidstubs) initBuilderFlags(ctx android.ModuleContext, implicits *android.Paths, | 
|  | 1285 | deps deps) (droiddocBuilderFlags, error) { | 
|  | 1286 | var flags droiddocBuilderFlags | 
|  | 1287 |  | 
|  | 1288 | *implicits = append(*implicits, deps.bootClasspath...) | 
|  | 1289 | *implicits = append(*implicits, deps.classpath...) | 
|  | 1290 |  | 
|  | 1291 | // continue to use -bootclasspath even if Metalava under -source 1.9 is enabled | 
|  | 1292 | // since it doesn't support system modules yet. | 
|  | 1293 | if len(deps.bootClasspath.Strings()) > 0 { | 
|  | 1294 | // For OpenJDK 8 we can use -bootclasspath to define the core libraries code. | 
|  | 1295 | flags.bootClasspathArgs = deps.bootClasspath.FormJavaClassPath("-bootclasspath") | 
|  | 1296 | } | 
|  | 1297 | flags.classpathArgs = deps.classpath.FormJavaClassPath("-classpath") | 
|  | 1298 |  | 
|  | 1299 | flags.sourcepathArgs = "-sourcepath " + strings.Join(d.Javadoc.sourcepaths.Strings(), ":") | 
|  | 1300 |  | 
|  | 1301 | return flags, nil | 
|  | 1302 | } | 
|  | 1303 |  | 
|  | 1304 | func (d *Droidstubs) collectStubsFlags(ctx android.ModuleContext, | 
|  | 1305 | implicitOutputs *android.WritablePaths) string { | 
|  | 1306 | var metalavaFlags string | 
|  | 1307 | if apiCheckEnabled(d.properties.Check_api.Current, "current") || | 
|  | 1308 | apiCheckEnabled(d.properties.Check_api.Last_released, "last_released") || | 
|  | 1309 | String(d.properties.Api_filename) != "" { | 
|  | 1310 | d.apiFile = android.PathForModuleOut(ctx, ctx.ModuleName()+"_api.txt") | 
|  | 1311 | metalavaFlags = metalavaFlags + " --api " + d.apiFile.String() | 
|  | 1312 | *implicitOutputs = append(*implicitOutputs, d.apiFile) | 
|  | 1313 | d.apiFilePath = d.apiFile | 
|  | 1314 | } | 
|  | 1315 |  | 
|  | 1316 | if apiCheckEnabled(d.properties.Check_api.Current, "current") || | 
|  | 1317 | apiCheckEnabled(d.properties.Check_api.Last_released, "last_released") || | 
|  | 1318 | String(d.properties.Removed_api_filename) != "" { | 
|  | 1319 | d.removedApiFile = android.PathForModuleOut(ctx, ctx.ModuleName()+"_removed.txt") | 
|  | 1320 | metalavaFlags = metalavaFlags + " --removed-api " + d.removedApiFile.String() | 
|  | 1321 | *implicitOutputs = append(*implicitOutputs, d.removedApiFile) | 
|  | 1322 | } | 
|  | 1323 |  | 
|  | 1324 | if String(d.properties.Private_api_filename) != "" { | 
|  | 1325 | d.privateApiFile = android.PathForModuleOut(ctx, String(d.properties.Private_api_filename)) | 
|  | 1326 | metalavaFlags = metalavaFlags + " --private-api " + d.privateApiFile.String() | 
|  | 1327 | *implicitOutputs = append(*implicitOutputs, d.privateApiFile) | 
|  | 1328 | } | 
|  | 1329 |  | 
|  | 1330 | if String(d.properties.Dex_api_filename) != "" { | 
|  | 1331 | d.dexApiFile = android.PathForModuleOut(ctx, String(d.properties.Dex_api_filename)) | 
|  | 1332 | metalavaFlags += " --dex-api " + d.dexApiFile.String() | 
|  | 1333 | *implicitOutputs = append(*implicitOutputs, d.dexApiFile) | 
|  | 1334 | } | 
|  | 1335 |  | 
|  | 1336 | if String(d.properties.Private_dex_api_filename) != "" { | 
|  | 1337 | d.privateDexApiFile = android.PathForModuleOut(ctx, String(d.properties.Private_dex_api_filename)) | 
|  | 1338 | metalavaFlags = metalavaFlags + " --private-dex-api " + d.privateDexApiFile.String() | 
|  | 1339 | *implicitOutputs = append(*implicitOutputs, d.privateDexApiFile) | 
|  | 1340 | } | 
|  | 1341 |  | 
|  | 1342 | if String(d.properties.Removed_dex_api_filename) != "" { | 
|  | 1343 | d.removedDexApiFile = android.PathForModuleOut(ctx, String(d.properties.Removed_dex_api_filename)) | 
|  | 1344 | metalavaFlags = metalavaFlags + " --removed-dex-api " + d.removedDexApiFile.String() | 
|  | 1345 | *implicitOutputs = append(*implicitOutputs, d.removedDexApiFile) | 
|  | 1346 | } | 
|  | 1347 |  | 
|  | 1348 | if String(d.properties.Exact_api_filename) != "" { | 
|  | 1349 | d.exactApiFile = android.PathForModuleOut(ctx, String(d.properties.Exact_api_filename)) | 
|  | 1350 | metalavaFlags = metalavaFlags + " --exact-api " + d.exactApiFile.String() | 
|  | 1351 | *implicitOutputs = append(*implicitOutputs, d.exactApiFile) | 
|  | 1352 | } | 
|  | 1353 |  | 
| Nan Zhang | 9c69a12 | 2018-08-22 10:22:08 -0700 | [diff] [blame] | 1354 | if String(d.properties.Dex_mapping_filename) != "" { | 
|  | 1355 | d.apiMappingFile = android.PathForModuleOut(ctx, String(d.properties.Dex_mapping_filename)) | 
|  | 1356 | metalavaFlags = metalavaFlags + " --dex-api-mapping " + d.apiMappingFile.String() | 
|  | 1357 | *implicitOutputs = append(*implicitOutputs, d.apiMappingFile) | 
|  | 1358 | } | 
|  | 1359 |  | 
|  | 1360 | if Bool(d.properties.Write_sdk_values) { | 
|  | 1361 | metalavaFlags = metalavaFlags + " --sdk-values " + android.PathForModuleOut(ctx, "out").String() | 
|  | 1362 | } | 
|  | 1363 |  | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 1364 | if Bool(d.properties.Create_doc_stubs) { | 
|  | 1365 | metalavaFlags += " --doc-stubs " + android.PathForModuleOut(ctx, "stubsDir").String() | 
|  | 1366 | } else { | 
|  | 1367 | metalavaFlags += " --stubs " + android.PathForModuleOut(ctx, "stubsDir").String() | 
|  | 1368 | } | 
|  | 1369 |  | 
|  | 1370 | return metalavaFlags | 
|  | 1371 | } | 
|  | 1372 |  | 
|  | 1373 | func (d *Droidstubs) collectAnnotationsFlags(ctx android.ModuleContext, | 
|  | 1374 | implicits *android.Paths, implicitOutputs *android.WritablePaths) string { | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 1375 | var flags string | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 1376 | if Bool(d.properties.Annotations_enabled) { | 
|  | 1377 | if String(d.properties.Previous_api) == "" { | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 1378 | ctx.PropertyErrorf("metalava_previous_api", | 
|  | 1379 | "has to be non-empty if annotations was enabled!") | 
|  | 1380 | } | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 1381 | previousApi := ctx.ExpandSource(String(d.properties.Previous_api), | 
| Nan Zhang | de860a4 | 2018-08-08 16:32:21 -0700 | [diff] [blame] | 1382 | "metalava_previous_api") | 
|  | 1383 | *implicits = append(*implicits, previousApi) | 
| Nan Zhang | de860a4 | 2018-08-08 16:32:21 -0700 | [diff] [blame] | 1384 |  | 
| Nan Zhang | d05a436 | 2018-08-15 13:28:54 -0700 | [diff] [blame] | 1385 | flags += " --include-annotations --migrate-nullness " + previousApi.String() | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 1386 |  | 
|  | 1387 | d.annotationsZip = android.PathForModuleOut(ctx, ctx.ModuleName()+"_annotations.zip") | 
|  | 1388 | *implicitOutputs = append(*implicitOutputs, d.annotationsZip) | 
|  | 1389 |  | 
| Nan Zhang | f4936b0 | 2018-08-01 15:00:28 -0700 | [diff] [blame] | 1390 | flags += " --extract-annotations " + d.annotationsZip.String() | 
|  | 1391 |  | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 1392 | if len(d.properties.Merge_annotations_dirs) == 0 { | 
| Nan Zhang | 9c69a12 | 2018-08-22 10:22:08 -0700 | [diff] [blame] | 1393 | ctx.PropertyErrorf("merge_annotations_dirs", | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 1394 | "has to be non-empty if annotations was enabled!") | 
|  | 1395 | } | 
| Nan Zhang | f4936b0 | 2018-08-01 15:00:28 -0700 | [diff] [blame] | 1396 | ctx.VisitDirectDepsWithTag(metalavaMergeAnnotationsDirTag, func(m android.Module) { | 
|  | 1397 | if t, ok := m.(*ExportedDroiddocDir); ok { | 
|  | 1398 | *implicits = append(*implicits, t.deps...) | 
| Pete Gillin | 7716790 | 2018-09-19 18:16:26 +0100 | [diff] [blame] | 1399 | flags += " --merge-qualifier-annotations " + t.dir.String() | 
| Nan Zhang | f4936b0 | 2018-08-01 15:00:28 -0700 | [diff] [blame] | 1400 | } else { | 
| Nan Zhang | 9c69a12 | 2018-08-22 10:22:08 -0700 | [diff] [blame] | 1401 | ctx.PropertyErrorf("merge_annotations_dirs", | 
| Nan Zhang | f4936b0 | 2018-08-01 15:00:28 -0700 | [diff] [blame] | 1402 | "module %q is not a metalava merge-annotations dir", ctx.OtherModuleName(m)) | 
|  | 1403 | } | 
|  | 1404 | }) | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 1405 | // TODO(tnorbye): find owners to fix these warnings when annotation was enabled. | 
|  | 1406 | flags += " --hide HiddenTypedefConstant --hide SuperfluousPrefix --hide AnnotationExtraction " | 
|  | 1407 | } | 
| Pete Gillin | 7716790 | 2018-09-19 18:16:26 +0100 | [diff] [blame] | 1408 | ctx.VisitDirectDepsWithTag(metalavaMergeInclusionAnnotationsDirTag, func(m android.Module) { | 
|  | 1409 | if t, ok := m.(*ExportedDroiddocDir); ok { | 
|  | 1410 | *implicits = append(*implicits, t.deps...) | 
|  | 1411 | flags += " --merge-inclusion-annotations " + t.dir.String() | 
|  | 1412 | } else { | 
|  | 1413 | ctx.PropertyErrorf("merge_inclusion_annotations_dirs", | 
|  | 1414 | "module %q is not a metalava merge-annotations dir", ctx.OtherModuleName(m)) | 
|  | 1415 | } | 
|  | 1416 | }) | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 1417 |  | 
|  | 1418 | return flags | 
|  | 1419 | } | 
|  | 1420 |  | 
| Nan Zhang | 9c69a12 | 2018-08-22 10:22:08 -0700 | [diff] [blame] | 1421 | func (d *Droidstubs) collectAPILevelsAnnotationsFlags(ctx android.ModuleContext, | 
|  | 1422 | implicits *android.Paths, implicitOutputs *android.WritablePaths) string { | 
|  | 1423 | var flags string | 
|  | 1424 | if Bool(d.properties.Api_levels_annotations_enabled) { | 
|  | 1425 | d.apiVersionsXml = android.PathForModuleOut(ctx, "api-versions.xml") | 
|  | 1426 | *implicitOutputs = append(*implicitOutputs, d.apiVersionsXml) | 
|  | 1427 |  | 
|  | 1428 | if len(d.properties.Api_levels_annotations_dirs) == 0 { | 
|  | 1429 | ctx.PropertyErrorf("api_levels_annotations_dirs", | 
|  | 1430 | "has to be non-empty if api levels annotations was enabled!") | 
|  | 1431 | } | 
|  | 1432 |  | 
|  | 1433 | flags = " --generate-api-levels " + d.apiVersionsXml.String() + " --apply-api-levels " + | 
|  | 1434 | d.apiVersionsXml.String() + " --current-version " + ctx.Config().PlatformSdkVersion() + | 
|  | 1435 | " --current-codename " + ctx.Config().PlatformSdkCodename() + " " | 
|  | 1436 |  | 
|  | 1437 | ctx.VisitDirectDepsWithTag(metalavaAPILevelsAnnotationsDirTag, func(m android.Module) { | 
|  | 1438 | if t, ok := m.(*ExportedDroiddocDir); ok { | 
|  | 1439 | var androidJars android.Paths | 
|  | 1440 | for _, dep := range t.deps { | 
|  | 1441 | if strings.HasSuffix(dep.String(), "android.jar") { | 
|  | 1442 | androidJars = append(androidJars, dep) | 
|  | 1443 | } | 
|  | 1444 | } | 
|  | 1445 | *implicits = append(*implicits, androidJars...) | 
|  | 1446 | flags += " --android-jar-pattern " + t.dir.String() + "/%/android.jar " | 
|  | 1447 | } else { | 
|  | 1448 | ctx.PropertyErrorf("api_levels_annotations_dirs", | 
|  | 1449 | "module %q is not a metalava api-levels-annotations dir", ctx.OtherModuleName(m)) | 
|  | 1450 | } | 
|  | 1451 | }) | 
|  | 1452 |  | 
|  | 1453 | } | 
|  | 1454 |  | 
|  | 1455 | return flags | 
|  | 1456 | } | 
|  | 1457 |  | 
| Nan Zhang | 71bbe63 | 2018-09-17 14:32:21 -0700 | [diff] [blame] | 1458 | func (d *Droidstubs) collectApiToXmlFlags(ctx android.ModuleContext, implicits *android.Paths, | 
|  | 1459 | implicitOutputs *android.WritablePaths) string { | 
|  | 1460 | var flags string | 
|  | 1461 | if Bool(d.properties.Jdiff_enabled) && !ctx.Config().IsPdkBuild() { | 
|  | 1462 | if d.apiFile.String() == "" { | 
|  | 1463 | ctx.ModuleErrorf("API signature file has to be specified in Metalava when jdiff is enabled.") | 
|  | 1464 | } | 
|  | 1465 |  | 
|  | 1466 | d.apiXmlFile = android.PathForModuleOut(ctx, ctx.ModuleName()+"_api.xml") | 
|  | 1467 | *implicitOutputs = append(*implicitOutputs, d.apiXmlFile) | 
|  | 1468 |  | 
|  | 1469 | flags = " --api-xml " + d.apiXmlFile.String() | 
|  | 1470 |  | 
|  | 1471 | if String(d.properties.Check_api.Last_released.Api_file) == "" { | 
|  | 1472 | ctx.PropertyErrorf("check_api.last_released.api_file", | 
|  | 1473 | "has to be non-empty if jdiff was enabled!") | 
|  | 1474 | } | 
|  | 1475 | lastReleasedApi := ctx.ExpandSource(String(d.properties.Check_api.Last_released.Api_file), | 
|  | 1476 | "check_api.last_released.api_file") | 
|  | 1477 | *implicits = append(*implicits, lastReleasedApi) | 
|  | 1478 |  | 
|  | 1479 | d.lastReleasedApiXmlFile = android.PathForModuleOut(ctx, ctx.ModuleName()+"_last_released_api.xml") | 
|  | 1480 | *implicitOutputs = append(*implicitOutputs, d.lastReleasedApiXmlFile) | 
|  | 1481 |  | 
|  | 1482 | flags += " --convert-to-jdiff " + lastReleasedApi.String() + " " + | 
|  | 1483 | d.lastReleasedApiXmlFile.String() | 
|  | 1484 | } | 
|  | 1485 |  | 
|  | 1486 | return flags | 
|  | 1487 | } | 
|  | 1488 |  | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 1489 | func (d *Droidstubs) transformMetalava(ctx android.ModuleContext, implicits android.Paths, | 
|  | 1490 | implicitOutputs android.WritablePaths, javaVersion, | 
|  | 1491 | bootclasspathArgs, classpathArgs, sourcepathArgs, opts string) { | 
| Nan Zhang | 9c69a12 | 2018-08-22 10:22:08 -0700 | [diff] [blame] | 1492 |  | 
| Nan Zhang | 86d2d55 | 2018-08-09 15:33:27 -0700 | [diff] [blame] | 1493 | ctx.Build(pctx, android.BuildParams{ | 
|  | 1494 | Rule:            metalava, | 
|  | 1495 | Description:     "Metalava", | 
|  | 1496 | Output:          d.Javadoc.stubsSrcJar, | 
|  | 1497 | Inputs:          d.Javadoc.srcFiles, | 
|  | 1498 | Implicits:       implicits, | 
|  | 1499 | ImplicitOutputs: implicitOutputs, | 
|  | 1500 | Args: map[string]string{ | 
| Nan Zhang | 86d2d55 | 2018-08-09 15:33:27 -0700 | [diff] [blame] | 1501 | "outDir":            android.PathForModuleOut(ctx, "out").String(), | 
|  | 1502 | "srcJarDir":         android.PathForModuleOut(ctx, "srcjars").String(), | 
|  | 1503 | "stubsDir":          android.PathForModuleOut(ctx, "stubsDir").String(), | 
|  | 1504 | "srcJars":           strings.Join(d.Javadoc.srcJars.Strings(), " "), | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 1505 | "javaVersion":       javaVersion, | 
| Nan Zhang | 86d2d55 | 2018-08-09 15:33:27 -0700 | [diff] [blame] | 1506 | "bootclasspathArgs": bootclasspathArgs, | 
|  | 1507 | "classpathArgs":     classpathArgs, | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 1508 | "sourcepathArgs":    sourcepathArgs, | 
|  | 1509 | "opts":              opts, | 
| Nan Zhang | 86d2d55 | 2018-08-09 15:33:27 -0700 | [diff] [blame] | 1510 | }, | 
|  | 1511 | }) | 
|  | 1512 | } | 
|  | 1513 |  | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 1514 | func (d *Droidstubs) transformCheckApi(ctx android.ModuleContext, | 
|  | 1515 | apiFile, removedApiFile android.Path, implicits android.Paths, | 
|  | 1516 | javaVersion, bootclasspathArgs, classpathArgs, sourcepathArgs, opts, msg string, | 
| Nan Zhang | 2760dfc | 2018-08-24 17:32:54 +0000 | [diff] [blame] | 1517 | output android.WritablePath) { | 
|  | 1518 | ctx.Build(pctx, android.BuildParams{ | 
|  | 1519 | Rule:        metalavaApiCheck, | 
|  | 1520 | Description: "Metalava Check API", | 
|  | 1521 | Output:      output, | 
|  | 1522 | Inputs:      d.Javadoc.srcFiles, | 
|  | 1523 | Implicits: append(android.Paths{apiFile, removedApiFile, d.apiFile, d.removedApiFile}, | 
|  | 1524 | implicits...), | 
|  | 1525 | Args: map[string]string{ | 
|  | 1526 | "srcJarDir":         android.PathForModuleOut(ctx, "srcjars").String(), | 
|  | 1527 | "srcJars":           strings.Join(d.Javadoc.srcJars.Strings(), " "), | 
|  | 1528 | "javaVersion":       javaVersion, | 
|  | 1529 | "bootclasspathArgs": bootclasspathArgs, | 
|  | 1530 | "classpathArgs":     classpathArgs, | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 1531 | "sourcepathArgs":    sourcepathArgs, | 
| Nan Zhang | 2760dfc | 2018-08-24 17:32:54 +0000 | [diff] [blame] | 1532 | "opts":              opts, | 
|  | 1533 | "msg":               msg, | 
|  | 1534 | }, | 
|  | 1535 | }) | 
|  | 1536 | } | 
|  | 1537 |  | 
| Nan Zhang | 71bbe63 | 2018-09-17 14:32:21 -0700 | [diff] [blame] | 1538 | func (d *Droidstubs) transformJdiff(ctx android.ModuleContext, implicits android.Paths, | 
|  | 1539 | implicitOutputs android.WritablePaths, | 
|  | 1540 | bootclasspathArgs, classpathArgs, sourcepathArgs, opts string) { | 
|  | 1541 | ctx.Build(pctx, android.BuildParams{ | 
|  | 1542 | Rule:            javadoc, | 
|  | 1543 | Description:     "Jdiff", | 
|  | 1544 | Output:          d.jdiffStubsSrcJar, | 
|  | 1545 | Inputs:          d.Javadoc.srcFiles, | 
|  | 1546 | Implicits:       implicits, | 
|  | 1547 | ImplicitOutputs: implicitOutputs, | 
|  | 1548 | Args: map[string]string{ | 
| Nan Zhang | 23a1ba6 | 2018-09-19 11:19:39 -0700 | [diff] [blame] | 1549 | "outDir":            android.PathForModuleOut(ctx, "jdiff-out").String(), | 
|  | 1550 | "srcJarDir":         android.PathForModuleOut(ctx, "jdiff-srcjars").String(), | 
|  | 1551 | "stubsDir":          android.PathForModuleOut(ctx, "jdiff-stubsDir").String(), | 
| Nan Zhang | 71bbe63 | 2018-09-17 14:32:21 -0700 | [diff] [blame] | 1552 | "srcJars":           strings.Join(d.Javadoc.srcJars.Strings(), " "), | 
|  | 1553 | "opts":              opts, | 
|  | 1554 | "bootclasspathArgs": bootclasspathArgs, | 
|  | 1555 | "classpathArgs":     classpathArgs, | 
|  | 1556 | "sourcepathArgs":    sourcepathArgs, | 
|  | 1557 | "docZip":            d.jdiffDocZip.String(), | 
|  | 1558 | }, | 
|  | 1559 | }) | 
|  | 1560 | } | 
|  | 1561 |  | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 1562 | func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) { | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 1563 | deps := d.Javadoc.collectDeps(ctx) | 
|  | 1564 |  | 
|  | 1565 | javaVersion := getJavaVersion(ctx, String(d.Javadoc.properties.Java_version), sdkContext(d)) | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 1566 |  | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 1567 | var implicits android.Paths | 
|  | 1568 | implicits = append(implicits, d.Javadoc.srcJars...) | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 1569 | implicits = append(implicits, d.Javadoc.argFiles...) | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 1570 |  | 
|  | 1571 | var implicitOutputs android.WritablePaths | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 1572 | for _, o := range d.Javadoc.properties.Out { | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 1573 | implicitOutputs = append(implicitOutputs, android.PathForModuleGen(ctx, o)) | 
|  | 1574 | } | 
|  | 1575 |  | 
|  | 1576 | flags, err := d.initBuilderFlags(ctx, &implicits, deps) | 
| Nan Zhang | 2760dfc | 2018-08-24 17:32:54 +0000 | [diff] [blame] | 1577 | metalavaCheckApiImplicits := implicits | 
| Nan Zhang | 71bbe63 | 2018-09-17 14:32:21 -0700 | [diff] [blame] | 1578 | jdiffImplicits := implicits | 
|  | 1579 |  | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 1580 | if err != nil { | 
|  | 1581 | return | 
|  | 1582 | } | 
|  | 1583 |  | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 1584 | flags.metalavaStubsFlags = d.collectStubsFlags(ctx, &implicitOutputs) | 
|  | 1585 | flags.metalavaAnnotationsFlags = d.collectAnnotationsFlags(ctx, &implicits, &implicitOutputs) | 
| Nan Zhang | 9c69a12 | 2018-08-22 10:22:08 -0700 | [diff] [blame] | 1586 | flags.metalavaApiLevelsAnnotationsFlags = d.collectAPILevelsAnnotationsFlags(ctx, &implicits, &implicitOutputs) | 
| Nan Zhang | 71bbe63 | 2018-09-17 14:32:21 -0700 | [diff] [blame] | 1587 | flags.metalavaApiToXmlFlags = d.collectApiToXmlFlags(ctx, &implicits, &implicitOutputs) | 
|  | 1588 |  | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 1589 | if strings.Contains(d.Javadoc.args, "--generate-documentation") { | 
|  | 1590 | // Currently Metalava have the ability to invoke Javadoc in a seperate process. | 
|  | 1591 | // Pass "-nodocs" to suppress the Javadoc invocation when Metalava receives | 
|  | 1592 | // "--generate-documentation" arg. This is not needed when Metalava removes this feature. | 
|  | 1593 | d.Javadoc.args = d.Javadoc.args + " -nodocs " | 
| Nan Zhang | 79614d1 | 2018-04-19 18:03:39 -0700 | [diff] [blame] | 1594 | } | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 1595 | d.transformMetalava(ctx, implicits, implicitOutputs, javaVersion, | 
|  | 1596 | flags.bootClasspathArgs, flags.classpathArgs, flags.sourcepathArgs, | 
| Nan Zhang | 9c69a12 | 2018-08-22 10:22:08 -0700 | [diff] [blame] | 1597 | flags.metalavaStubsFlags+flags.metalavaAnnotationsFlags+ | 
| Nan Zhang | 71bbe63 | 2018-09-17 14:32:21 -0700 | [diff] [blame] | 1598 | flags.metalavaApiLevelsAnnotationsFlags+flags.metalavaApiToXmlFlags+" "+d.Javadoc.args) | 
| Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 1599 |  | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 1600 | if apiCheckEnabled(d.properties.Check_api.Current, "current") && | 
|  | 1601 | !ctx.Config().IsPdkBuild() { | 
| Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 1602 | apiFile := ctx.ExpandSource(String(d.properties.Check_api.Current.Api_file), | 
|  | 1603 | "check_api.current.api_file") | 
|  | 1604 | removedApiFile := ctx.ExpandSource(String(d.properties.Check_api.Current.Removed_api_file), | 
|  | 1605 | "check_api.current_removed_api_file") | 
|  | 1606 |  | 
| Nan Zhang | 2760dfc | 2018-08-24 17:32:54 +0000 | [diff] [blame] | 1607 | d.checkCurrentApiTimestamp = android.PathForModuleOut(ctx, "check_current_api.timestamp") | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 1608 | opts := d.Javadoc.args + " --check-compatibility:api:current " + apiFile.String() + | 
|  | 1609 | " --check-compatibility:removed:current " + removedApiFile.String() + " " | 
| Nan Zhang | 2760dfc | 2018-08-24 17:32:54 +0000 | [diff] [blame] | 1610 |  | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 1611 | d.transformCheckApi(ctx, apiFile, removedApiFile, metalavaCheckApiImplicits, | 
|  | 1612 | javaVersion, flags.bootClasspathArgs, flags.classpathArgs, flags.sourcepathArgs, opts, | 
|  | 1613 | fmt.Sprintf(`\n******************************\n`+ | 
|  | 1614 | `You have tried to change the API from what has been previously approved.\n\n`+ | 
|  | 1615 | `To make these errors go away, you have two choices:\n`+ | 
|  | 1616 | `   1. You can add '@hide' javadoc comments to the methods, etc. listed in the\n`+ | 
|  | 1617 | `      errors above.\n\n`+ | 
|  | 1618 | `   2. You can update current.txt by executing the following command:\n`+ | 
|  | 1619 | `         make %s-update-current-api\n\n`+ | 
|  | 1620 | `      To submit the revised current.txt to the main Android repository,\n`+ | 
|  | 1621 | `      you will need approval.\n`+ | 
|  | 1622 | `******************************\n`, ctx.ModuleName()), | 
|  | 1623 | d.checkCurrentApiTimestamp) | 
| Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 1624 |  | 
|  | 1625 | d.updateCurrentApiTimestamp = android.PathForModuleOut(ctx, "update_current_api.timestamp") | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 1626 | transformUpdateApi(ctx, apiFile, removedApiFile, d.apiFile, d.removedApiFile, | 
|  | 1627 | d.updateCurrentApiTimestamp) | 
| Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 1628 | } | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 1629 |  | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 1630 | if apiCheckEnabled(d.properties.Check_api.Last_released, "last_released") && | 
|  | 1631 | !ctx.Config().IsPdkBuild() { | 
| Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 1632 | apiFile := ctx.ExpandSource(String(d.properties.Check_api.Last_released.Api_file), | 
|  | 1633 | "check_api.last_released.api_file") | 
|  | 1634 | removedApiFile := ctx.ExpandSource(String(d.properties.Check_api.Last_released.Removed_api_file), | 
|  | 1635 | "check_api.last_released.removed_api_file") | 
|  | 1636 |  | 
| Nan Zhang | 2760dfc | 2018-08-24 17:32:54 +0000 | [diff] [blame] | 1637 | d.checkLastReleasedApiTimestamp = android.PathForModuleOut(ctx, "check_last_released_api.timestamp") | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 1638 | opts := d.Javadoc.args + " --check-compatibility:api:released " + apiFile.String() + | 
|  | 1639 | " --check-compatibility:removed:released " + removedApiFile.String() + " " | 
| Nan Zhang | 2760dfc | 2018-08-24 17:32:54 +0000 | [diff] [blame] | 1640 |  | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 1641 | d.transformCheckApi(ctx, apiFile, removedApiFile, metalavaCheckApiImplicits, | 
|  | 1642 | javaVersion, flags.bootClasspathArgs, flags.classpathArgs, flags.sourcepathArgs, opts, | 
|  | 1643 | `\n******************************\n`+ | 
|  | 1644 | `You have tried to change the API from what has been previously released in\n`+ | 
|  | 1645 | `an SDK.  Please fix the errors listed above.\n`+ | 
|  | 1646 | `******************************\n`, | 
|  | 1647 | d.checkLastReleasedApiTimestamp) | 
| Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 1648 | } | 
| Nan Zhang | 71bbe63 | 2018-09-17 14:32:21 -0700 | [diff] [blame] | 1649 |  | 
|  | 1650 | if Bool(d.properties.Jdiff_enabled) && !ctx.Config().IsPdkBuild() { | 
|  | 1651 |  | 
| Nan Zhang | 86b0620 | 2018-09-21 17:09:21 -0700 | [diff] [blame] | 1652 | // Please sync with android-api-council@ before making any changes for the name of jdiffDocZip below | 
|  | 1653 | // since there's cron job downstream that fetch this .zip file periodically. | 
|  | 1654 | // See b/116221385 for reference. | 
| Nan Zhang | 71bbe63 | 2018-09-17 14:32:21 -0700 | [diff] [blame] | 1655 | d.jdiffDocZip = android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"jdiff-docs.zip") | 
|  | 1656 | d.jdiffStubsSrcJar = android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"jdiff-stubs.srcjar") | 
|  | 1657 |  | 
|  | 1658 | var jdiffImplicitOutputs android.WritablePaths | 
|  | 1659 | jdiffImplicitOutputs = append(jdiffImplicitOutputs, d.jdiffDocZip) | 
|  | 1660 |  | 
|  | 1661 | jdiff := android.PathForOutput(ctx, "host", ctx.Config().PrebuiltOS(), "framework", "jdiff.jar") | 
|  | 1662 | jdiffImplicits = append(jdiffImplicits, android.Paths{jdiff, d.apiXmlFile, d.lastReleasedApiXmlFile}...) | 
|  | 1663 |  | 
|  | 1664 | opts := " -encoding UTF-8 -source 1.8 -J-Xmx1600m -XDignore.symbol.file " + | 
|  | 1665 | "-doclet jdiff.JDiff -docletpath " + jdiff.String() + " -quiet " + | 
|  | 1666 | "-newapi " + strings.TrimSuffix(d.apiXmlFile.Base(), d.apiXmlFile.Ext()) + | 
|  | 1667 | " -newapidir " + filepath.Dir(d.apiXmlFile.String()) + | 
|  | 1668 | " -oldapi " + strings.TrimSuffix(d.lastReleasedApiXmlFile.Base(), d.lastReleasedApiXmlFile.Ext()) + | 
|  | 1669 | " -oldapidir " + filepath.Dir(d.lastReleasedApiXmlFile.String()) | 
|  | 1670 |  | 
|  | 1671 | d.transformJdiff(ctx, jdiffImplicits, jdiffImplicitOutputs, flags.bootClasspathArgs, flags.classpathArgs, | 
|  | 1672 | flags.sourcepathArgs, opts) | 
|  | 1673 | } | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 1674 | } | 
| Dan Willemsen | cc09097 | 2018-02-26 14:33:31 -0800 | [diff] [blame] | 1675 |  | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 1676 | // | 
| Nan Zhang | f4936b0 | 2018-08-01 15:00:28 -0700 | [diff] [blame] | 1677 | // Exported Droiddoc Directory | 
| Nan Zhang | a40da04 | 2018-08-01 12:48:00 -0700 | [diff] [blame] | 1678 | // | 
| Dan Willemsen | cc09097 | 2018-02-26 14:33:31 -0800 | [diff] [blame] | 1679 | var droiddocTemplateTag = dependencyTag{name: "droiddoc-template"} | 
| Nan Zhang | f4936b0 | 2018-08-01 15:00:28 -0700 | [diff] [blame] | 1680 | var metalavaMergeAnnotationsDirTag = dependencyTag{name: "metalava-merge-annotations-dir"} | 
| Pete Gillin | 7716790 | 2018-09-19 18:16:26 +0100 | [diff] [blame] | 1681 | var metalavaMergeInclusionAnnotationsDirTag = dependencyTag{name: "metalava-merge-inclusion-annotations-dir"} | 
| Nan Zhang | 9c69a12 | 2018-08-22 10:22:08 -0700 | [diff] [blame] | 1682 | var metalavaAPILevelsAnnotationsDirTag = dependencyTag{name: "metalava-api-levels-annotations-dir"} | 
| Dan Willemsen | cc09097 | 2018-02-26 14:33:31 -0800 | [diff] [blame] | 1683 |  | 
| Nan Zhang | f4936b0 | 2018-08-01 15:00:28 -0700 | [diff] [blame] | 1684 | type ExportedDroiddocDirProperties struct { | 
|  | 1685 | // path to the directory containing Droiddoc related files. | 
| Dan Willemsen | cc09097 | 2018-02-26 14:33:31 -0800 | [diff] [blame] | 1686 | Path *string | 
|  | 1687 | } | 
|  | 1688 |  | 
| Nan Zhang | f4936b0 | 2018-08-01 15:00:28 -0700 | [diff] [blame] | 1689 | type ExportedDroiddocDir struct { | 
| Dan Willemsen | cc09097 | 2018-02-26 14:33:31 -0800 | [diff] [blame] | 1690 | android.ModuleBase | 
|  | 1691 |  | 
| Nan Zhang | f4936b0 | 2018-08-01 15:00:28 -0700 | [diff] [blame] | 1692 | properties ExportedDroiddocDirProperties | 
| Dan Willemsen | cc09097 | 2018-02-26 14:33:31 -0800 | [diff] [blame] | 1693 |  | 
|  | 1694 | deps android.Paths | 
|  | 1695 | dir  android.Path | 
|  | 1696 | } | 
|  | 1697 |  | 
| Nan Zhang | f4936b0 | 2018-08-01 15:00:28 -0700 | [diff] [blame] | 1698 | func ExportedDroiddocDirFactory() android.Module { | 
|  | 1699 | module := &ExportedDroiddocDir{} | 
| Dan Willemsen | cc09097 | 2018-02-26 14:33:31 -0800 | [diff] [blame] | 1700 | module.AddProperties(&module.properties) | 
|  | 1701 | android.InitAndroidModule(module) | 
|  | 1702 | return module | 
|  | 1703 | } | 
|  | 1704 |  | 
| Nan Zhang | f4936b0 | 2018-08-01 15:00:28 -0700 | [diff] [blame] | 1705 | func (d *ExportedDroiddocDir) DepsMutator(android.BottomUpMutatorContext) {} | 
| Dan Willemsen | cc09097 | 2018-02-26 14:33:31 -0800 | [diff] [blame] | 1706 |  | 
| Nan Zhang | f4936b0 | 2018-08-01 15:00:28 -0700 | [diff] [blame] | 1707 | func (d *ExportedDroiddocDir) GenerateAndroidBuildActions(ctx android.ModuleContext) { | 
| Dan Willemsen | cc09097 | 2018-02-26 14:33:31 -0800 | [diff] [blame] | 1708 | path := android.PathForModuleSrc(ctx, String(d.properties.Path)) | 
|  | 1709 | d.dir = path | 
|  | 1710 | d.deps = ctx.Glob(path.Join(ctx, "**/*").String(), nil) | 
|  | 1711 | } | 
| Nan Zhang | b2b33de | 2018-02-23 11:18:47 -0800 | [diff] [blame] | 1712 |  | 
|  | 1713 | // | 
|  | 1714 | // Defaults | 
|  | 1715 | // | 
|  | 1716 | type DocDefaults struct { | 
|  | 1717 | android.ModuleBase | 
|  | 1718 | android.DefaultsModuleBase | 
|  | 1719 | } | 
|  | 1720 |  | 
|  | 1721 | func (*DocDefaults) GenerateAndroidBuildActions(ctx android.ModuleContext) { | 
|  | 1722 | } | 
|  | 1723 |  | 
|  | 1724 | func (d *DocDefaults) DepsMutator(ctx android.BottomUpMutatorContext) { | 
|  | 1725 | } | 
|  | 1726 |  | 
|  | 1727 | func DocDefaultsFactory() android.Module { | 
|  | 1728 | module := &DocDefaults{} | 
|  | 1729 |  | 
|  | 1730 | module.AddProperties( | 
|  | 1731 | &JavadocProperties{}, | 
|  | 1732 | &DroiddocProperties{}, | 
|  | 1733 | ) | 
|  | 1734 |  | 
|  | 1735 | android.InitDefaultsModule(module) | 
|  | 1736 |  | 
|  | 1737 | return module | 
|  | 1738 | } | 
| Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 1739 |  | 
|  | 1740 | func StubsDefaultsFactory() android.Module { | 
|  | 1741 | module := &DocDefaults{} | 
|  | 1742 |  | 
|  | 1743 | module.AddProperties( | 
|  | 1744 | &JavadocProperties{}, | 
|  | 1745 | &DroidstubsProperties{}, | 
|  | 1746 | ) | 
|  | 1747 |  | 
|  | 1748 | android.InitDefaultsModule(module) | 
|  | 1749 |  | 
|  | 1750 | return module | 
|  | 1751 | } |