From d532ba8442fc0f72fb616fd0958f67bca7095977 Mon Sep 17 00:00:00 2001 From: Nan Zhang Date: Thu, 26 Jul 2018 11:26:02 -0700 Subject: [PATCH 1/7] bundle files related to sdk dev tool with generated docs. bundle files related to sdk dev tool(activity_actions.txt, and etc.) to the final -docs.zip file since sdk.atree needs to copy these files from $(OUT_DOCS)/offline-sdk dir. Test: m -j out/target/common/docs/offline-sdk-timestamp Bug: b/70351683 Change-Id: I3bfb3c56570dd6728dec272d38c6046e0d44c40f --- java/droiddoc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/droiddoc.go b/java/droiddoc.go index bdf7f538a..6a5758b2f 100644 --- a/java/droiddoc.go +++ b/java/droiddoc.go @@ -904,7 +904,7 @@ func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) { } if Bool(d.properties.Write_sdk_values) { - opts += " -sdkvalues " + android.PathForModuleOut(ctx, "docs").String() + opts += " -sdkvalues " + android.PathForModuleOut(ctx, "docs", "out").String() } var postDoclavaCmds string From 3810aa5fe8eb05583cf71622df7c04bd7a582da7 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 29 Aug 2018 17:03:17 -0700 Subject: [PATCH 2/7] Revert "Fix manifest merging flags" DO NOT MERGE This reverts commit 6f937a99e312841401751244c528d7e23036280f. This branch is missing some changes, but the ones before and after it are fine. Temporarily revert this change in only this branch. Bug: 112467584 Test: none --- java/android_manifest.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/android_manifest.go b/java/android_manifest.go index 657747520..77b6214e1 100644 --- a/java/android_manifest.go +++ b/java/android_manifest.go @@ -68,7 +68,7 @@ func manifestMerger(ctx android.ModuleContext, manifest android.Path, sdkContext Implicits: staticLibManifests, Output: mergedManifest, Args: map[string]string{ - "libs": android.JoinWithPrefix(staticLibManifests.Strings(), "--libs "), + "libs": android.JoinWithPrefix(staticLibManifests.Strings(), "--uses-library "), }, }) manifest = mergedManifest From eb124c468dfbb0b44324e465653a91da522d91de Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 29 Aug 2018 17:52:00 -0700 Subject: [PATCH 3/7] Revert "Revert "Fix manifest merging flags"" DO NOT MERGE This reverts commit 3810aa5fe8eb05583cf71622df7c04bd7a582da7. Bug: 112467584 Test: m java Change-Id: I8dba06bf1245fdbb4bb4c078270a234662712ee4 --- java/android_manifest.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/android_manifest.go b/java/android_manifest.go index 77b6214e1..657747520 100644 --- a/java/android_manifest.go +++ b/java/android_manifest.go @@ -68,7 +68,7 @@ func manifestMerger(ctx android.ModuleContext, manifest android.Path, sdkContext Implicits: staticLibManifests, Output: mergedManifest, Args: map[string]string{ - "libs": android.JoinWithPrefix(staticLibManifests.Strings(), "--uses-library "), + "libs": android.JoinWithPrefix(staticLibManifests.Strings(), "--libs "), }, }) manifest = mergedManifest From babb1573f1b9e2fc8c81879fd128b7f2658579ba Mon Sep 17 00:00:00 2001 From: Sundong Ahn Date: Mon, 17 Sep 2018 13:23:09 +0900 Subject: [PATCH 4/7] Support Metalava in java_sdk_library The metalava is supported instead of doclava. However, not all sdk libraries are available now. So metalava_enabled property is added for it. when using metalava, DroidstubsFactory module will be created instead of DroiddocFactory. Test: make -j Test: make apicheck Bug: 117127012 Merged-In: I7fd10230bfe30a4ef4dceb1a4459145b674668cd Change-Id: I7fd10230bfe30a4ef4dceb1a4459145b674668cd (cherry picked from commit 0817d01ab163ffb41829c61f484f2134bf955bfa) --- java/sdk_library.go | 90 ++++++++++++++++++++++++++++++--------------- 1 file changed, 60 insertions(+), 30 deletions(-) diff --git a/java/sdk_library.go b/java/sdk_library.go index 3e6908bde..bbb62512d 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -128,6 +128,11 @@ type sdkLibraryProperties struct { // Defaults to "android.annotation". Srcs_lib_whitelist_pkgs []string + // if set to true, create stubs through Metalava instead of Doclava. Javadoc/Doclava is + // currently still used for documentation generation, and will be replaced by Dokka soon. + // Defaults to true. + Metalava_enabled *bool + // TODO: determines whether to create HTML doc or not //Html_doc *bool } @@ -417,7 +422,6 @@ func (module *sdkLibrary) createDocs(mctx android.TopDownMutatorContext, apiScop props := struct { Name *string Srcs []string - Custom_template *string Installable *bool Srcs_lib *string Srcs_lib_whitelist_dirs []string @@ -436,11 +440,13 @@ func (module *sdkLibrary) createDocs(mctx android.TopDownMutatorContext, apiScop Local_include_dirs []string } }{} + droiddocProps := struct { + Custom_template *string + }{} props.Name = proptools.StringPtr(module.docsName(apiScope)) props.Srcs = append(props.Srcs, module.properties.Srcs...) props.Srcs = append(props.Srcs, module.properties.Api_srcs...) - props.Custom_template = proptools.StringPtr("droiddoc-templates-sdk") props.Installable = proptools.BoolPtr(false) // A droiddoc module has only one Libs property and doesn't distinguish between // shared libs and static libs. So we need to add both of these libs to Libs property. @@ -449,10 +455,26 @@ func (module *sdkLibrary) createDocs(mctx android.TopDownMutatorContext, apiScop props.Aidl.Include_dirs = module.deviceProperties.Aidl.Include_dirs props.Aidl.Local_include_dirs = module.deviceProperties.Aidl.Local_include_dirs - droiddocArgs := " -hide 110 -hide 111 -hide 113 -hide 121 -hide 125 -hide 126 -hide 127 -hide 128" + - " -stubpackages " + strings.Join(module.properties.Api_packages, ":") + - " " + android.JoinWithPrefix(module.properties.Hidden_api_packages, "-hidePackage ") + - " " + android.JoinWithPrefix(module.properties.Droiddoc_options, "-") + " -nodocs" + if module.properties.Metalava_enabled == nil { + module.properties.Metalava_enabled = proptools.BoolPtr(true) + } + + droiddocArgs := "" + if Bool(module.properties.Metalava_enabled) == true { + droiddocArgs = " --stub-packages " + strings.Join(module.properties.Api_packages, ":") + + " " + android.JoinWithPrefix(module.properties.Hidden_api_packages, " --hide-package ") + + " " + android.JoinWithPrefix(module.properties.Droiddoc_options, " ") + + " --hide MissingPermission --hide BroadcastBehavior " + + "--hide HiddenSuperclass --hide DeprecationMismatch --hide UnavailableSymbol " + + "--hide SdkConstant --hide HiddenTypeParameter --hide Todo --hide Typo" + } else { + droiddocProps.Custom_template = proptools.StringPtr("droiddoc-templates-sdk") + droiddocArgs = " -stubpackages " + strings.Join(module.properties.Api_packages, ":") + + " " + android.JoinWithPrefix(module.properties.Hidden_api_packages, " -hidePackage ") + + " " + android.JoinWithPrefix(module.properties.Droiddoc_options, " ") + + " -hide 110 -hide 111 -hide 113 -hide 121 -hide 125 -hide 126 -hide 127 -hide 128 -nodocs" + } + switch apiScope { case apiScopeSystem: droiddocArgs = droiddocArgs + " -showAnnotation android.annotation.SystemApi" @@ -484,36 +506,40 @@ func (module *sdkLibrary) createDocs(mctx android.TopDownMutatorContext, apiScop // check against the not-yet-release API props.Check_api.Current.Api_file = proptools.StringPtr(currentApiFileName) props.Check_api.Current.Removed_api_file = proptools.StringPtr(removedApiFileName) - // any change is reported as error - props.Check_api.Current.Args = proptools.StringPtr("-error 2 -error 3 -error 4 -error 5 " + - "-error 6 -error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 " + - "-error 14 -error 15 -error 16 -error 17 -error 18 -error 19 -error 20 " + - "-error 21 -error 23 -error 24 -error 25 -error 26 -error 27") // check against the latest released API props.Check_api.Last_released.Api_file = proptools.StringPtr( module.latestApiFilegroupName(apiScope)) props.Check_api.Last_released.Removed_api_file = proptools.StringPtr( module.latestRemovedApiFilegroupName(apiScope)) - // backward incompatible changes are reported as error - props.Check_api.Last_released.Args = proptools.StringPtr("-hide 2 -hide 3 -hide 4 -hide 5 " + - "-hide 6 -hide 24 -hide 25 -hide 26 -hide 27 " + - "-error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 " + - "-error 15 -error 16 -error 17 -error 18") + if Bool(module.properties.Metalava_enabled) == false { + // any change is reported as error + props.Check_api.Current.Args = proptools.StringPtr("-error 2 -error 3 -error 4 -error 5 " + + "-error 6 -error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 " + + "-error 14 -error 15 -error 16 -error 17 -error 18 -error 19 -error 20 " + + "-error 21 -error 23 -error 24 -error 25 -error 26 -error 27") - // Include the part of the framework source. This is required for the case when - // API class is extending from the framework class. In that case, doclava needs - // to know whether the base class is hidden or not. Since that information is - // encoded as @hide string in the comment, we need source files for the classes, - // not the compiled ones. - props.Srcs_lib = proptools.StringPtr("framework") - props.Srcs_lib_whitelist_dirs = []string{"core/java"} - // Add android.annotation package to give access to the framework-defined - // annotations such as SystemApi, NonNull, etc. - if module.properties.Srcs_lib_whitelist_pkgs != nil { - props.Srcs_lib_whitelist_pkgs = module.properties.Srcs_lib_whitelist_pkgs - } else { - props.Srcs_lib_whitelist_pkgs = []string{"android.annotation"} + // backward incompatible changes are reported as error + props.Check_api.Last_released.Args = proptools.StringPtr("-hide 2 -hide 3 -hide 4 -hide 5 " + + "-hide 6 -hide 24 -hide 25 -hide 26 -hide 27 " + + "-error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 " + + "-error 15 -error 16 -error 17 -error 18") + + // Include the part of the framework source. This is required for the case when + // API class is extending from the framework class. In that case, doclava needs + // to know whether the base class is hidden or not. Since that information is + // encoded as @hide string in the comment, we need source files for the classes, + // not the compiled ones. + props.Srcs_lib = proptools.StringPtr("framework") + props.Srcs_lib_whitelist_dirs = []string{"core/java"} + + // Add android.annotation package to give access to the framework-defined + // annotations such as SystemApi, NonNull, etc. + if module.properties.Srcs_lib_whitelist_pkgs != nil { + props.Srcs_lib_whitelist_pkgs = module.properties.Srcs_lib_whitelist_pkgs + } else { + props.Srcs_lib_whitelist_pkgs = []string{"android.annotation"} + } } // These libs are required by doclava to parse the framework sources add via // Src_lib and Src_lib_whitelist_* properties just above. @@ -521,7 +547,11 @@ func (module *sdkLibrary) createDocs(mctx android.TopDownMutatorContext, apiScop // though they don't break the build. props.Libs = append(props.Libs, "conscrypt", "bouncycastle", "okhttp", "framework") - mctx.CreateModule(android.ModuleFactoryAdaptor(DroiddocFactory), &props) + if Bool(module.properties.Metalava_enabled) == true { + mctx.CreateModule(android.ModuleFactoryAdaptor(DroidstubsFactory), &props) + } else { + mctx.CreateModule(android.ModuleFactoryAdaptor(DroiddocFactory), &props, &droiddocProps) + } } // Creates the runtime library. This is not directly linkable from other modules. From 098d22b5f6d965872b524ce798ce728580ce405c Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Thu, 4 Oct 2018 23:29:14 -0700 Subject: [PATCH 5/7] genrule: add $(location) for inputs and outputs There was no way to select a single source file from a genrule that has multiple source files. Make Soong's genrule closer to Bazel by supporting $(location) for input and outputs. Change the label used for tools referenced through filegroups to the name of the module instead of the name of the file, which means it matches the string used in the tools property. Also support :module format in the tools property in preparation for deprecating the tool_files property and putting both files and modules in the tools property. Bug: 117354232 Test: genrule_test.go Change-Id: Id31a4ac4ff7064076a576c1d8ffeb7c19fc6b9a4 --- genrule/genrule.go | 103 +++++++++++++++++++++++----------- genrule/genrule_test.go | 119 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 188 insertions(+), 34 deletions(-) diff --git a/genrule/genrule.go b/genrule/genrule.go index f19e2aa01..2824e4907 100644 --- a/genrule/genrule.go +++ b/genrule/genrule.go @@ -52,10 +52,9 @@ type HostToolProvider interface { type hostToolDependencyTag struct { blueprint.BaseDependencyTag + label string } -var hostToolDepTag hostToolDependencyTag - type generatorProperties struct { // The command to run on one or more input files. Cmd supports substitution of a few variables // (the actual substitution is implemented in GenerateAndroidBuildActions below) @@ -63,7 +62,7 @@ type generatorProperties struct { // Available variables for substitution: // // $(location): the path to the first entry in tools or tool_files - // $(location