Commit graph

2067 commits

Author SHA1 Message Date
Paul Duffin
87a05a389d java_sdk_library: Add sdk_version for API scopes
Allow the sdk_version against which the stubs for a scope are compiled
to be specified in the module on a per scope basis.

Bug: 155164730
Test: m nothing
Change-Id: I5881e5ee7c2169c30f544882344a60a602dae917
2020-05-13 13:09:23 +01:00
Paul Duffin
6c9c5fc4bc java_sdk_library: Add framework-modules naming scheme
Matches the naming scheme used by the separate manually created modules
that will be replaced by java_sdk_library's automatically created
components. This will simplify conversion to java_sdk_library as it
will allow developers to concentrate on getting the conversion correct
without also having to worry about name changes. It will also allow the
conversions to be parallelized as many of the references to the
components are in places where conflicts are likely.

Test: m nothing
Bug: 155480189
Change-Id: Ic859a61de155b3e582c17f6ab5e9298f5f4e709a
2020-05-13 08:52:56 +01:00
Paul Duffin
dd9d0740fa java_sdk_library: Remove some almost single use constants
The constants are only used in one place in the code and in the test.
This change switches the test code to use the apiScope methods to
generate the names and then inlines the constants in those methods. It
makes it easier to see the naming convention.

Test: m nothing
Bug: 155480189
Change-Id: I966e82b8ae67624da168e05f5a2b062b832cb8cd
2020-05-13 08:52:56 +01:00
Paul Duffin
1b1e8069ec java_sdk_library: Delegate component module to naming scheme
Adds a naming scheme abstraction to which the java_sdk_library/import
will delegate the task of creating the names of their component
modules. The naming scheme can be selected in a module definition but
for now the only supported option is "default".

Test: m nothing
Bug: 155480189
Change-Id: I708657661188ea4a14a4dd8c6bc4b46237bbe5e0
2020-05-13 08:52:56 +01:00
Paul Duffin
c3091c8c19 java_sdk_library: Extract child module naming to common struct
Extracts the child module naming to the commonToSdkLibraryAndImport
struct so it can be reused by both sdk library source and prebuilt.

Also:
* Makes all child module name generation go through the common struct.
* Renames some of the methods to clarify their purpose and improve
  consistency.

Test: m nothing
Bug: 155480189
Change-Id: I9be9aab07252b491ab292b8847138a93b487cf53
2020-05-13 08:52:56 +01:00
Paul Duffin
0ff08bdb07 java_sdk_library: Allow separate api/stubs source modules
The API file for a scope represents the differences between the API
provided by that scope and that provided by the scope that it extends.
On the other hand the stubs source for a scope represents the union of
the API provided by the scope and the scope it extends (all the way
back to public).

Unfortunately, while metalava supports this behavior for scopes that
extend public (e.g. system and test) it does not support this behavior
for scopes that extend others, e.g. module_lib which extends system.
This is because it always assumes that the baseline for the API file
is 'public' and so has no way to defined other baselines.

This change works around that by having separate droidstubs modules to
generate the API and stubs sources for scopes that require different
arguments to generate the API and stubs sources.

Test: m checkapi
Bug: 155164730
Change-Id: Iea7d59852d7aeb503120acf3c44e08eb0d9d07b9
2020-05-13 08:52:53 +01:00
Treehugger Robot
fced20c3b4 Merge "java_sdk_library: Preserve sdk_version: "none" in snapshot" 2020-05-13 07:36:43 +00:00
Treehugger Robot
c0320878e6 Merge "Enable api_lint in java_sdk_library" 2020-05-13 07:35:15 +00:00
Colin Cross
2bdf0da9e7 Merge "Revert "enforce sdk_version for JNI libs for updatable APKs"" 2020-05-13 01:26:25 +00:00
Jooyung Han
cc928d9059 Revert "enforce sdk_version for JNI libs for updatable APKs"
This reverts commit 98c4750f39.

Reason for revert: broken builds

Change-Id: Icd3a9e226ff8ff288b682757cded9f43069ebc5e
2020-05-13 01:22:56 +00:00
Treehugger Robot
1852b586bf Merge "enforce sdk_version for JNI libs for updatable APKs" 2020-05-13 00:57:34 +00:00
Paul Duffin
780c5f4715 java_sdk_library: Preserve sdk_version: "none" in snapshot
Test: m nothing
Bug: 156354511
Change-Id: Icf7c20dc109a773430768c1a2d91c674551dbc1b
2020-05-12 15:52:55 +01: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
Anton Hansson
432f75c61a Merge "Fix API lint copy command" 2020-05-11 17:54:08 +00: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
satayev
ecea813997 Merge "Introduce app -deps-info." 2020-05-11 16:51:30 +00:00
Artur Satayev
1111b84822 Introduce app -deps-info.
Similar to APEX-deps-info, app deps info produces two lists with
transitive dependencies.

Bug: 149622332
Test: m NetworkStack-deps-info
Change-Id: Ic6d94df3b7b4be5afe328a0abe768beee1a58362
Exempt-From-Owner-Approval: previous patch approved.
2020-05-11 16:51:06 +00:00
Treehugger Robot
a586fecea6 Merge "java_sdk_library: Path extraction from deps depend on tag" 2020-05-11 14:47:21 +00: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
Treehugger Robot
d2e4822774 Merge "Expand SystemApi annotation for generating system api" 2020-05-11 14:24:36 +00:00
Paul Duffin
c878250d3f java_sdk_library: Path extraction from deps depend on tag
Previously, the information that the java_sdk_library extracted from
its child dependencies was determined purely by the type of the
dependency and whether it had a tag of the appropriate type. The actual
tag itself was ignored. That worked but was a little fragile as it
relied on there being no overlap between the types of the dependencies
or if there was overlap on the order in which the dependencies were
processed and the dependency types were checked to ensure that the
correct information was collected.

This change makes the information that is extracted dependent on the
tag that is used. That makes the behavior much more robust and also
simplifes the follow up change which may get the stubs source and API
files from separate droidstubs invocations.

Changes:
* A func field is added to the scopeDependencyTag that is supplied with
  a dependency from which to extract the information and scopePaths
  into which the information will be stored.
* Each scopeDependencyTag instance supplies its own function.
* Various items are renamed to more closely reflect what they actually
  do. e.g. the apiFileTag is renamed to stubsSourceAndApiTag field
  because if provides access to both api file and stubs source.

Test: m checkapi
Bug: 155164730
Change-Id: I4e1861ea67f441f2948a0d7d7053ab0b1169955f
2020-05-10 23:42:02 +01:00
Paul Duffin
6e7ecbf972 Switch java_sdk_library_import to use SetDefaultableHook()
Ensure consistency with java_sdk_library.

Bug: 155295806
Test: m checkapi
Change-Id: I074e7c865b6b52c7bcf568da3342d8772623ce4f
2020-05-10 19:33:36 +01:00
Paul Duffin
9f10bbf4cf Merge "java_sdk_library: Specify visibility of stubs modules" 2020-05-10 18:31:56 +00:00
Paul Duffin
385378bf99 Merge "Retry: Detect invalid arch specific properties in snapshot" 2020-05-09 07:33:35 +00:00
Treehugger Robot
9c3a1291e2 Merge "Add error checking and tests for jni_uses_sdk_apis and jni_uses_platform_apis" 2020-05-09 02:13:42 +00:00
Colin Cross
3c007704c7 Add error checking and tests for jni_uses_sdk_apis and jni_uses_platform_apis
Check that jni_uses_sdk_apis and jni_uses_platform_apis are consistent
with sdk_version, and add tests that they select the right variant.

Bug: 154665579
Test: app_test.go
Change-Id: I544a4f881ba16dacd7e74cd480c095091b3cf667
2020-05-08 16:55:14 -07:00
Paul Duffin
864e1b45db Retry: Detect invalid arch specific properties in snapshot
Previously, the snapshot code did not know whether a specific property
could be arch specific or not and assumed that they all were which
meant that it could generate snapshots containing arch specific values
for properties that are not arch specific and so would fail when
unpacked.

This change requires arch specific fields in SdkMemberProperties to be
tagged as such using `android:"arch_variant"` (just as in module input
property structures). Any property without that must have properties
that are common across all variants.

Bug: 155628860
Test: m nothing
Change-Id: I3df60f0b53ba02ec2c55a80c7da058eac5909d26
2020-05-08 22:31:56 +01:00
Greg Kaiser
a71fe150fa Merge changes from topic "revert-1302576-NGVCIVIIJO"
* changes:
  Revert "Detect invalid arch specific properties in snapshot"
  Revert "Adds support for 'ignored-on-host'"
  Revert "Fix snapshot of a host/device cc_library with stubs"
2020-05-08 19:18:40 +00:00
Greg Kaiser
e509447c93 Revert "Detect invalid arch specific properties in snapshot"
Revert submission 1302576

Bug: 156054601
Reason for revert: Presumed root cause of build break.
Reverted Changes:
Ifc8116e11:Detect invalid arch specific properties in snapsho...
I7ebd33307:Adds support for 'ignored-on-host'
I167b47a13:Fix snapshot of a host/device cc_library with stub...

Change-Id: Id7eba0bdde5c579e10e9b42d94a7cfab5f34995f
2020-05-08 19:12:34 +00:00
Paul Duffin
4911a89181 java_sdk_library: Specify visibility of stubs modules
Adds two new properties to specify the visibility of the stubs modules
(source and library) created by the java_sdk_library. Excludes
visibility property from being inherited when creating the module so it
can be properly specified by copying across the relevant property.

Test: m checkapi
Bug: 155164730
Change-Id: Iffdd9f191ff0d74646356ac577560cc38efdd790
2020-05-08 18:03:31 +01:00
Paul Duffin
0d543640d5 Expand SystemApi annotation for generating system api
Metalava apparently normalizes the SystemApi annotation that was
previously used to the form that this change uses so this is
effectively a no-op. However, this does make this code more
self-consistent and also matches the form that is used in the framework
defaults for the mainline modules.

Test: m checkapi
Bug: 155164730
Change-Id: Ic99b7333730ed8b918d8af72ae7bd6a851c2093a
2020-05-08 12:33:27 +01:00
Paul Duffin
8f265b9ab9 java_sdk_library: Add support for module_lib API surface
Adds api scope for the module_lib and adds that to the list of all
all available scopes. The scope is generated if and only if the
api_surfaces property contains "module_lib".

No other changes are needed as the generation of the APIs is completely
driven by the allApiScopes array and the information in its contained
apiScope structures.

Test: m checkapi
Bug: 155164730
Change-Id: I7769af6823badca8715a270f86cf53b4e954b7df
2020-05-08 07:51:00 +01:00
Paul Duffin
3375e35d99 java_sdk_library: Control API surfaces generated
Adds a per scope set of properties that allows explicit control over
the API surfaces generated.

Previously, the term active was used to determine whether it was
generated but that was a little abstract and unclear so has been
replaced by generated.

Test: m nothing
Bug: 155164730
Change-Id: I7539d89618b61f6b9d1a4b60cc3f9614b157f0d9
2020-05-08 07:51:00 +01:00
Paul Duffin
af6fbcbcca Merge changes I167b47a1,I7ebd3330,Ifc8116e1
* changes:
  Fix snapshot of a host/device cc_library with stubs
  Adds support for 'ignored-on-host'
  Detect invalid arch specific properties in snapshot
2020-05-07 21:58:14 +00:00
Treehugger Robot
cf23ab4cd8 Merge "Skip dexpreopting android_test_import modules" 2020-05-07 21:37:37 +00:00
Treehugger Robot
3d60daadbc Merge "Switch java_sdk_library to use SetDefaultableHook()" 2020-05-07 20:39:05 +00:00
Colin Cross
c80828d567 Skip dexpreopting android_test_import modules
android_test_import modules should be labelled as tests so they are
not dexpreopted.

Bug: 155778135
Test: m CtsCorruptApkTests_Compressed_Q
Change-Id: I7baa5405d03df03920b01616b030ba77f882a77e
2020-05-07 12:06:14 -07:00
Colin Cross
7500f46b95 Merge "Add jni_uses_sdk_apis" 2020-05-07 18:09:47 +00:00
Colin Cross
7204cf0e6a Add jni_uses_sdk_apis
NetworkStackTests is using platform APIs for its Java code, but needs
to use portable JNI libraries.  Add a jni_uses_sdk_apis so that it
can select the SDK variants of JNI libraries even though it doesn't
set sdk_version.

(clean cherry-pick from internal branch)
Bug: 154665579
Test: atest NetworkStackTests
Merged-In: I841fb761ec1c1ab8596aac44e01eb7eb91428006
Change-Id: I841fb761ec1c1ab8596aac44e01eb7eb91428006
2020-05-07 18:09:06 +00:00
Ivan Lozano
6c4e5c05c3 Merge "Add gcov coverage support to Rust modules." 2020-05-07 17:56:43 +00:00
Paul Duffin
ee20962378 Detect invalid arch specific properties in snapshot
Previously, the snapshot code did not know whether a specific property
could be arch specific or not and assumed that they all were which
meant that it could generate snapshots containing arch specific values
for properties that are not arch specific and so would fail when
unpacked.

This change requires arch specific fields in SdkMemberProperties to be
tagged as such using `android:"arch_variant"` (just as in module input
property structures). Any property without that must have properties
that are common across all variants.

Bug: 155628860
Test: m nothing
Change-Id: Ifc8116e11d987cfe7aec2eeaa964f3bbf36b5dc2
2020-05-07 18:35:11 +01:00
Treehugger Robot
aa71638941 Merge "java_sdk_library: Define relationship between api scopes" 2020-05-07 09:37:54 +00:00
Paul Duffin
f022920bde Switch java_sdk_library to use SetDefaultableHook()
Previously, java_sdk_library used AddLoadHook() to register a hook that
when called would create its child modules. That meant the
java_sdk_library properties that were used to create the child modules,
e.g. sdk_version could not be defaulted because the modules are created
before the defaults are applied.

This change switches java_sdk_library to use the new
SetDefaultableHook() mechanism to register the hook instead of the
AddLoadHook() mechanism.

It also prevents the child modules from being created if the module has
been disabled.

Bug: 155295806
Test: m checkapi
Change-Id: Ic6f90eb4449338e549878f64e8119e286b9aa549
2020-05-07 10:24:00 +01:00
Paul Duffin
97b53b83e4 java_sdk_library: Define relationship between api scopes
Needed for follow up changes.

Test: m checkapi
Bug: 155164730
Change-Id: I163223caed38161ce1fa7b96dc3772194c32c3e2
2020-05-06 18:40:35 +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
Jooyung Han
98c4750f39 enforce sdk_version for JNI libs for updatable APKs
JNI libs for "updatable" APKs or APKs in "updatable" APEXes should set
sdk_version which is equal to or less than APK's min_sdk_version.

In fact, we'd better check if min_sdk_version of JNI libs matches(or is
earlier than) min_sdk_version of the APK. But for now the build system
can't handle sdk_version/min_sdk_version correctly for JNI libs. That's
why sdk_version of JNI libs is enforced to match with min_sdk_version
of APK in this change.

Bug: 145796956
Test: m
Change-Id: Iee7e09dd25bd139d84d50f6a77836b4068c78ea9
2020-05-06 13:54:34 +09:00
Ramy Medhat
a1ffd53fe4 Merge "Add support for the remote execution of metalava actions." 2020-05-05 21:53:26 +00:00
Chris Gross
7097b0580c Merge "Allow bootjars in system_ext." 2020-05-05 21:12:39 +00:00
Anton Hansson
a1910e8488 Merge "Disable "check last" for test api" 2020-05-05 15:42:53 +00:00