blob: b1e3ea80a42751ba53626350a57aa3138c0106d0 [file] [log] [blame]
Nan Zhang581fd212018-01-10 16:06:12 -08001// 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
15package java
16
17import (
18 "android/soong/android"
19 "android/soong/java/config"
20 "fmt"
Nan Zhangb2b33de2018-02-23 11:18:47 -080021 "path/filepath"
Nan Zhang46130972018-06-04 11:28:01 -070022 "runtime"
Nan Zhang581fd212018-01-10 16:06:12 -080023 "strings"
24
25 "github.com/google/blueprint"
26)
27
28var (
29 javadoc = pctx.AndroidStaticRule("javadoc",
30 blueprint.RuleParams{
31 Command: `rm -rf "$outDir" "$srcJarDir" "$stubsDir" && mkdir -p "$outDir" "$srcJarDir" "$stubsDir" && ` +
Colin Cross436b7652018-03-15 16:24:10 -070032 `${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` +
Nan Zhangaf322cc2018-06-19 15:15:38 -070033 `${config.JavadocCmd} -encoding UTF-8 @$out.rsp @$srcJarDir/list ` +
Nan Zhang581fd212018-01-10 16:06:12 -080034 `$opts $bootclasspathArgs $classpathArgs -sourcepath $sourcepath ` +
35 `-d $outDir -quiet && ` +
36 `${config.SoongZipCmd} -write_if_changed -d -o $docZip -C $outDir -D $outDir && ` +
Nan Zhange2ba5d42018-07-11 15:16:55 -070037 `${config.SoongZipCmd} -write_if_changed -jar -o $out -C $stubsDir -D $stubsDir $postDoclavaCmds`,
Nan Zhang581fd212018-01-10 16:06:12 -080038 CommandDeps: []string{
Colin Cross436b7652018-03-15 16:24:10 -070039 "${config.ZipSyncCmd}",
Nan Zhang581fd212018-01-10 16:06:12 -080040 "${config.JavadocCmd}",
41 "${config.SoongZipCmd}",
Nan Zhang581fd212018-01-10 16:06:12 -080042 },
43 Rspfile: "$out.rsp",
44 RspfileContent: "$in",
45 Restat: true,
46 },
Nan Zhangaf322cc2018-06-19 15:15:38 -070047 "outDir", "srcJarDir", "stubsDir", "srcJars", "opts",
Nan Zhange2ba5d42018-07-11 15:16:55 -070048 "bootclasspathArgs", "classpathArgs", "sourcepath", "docZip", "postDoclavaCmds")
Nan Zhang61819ce2018-05-04 18:49:16 -070049
50 apiCheck = pctx.AndroidStaticRule("apiCheck",
51 blueprint.RuleParams{
52 Command: `( ${config.ApiCheckCmd} -JXmx1024m -J"classpath $classpath" $opts ` +
53 `$apiFile $apiFileToCheck $removedApiFile $removedApiFileToCheck ` +
Jiyong Parkeeb8a642018-05-12 22:21:20 +090054 `&& touch $out ) || (echo -e "$msg" ; exit 38)`,
Nan Zhang61819ce2018-05-04 18:49:16 -070055 CommandDeps: []string{
56 "${config.ApiCheckCmd}",
57 },
58 },
59 "classpath", "opts", "apiFile", "apiFileToCheck", "removedApiFile", "removedApiFileToCheck", "msg")
60
61 updateApi = pctx.AndroidStaticRule("updateApi",
62 blueprint.RuleParams{
63 Command: `( ( cp -f $apiFileToCheck $apiFile && cp -f $removedApiFileToCheck $removedApiFile ) ` +
64 `&& touch $out ) || (echo failed to update public API ; exit 38)`,
65 },
66 "apiFile", "apiFileToCheck", "removedApiFile", "removedApiFileToCheck")
Nan Zhang79614d12018-04-19 18:03:39 -070067
68 metalava = pctx.AndroidStaticRule("metalava",
69 blueprint.RuleParams{
Nan Zhangde860a42018-08-08 16:32:21 -070070 Command: `rm -rf "$outDir" "$srcJarDir" "$stubsDir" "$docStubsDir" && ` +
71 `mkdir -p "$outDir" "$srcJarDir" "$stubsDir" "$docStubsDir" && ` +
Nan Zhang79614d12018-04-19 18:03:39 -070072 `${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` +
Nan Zhang357466b2018-04-17 17:38:36 -070073 `${config.JavaCmd} -jar ${config.MetalavaJar} -encoding UTF-8 -source $javaVersion @$out.rsp @$srcJarDir/list ` +
Nan Zhang16c0a312018-06-13 17:42:48 -070074 `$bootclasspathArgs $classpathArgs -sourcepath $sourcepath --no-banner --color --quiet ` +
75 `--stubs $stubsDir $opts && ` +
Nan Zhang79614d12018-04-19 18:03:39 -070076 `${config.SoongZipCmd} -write_if_changed -d -o $docZip -C $outDir -D $outDir && ` +
77 `${config.SoongZipCmd} -write_if_changed -jar -o $out -C $stubsDir -D $stubsDir`,
78 CommandDeps: []string{
79 "${config.ZipSyncCmd}",
80 "${config.JavaCmd}",
81 "${config.MetalavaJar}",
82 "${config.JavadocCmd}",
83 "${config.SoongZipCmd}",
84 },
85 Rspfile: "$out.rsp",
86 RspfileContent: "$in",
87 Restat: true,
88 },
Nan Zhangde860a42018-08-08 16:32:21 -070089 "outDir", "srcJarDir", "stubsDir", "docStubsDir", "srcJars", "javaVersion", "bootclasspathArgs",
Nan Zhang357466b2018-04-17 17:38:36 -070090 "classpathArgs", "sourcepath", "opts", "docZip")
Nan Zhang581fd212018-01-10 16:06:12 -080091)
92
93func init() {
Nan Zhangb2b33de2018-02-23 11:18:47 -080094 android.RegisterModuleType("doc_defaults", DocDefaultsFactory)
95
Nan Zhang581fd212018-01-10 16:06:12 -080096 android.RegisterModuleType("droiddoc", DroiddocFactory)
97 android.RegisterModuleType("droiddoc_host", DroiddocHostFactory)
Nan Zhangf4936b02018-08-01 15:00:28 -070098 android.RegisterModuleType("droiddoc_exported_dir", ExportedDroiddocDirFactory)
Nan Zhang581fd212018-01-10 16:06:12 -080099 android.RegisterModuleType("javadoc", JavadocFactory)
100 android.RegisterModuleType("javadoc_host", JavadocHostFactory)
101}
102
Colin Crossa1ce2a02018-06-20 15:19:39 -0700103var (
104 srcsLibTag = dependencyTag{name: "sources from javalib"}
105)
106
Nan Zhang581fd212018-01-10 16:06:12 -0800107type JavadocProperties struct {
108 // list of source files used to compile the Java module. May be .java, .logtags, .proto,
109 // or .aidl files.
110 Srcs []string `android:"arch_variant"`
111
112 // list of directories rooted at the Android.bp file that will
113 // be added to the search paths for finding source files when passing package names.
Nan Zhangb2b33de2018-02-23 11:18:47 -0800114 Local_sourcepaths []string
Nan Zhang581fd212018-01-10 16:06:12 -0800115
116 // list of source files that should not be used to build the Java module.
117 // This is most useful in the arch/multilib variants to remove non-common files
118 // filegroup or genrule can be included within this property.
119 Exclude_srcs []string `android:"arch_variant"`
120
Nan Zhangb2b33de2018-02-23 11:18:47 -0800121 // list of java libraries that will be in the classpath.
Nan Zhang581fd212018-01-10 16:06:12 -0800122 Libs []string `android:"arch_variant"`
123
Nan Zhange66c7272018-03-06 12:59:27 -0800124 // don't build against the framework libraries (legacy-test, core-junit,
125 // ext, and framework for device targets)
126 No_framework_libs *bool
127
Nan Zhangb2b33de2018-02-23 11:18:47 -0800128 // the java library (in classpath) for documentation that provides java srcs and srcjars.
129 Srcs_lib *string
130
131 // the base dirs under srcs_lib will be scanned for java srcs.
132 Srcs_lib_whitelist_dirs []string
133
134 // the sub dirs under srcs_lib_whitelist_dirs will be scanned for java srcs.
135 Srcs_lib_whitelist_pkgs []string
136
Nan Zhang581fd212018-01-10 16:06:12 -0800137 // If set to false, don't allow this module(-docs.zip) to be exported. Defaults to true.
Nan Zhangb2b33de2018-02-23 11:18:47 -0800138 Installable *bool
Nan Zhang581fd212018-01-10 16:06:12 -0800139
140 // if not blank, set to the version of the sdk to compile against
141 Sdk_version *string `android:"arch_variant"`
Jiyong Park1e440682018-05-23 18:42:04 +0900142
143 Aidl struct {
144 // Top level directories to pass to aidl tool
145 Include_dirs []string
146
147 // Directories rooted at the Android.bp file to pass to aidl tool
148 Local_include_dirs []string
149 }
Nan Zhang357466b2018-04-17 17:38:36 -0700150
151 // If not blank, set the java version passed to javadoc as -source
152 Java_version *string
Nan Zhang581fd212018-01-10 16:06:12 -0800153}
154
Nan Zhang61819ce2018-05-04 18:49:16 -0700155type ApiToCheck struct {
Jiyong Parkeeb8a642018-05-12 22:21:20 +0900156 // path to the API txt file that the new API extracted from source code is checked
157 // against. The path can be local to the module or from other module (via :module syntax).
Nan Zhang61819ce2018-05-04 18:49:16 -0700158 Api_file *string
159
Jiyong Parkeeb8a642018-05-12 22:21:20 +0900160 // path to the API txt file that the new @removed API extractd from source code is
161 // checked against. The path can be local to the module or from other module (via
162 // :module syntax).
Nan Zhang61819ce2018-05-04 18:49:16 -0700163 Removed_api_file *string
164
Jiyong Parkeeb8a642018-05-12 22:21:20 +0900165 // Arguments to the apicheck tool.
Nan Zhang61819ce2018-05-04 18:49:16 -0700166 Args *string
167}
168
Nan Zhang581fd212018-01-10 16:06:12 -0800169type DroiddocProperties struct {
170 // directory relative to top of the source tree that contains doc templates files.
Nan Zhangb2b33de2018-02-23 11:18:47 -0800171 Custom_template *string
Nan Zhang581fd212018-01-10 16:06:12 -0800172
Nan Zhanga40da042018-08-01 12:48:00 -0700173 // directories under current module source which contains html/jd files.
Nan Zhangb2b33de2018-02-23 11:18:47 -0800174 Html_dirs []string
Nan Zhang581fd212018-01-10 16:06:12 -0800175
176 // set a value in the Clearsilver hdf namespace.
Nan Zhangb2b33de2018-02-23 11:18:47 -0800177 Hdf []string
Nan Zhang581fd212018-01-10 16:06:12 -0800178
179 // proofread file contains all of the text content of the javadocs concatenated into one file,
180 // suitable for spell-checking and other goodness.
Nan Zhangb2b33de2018-02-23 11:18:47 -0800181 Proofread_file *string
Nan Zhang581fd212018-01-10 16:06:12 -0800182
183 // a todo file lists the program elements that are missing documentation.
184 // At some point, this might be improved to show more warnings.
Nan Zhangb2b33de2018-02-23 11:18:47 -0800185 Todo_file *string
186
187 // directory under current module source that provide additional resources (images).
188 Resourcesdir *string
189
190 // resources output directory under out/soong/.intermediates.
191 Resourcesoutdir *string
Nan Zhang581fd212018-01-10 16:06:12 -0800192
193 // local files that are used within user customized droiddoc options.
Nan Zhangb2b33de2018-02-23 11:18:47 -0800194 Arg_files []string
Nan Zhang581fd212018-01-10 16:06:12 -0800195
196 // user customized droiddoc args.
197 // Available variables for substitution:
198 //
199 // $(location <label>): the path to the arg_files with name <label>
Nan Zhangb2b33de2018-02-23 11:18:47 -0800200 Args *string
Nan Zhang581fd212018-01-10 16:06:12 -0800201
202 // names of the output files used in args that will be generated
Nan Zhangb2b33de2018-02-23 11:18:47 -0800203 Out []string
Nan Zhang581fd212018-01-10 16:06:12 -0800204
Nan Zhange2ba5d42018-07-11 15:16:55 -0700205 // if set to true, collect the values used by the Dev tools and
206 // write them in files packaged with the SDK. Defaults to false.
207 Write_sdk_values *bool
208
209 // index.html under current module will be copied to docs out dir, if not null.
210 Static_doc_index_redirect *string
211
212 // source.properties under current module will be copied to docs out dir, if not null.
213 Static_doc_properties *string
214
Nan Zhang581fd212018-01-10 16:06:12 -0800215 // a list of files under current module source dir which contains known tags in Java sources.
216 // filegroup or genrule can be included within this property.
Nan Zhangb2b33de2018-02-23 11:18:47 -0800217 Knowntags []string
Nan Zhang28c68b92018-03-13 16:17:01 -0700218
219 // the tag name used to distinguish if the API files belong to public/system/test.
220 Api_tag_name *string
221
222 // the generated public API filename by Doclava.
223 Api_filename *string
224
David Brazdilfbe4cc32018-05-31 13:56:46 +0100225 // the generated public Dex API filename by Doclava.
226 Dex_api_filename *string
227
Nan Zhang28c68b92018-03-13 16:17:01 -0700228 // the generated private API filename by Doclava.
229 Private_api_filename *string
230
231 // the generated private Dex API filename by Doclava.
232 Private_dex_api_filename *string
233
234 // the generated removed API filename by Doclava.
235 Removed_api_filename *string
236
David Brazdilaac0c3c2018-04-24 16:23:29 +0100237 // the generated removed Dex API filename by Doclava.
238 Removed_dex_api_filename *string
239
Mathew Inwood76c3de12018-06-22 15:28:11 +0100240 // mapping of dex signatures to source file and line number. This is a temporary property and
241 // will be deleted; you probably shouldn't be using it.
242 Dex_mapping_filename *string
243
Nan Zhang28c68b92018-03-13 16:17:01 -0700244 // the generated exact API filename by Doclava.
245 Exact_api_filename *string
Nan Zhang853f4202018-04-12 16:55:56 -0700246
Nan Zhang66dc2362018-08-14 20:41:04 -0700247 // the generated proguard filename by Doclava.
248 Proguard_filename *string
249
Nan Zhang853f4202018-04-12 16:55:56 -0700250 // if set to false, don't allow droiddoc to generate stubs source files. Defaults to true.
251 Create_stubs *bool
Nan Zhang61819ce2018-05-04 18:49:16 -0700252
253 Check_api struct {
254 Last_released ApiToCheck
255
256 Current ApiToCheck
257 }
Nan Zhang79614d12018-04-19 18:03:39 -0700258
259 // if set to true, create stubs through Metalava instead of Doclava. Javadoc/Doclava is
260 // currently still used for documentation generation, and will be replaced by Dokka soon.
261 Metalava_enabled *bool
262
263 // user can specify the version of previous released API file in order to do compatibility check.
264 Metalava_previous_api *string
265
266 // is set to true, Metalava will allow framework SDK to contain annotations.
267 Metalava_annotations_enabled *bool
268
Pete Gillinb13a0152018-07-19 17:56:49 +0100269 // a list of top-level directories containing files to merge annotations from.
270 Metalava_merge_annotations_dirs []string
Nan Zhang86d2d552018-08-09 15:33:27 -0700271
272 // if set to true, generate docs through Dokka instead of Doclava. Valid only when
273 // metalava_enabled is set to true.
274 Dokka_enabled *bool
Nan Zhang581fd212018-01-10 16:06:12 -0800275}
276
Nan Zhanga40da042018-08-01 12:48:00 -0700277//
278// Common flags passed down to build rule
279//
280type droiddocBuilderFlags struct {
Nan Zhang86d2d552018-08-09 15:33:27 -0700281 args string
282 bootClasspathArgs string
283 classpathArgs string
284 dokkaClasspathArgs string
285 aidlFlags string
Nan Zhanga40da042018-08-01 12:48:00 -0700286
Nan Zhanga40da042018-08-01 12:48:00 -0700287 doclavaStubsFlags string
Nan Zhang86d2d552018-08-09 15:33:27 -0700288 doclavaDocsFlags string
Nan Zhanga40da042018-08-01 12:48:00 -0700289 postDoclavaCmds string
290
Nan Zhanga40da042018-08-01 12:48:00 -0700291 metalavaStubsFlags string
Nan Zhang86d2d552018-08-09 15:33:27 -0700292 metalavaAnnotationsFlags string
293 metalavaJavadocFlags string
Nan Zhanga40da042018-08-01 12:48:00 -0700294
Nan Zhang86d2d552018-08-09 15:33:27 -0700295 metalavaDokkaFlags string
Nan Zhanga40da042018-08-01 12:48:00 -0700296}
297
298func InitDroiddocModule(module android.DefaultableModule, hod android.HostOrDeviceSupported) {
299 android.InitAndroidArchModule(module, hod, android.MultilibCommon)
300 android.InitDefaultableModule(module)
301}
302
303//
304// Javadoc
305//
Nan Zhang581fd212018-01-10 16:06:12 -0800306type Javadoc struct {
307 android.ModuleBase
308 android.DefaultableModuleBase
309
310 properties JavadocProperties
311
312 srcJars android.Paths
313 srcFiles android.Paths
314 sourcepaths android.Paths
315
Nan Zhangccff0f72018-03-08 17:26:16 -0800316 docZip android.WritablePath
317 stubsSrcJar android.WritablePath
Nan Zhang581fd212018-01-10 16:06:12 -0800318}
319
Nan Zhangb2b33de2018-02-23 11:18:47 -0800320func (j *Javadoc) Srcs() android.Paths {
321 return android.Paths{j.stubsSrcJar}
322}
323
Nan Zhang581fd212018-01-10 16:06:12 -0800324func JavadocFactory() android.Module {
325 module := &Javadoc{}
326
327 module.AddProperties(&module.properties)
328
329 InitDroiddocModule(module, android.HostAndDeviceSupported)
330 return module
331}
332
333func JavadocHostFactory() android.Module {
334 module := &Javadoc{}
335
336 module.AddProperties(&module.properties)
337
338 InitDroiddocModule(module, android.HostSupported)
339 return module
340}
341
Nan Zhanga40da042018-08-01 12:48:00 -0700342var _ android.SourceFileProducer = (*Javadoc)(nil)
Nan Zhang581fd212018-01-10 16:06:12 -0800343
Colin Cross83bb3162018-06-25 15:48:06 -0700344func (j *Javadoc) sdkVersion() string {
345 return String(j.properties.Sdk_version)
346}
347
348func (j *Javadoc) minSdkVersion() string {
349 return j.sdkVersion()
350}
351
Nan Zhang581fd212018-01-10 16:06:12 -0800352func (j *Javadoc) addDeps(ctx android.BottomUpMutatorContext) {
353 if ctx.Device() {
Colin Cross83bb3162018-06-25 15:48:06 -0700354 sdkDep := decodeSdkDep(ctx, sdkContext(j))
Nan Zhang581fd212018-01-10 16:06:12 -0800355 if sdkDep.useDefaultLibs {
356 ctx.AddDependency(ctx.Module(), bootClasspathTag, config.DefaultBootclasspathLibraries...)
Nan Zhang357466b2018-04-17 17:38:36 -0700357 if ctx.Config().TargetOpenJDK9() {
358 ctx.AddDependency(ctx.Module(), systemModulesTag, config.DefaultSystemModules)
359 }
Nan Zhang9cbe6772018-03-21 17:56:39 -0700360 if !Bool(j.properties.No_framework_libs) {
Nan Zhang77a69ec2018-08-02 16:28:26 -0700361 ctx.AddDependency(ctx.Module(), libTag, config.DefaultLibraries...)
Nan Zhange66c7272018-03-06 12:59:27 -0800362 }
Nan Zhang581fd212018-01-10 16:06:12 -0800363 } else if sdkDep.useModule {
Nan Zhang357466b2018-04-17 17:38:36 -0700364 if ctx.Config().TargetOpenJDK9() {
365 ctx.AddDependency(ctx.Module(), systemModulesTag, sdkDep.systemModules)
366 }
Colin Cross86a60ae2018-05-29 14:44:55 -0700367 ctx.AddDependency(ctx.Module(), bootClasspathTag, sdkDep.modules...)
Nan Zhang581fd212018-01-10 16:06:12 -0800368 }
369 }
370
371 ctx.AddDependency(ctx.Module(), libTag, j.properties.Libs...)
Colin Crossa1ce2a02018-06-20 15:19:39 -0700372 if j.properties.Srcs_lib != nil {
373 ctx.AddDependency(ctx.Module(), srcsLibTag, *j.properties.Srcs_lib)
374 }
Nan Zhang581fd212018-01-10 16:06:12 -0800375
376 android.ExtractSourcesDeps(ctx, j.properties.Srcs)
377
378 // exclude_srcs may contain filegroup or genrule.
379 android.ExtractSourcesDeps(ctx, j.properties.Exclude_srcs)
380}
381
Nan Zhangb2b33de2018-02-23 11:18:47 -0800382func (j *Javadoc) genWhitelistPathPrefixes(whitelistPathPrefixes map[string]bool) {
383 for _, dir := range j.properties.Srcs_lib_whitelist_dirs {
384 for _, pkg := range j.properties.Srcs_lib_whitelist_pkgs {
Jiyong Park82484c02018-04-23 21:41:26 +0900385 // convert foo.bar.baz to foo/bar/baz
386 pkgAsPath := filepath.Join(strings.Split(pkg, ".")...)
387 prefix := filepath.Join(dir, pkgAsPath)
Nan Zhangb2b33de2018-02-23 11:18:47 -0800388 if _, found := whitelistPathPrefixes[prefix]; !found {
389 whitelistPathPrefixes[prefix] = true
390 }
391 }
392 }
393}
394
Nan Zhanga40da042018-08-01 12:48:00 -0700395func (j *Javadoc) collectAidlFlags(ctx android.ModuleContext, deps deps) droiddocBuilderFlags {
396 var flags droiddocBuilderFlags
Jiyong Park1e440682018-05-23 18:42:04 +0900397
398 // aidl flags.
399 aidlFlags := j.aidlFlags(ctx, deps.aidlPreprocess, deps.aidlIncludeDirs)
400 if len(aidlFlags) > 0 {
401 // optimization.
402 ctx.Variable(pctx, "aidlFlags", strings.Join(aidlFlags, " "))
403 flags.aidlFlags = "$aidlFlags"
404 }
405
406 return flags
407}
408
409func (j *Javadoc) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.OptionalPath,
410 aidlIncludeDirs android.Paths) []string {
411
412 aidlIncludes := android.PathsForModuleSrc(ctx, j.properties.Aidl.Local_include_dirs)
413 aidlIncludes = append(aidlIncludes, android.PathsForSource(ctx, j.properties.Aidl.Include_dirs)...)
414
415 var flags []string
416 if aidlPreprocess.Valid() {
417 flags = append(flags, "-p"+aidlPreprocess.String())
418 } else {
419 flags = append(flags, android.JoinWithPrefix(aidlIncludeDirs.Strings(), "-I"))
420 }
421
422 flags = append(flags, android.JoinWithPrefix(aidlIncludes.Strings(), "-I"))
423 flags = append(flags, "-I"+android.PathForModuleSrc(ctx).String())
424 if src := android.ExistentPathForSource(ctx, ctx.ModuleDir(), "src"); src.Valid() {
425 flags = append(flags, "-I"+src.String())
426 }
427
428 return flags
429}
430
431func (j *Javadoc) genSources(ctx android.ModuleContext, srcFiles android.Paths,
Nan Zhanga40da042018-08-01 12:48:00 -0700432 flags droiddocBuilderFlags) android.Paths {
Jiyong Park1e440682018-05-23 18:42:04 +0900433
434 outSrcFiles := make(android.Paths, 0, len(srcFiles))
435
436 for _, srcFile := range srcFiles {
437 switch srcFile.Ext() {
438 case ".aidl":
439 javaFile := genAidl(ctx, srcFile, flags.aidlFlags)
440 outSrcFiles = append(outSrcFiles, javaFile)
441 default:
442 outSrcFiles = append(outSrcFiles, srcFile)
443 }
444 }
445
446 return outSrcFiles
447}
448
Nan Zhang581fd212018-01-10 16:06:12 -0800449func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
450 var deps deps
451
Colin Cross83bb3162018-06-25 15:48:06 -0700452 sdkDep := decodeSdkDep(ctx, sdkContext(j))
Nan Zhang581fd212018-01-10 16:06:12 -0800453 if sdkDep.invalidVersion {
Colin Cross86a60ae2018-05-29 14:44:55 -0700454 ctx.AddMissingDependencies(sdkDep.modules)
Nan Zhang581fd212018-01-10 16:06:12 -0800455 } else if sdkDep.useFiles {
Colin Cross86a60ae2018-05-29 14:44:55 -0700456 deps.bootClasspath = append(deps.bootClasspath, sdkDep.jars...)
Nan Zhang581fd212018-01-10 16:06:12 -0800457 }
458
459 ctx.VisitDirectDeps(func(module android.Module) {
460 otherName := ctx.OtherModuleName(module)
461 tag := ctx.OtherModuleDependencyTag(module)
462
Colin Cross2d24c1b2018-05-23 10:59:18 -0700463 switch tag {
464 case bootClasspathTag:
465 if dep, ok := module.(Dependency); ok {
Nan Zhang581fd212018-01-10 16:06:12 -0800466 deps.bootClasspath = append(deps.bootClasspath, dep.ImplementationJars()...)
Colin Cross2d24c1b2018-05-23 10:59:18 -0700467 } else {
468 panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName()))
469 }
470 case libTag:
471 switch dep := module.(type) {
472 case Dependency:
Nan Zhang581fd212018-01-10 16:06:12 -0800473 deps.classpath = append(deps.classpath, dep.ImplementationJars()...)
Colin Cross2d24c1b2018-05-23 10:59:18 -0700474 case SdkLibraryDependency:
Colin Cross83bb3162018-06-25 15:48:06 -0700475 sdkVersion := j.sdkVersion()
Jiyong Parkc678ad32018-04-10 13:07:10 +0900476 linkType := javaSdk
477 if strings.HasPrefix(sdkVersion, "system_") || strings.HasPrefix(sdkVersion, "test_") {
478 linkType = javaSystem
479 } else if sdkVersion == "" {
480 linkType = javaPlatform
481 }
Sundong Ahn241cd372018-07-13 16:16:44 +0900482 deps.classpath = append(deps.classpath, dep.ImplementationJars(linkType)...)
Colin Cross2d24c1b2018-05-23 10:59:18 -0700483 case android.SourceFileProducer:
Nan Zhang581fd212018-01-10 16:06:12 -0800484 checkProducesJars(ctx, dep)
485 deps.classpath = append(deps.classpath, dep.Srcs()...)
Nan Zhang581fd212018-01-10 16:06:12 -0800486 default:
487 ctx.ModuleErrorf("depends on non-java module %q", otherName)
488 }
Colin Crossa1ce2a02018-06-20 15:19:39 -0700489 case srcsLibTag:
490 switch dep := module.(type) {
491 case Dependency:
492 srcs := dep.(SrcDependency).CompiledSrcs()
493 whitelistPathPrefixes := make(map[string]bool)
494 j.genWhitelistPathPrefixes(whitelistPathPrefixes)
495 for _, src := range srcs {
496 if _, ok := src.(android.WritablePath); ok { // generated sources
497 deps.srcs = append(deps.srcs, src)
498 } else { // select source path for documentation based on whitelist path prefixs.
499 for k, _ := range whitelistPathPrefixes {
500 if strings.HasPrefix(src.Rel(), k) {
501 deps.srcs = append(deps.srcs, src)
502 break
503 }
504 }
505 }
506 }
507 deps.srcJars = append(deps.srcJars, dep.(SrcDependency).CompiledSrcJars()...)
508 default:
509 ctx.ModuleErrorf("depends on non-java module %q", otherName)
510 }
Nan Zhang357466b2018-04-17 17:38:36 -0700511 case systemModulesTag:
512 if deps.systemModules != nil {
513 panic("Found two system module dependencies")
514 }
515 sm := module.(*SystemModules)
516 if sm.outputFile == nil {
517 panic("Missing directory for system module dependency")
518 }
519 deps.systemModules = sm.outputFile
Nan Zhang581fd212018-01-10 16:06:12 -0800520 }
521 })
522 // do not pass exclude_srcs directly when expanding srcFiles since exclude_srcs
523 // may contain filegroup or genrule.
524 srcFiles := ctx.ExpandSources(j.properties.Srcs, j.properties.Exclude_srcs)
Nan Zhanga40da042018-08-01 12:48:00 -0700525 flags := j.collectAidlFlags(ctx, deps)
Jiyong Park1e440682018-05-23 18:42:04 +0900526 srcFiles = j.genSources(ctx, srcFiles, flags)
Nan Zhang581fd212018-01-10 16:06:12 -0800527
528 // srcs may depend on some genrule output.
529 j.srcJars = srcFiles.FilterByExt(".srcjar")
Nan Zhangb2b33de2018-02-23 11:18:47 -0800530 j.srcJars = append(j.srcJars, deps.srcJars...)
531
Nan Zhang581fd212018-01-10 16:06:12 -0800532 j.srcFiles = srcFiles.FilterOutByExt(".srcjar")
Nan Zhangb2b33de2018-02-23 11:18:47 -0800533 j.srcFiles = append(j.srcFiles, deps.srcs...)
Nan Zhang581fd212018-01-10 16:06:12 -0800534
535 j.docZip = android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"docs.zip")
Nan Zhangccff0f72018-03-08 17:26:16 -0800536 j.stubsSrcJar = android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"stubs.srcjar")
Nan Zhang581fd212018-01-10 16:06:12 -0800537
538 if j.properties.Local_sourcepaths == nil {
539 j.properties.Local_sourcepaths = append(j.properties.Local_sourcepaths, ".")
540 }
541 j.sourcepaths = android.PathsForModuleSrc(ctx, j.properties.Local_sourcepaths)
Nan Zhang581fd212018-01-10 16:06:12 -0800542
543 return deps
544}
545
546func (j *Javadoc) DepsMutator(ctx android.BottomUpMutatorContext) {
547 j.addDeps(ctx)
548}
549
550func (j *Javadoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
551 deps := j.collectDeps(ctx)
552
553 var implicits android.Paths
554 implicits = append(implicits, deps.bootClasspath...)
555 implicits = append(implicits, deps.classpath...)
556
557 var bootClasspathArgs, classpathArgs string
Nan Zhang357466b2018-04-17 17:38:36 -0700558
Colin Cross83bb3162018-06-25 15:48:06 -0700559 javaVersion := getJavaVersion(ctx, String(j.properties.Java_version), sdkContext(j))
Colin Cross997262f2018-06-19 22:49:39 -0700560 if len(deps.bootClasspath) > 0 {
561 var systemModules classpath
562 if deps.systemModules != nil {
563 systemModules = append(systemModules, deps.systemModules)
Nan Zhang581fd212018-01-10 16:06:12 -0800564 }
Colin Cross997262f2018-06-19 22:49:39 -0700565 bootClasspathArgs = systemModules.FormJavaSystemModulesPath("--system ", ctx.Device())
566 bootClasspathArgs = bootClasspathArgs + " --patch-module java.base=."
Nan Zhang581fd212018-01-10 16:06:12 -0800567 }
568 if len(deps.classpath.Strings()) > 0 {
569 classpathArgs = "-classpath " + strings.Join(deps.classpath.Strings(), ":")
570 }
571
572 implicits = append(implicits, j.srcJars...)
573
Nan Zhangaf322cc2018-06-19 15:15:38 -0700574 opts := "-source " + javaVersion + " -J-Xmx1024m -XDignore.symbol.file -Xdoclint:none"
Nan Zhang581fd212018-01-10 16:06:12 -0800575
576 ctx.Build(pctx, android.BuildParams{
577 Rule: javadoc,
578 Description: "Javadoc",
Nan Zhangccff0f72018-03-08 17:26:16 -0800579 Output: j.stubsSrcJar,
Nan Zhang581fd212018-01-10 16:06:12 -0800580 ImplicitOutput: j.docZip,
581 Inputs: j.srcFiles,
582 Implicits: implicits,
583 Args: map[string]string{
Nan Zhangde860a42018-08-08 16:32:21 -0700584 "outDir": android.PathForModuleOut(ctx, "out").String(),
585 "srcJarDir": android.PathForModuleOut(ctx, "srcjars").String(),
586 "stubsDir": android.PathForModuleOut(ctx, "stubsDir").String(),
Nan Zhang581fd212018-01-10 16:06:12 -0800587 "srcJars": strings.Join(j.srcJars.Strings(), " "),
588 "opts": opts,
Nan Zhang853f4202018-04-12 16:55:56 -0700589 "bootclasspathArgs": bootClasspathArgs,
Nan Zhang581fd212018-01-10 16:06:12 -0800590 "classpathArgs": classpathArgs,
591 "sourcepath": strings.Join(j.sourcepaths.Strings(), ":"),
592 "docZip": j.docZip.String(),
593 },
594 })
595}
596
Nan Zhanga40da042018-08-01 12:48:00 -0700597//
598// Droiddoc
599//
600type Droiddoc struct {
601 Javadoc
602
603 properties DroiddocProperties
604 apiFile android.WritablePath
605 dexApiFile android.WritablePath
606 privateApiFile android.WritablePath
607 privateDexApiFile android.WritablePath
608 removedApiFile android.WritablePath
609 removedDexApiFile android.WritablePath
610 exactApiFile android.WritablePath
611 apiMappingFile android.WritablePath
Nan Zhang66dc2362018-08-14 20:41:04 -0700612 proguardFile android.WritablePath
Nan Zhanga40da042018-08-01 12:48:00 -0700613
614 checkCurrentApiTimestamp android.WritablePath
615 updateCurrentApiTimestamp android.WritablePath
616 checkLastReleasedApiTimestamp android.WritablePath
617
618 annotationsZip android.WritablePath
619
620 apiFilePath android.Path
621}
622
623type ApiFilePath interface {
624 ApiFilePath() android.Path
625}
626
627func DroiddocFactory() android.Module {
628 module := &Droiddoc{}
629
630 module.AddProperties(&module.properties,
631 &module.Javadoc.properties)
632
633 InitDroiddocModule(module, android.HostAndDeviceSupported)
634 return module
635}
636
637func DroiddocHostFactory() android.Module {
638 module := &Droiddoc{}
639
640 module.AddProperties(&module.properties,
641 &module.Javadoc.properties)
642
643 InitDroiddocModule(module, android.HostSupported)
644 return module
645}
646
647func (d *Droiddoc) ApiFilePath() android.Path {
648 return d.apiFilePath
649}
650
Nan Zhang61819ce2018-05-04 18:49:16 -0700651func (d *Droiddoc) checkCurrentApi() bool {
652 if String(d.properties.Check_api.Current.Api_file) != "" &&
653 String(d.properties.Check_api.Current.Removed_api_file) != "" {
654 return true
655 } else if String(d.properties.Check_api.Current.Api_file) != "" {
656 panic("check_api.current.removed_api_file: has to be non empty!")
657 } else if String(d.properties.Check_api.Current.Removed_api_file) != "" {
658 panic("check_api.current.api_file: has to be non empty!")
659 }
660
661 return false
662}
663
664func (d *Droiddoc) checkLastReleasedApi() bool {
665 if String(d.properties.Check_api.Last_released.Api_file) != "" &&
666 String(d.properties.Check_api.Last_released.Removed_api_file) != "" {
667 return true
668 } else if String(d.properties.Check_api.Last_released.Api_file) != "" {
669 panic("check_api.last_released.removed_api_file: has to be non empty!")
670 } else if String(d.properties.Check_api.Last_released.Removed_api_file) != "" {
671 panic("check_api.last_released.api_file: has to be non empty!")
672 }
673
674 return false
675}
676
Nan Zhang581fd212018-01-10 16:06:12 -0800677func (d *Droiddoc) DepsMutator(ctx android.BottomUpMutatorContext) {
678 d.Javadoc.addDeps(ctx)
679
Nan Zhang79614d12018-04-19 18:03:39 -0700680 if String(d.properties.Custom_template) != "" {
Dan Willemsencc090972018-02-26 14:33:31 -0800681 ctx.AddDependency(ctx.Module(), droiddocTemplateTag, String(d.properties.Custom_template))
682 }
683
Nan Zhanga40da042018-08-01 12:48:00 -0700684 // arg_files may contains filegroup or genrule.
Nan Zhang581fd212018-01-10 16:06:12 -0800685 android.ExtractSourcesDeps(ctx, d.properties.Arg_files)
686
687 // knowntags may contain filegroup or genrule.
688 android.ExtractSourcesDeps(ctx, d.properties.Knowntags)
Nan Zhang61819ce2018-05-04 18:49:16 -0700689
Nan Zhange2ba5d42018-07-11 15:16:55 -0700690 if String(d.properties.Static_doc_index_redirect) != "" {
691 android.ExtractSourceDeps(ctx, d.properties.Static_doc_index_redirect)
692 }
693
694 if String(d.properties.Static_doc_properties) != "" {
695 android.ExtractSourceDeps(ctx, d.properties.Static_doc_properties)
696 }
697
Nan Zhang61819ce2018-05-04 18:49:16 -0700698 if d.checkCurrentApi() {
699 android.ExtractSourceDeps(ctx, d.properties.Check_api.Current.Api_file)
700 android.ExtractSourceDeps(ctx, d.properties.Check_api.Current.Removed_api_file)
701 }
702
703 if d.checkLastReleasedApi() {
704 android.ExtractSourceDeps(ctx, d.properties.Check_api.Last_released.Api_file)
705 android.ExtractSourceDeps(ctx, d.properties.Check_api.Last_released.Removed_api_file)
706 }
Nan Zhang79614d12018-04-19 18:03:39 -0700707
708 if String(d.properties.Metalava_previous_api) != "" {
709 android.ExtractSourceDeps(ctx, d.properties.Metalava_previous_api)
710 }
Nan Zhangf4936b02018-08-01 15:00:28 -0700711
712 if len(d.properties.Metalava_merge_annotations_dirs) != 0 {
713 for _, mergeAnnotationsDir := range d.properties.Metalava_merge_annotations_dirs {
714 ctx.AddDependency(ctx.Module(), metalavaMergeAnnotationsDirTag, mergeAnnotationsDir)
715 }
716 }
Nan Zhang581fd212018-01-10 16:06:12 -0800717}
718
Nan Zhang66dc2362018-08-14 20:41:04 -0700719func (d *Droiddoc) initBuilderFlags(ctx android.ModuleContext, implicits *android.Paths,
720 deps deps) (droiddocBuilderFlags, error) {
Nan Zhanga40da042018-08-01 12:48:00 -0700721 var flags droiddocBuilderFlags
Nan Zhang581fd212018-01-10 16:06:12 -0800722
Nan Zhanga40da042018-08-01 12:48:00 -0700723 *implicits = append(*implicits, deps.bootClasspath...)
724 *implicits = append(*implicits, deps.classpath...)
Nan Zhang581fd212018-01-10 16:06:12 -0800725
Nan Zhangc94f9d82018-06-26 10:02:26 -0700726 // continue to use -bootclasspath even if Metalava under -source 1.9 is enabled
727 // since it doesn't support system modules yet.
728 if len(deps.bootClasspath.Strings()) > 0 {
729 // For OpenJDK 8 we can use -bootclasspath to define the core libraries code.
Nan Zhanga40da042018-08-01 12:48:00 -0700730 flags.bootClasspathArgs = deps.bootClasspath.FormJavaClassPath("-bootclasspath")
Nan Zhang357466b2018-04-17 17:38:36 -0700731 }
Nan Zhanga40da042018-08-01 12:48:00 -0700732 flags.classpathArgs = deps.classpath.FormJavaClassPath("-classpath")
Nan Zhang86d2d552018-08-09 15:33:27 -0700733 // Dokka doesn't support boocClasspath, so combine these two classpath vars for Dokka.
734 dokkaClasspath := classpath{}
735 dokkaClasspath = append(dokkaClasspath, deps.bootClasspath...)
736 dokkaClasspath = append(dokkaClasspath, deps.classpath...)
737 flags.dokkaClasspathArgs = dokkaClasspath.FormJavaClassPath("-classpath")
Nan Zhang79614d12018-04-19 18:03:39 -0700738
Nan Zhang581fd212018-01-10 16:06:12 -0800739 argFiles := ctx.ExpandSources(d.properties.Arg_files, nil)
740 argFilesMap := map[string]android.Path{}
741
742 for _, f := range argFiles {
Nan Zhanga40da042018-08-01 12:48:00 -0700743 *implicits = append(*implicits, f)
Nan Zhang581fd212018-01-10 16:06:12 -0800744 if _, exists := argFilesMap[f.Rel()]; !exists {
745 argFilesMap[f.Rel()] = f
746 } else {
747 ctx.ModuleErrorf("multiple arg_files for %q, %q and %q",
748 f, argFilesMap[f.Rel()], f.Rel())
749 }
750 }
751
Nan Zhanga40da042018-08-01 12:48:00 -0700752 var err error
753 flags.args, err = android.Expand(String(d.properties.Args), func(name string) (string, error) {
Nan Zhang581fd212018-01-10 16:06:12 -0800754 if strings.HasPrefix(name, "location ") {
755 label := strings.TrimSpace(strings.TrimPrefix(name, "location "))
756 if f, ok := argFilesMap[label]; ok {
757 return f.String(), nil
758 } else {
759 return "", fmt.Errorf("unknown location label %q", label)
760 }
761 } else if name == "genDir" {
762 return android.PathForModuleGen(ctx).String(), nil
763 }
764 return "", fmt.Errorf("unknown variable '$(%s)'", name)
765 })
766
767 if err != nil {
Nan Zhang79614d12018-04-19 18:03:39 -0700768 ctx.PropertyErrorf("args", "%s", err.Error())
Nan Zhanga40da042018-08-01 12:48:00 -0700769 return droiddocBuilderFlags{}, err
Nan Zhang581fd212018-01-10 16:06:12 -0800770 }
Nan Zhanga40da042018-08-01 12:48:00 -0700771 return flags, nil
772}
Nan Zhang581fd212018-01-10 16:06:12 -0800773
Nan Zhanga40da042018-08-01 12:48:00 -0700774func (d *Droiddoc) collectDoclavaDocsFlags(ctx android.ModuleContext, implicits *android.Paths,
Nan Zhang443fa522018-08-20 20:58:28 -0700775 jsilver, doclava android.Path) string {
Nan Zhang581fd212018-01-10 16:06:12 -0800776
Nan Zhanga40da042018-08-01 12:48:00 -0700777 *implicits = append(*implicits, jsilver)
778 *implicits = append(*implicits, doclava)
Nan Zhang30963742018-04-23 09:59:14 -0700779
Nan Zhang46130972018-06-04 11:28:01 -0700780 var date string
781 if runtime.GOOS == "darwin" {
782 date = `date -r`
783 } else {
784 date = `date -d`
785 }
786
Nan Zhang443fa522018-08-20 20:58:28 -0700787 // Droiddoc always gets "-source 1.8" because it doesn't support 1.9 sources. For modules with 1.9
788 // sources, droiddoc will get sources produced by metalava which will have already stripped out the
789 // 1.9 language features.
790 args := " -source 1.8 -J-Xmx1600m -J-XX:-OmitStackTraceInFastThrow -XDignore.symbol.file " +
Nan Zhang30963742018-04-23 09:59:14 -0700791 "-doclet com.google.doclava.Doclava -docletpath " + jsilver.String() + ":" + doclava.String() + " " +
Nan Zhang581fd212018-01-10 16:06:12 -0800792 "-hdf page.build " + ctx.Config().BuildId() + "-" + ctx.Config().BuildNumberFromFile() + " " +
Nan Zhang79614d12018-04-19 18:03:39 -0700793 `-hdf page.now "$$(` + date + ` @$$(cat ` + ctx.Config().Getenv("BUILD_DATETIME_FILE") + `) "+%d %b %Y %k:%M")" `
Nan Zhang46130972018-06-04 11:28:01 -0700794
Nan Zhanga40da042018-08-01 12:48:00 -0700795 if String(d.properties.Custom_template) == "" {
796 // TODO: This is almost always droiddoc-templates-sdk
797 ctx.PropertyErrorf("custom_template", "must specify a template")
798 }
799
800 ctx.VisitDirectDepsWithTag(droiddocTemplateTag, func(m android.Module) {
Nan Zhangf4936b02018-08-01 15:00:28 -0700801 if t, ok := m.(*ExportedDroiddocDir); ok {
Nan Zhanga40da042018-08-01 12:48:00 -0700802 *implicits = append(*implicits, t.deps...)
803 args = args + " -templatedir " + t.dir.String()
804 } else {
805 ctx.PropertyErrorf("custom_template", "module %q is not a droiddoc_template", ctx.OtherModuleName(m))
806 }
807 })
808
809 if len(d.properties.Html_dirs) > 0 {
810 htmlDir := android.PathForModuleSrc(ctx, d.properties.Html_dirs[0])
811 *implicits = append(*implicits, ctx.Glob(htmlDir.Join(ctx, "**/*").String(), nil)...)
812 args = args + " -htmldir " + htmlDir.String()
813 }
814
815 if len(d.properties.Html_dirs) > 1 {
816 htmlDir2 := android.PathForModuleSrc(ctx, d.properties.Html_dirs[1])
817 *implicits = append(*implicits, ctx.Glob(htmlDir2.Join(ctx, "**/*").String(), nil)...)
818 args = args + " -htmldir2 " + htmlDir2.String()
819 }
820
821 if len(d.properties.Html_dirs) > 2 {
822 ctx.PropertyErrorf("html_dirs", "Droiddoc only supports up to 2 html dirs")
823 }
824
825 knownTags := ctx.ExpandSources(d.properties.Knowntags, nil)
826 *implicits = append(*implicits, knownTags...)
827
828 for _, kt := range knownTags {
829 args = args + " -knowntags " + kt.String()
830 }
831
832 for _, hdf := range d.properties.Hdf {
833 args = args + " -hdf " + hdf
834 }
835
836 if String(d.properties.Proofread_file) != "" {
837 proofreadFile := android.PathForModuleOut(ctx, String(d.properties.Proofread_file))
838 args = args + " -proofread " + proofreadFile.String()
839 }
840
841 if String(d.properties.Todo_file) != "" {
842 // tricky part:
843 // we should not compute full path for todo_file through PathForModuleOut().
844 // the non-standard doclet will get the full path relative to "-o".
845 args = args + " -todo " + String(d.properties.Todo_file)
846 }
847
848 if String(d.properties.Resourcesdir) != "" {
849 // TODO: should we add files under resourcesDir to the implicits? It seems that
850 // resourcesDir is one sub dir of htmlDir
851 resourcesDir := android.PathForModuleSrc(ctx, String(d.properties.Resourcesdir))
852 args = args + " -resourcesdir " + resourcesDir.String()
853 }
854
855 if String(d.properties.Resourcesoutdir) != "" {
856 // TODO: it seems -resourceoutdir reference/android/images/ didn't get generated anywhere.
857 args = args + " -resourcesoutdir " + String(d.properties.Resourcesoutdir)
858 }
859 return args
860}
861
862func (d *Droiddoc) collectStubsFlags(ctx android.ModuleContext, implicitOutputs *android.WritablePaths) (string, string) {
863 var doclavaFlags, MetalavaFlags string
864 if d.checkCurrentApi() || d.checkLastReleasedApi() || String(d.properties.Api_filename) != "" {
865 d.apiFile = android.PathForModuleOut(ctx, ctx.ModuleName()+"_api.txt")
866 doclavaFlags += " -api " + d.apiFile.String()
867 MetalavaFlags = MetalavaFlags + " --api " + d.apiFile.String()
868 *implicitOutputs = append(*implicitOutputs, d.apiFile)
869 d.apiFilePath = d.apiFile
870 }
871
872 if d.checkCurrentApi() || d.checkLastReleasedApi() || String(d.properties.Removed_api_filename) != "" {
873 d.removedApiFile = android.PathForModuleOut(ctx, ctx.ModuleName()+"_removed.txt")
874 doclavaFlags += " -removedApi " + d.removedApiFile.String()
875 MetalavaFlags = MetalavaFlags + " --removed-api " + d.removedApiFile.String()
876 *implicitOutputs = append(*implicitOutputs, d.removedApiFile)
877 }
878
879 if String(d.properties.Private_api_filename) != "" {
880 d.privateApiFile = android.PathForModuleOut(ctx, String(d.properties.Private_api_filename))
881 doclavaFlags += " -privateApi " + d.privateApiFile.String()
882 MetalavaFlags = MetalavaFlags + " --private-api " + d.privateApiFile.String()
883 *implicitOutputs = append(*implicitOutputs, d.privateApiFile)
884 }
885
886 if String(d.properties.Dex_api_filename) != "" {
887 d.dexApiFile = android.PathForModuleOut(ctx, String(d.properties.Dex_api_filename))
888 doclavaFlags += " -dexApi " + d.dexApiFile.String()
889 *implicitOutputs = append(*implicitOutputs, d.dexApiFile)
890 }
891
892 if String(d.properties.Private_dex_api_filename) != "" {
893 d.privateDexApiFile = android.PathForModuleOut(ctx, String(d.properties.Private_dex_api_filename))
894 doclavaFlags += " -privateDexApi " + d.privateDexApiFile.String()
895 MetalavaFlags = MetalavaFlags + " --private-dex-api " + d.privateDexApiFile.String()
896 *implicitOutputs = append(*implicitOutputs, d.privateDexApiFile)
897 }
898
899 if String(d.properties.Removed_dex_api_filename) != "" {
900 d.removedDexApiFile = android.PathForModuleOut(ctx, String(d.properties.Removed_dex_api_filename))
901 doclavaFlags += " -removedDexApi " + d.removedDexApiFile.String()
902 MetalavaFlags = MetalavaFlags + " --removed-dex-api " + d.removedDexApiFile.String()
903 *implicitOutputs = append(*implicitOutputs, d.removedDexApiFile)
904 }
905
906 if String(d.properties.Exact_api_filename) != "" {
907 d.exactApiFile = android.PathForModuleOut(ctx, String(d.properties.Exact_api_filename))
908 doclavaFlags += " -exactApi " + d.exactApiFile.String()
909 MetalavaFlags = MetalavaFlags + " --exact-api " + d.exactApiFile.String()
910 *implicitOutputs = append(*implicitOutputs, d.exactApiFile)
911 }
912
913 if String(d.properties.Dex_mapping_filename) != "" {
914 d.apiMappingFile = android.PathForModuleOut(ctx, String(d.properties.Dex_mapping_filename))
915 doclavaFlags += " -apiMapping " + d.apiMappingFile.String()
916 // Omitted: metalava support
917 *implicitOutputs = append(*implicitOutputs, d.apiMappingFile)
918 }
919
Nan Zhang66dc2362018-08-14 20:41:04 -0700920 if String(d.properties.Proguard_filename) != "" {
921 d.proguardFile = android.PathForModuleOut(ctx, String(d.properties.Proguard_filename))
922 doclavaFlags += " -proguard " + d.proguardFile.String()
923 // Omitted: metalava support
924 *implicitOutputs = append(*implicitOutputs, d.proguardFile)
925 }
926
Nan Zhanga40da042018-08-01 12:48:00 -0700927 if BoolDefault(d.properties.Create_stubs, true) {
Nan Zhangde860a42018-08-08 16:32:21 -0700928 doclavaFlags += " -stubs " + android.PathForModuleOut(ctx, "stubsDir").String()
Nan Zhanga40da042018-08-01 12:48:00 -0700929 }
930
931 if Bool(d.properties.Write_sdk_values) {
Nan Zhangde860a42018-08-08 16:32:21 -0700932 doclavaFlags += " -sdkvalues " + android.PathForModuleOut(ctx, "out").String()
Nan Zhanga40da042018-08-01 12:48:00 -0700933 }
934 return doclavaFlags, MetalavaFlags
935}
936
937func (d *Droiddoc) getPostDoclavaCmds(ctx android.ModuleContext, implicits *android.Paths) string {
938 var cmds string
939 if String(d.properties.Static_doc_index_redirect) != "" {
940 static_doc_index_redirect := ctx.ExpandSource(String(d.properties.Static_doc_index_redirect),
941 "static_doc_index_redirect")
942 *implicits = append(*implicits, static_doc_index_redirect)
943 cmds = cmds + " && cp " + static_doc_index_redirect.String() + " " +
Nan Zhangde860a42018-08-08 16:32:21 -0700944 android.PathForModuleOut(ctx, "out", "index.html").String()
Nan Zhanga40da042018-08-01 12:48:00 -0700945 }
946
947 if String(d.properties.Static_doc_properties) != "" {
948 static_doc_properties := ctx.ExpandSource(String(d.properties.Static_doc_properties),
949 "static_doc_properties")
950 *implicits = append(*implicits, static_doc_properties)
951 cmds = cmds + " && cp " + static_doc_properties.String() + " " +
Nan Zhangde860a42018-08-08 16:32:21 -0700952 android.PathForModuleOut(ctx, "out", "source.properties").String()
Nan Zhanga40da042018-08-01 12:48:00 -0700953 }
954 return cmds
955}
956
957func (d *Droiddoc) collectMetalavaAnnotationsFlags(
958 ctx android.ModuleContext, implicits *android.Paths, implicitOutputs *android.WritablePaths) string {
959 var flags string
Nan Zhanga40da042018-08-01 12:48:00 -0700960 if Bool(d.properties.Metalava_annotations_enabled) {
961 if String(d.properties.Metalava_previous_api) == "" {
962 ctx.PropertyErrorf("metalava_previous_api",
963 "has to be non-empty if annotations was enabled!")
964 }
Nan Zhangde860a42018-08-08 16:32:21 -0700965 previousApi := ctx.ExpandSource(String(d.properties.Metalava_previous_api),
966 "metalava_previous_api")
967 *implicits = append(*implicits, previousApi)
Nan Zhangde860a42018-08-08 16:32:21 -0700968
Nan Zhangd05a4362018-08-15 13:28:54 -0700969 flags += " --include-annotations --migrate-nullness " + previousApi.String()
Nan Zhanga40da042018-08-01 12:48:00 -0700970
971 d.annotationsZip = android.PathForModuleOut(ctx, ctx.ModuleName()+"_annotations.zip")
972 *implicitOutputs = append(*implicitOutputs, d.annotationsZip)
973
Nan Zhangf4936b02018-08-01 15:00:28 -0700974 flags += " --extract-annotations " + d.annotationsZip.String()
975
Nan Zhanga40da042018-08-01 12:48:00 -0700976 if len(d.properties.Metalava_merge_annotations_dirs) == 0 {
977 ctx.PropertyErrorf("metalava_merge_annotations_dirs",
978 "has to be non-empty if annotations was enabled!")
979 }
Nan Zhangf4936b02018-08-01 15:00:28 -0700980 ctx.VisitDirectDepsWithTag(metalavaMergeAnnotationsDirTag, func(m android.Module) {
981 if t, ok := m.(*ExportedDroiddocDir); ok {
982 *implicits = append(*implicits, t.deps...)
983 flags += " --merge-annotations " + t.dir.String()
984 } else {
985 ctx.PropertyErrorf("metalava_merge_annotations_dirs",
986 "module %q is not a metalava merge-annotations dir", ctx.OtherModuleName(m))
987 }
988 })
Nan Zhanga40da042018-08-01 12:48:00 -0700989 // TODO(tnorbye): find owners to fix these warnings when annotation was enabled.
990 flags += " --hide HiddenTypedefConstant --hide SuperfluousPrefix --hide AnnotationExtraction "
991 }
992
993 return flags
994}
995
Nan Zhang86d2d552018-08-09 15:33:27 -0700996func (d *Droiddoc) collectMetalavaJavadocFlags(ctx android.ModuleContext,
Nan Zhangde860a42018-08-08 16:32:21 -0700997 bootClasspathArgs, classpathArgs, outDir, docStubsDir string) string {
998 return " --doc-stubs " + docStubsDir +
999 " --write-doc-stubs-source-list " + android.PathForModuleOut(ctx, "doc_stubs.srclist").String() +
Nan Zhanga40da042018-08-01 12:48:00 -07001000 " --generate-documentation ${config.JavadocCmd} -encoding UTF-8 DOC_STUBS_SOURCE_LIST " +
1001 bootClasspathArgs + " " + classpathArgs + " " + " -sourcepath " +
Nan Zhangde860a42018-08-08 16:32:21 -07001002 docStubsDir + " -quiet -d " + outDir
Nan Zhanga40da042018-08-01 12:48:00 -07001003}
1004
Nan Zhang86d2d552018-08-09 15:33:27 -07001005func (d *Droiddoc) collectMetalavaDokkaFlags(ctx android.ModuleContext, implicits *android.Paths,
1006 classpathArgs, outDir, docStubsDir string) string {
1007 dokka := android.PathForOutput(ctx, "host", ctx.Config().PrebuiltOS(), "framework", "dokka.jar")
1008 *implicits = append(*implicits, dokka)
1009
1010 return " --doc-stubs " + docStubsDir + " --write-doc-stubs-source-list " +
1011 android.PathForModuleOut(ctx, "doc_stubs.srclist").String() +
1012 " --generate-documentation ${config.JavaCmd} -jar " + dokka.String() + " " +
1013 docStubsDir + " " + classpathArgs + " -format dac -dacRoot /reference/kotlin -output " + outDir
1014}
1015
1016func (d *Droiddoc) transformMetalava(ctx android.ModuleContext, implicits android.Paths,
1017 implicitOutputs android.WritablePaths, outDir, docStubsDir, javaVersion,
1018 bootclasspathArgs, classpathArgs, opts string) {
1019 ctx.Build(pctx, android.BuildParams{
1020 Rule: metalava,
1021 Description: "Metalava",
1022 Output: d.Javadoc.stubsSrcJar,
1023 Inputs: d.Javadoc.srcFiles,
1024 Implicits: implicits,
1025 ImplicitOutputs: implicitOutputs,
1026 Args: map[string]string{
1027 "outDir": outDir,
1028 "srcJarDir": android.PathForModuleOut(ctx, "srcjars").String(),
1029 "stubsDir": android.PathForModuleOut(ctx, "stubsDir").String(),
1030 "docStubsDir": docStubsDir,
1031 "srcJars": strings.Join(d.Javadoc.srcJars.Strings(), " "),
1032 "javaVersion": javaVersion,
1033 "bootclasspathArgs": bootclasspathArgs,
1034 "classpathArgs": classpathArgs,
1035 "sourcepath": strings.Join(d.Javadoc.sourcepaths.Strings(), ":"),
1036 "docZip": d.Javadoc.docZip.String(),
1037 "opts": opts,
1038 },
1039 })
1040}
1041
1042func (d *Droiddoc) transformDoclava(ctx android.ModuleContext, implicits android.Paths,
1043 implicitOutputs android.WritablePaths, bootclasspathArgs, classpathArgs, opts, postDoclavaCmds string) {
1044 ctx.Build(pctx, android.BuildParams{
1045 Rule: javadoc,
1046 Description: "Doclava",
1047 Output: d.Javadoc.stubsSrcJar,
1048 Inputs: d.Javadoc.srcFiles,
1049 Implicits: implicits,
1050 ImplicitOutputs: implicitOutputs,
1051 Args: map[string]string{
1052 "outDir": android.PathForModuleOut(ctx, "out").String(),
1053 "srcJarDir": android.PathForModuleOut(ctx, "srcjars").String(),
1054 "stubsDir": android.PathForModuleOut(ctx, "stubsDir").String(),
1055 "srcJars": strings.Join(d.Javadoc.srcJars.Strings(), " "),
1056 "opts": opts,
1057 "bootclasspathArgs": bootclasspathArgs,
1058 "classpathArgs": classpathArgs,
1059 "sourcepath": strings.Join(d.Javadoc.sourcepaths.Strings(), ":"),
1060 "docZip": d.Javadoc.docZip.String(),
1061 "postDoclavaCmds": postDoclavaCmds,
1062 },
1063 })
1064}
1065
1066func (d *Droiddoc) transformCheckApi(ctx android.ModuleContext, apiFile, removedApiFile android.Path,
1067 checkApiClasspath classpath, msg, opts string, output android.WritablePath) {
1068 ctx.Build(pctx, android.BuildParams{
1069 Rule: apiCheck,
1070 Description: "Check API",
1071 Output: output,
1072 Inputs: nil,
1073 Implicits: append(android.Paths{apiFile, removedApiFile, d.apiFile, d.removedApiFile},
1074 checkApiClasspath...),
1075 Args: map[string]string{
1076 "classpath": checkApiClasspath.FormJavaClassPath(""),
1077 "opts": opts,
1078 "apiFile": apiFile.String(),
1079 "apiFileToCheck": d.apiFile.String(),
1080 "removedApiFile": removedApiFile.String(),
1081 "removedApiFileToCheck": d.removedApiFile.String(),
1082 "msg": msg,
1083 },
1084 })
1085}
1086
1087func (d *Droiddoc) transformUpdateApi(ctx android.ModuleContext, apiFile, removedApiFile android.Path,
1088 output android.WritablePath) {
1089 ctx.Build(pctx, android.BuildParams{
1090 Rule: updateApi,
1091 Description: "Update API",
1092 Output: output,
1093 Implicits: append(android.Paths{}, apiFile, removedApiFile, d.apiFile, d.removedApiFile),
1094 Args: map[string]string{
1095 "apiFile": apiFile.String(),
1096 "apiFileToCheck": d.apiFile.String(),
1097 "removedApiFile": removedApiFile.String(),
1098 "removedApiFileToCheck": d.removedApiFile.String(),
1099 },
1100 })
1101}
1102
Nan Zhanga40da042018-08-01 12:48:00 -07001103func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
1104 deps := d.Javadoc.collectDeps(ctx)
1105
1106 javaVersion := getJavaVersion(ctx, String(d.Javadoc.properties.Java_version), sdkContext(d))
Nan Zhanga40da042018-08-01 12:48:00 -07001107 jsilver := android.PathForOutput(ctx, "host", ctx.Config().PrebuiltOS(), "framework", "jsilver.jar")
1108 doclava := android.PathForOutput(ctx, "host", ctx.Config().PrebuiltOS(), "framework", "doclava.jar")
1109 java8Home := ctx.Config().Getenv("ANDROID_JAVA8_HOME")
1110 checkApiClasspath := classpath{jsilver, doclava, android.PathForSource(ctx, java8Home, "lib/tools.jar")}
Nan Zhang581fd212018-01-10 16:06:12 -08001111
Nan Zhanga40da042018-08-01 12:48:00 -07001112 var implicits android.Paths
1113 implicits = append(implicits, d.Javadoc.srcJars...)
1114
1115 var implicitOutputs android.WritablePaths
1116 implicitOutputs = append(implicitOutputs, d.Javadoc.docZip)
1117 for _, o := range d.properties.Out {
1118 implicitOutputs = append(implicitOutputs, android.PathForModuleGen(ctx, o))
1119 }
1120
1121 flags, err := d.initBuilderFlags(ctx, &implicits, deps)
1122 if err != nil {
1123 return
1124 }
1125
1126 flags.doclavaStubsFlags, flags.metalavaStubsFlags = d.collectStubsFlags(ctx, &implicitOutputs)
1127 if Bool(d.properties.Metalava_enabled) {
Nan Zhanga40da042018-08-01 12:48:00 -07001128 flags.metalavaAnnotationsFlags = d.collectMetalavaAnnotationsFlags(ctx, &implicits, &implicitOutputs)
Nan Zhang86d2d552018-08-09 15:33:27 -07001129 outDir := android.PathForModuleOut(ctx, "out").String()
Nan Zhangde860a42018-08-08 16:32:21 -07001130 docStubsDir := android.PathForModuleOut(ctx, "docStubsDir").String()
Nan Zhang86d2d552018-08-09 15:33:27 -07001131 // TODO(nanzhang): Add a Soong property to handle documentation args.
1132 if strings.Contains(flags.args, "--generate-documentation") { // enable docs generation
1133 if Bool(d.properties.Dokka_enabled) {
1134 flags.metalavaDokkaFlags = d.collectMetalavaDokkaFlags(ctx, &implicits,
1135 flags.dokkaClasspathArgs, outDir, docStubsDir)
1136 d.transformMetalava(ctx, implicits, implicitOutputs, outDir, docStubsDir, javaVersion,
1137 flags.bootClasspathArgs, flags.classpathArgs, flags.metalavaStubsFlags+
1138 flags.metalavaAnnotationsFlags+" "+strings.Split(flags.args, "--generate-documentation")[0]+
1139 flags.metalavaDokkaFlags+" "+strings.Split(flags.args, "--generate-documentation")[1])
1140 } else {
1141 flags.metalavaJavadocFlags = d.collectMetalavaJavadocFlags(
1142 ctx, flags.bootClasspathArgs, flags.classpathArgs, outDir, docStubsDir)
Nan Zhang443fa522018-08-20 20:58:28 -07001143 flags.doclavaDocsFlags = d.collectDoclavaDocsFlags(ctx, &implicits, jsilver, doclava)
Nan Zhang86d2d552018-08-09 15:33:27 -07001144 d.transformMetalava(ctx, implicits, implicitOutputs, outDir, docStubsDir, javaVersion,
1145 flags.bootClasspathArgs, flags.classpathArgs, flags.metalavaStubsFlags+
1146 flags.metalavaAnnotationsFlags+" "+strings.Split(flags.args, "--generate-documentation")[0]+
1147 flags.metalavaJavadocFlags+flags.doclavaDocsFlags+
1148 " "+strings.Split(flags.args, "--generate-documentation")[1])
1149 }
Nan Zhanga40da042018-08-01 12:48:00 -07001150 } else {
Nan Zhang86d2d552018-08-09 15:33:27 -07001151 d.transformMetalava(ctx, implicits, implicitOutputs, outDir, docStubsDir, javaVersion,
1152 flags.bootClasspathArgs, flags.classpathArgs,
1153 flags.metalavaStubsFlags+flags.metalavaAnnotationsFlags+flags.args)
Nan Zhang79614d12018-04-19 18:03:39 -07001154 }
Nan Zhanga40da042018-08-01 12:48:00 -07001155 } else {
Nan Zhang443fa522018-08-20 20:58:28 -07001156 flags.doclavaDocsFlags = d.collectDoclavaDocsFlags(ctx, &implicits, jsilver, doclava)
Nan Zhanga40da042018-08-01 12:48:00 -07001157 flags.postDoclavaCmds = d.getPostDoclavaCmds(ctx, &implicits)
Nan Zhang86d2d552018-08-09 15:33:27 -07001158 d.transformDoclava(ctx, implicits, implicitOutputs, flags.bootClasspathArgs, flags.classpathArgs,
1159 flags.doclavaDocsFlags+flags.doclavaStubsFlags+" "+flags.args,
1160 flags.postDoclavaCmds)
Nan Zhang79614d12018-04-19 18:03:39 -07001161 }
Nan Zhang61819ce2018-05-04 18:49:16 -07001162
Nan Zhang61819ce2018-05-04 18:49:16 -07001163 if d.checkCurrentApi() && !ctx.Config().IsPdkBuild() {
Nan Zhang61819ce2018-05-04 18:49:16 -07001164 apiFile := ctx.ExpandSource(String(d.properties.Check_api.Current.Api_file),
1165 "check_api.current.api_file")
1166 removedApiFile := ctx.ExpandSource(String(d.properties.Check_api.Current.Removed_api_file),
1167 "check_api.current_removed_api_file")
1168
Nan Zhang55e0bf42018-08-16 16:23:11 -07001169 if !Bool(d.properties.Metalava_enabled) {
1170 d.checkCurrentApiTimestamp = android.PathForModuleOut(ctx, "check_current_api.timestamp")
1171 d.transformCheckApi(ctx, apiFile, removedApiFile, checkApiClasspath,
1172 fmt.Sprintf(`\n******************************\n`+
1173 `You have tried to change the API from what has been previously approved.\n\n`+
1174 `To make these errors go away, you have two choices:\n`+
1175 ` 1. You can add '@hide' javadoc comments to the methods, etc. listed in the\n`+
1176 ` errors above.\n\n`+
1177 ` 2. You can update current.txt by executing the following command:\n`+
1178 ` make %s-update-current-api\n\n`+
1179 ` To submit the revised current.txt to the main Android repository,\n`+
1180 ` you will need approval.\n`+
1181 `******************************\n`, ctx.ModuleName()), String(d.properties.Check_api.Current.Args),
1182 d.checkCurrentApiTimestamp)
1183 } else {
1184 // TODO(nanzhang): Refactor below when Metalava support API check.
1185 if d.apiFile == nil || d.removedApiFile == nil {
1186 ctx.ModuleErrorf("api_filename and removed_api_filename properties cannot be empty for API check!")
1187 }
1188 }
Nan Zhang61819ce2018-05-04 18:49:16 -07001189
1190 d.updateCurrentApiTimestamp = android.PathForModuleOut(ctx, "update_current_api.timestamp")
Nan Zhang86d2d552018-08-09 15:33:27 -07001191 d.transformUpdateApi(ctx, apiFile, removedApiFile, d.updateCurrentApiTimestamp)
Nan Zhang61819ce2018-05-04 18:49:16 -07001192 }
Nan Zhanga40da042018-08-01 12:48:00 -07001193
Nan Zhang61819ce2018-05-04 18:49:16 -07001194 if d.checkLastReleasedApi() && !ctx.Config().IsPdkBuild() {
1195 d.checkLastReleasedApiTimestamp = android.PathForModuleOut(ctx, "check_last_released_api.timestamp")
1196
1197 apiFile := ctx.ExpandSource(String(d.properties.Check_api.Last_released.Api_file),
1198 "check_api.last_released.api_file")
1199 removedApiFile := ctx.ExpandSource(String(d.properties.Check_api.Last_released.Removed_api_file),
1200 "check_api.last_released.removed_api_file")
1201
Nan Zhang86d2d552018-08-09 15:33:27 -07001202 d.transformCheckApi(ctx, apiFile, removedApiFile, checkApiClasspath,
1203 `\n******************************\n`+
1204 `You have tried to change the API from what has been previously released in\n`+
1205 `an SDK. Please fix the errors listed above.\n`+
1206 `******************************\n`, String(d.properties.Check_api.Last_released.Args),
1207 d.checkLastReleasedApiTimestamp)
Nan Zhang61819ce2018-05-04 18:49:16 -07001208 }
Nan Zhang581fd212018-01-10 16:06:12 -08001209}
Dan Willemsencc090972018-02-26 14:33:31 -08001210
Nan Zhanga40da042018-08-01 12:48:00 -07001211//
Nan Zhangf4936b02018-08-01 15:00:28 -07001212// Exported Droiddoc Directory
Nan Zhanga40da042018-08-01 12:48:00 -07001213//
Dan Willemsencc090972018-02-26 14:33:31 -08001214var droiddocTemplateTag = dependencyTag{name: "droiddoc-template"}
Nan Zhangf4936b02018-08-01 15:00:28 -07001215var metalavaMergeAnnotationsDirTag = dependencyTag{name: "metalava-merge-annotations-dir"}
Dan Willemsencc090972018-02-26 14:33:31 -08001216
Nan Zhangf4936b02018-08-01 15:00:28 -07001217type ExportedDroiddocDirProperties struct {
1218 // path to the directory containing Droiddoc related files.
Dan Willemsencc090972018-02-26 14:33:31 -08001219 Path *string
1220}
1221
Nan Zhangf4936b02018-08-01 15:00:28 -07001222type ExportedDroiddocDir struct {
Dan Willemsencc090972018-02-26 14:33:31 -08001223 android.ModuleBase
1224
Nan Zhangf4936b02018-08-01 15:00:28 -07001225 properties ExportedDroiddocDirProperties
Dan Willemsencc090972018-02-26 14:33:31 -08001226
1227 deps android.Paths
1228 dir android.Path
1229}
1230
Nan Zhangf4936b02018-08-01 15:00:28 -07001231func ExportedDroiddocDirFactory() android.Module {
1232 module := &ExportedDroiddocDir{}
Dan Willemsencc090972018-02-26 14:33:31 -08001233 module.AddProperties(&module.properties)
1234 android.InitAndroidModule(module)
1235 return module
1236}
1237
Nan Zhangf4936b02018-08-01 15:00:28 -07001238func (d *ExportedDroiddocDir) DepsMutator(android.BottomUpMutatorContext) {}
Dan Willemsencc090972018-02-26 14:33:31 -08001239
Nan Zhangf4936b02018-08-01 15:00:28 -07001240func (d *ExportedDroiddocDir) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Dan Willemsencc090972018-02-26 14:33:31 -08001241 path := android.PathForModuleSrc(ctx, String(d.properties.Path))
1242 d.dir = path
1243 d.deps = ctx.Glob(path.Join(ctx, "**/*").String(), nil)
1244}
Nan Zhangb2b33de2018-02-23 11:18:47 -08001245
1246//
1247// Defaults
1248//
1249type DocDefaults struct {
1250 android.ModuleBase
1251 android.DefaultsModuleBase
1252}
1253
1254func (*DocDefaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
1255}
1256
1257func (d *DocDefaults) DepsMutator(ctx android.BottomUpMutatorContext) {
1258}
1259
1260func DocDefaultsFactory() android.Module {
1261 module := &DocDefaults{}
1262
1263 module.AddProperties(
1264 &JavadocProperties{},
1265 &DroiddocProperties{},
1266 )
1267
1268 android.InitDefaultsModule(module)
1269
1270 return module
1271}