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