Commit graph

181 commits

Author SHA1 Message Date
Paul Duffin
649dadfb87 Switch droiddoc to use SdkHeaderJars()
Previously, droiddoc was using SdkImplementationJars() to get a JAR to
add to the classpath in order to resolve unknown references in the
source.

Given that SdkHeaderJars() returns jars created by Turbine which are
(for compilation at least) functionally identical to the implementation
jars there is no point in using the implementation jars.

Bug: 148080325
Test: m nothing
Change-Id: I2b718cc1445c04e849dcb0b1f53bba2b0bd90c95
2020-05-26 18:32:44 +01:00
Paul Duffin
0f8faffdc0 java_sdk_library: Improve consistency with ..._import
The scopePaths struct is used by both java_sdk_library and its prebuilt
but was not populated in the same way. This change addresses those
discrepancies in preparation for a follow up change which will allow
access to some of those fields through OutputFileProvider.

Changes:
* Document the scopePaths field and struct.
* Switch those fields that may not be fully populated from Paths to
  OptionalPath to make that 100% clear and protect against unchecked
  use.
* Switch java_sdk_library_import to use the dependency extraction
  mechanism driven by the dependency tag. This should actually have
  been part of the change that added that mechanism.
* Only create prebuilt_stubs_sources if sources have been provided.
* Add dependencies from java_sdk_library_import on its stubs source
  child modules if sources have been provided. That will ensure the
  stubsSrcJar field is updated.
* Updates current/removedApiFilePath if provided for the scope in
  java_sdk_library_import.
* Extracts ApiStubsSrcProvider from ApiStubsProvider to allow it to
  be implemented by PrebuiltStubsSources so that it can provide access
  to the stubs src jar that it creates.

Test: m nothing
Bug: 148080325
Bug: 155164730
Change-Id: Ic5bf884b2b1e79841843e7c3b4642796ecd49f5d
2020-05-20 18:00:45 +01:00
Treehugger Robot
c0320878e6 Merge "Enable api_lint in java_sdk_library" 2020-05-13 07:35:15 +00:00
Treehugger Robot
e72da7f63c Merge "Add sourcepath to inputs of remoteable metalava action." 2020-05-12 04:15:16 +00:00
Ramy Medhat
0a5c8dea01 Add sourcepath to inputs of remoteable metalava action.
Test: presubmit
Change-Id: Idd77abddac0a676302226eb62883c74d5d7489af
2020-05-11 16:49:37 -04:00
Paul Duffin
160fe41c39 Enable api_lint in java_sdk_library
Adds api_lint.enabled property to control whether API linting should be
performed.

Test: m checkapi
Bug: 156126315
Change-Id: I87ca5a942228cf6af1a9939f0334d6fc46c39a63
2020-05-11 18:05:45 +01:00
Anton Hansson
3361a294c0 Fix API lint copy command
The space after the backtick prevents it working when copy-pasting it
into the shell.

Test: create lint error => m => cp/pasted command runs successfully
Change-Id: I42b8b60d01dcaed34dbde0390eb1691d656a32cf
2020-05-11 15:40:30 +01:00
Makoto Onuki
88b9905d74 Merge the "big 3" metalava invocations into one
This CL merges the biggest three metalava invocations --
stub and signature file generation, api lint, and "check released" --
into one call.

For each of the existing separate rules for api lint and check released this change:
1) Stopped creating a separate rule containing its own metalava invocation.
2) Moved the code for creating the rule earlier so it can add extra flags to the combined metalava command.
3) Moved the message handling into metalava, allowing the message to be passed in.
4) Added a flag to record whether the specific check was needed so that you can separate the timestamp file creation out to run after the merged metalava command.

A couple of minor bug fixes and clarifications.

Bug: 151160048
Test:  "m" and treehugger

Test: Apply https://android-review.googlesource.com/c/platform/frameworks/base/+/1295541 and run `NINJA_ARGS="-k 999" m checkapi`
-> Make sure there are 4 kinds of lint failures ("AddedFinal" and "VisiblySynchronized") with the valid error messages, from:
- api-stubs-docs
- system-api-stubs-docs
- test-api-stubs-docs
- module-lib-api-

Test: Run the 4 cp commands shown by lint
-> Make sure the following 4 baseline files are updated:
frameworks/base/api/lint-baseline.txt
frameworks/base/api/module-lib-lint-baseline.txt
frameworks/base/api/system-lint-baseline.txt
frameworks/base/api/test-lint-baseline.txt

Test: Then run `NINJA_ARGS="-k 999" m checkapi` again.
-> Make sure the API lint errors are gone
-> Make sure "api-stubs-docs" shows the "You have tried to change the API from what has been
previously released in ..." error. (because of "AddedFinal")
-> Make sure it the other 3 API surfaces show the "You have tried to change the API from
what has been previously approved" error.

Test: Remove "final" from Intent.java and run "NINJA_ARGS="-k 999" m checkapi" again.
-> This time, all the 4 API surfaces say "You have tried to change the API from
what has been previously approved" error."

Test: Run the 4 "make *-update-current-api" commands shown in the above errors and "NINJA_ARGS="-k 999" m checkapi"
-> The exact command is:
$ make \
  module-lib-api-update-current-api \
  api-stubs-docs-update-current-api \
  test-api-stubs-docs-update-current-api \
  system-api-stubs-docs-update-current-api

-> Make sure frameworks/base/api/*-current.txt are properly updated.

Test: Run "m update-api"
-> Make sure no text signature files get updated.

Test: Run "m droid".
-> Make sure everything builds fine.

Change-Id: Ia1a5510b57d58748b4655473d4585636deb7f45e
Merged-In: Ia1a5510b57d58748b4655473d4585636deb7f45e
2020-05-06 13:00:01 +01:00
Ramy Medhat
a1ffd53fe4 Merge "Add support for the remote execution of metalava actions." 2020-05-05 21:53:26 +00:00
Anton Hansson
75ac71eea2 Fix soong crashing when there's no baseline file
Soong was referencing the baseline file regardless of whether it was
valid or not.

Also update the lint message to match the one metalava itself prints,
which only suggests whitelisting the error if it's not possible to fix
it properly.

Bug: 154616909
Test: m (with lint error)
Change-Id: I4c6ec327a59aefe74825b4c4719393dd267ba3aa
Merged-In: I4c6ec327a59aefe74825b4c4719393dd267ba3aa
(cherry picked from commit 34ced82d2a)
2020-05-02 11:23:34 +01:00
Ramy Medhat
427683cad7 Add support for the remote execution of metalava actions.
Test: built aosp crosshatch userdebug with RBE_METALAVA=1
Change-Id: I3d42d75b4522f99ff95ce8c997ead782e4322f6e
2020-04-30 03:24:48 -04:00
Makoto Onuki
ef720013ef Merge "Don't use metalava for "check-current"" 2020-04-27 18:39:07 +00:00
Anton Hansson
0f15a9f866 Remove unused arguments in droiddoc
Nothing passes these arguments, so it's dead code.

There is a lot of other cruft in this file that is effectively
dead code, but required further cleanup.

Bug: 152479829
Test: m
Change-Id: Ib2630d4d49f21003b17e2331b0900e8df0a27e66
Merged-In: Ib2630d4d49f21003b17e2331b0900e8df0a27e66
(cherry picked from commit 0ee713aa0e)
2020-04-22 21:15:09 +01:00
Makoto Onuki
5405a737c3 Don't use metalava for "check-current"
Because we already generate the latest current.txt and removed.txt
during the "main" metalava invocation (i.e. stub generation),
we don't have to use metalava for current API check.

Just use diff instead.

Bug: 151160048

Test: Remove @hide from Intent.EXTRA_INSTALL_RESULT, and do `m out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/check_current_api.timestamp`.
Result is:
```
FAILED: out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/check_current_api.timestamp
( true && diff -u -F '{ *$' frameworks/base/api/current.txt out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/api-stubs-docs_api.txt && diff -u -F '{ *$' frameworks/base/api/removed.txt out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/api-stubs-docs_removed.txt && touch out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/check_current_api.timestamp ) || ( echo -e "\n******************************\nYou have tried to change the API from what has been previously approved.\n\nTo make these errors go away, you have two choices:\n   1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)\n      to the new methods, etc. shown in the above diff.\n\n   2. You can update current.txt and/or removed.txt by executing the following command:\n         make api-stubs-docs-update-current-api\n\n      To submit the revised current.txt to the main Android repository,\n      you will need approval.\n******************************\n" ; exit 38 )

Change-Id: I63f237c6e046de8a6b6538c44ec0ab8bd8fbbdb1
--- frameworks/base/api/current.txt     2020-04-16 17:50:21.911899599 -0700
+++ out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/api-stubs-docs_api.txt       2020-04-16 17:51:35.211792638 -0700
@@ -10415,6 +10415,7 @@ public class Intent implements java.lang
     field public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
     field public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
     field public static final String EXTRA_INSTALLER_PACKAGE_NAME = "android.intent.extra.INSTALLER_PACKAGE_NAME";
+    field public static final String EXTRA_INSTALL_RESULT = "android.intent.extra.INSTALL_RESULT";
     field public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
     field public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
     field public static final String EXTRA_LOCAL_ONLY = "android.intent.extra.LOCAL_ONLY";

******************************
You have tried to change the API from what has been previously approved.

To make these errors go away, you have two choices:
   1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)
      to the new methods, etc. shown in the above diff.

   2. You can update current.txt and/or removed.txt by executing the following command:
         make api-stubs-docs-update-current-api

      To submit the revised current.txt to the main Android repository,
      you will need approval.
******************************

ninja: build stopped: subcommand failed.
```

Test: Remove @removed and @SystemApi from Intent.ACTION_MASTER_CLEAR, and do `m out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/check_current_api.timestamp`
Result is:
```
( true && diff -u -F '{ *$' frameworks/base/api/system-current.txt out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/system-api-stubs-docs_api.txt && diff -u -F '{ *$' frameworks/base/api/system-removed.txt out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/system-api-stubs-docs_removed.txt && touch out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/check_current_api.timestamp ) || ( echo -e "\n******************************\nYou have tried to change the API from what has been previously approved.\n\nTo make these errors go away, you have two choices:\n   1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)\n      to the new methods, etc. shown in the above diff.\n\n   2. You can update current.txt and/or removed.txt by executing the following command:\n         make system-api-stubs-docs-update-current-api\n\n      To submit the revised current.txt to the main Android repository,\n      you will need approval.\n******************************\n" ; exit 38 )
--- frameworks/base/api/system-removed.txt      2020-04-16 17:50:21.911899599 -0700
+++ out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/system-api-stubs-docs_removed.txt     2020-04-16 17:53:45.319602905 -0700
@@ -55,7 +55,6 @@ package android.content {

   public class Intent implements java.lang.Cloneable android.os.Parcelable {
     field @Deprecated public static final String ACTION_DEVICE_INITIALIZATION_WIZARD = "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
-    field @Deprecated public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
     field @Deprecated public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
     field @Deprecated public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
     field @Deprecated public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";

******************************
You have tried to change the API from what has been previously approved.

To make these errors go away, you have two choices:
   1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)
      to the new methods, etc. shown in the above diff.

   2. You can update current.txt and/or removed.txt by executing the following command:
         make system-api-stubs-docs-update-current-api

      To submit the revised current.txt to the main Android repository,
      you will need approval.
******************************
```

Test: Add `baseline_file` to `check_api.current` and run `m`
FAILED: out/soong/build.ninja
out/soong/.bootstrap/bin/soong_build -t -l out/.module_paths/Android.bp.list -b out/soong -n out -d out/soong/build.ninja.d -globFile out/soong/.bootstrap/build-globs.ninja -o out/soong/build.ninja Android.bp
error: frameworks/base/StubLibraries.bp:86:1: module "api-stubs-docs" variant "android_common": current API check can't have a baseline file. (module %s): api-stubs-docs
ninja: build stopped: subcommand failed.

Test: With the above changes, run "m api-stubs-docs-update-current-api system-api-stubs-docs-update-current-api", make sure the API files got updated, and then run "m"
Change-Id: I47b146c6fe4caa65775ecf5425ab09b57f43f839
2020-04-17 08:55:15 -07:00
Treehugger Robot
318f68226b Merge "Export API files as part of the java_sdk_library" 2020-04-10 03:57:11 +00:00
Treehugger Robot
b661961825 Merge "Export stub sources as part of the java_sdk_library" 2020-04-10 03:57:04 +00:00
Paul Duffin
1fd005d5b3 Export API files as part of the java_sdk_library
Bug: 153443117
Test: m nothing

Change-Id: I9d6f5b91a7cc25019e2eb9e3c138f0874d2831de
2020-04-09 01:33:46 +01:00
Paul Duffin
3d1248ceb6 Export stub sources as part of the java_sdk_library
Minor refactoring of checkMergeZip(string) -> checkMergeZips(...string)
to allow testing of multiple merge zips.

Bug: 153443117
Test: m nothing
Change-Id: I8db00f611ced15f8476ba16f2834a72e8c913596
2020-04-09 01:32:38 +01:00
Paul Duffin
3ae2951296 Allow droidstubs to not generate any stubs
Needed to optimize the handling of the module_lib API surface which
currently has to be generated with two separate droidstubs instances,
one to generate the stubs and another to generate the .txt file. This
allows the module generating the .txt file to avoid also wasting time
generating stubs that are not used.

This change:
* Adds a generate_stubs property that defaults to true to allow the
  behavior to be customized on a per module basis.
* Uses either the stubs srcjar or the api .txt file as the OutputFile
  for the AndroidMkEntries to ensure that they get written out properly.
* Rearranges the code for generating stubs to make it easier to
  turn it off.

Bug: 146727827
Test: m droid
      Check output dir of framework-sdkextensions-api-module_libs_api
	  to make sure it does not contain any sources or srcjars.
Change-Id: Ib8025019f8a7a8cf5fa8765d76b5ad470af20006
2020-04-08 18:50:37 +01:00
Paul Duffin
495ffb9ff9 Remove old SdkMemberType API for creating snapshot modules
Migrates system modules and droid stubs over to use the new API for
creating the snapshot modules and removes the old API.

Test: m nothing
Change-Id: Ia825767f1f7ee77f68cfe00f53e09e6f6bfa027f
2020-03-23 08:48:03 +00:00
Aurimas Liutikas
39de325122 Do not include any documentation when building stubs
We only need documentation (javadocs) when building docs stubs,
for regular stubs, we can drop printing out all the docs.

Tested with:
touch frameworks/base/core/java/android/view/View.java && time make -j framework

Before (with just r.android.com/1254909)
Run #1 2m4.779s
Run #2 2m6.672s
Run #3 2m4.179s

Average: 125.2 seconds

After (with this patch and r.android.com/1254909)
Run #1 1m58.682s
Run #2 1m58.820s
Run #3 1m57.724s

Average: 118.4 seconds

Speedup ~6.8 seconds (5.4%)

Bug: 151160048
Test: make checkapi
Change-Id: I27eafb5a61bb9d26a74ca25f84c9daca17a8394f
2020-03-11 23:53:13 +00:00
Colin Cross
2a2e0db2a2 Add an order-only dependency on the build number file
Remote execution and other tools can be confused by references to
build_number.txt without a dependency.  Add an order-only dependency,
which maintains the current behavior.

Test: BUILD_NUMBER=1 && m aapt && aapt version # shows 1
      BUILD_NUMBER=2 && m aapt && aapt version # shows 1
      rm out/soong/.intermediates/frameworks/base/tools/aapt/aapt/linux_glibc_x86_64/aapt
      BUILD_NUMBER=2 && m aapt && aapt version # shows 2
Change-Id: Icfa98d6840b1dc2e273ba29c33011635d1cf93b1
2020-02-28 18:16:56 +00:00
Paul Duffin
83a2d967de Allow java_system_modules_import to replace java_system_modules
Previously, there were some places where a java_system_module_import
could not be used in place of a java_system_module. That was because
the code assumed a *SystemModules type not a *systemModulesImport type.
This change introduces a SystemModulesProvider interface that is used
instead and is implemented on both types.

Bug: 142940300
Test: m nothing
      ran new tests before changes to make sure they detected the issue
	  and after to make sure the changes fixed the issue.
Change-Id: I7b16ac5708880bdf61e6f5b1e6616c986f0ed763
2020-02-19 14:24:15 +00:00
Jaewoong Jung
3aff5787e2 Simple refactoring of prefix related functions.
Rename the two prefix-in-list funcs so that their usages are clearer.
Also find and replace all the code that essentially does either.

This introduces additional loops in some places, but I think the added
readability and simplicity outweighs the performance degradation, which
should be negligible anyway.

Test: m nothing
Test: TreeHugger
Change-Id: I37e2276ca0c815105ed0031f23c0b1264b480e4f
2020-02-14 14:33:49 -08:00
Anton Hansson
26bf49b0b2 Fix sdk aidl include for droiddoc
Prior to this change droidstubs modules that set sdk_version
did not get framework.aidl added to its aidl includes.

Bug: 149138391
Test: patch CL in bug && m system_aidl_test-droidstubs
Change-Id: I92ab344c8a4311e10c1e5c8ebf525fa2dc704075
(cherry picked from commit f278ca60e06da86c67f6a3865c290f8451657ce9)
2020-02-08 20:37:07 +00:00
Mathew Inwood
abd49ab4df Build rules for compat config docs generation.
We add a compat config build rule to extract the merged config, and
then update the droiddoc build rule to consume that.

Test: m -j offline-sdk-docs
Bug: 144927670
Change-Id: Ib1e85f97895c89227882e665572bda9bfc2a8cba
Exempt-From-Owner-Approval: ag/10097965 approved internally, Colin requested to patch to aosp
2020-02-04 16:28:22 +00:00
Jiyong Park
6a927c4e6a Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.

The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.

The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.

Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-25 21:56:43 +09:00
Colin Cross
8b8bec3b3a Create a highmem pool and put metalava into it
Create a highmem pool based on the total RAM and the number of CPUs,
with an override via the NINJA_HIGHMEM_NUM_JOBS variable.  Put
metalava into the highmem pool.

Ninja does not support nested pools, and when goma or RBE is enabled
the maximum ninja parallelism is set very high with local jobs in a
local pool.  When both the local pool and highmem pool are enabled,
the total number of local jobs will be as high as the sum of the sizes
of the two pools.  Keep the highmem pool limited to 1/16th of the
local pool when remote builds are enabled to try to minimize the
effect while still limiting highmem jobs.

Fixes: 142644983
Test: m nothing, examine pools
Test: m USE_GOMA=true nothing, examine pools
Change-Id: Id79f11f44948992960ac34ecf831dacbe21bd332
2020-01-24 11:44:23 -08:00
Paul Duffin
e602918294 Restrict SdkMemberTypes that can be used with sdk/sdk_snapshot
By default SdkMemberTypes are only supported on module_exports module
type. Support for sdk module type has to be explicitly specified.

The java_header_libs, native_shared_libs and stubs_sources are
supported on sdk. The latter is required to provide the stubs source
for an API specified in java_header_libs as they should be kept in
sync.

Bug: 146341462
Test: m nothing
Change-Id: I19b9e60792780a797458d4a9e489506602b13144
2019-12-31 15:08:59 +00:00
Paul Duffin
9b478b0831 Generate .srcjar for prebuilt_stubs_sources
Changes prebuilt_stubs_sources to generate a .srcjar from its input
instead of just exposing the srcs it is given. This ensures that it can
be used as a drop in replacement for a droidstubs module.

Updates the test for prebuilt_stubs_sources to be more representative
of the actual use made of it by sdk snapshot which outputs a directory
not a glob pattern. Added some documentation of the
prebuilts_stubs_sources srcs property to make it clear that it is
supposed to be a set of directories.

Extracts common code from sdk/testing.go for normalizing path/paths
for testing.

Bug: 143678475
Test: m conscrypt-module-sdk conscrypt-module-host-sdk conscrypt-module-test-sdk
      unzip those in place of external/conscrypt
	  build core-current-stubs-source which expects it to provide a .srcjar.
Change-Id: I8204a022557a9b0b45e19eac79ecba98ff95213d
2019-12-20 08:13:45 +00:00
Paul Duffin
884363e782 Dedup droiddoc module type registration
Some tests were changed as they were using the wrong name for the
droiddoc_exported_dir module type.

Test: m checkbuild
Bug: 146540677
Change-Id: If57404760d2df3757c93e237696359355cf0c96e
2019-12-19 19:19:40 +00:00
Paul Duffin
255f18e584 Decouple addition of new sdk member types from sdk code
Previously, adding a new SdkMemberType would require adding a new
sdkMemberListProperty instance to the sdkMemberListProperties as well
as adding a new property into the sdkProperties struct. They are
potential sources of conflict and couple the sdk code with all the
packages that add members to it. This change switched to a
registration model that allows each package to register its sdk
member types decoupling them from the sdk code.

Adds an SdkPropertyName() method to SdkMemberType that specifies the
name of the property to use in the sdk/sdk_snapshot. Also provides
an SdkMemberTypeBase struct to be used by providers of SdkMemberType
implementations.

SdkMemberType instances are registered using the
RegisterSdkMemberType() func which sorts the registered instances
by their SdkPropertyName() to ensure the behavior is consistent and
not affected by order of registration.

When creating a new sdk module a dynamicSdkMemberTypes instance is
created that contains the following:

* A properties struct is created dynamically that contains a field for
  each registered SdkMemberType, corresponding to that type's
  SdkPropertyName().

* A list of sdkMemberListProperty instances is also created, one for
  each registered SdkMemberType.

The dynamicSdkMemberTypes instance is cached using a key that uniquely
identifies the set of registered types just in case new types are
registered after one has been created, e.g. by tests.

Bug: 142918168
Test: m checkbuild
Change-Id: I4bf2bf56a2a49025aa41454048bc1e8ccc6baca2
2019-12-13 20:07:33 +00:00
Paul Duffin
9d8d609fcd Pass SdkMember to AddPrebuiltModule instead of the name
This is needed for a follow up change that makes sure that the
prebuilt modules have the same visibility as the source modules.

Bug: 143678475
Test: m conscrypt-module-sdk
Change-Id: I9461c8c094ab19ee9ececb5e5fd50565789f2fa2
2019-12-09 13:28:36 +00:00
Paul Duffin
1387957727 Parameterize the sdk member processing
Extracts the type specific functionality into the SdkMemberType
interface which has to be implemented by each module type that can
be added as a member of the sdk. It provides functionality to add
the required dependencies for the module type, check to see if a
resolved module is the correct instance and build the snapshot.

The latter was previously part of SdkAware but was moved because
it has to be able to process multiple SdkAware variants so delegating
it to a single instance did not make sense.

The custom code for handling each member type specific property,
e.g. java_libs, has been replaced with common code that processes
a list of sdkMemberListProperty struct which associates the
property (name and getter) with the SdkMemberType and a special
DependencyTag which is passed to the SdkMemberType when it has to add
dependencies.

The DependencyTag contains a reference to the appropriate
sdkMemberListProperty which allows the resolved dependencies to be
grouped by type.

Previously, the dependency collection methods would ignore a module if
it was an unsupported type because they did not have a way of
determining which property it was initially listed in. That meant it
was possible to add say a droidstubs module to the java_libs property
(and because they had the same variants) it would work as if it was
added to the stubs_sources property. Or alternatively, a module of an
unsupported type could be added to any property and it would just be
ignored.

However, the DependencyTag provides information about which property
a resolved module was referenced in and so it can detect when the
resolved module is of the wrong type and report an error. That check
identified a bug in one of the tests where the sdk referenced a
java_import module (which is not allowed in an sdk) instead of a
java_library module (which is allowed). That test was fixed as part
of this.

A list of sdkMemberListProperty structs defines the member properties
supported by the sdk and are processed in order to ensure consistent
behaviour.

The resolved dependencies are grouped by type and each group is then
processed in defined order. Within each type dependencies are grouped
by name and encapsulated behind an SdkMember interface which includes
the name and the list of variants.

The Droidstubs and java.Library types can only support one variant and
will fail if given more.

The processing for the native_shared_libs property has been moved into
the cc/library.go file so the sdk package code should now have no type
specific information in it apart from what is if the list of
sdkMemberListProperty structs.

Bug: 143678475
Test: m conscrypt-module-sdk
Change-Id: I10203594d33dbf53441f655aff124f9ab3538d87
2019-12-06 12:16:59 +00:00
Paul Duffin
b645ec8e34 Add model to represent generated snapshot .bp file
Having each module type generate the contents of the snapshot's .bp
file results in lots of duplicated code. This adds an intermediate
model for use by the module types and then generates the .bp file
contents from that.

This not only removes the duplicated formatting code but it also
allows consistent handling of shared properties such as name further
reducing duplication. It also makes it possible to duplicate the
versioned and unversioned prebuilt modules from the same model.

Extracts generatedContents from generatedFile to allow the contents
to be populated without creating an output file, for testing.

Cleans up unused code.

Bug: 143678475
Test: m nothing
Change-Id: If21b84db0ef3fdfb5dc11ea0973ce6cb73603ea3
2019-12-02 12:59:38 +00:00
Paul Duffin
b1a8813520 Dedup code for generating prebuilt_stubs_sources in snapshot
Removes duplicated code for generating a versioned and non-versioned
form of the prebuilt_stubs_sources module in the snapshot.

Bug: 143678475
Test: m nothing

Change-Id: Ic431b6fcb6f3c7c85f1a04cb6f087424aaf0cffa
2019-11-26 22:30:27 +00:00
Paul Duffin
9154718303 Adds droidstubs support to sdk module
Adds stubs_sources property to sdk and unzips the droidstubs srcjar
into the snapshot directory.

Adds an UnzipToSnapshot method to the SnapshotBuilder which creates
a rule that uses zip2zip to repackage the supplied zip content into a
temporary zip file that matches what the required snapshot structure.
e.g. if the supplied zip contains foo/Foo.java and that needs to be in
the snapshot directory java/foo/stubs then it will create a zip that
contains java/foo/stubs/foo/Foo.java.

The temporary zip that is the output of that rule is added to the
zipsToMerge field for merging later.

If the zipsToMerge is empty then the snapshot zip is created as
before. Otherwise, a temporary zip file is created. That is then
merged with the other zip files in zipsToMerge to create the final
snapshot zip.

Adds prebuilt_stubs_sources for use by the generated .bp module.

Bug: 143678475
Test: added conscrypt sdk module and attempted to build it
Change-Id: Ie274263af3a08e36a73c61c0dbf0c341fd6967e2
2019-11-22 20:52:59 +00:00
Treehugger Robot
80df439072 Merge "Enforce hidden apis usage in product(soong)" 2019-11-11 02:05:16 +00:00
Paul Duffin
13a9dd604b Remove unnecessary constraint on previous_api
The constraint requires the previous_api property to be specified
unless validating nullness. However, there is no reason within the
Soong code why that should be.

The only use of previous_api is as the argument to the metalava
--migrate-nullness option which is only added when previous_api is
specified. So, there is no reason in the Soong code for the
constraint.

Metalava also does not require the --migrate-nullness option to be
specified unless validating nullness. So, there is no reason in
metalava for the constraint.

It is therefore safe to remove the constraint.

Bug: 142113521
Test: m checkbuild
Change-Id: I189071e215e928fdf43a39a03d540732743b7a32
2019-11-08 08:23:14 +00:00
Adrian Roos
109f64766e Merge "API Lint: Archive lint errors" 2019-11-06 12:35:55 +00:00
Jeongik Cha
2cc570dc63 Enforce hidden apis usage in product(soong)
Only if PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE is set,
every app and java library in product cannot use hidden APIs anymore.

checkSdkVersion() checks if sdk_version of app and library is narrow enough,
checkLinkType() checks every library that app links agianst

Bug: 132780927
Test: m
Test: set PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE, and check whether build
error occurs.
Change-Id: Ic630503b875040f730feda4fef826ed6d71da111
2019-11-06 19:42:42 +09:00
Adrian Roos
3b8f1cda45 API Lint: Archive lint errors
Adds reported lint errors to dist. This lets us track them and
build tooling on top.

Bug: 138440867
Test: make dist droid; ls -l out/dist/apilint
Change-Id: I75629e3d9e1a53d161d844dfac121a5998429e04
2019-11-04 19:04:52 +01:00
Colin Cross
6cef481ee7 Use java language 1.9 for sdk_version: "current"
Java language was set for 1.8 for anything building against the
current SDK because the stubs were not built in Soong, so the
system modules could not be built.  The stubs have been built
in Soong since Iabd32b30954b3f4a6d9a779fde52a032b684807e, but
I5e870c34dd0ebc8ae3f888ec627da590c846a76f missed updating
this TODO.

Use 1.9 when building against the stubs, but continue using
1.8 for unbundled builds until we have prebuilt system modules.

Always use the core-current-stubs-system-modules to avoid
splitting android.* packages between the system modules and
the classpath, which would cause new classes in android.*
packages in classpath jars to be ignored.  Add a new
java9Classpath field to sdkDep that will contain the stubs jar
when targeting Java language level 1.9, and plumb it through
to javac and turbine.  Rename the modules field to bootclasspath.

Bug: 142896162
Test: m checkbuild
Change-Id: Icfd32d0a863b2303a997c7cf03cb3708aade4724
2019-10-29 13:35:39 -07:00
Colin Cross
6d8d8c6a91 Remove special case for sdk_version: "none"
The dependency handling for sdk_version: "none" (which propagated to
!sdkDep.hasStandardLibs()) was very similar to the normal useModule
case.  Combine the cases by making decodeSdkDep set useModule: true
and put the system modules in modules for the sdk_version: "none"
case.

Test: TestClasspath
Change-Id: Icc9ff4d43a38da25cc0e3628be95951d61773ad5
2019-10-29 13:35:39 -07:00
Colin Cross
1e7438524b Make javaVersion an enum
Remove the hardcoded checks against "1.9" by making javaVersion
an enum and implementing javaVersion.usesJavaModules().

Test: TestClasspath
Change-Id: I559eeb1f45880bb8177269c6d977ee4dfbadce57
2019-10-28 14:55:03 -07:00
Pete Gillin
a1c9e9da55 Remove support for EXPERIMENTAL_JAVA_LANGUAGE_LEVEL_9.
Prior to this change, setting that to "false" turned the default Java
language level back to 8. This change removes that option.

Bug: 115604102
Test: m java droid docs tests cts
Change-Id: I97bfd0dc8d941008b4071c6efe1c0c24950c4f1f
2019-10-25 16:55:06 +01:00
Jerome Gaillard
8436ccea9c Merge "Update droidstubs build target" 2019-10-21 09:32:12 +00:00
Jerome Gaillard
0f59903d09 Update droidstubs build target
This allows to use Metalava to generate metadata files useful for
Android Studio as part of a droidstubs target.
Once those files have been created in a new metadata folder, they are
zipped to make it easier to transfer them into the
out/target/common/obj/PACKAGING folder where they can then be picked up
by the SDK build to be included there.

Bug: 142480924
Test: m sdk
Change-Id: I4be1c9e78369c65ee9cd94706c6d20ab0df6b797
2019-10-18 14:21:55 +01:00
Adrian Roos
cab4a2c84a API Lint: Apply Javadoc.args when invoking api lint
Bug: 142459906
Test: make checkapi
Change-Id: I64c83a8064491303088cca713537c391f1a3d876
Merged-In: I64c83a8064491303088cca713537c391f1a3d876
2019-10-14 16:33:08 +02:00
Paul Duffin
e25c644f1e Add system_modules to droidstubs
This allows droidstubs to use the same system modules to create the
stubs that will be used to compile them. It improves consistency and
avoids droidstubs having to duplicate the libraries that make up the
system modules on its libs property.

Adds systemModules() to the sdkContext which allows consistent error
checking behavior between droidstubs and java_library.

Bug: 142534789
Test: m checkbuild
Change-Id: Ib2006906d9528a900f16851f50b62152ffb51a1b
2019-10-11 16:38:14 +01:00