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