Commit graph

425 commits

Author SHA1 Message Date
Yu Liu
e916a2c758 Make container mandatory in aconfig_declarations.
Bug: 330354107
Test: Unit test and CI.

Ignore-AOSP-First: It is easier to detect all the missing ones in internal
master.

Change-Id: I4ab4271c67a35d0fdcc0b57c27260e29fb7dea56
2024-04-23 21:54:54 +00:00
Ronald Braunstein
cdc66f4268 Add "test-only" flag for java modules
As part of aosp/3022586 where we added the idea of "test-only" modules
and top_level_test_targets, this CL implements that for java modules.

We let users set "test-only" on java_library, but not on other modules
where the module kind is implicitly test-only, like java_test.
The implementation, not the user decides it is test-only.
We also exclude it from java_defaults.

	% gqui from  "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind, count(*) where teams.test_only = true and teams.kind not like "%cc_%" group by teams.kind'
	+--------------------------+----------+
	|        teams.kind        | count(*) |
	+--------------------------+----------+
	| android_test             |     1382 |
	| android_test_helper_app  |     1680 |
	| java_fuzz                |        5 |
	| java_test                |      774 |
	| java_test_helper_library |       29 |
	+--------------------------+----------+

	 % gqui from  "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind, count(*) where teams.top_level_target = true and teams.kind not like "%cc_%" group by teams.kind'
	+--------------+----------+
	|  teams.kind  | count(*) |
	+--------------+----------+
	| android_test |     1382 |
	| java_fuzz    |        5 |
	| java_test    |      774 |
	+--------------+----------+

Test: m nothing --no-skip-soong-tests
Test: go test ./java
Test: m all_teams

Bug: b/327280661
Change-Id: I9c3ad947dc3d68d6427abada27449526d69daa6b
2024-04-12 11:42:10 -07:00
Colin Cross
5e87f349b8 Strip relative paths from java_import output files
androidx.annotation_annotation is used as a test data file, and
converting it from a java_library to a java_library_import causes
the relative path used in the test data path to change. Clear the
relative path in java_import the same way that other java based
modules do.

Bug: 288358614
Test: TestJavaLibraryOutputFileRel
Change-Id: I1f494110da32e916043ca94ac6ebeeafccc06f9a
2024-04-11 16:51:21 -07:00
Colin Cross
dad2a361ef Revert^2 "Support static_libs for java_import modules"
c6c9c7354b

Change-Id: Id011aca133d7bb45023a63c0f53d84a4d694cc2f
2024-03-23 04:43:41 +00:00
Colin Cross
c6c9c7354b Revert "Support static_libs for java_import modules"
Revert submission 3008874

Reason for revert: b/330903911
Reverted changes: /q/submissionid:3008874

Change-Id: I34cca9d021d9c806e28bb6a6a6da78efd61cde27
2024-03-22 18:17:00 +00:00
Colin Cross
a174d2e987 Support static_libs for java_import modules
Remove the need to wrap java_import modules with a java_library
just to include static dependencies.

Bug: 288358614
Test: TestJavaImport
Change-Id: I888aecc6c0efc696a397fc1dd5d0ef5fd644bebc
2024-03-21 15:36:01 -07:00
Treehugger Robot
064b145365 Merge "Change java stem attribute for both device and host" into main 2024-03-20 01:05:50 +00:00
yangbill
2af0b6edd7 Change java stem attribute for both device and host
Bug: 329762127
Test: cd build/soong/java ; go test -run TestJavaLibHostWithStem
Test: cd build/soong/java ; go test -run TestAppStem
Test: cd build/soong/java ; go test -run TestAndroidAppImport_ArchVariants
Test: cd build/soong/java ; go test -run TestOverrideAndroidAppStem
Test: cd build/soong/java ; go test -run TestOverrideAndroidApp
Test: cd build/soong/java ; go test -run TestPackageNameOverride

Change-Id: I8fbdc82116f9a0c68121fbbeb1ef4f78f2b6fea3
2024-03-19 09:11:59 +00:00
Spandan Das
e4c911e6fc Support mechanism to select a specific version of module sdk prebuilt
This CL is the platform_compat_config equivalent of aosp/2928483.

{prebuilt_}_platform_compat_config are collated by
`global_compat_config` via a singleton. The collated data is then used
in some CTS tests. At ToT, we ensure that the collation ignores the
platform_compat_config of prebuilt when source is selected, and vice
versa.

With trunk stable, multiple versions of prebuilt apexes and prebuilt
platform compat configs might exist in the tree. This CL uses
`Source_module_name` to hide the platform compat configs of the
unselected prebuilt apexes.

Bug: 322175508

Test: Added a unit test
Change-Id: Iafdde8fc0458b37b3ccde25433070936f144915c
2024-03-16 01:41:12 +00:00
Jihoon Kang
5d701272e4 Enable non-"everything" stubs generation in java_api_library
This change adds support to generate non-"everything" (i.e. "runtime"
and "exportable") stubs in java_api_library, which generates the stubs
from the api signature files.

Unlike droidstubs module that generates "everything", "exportable" and
"runtime" stubs in a single module, java_api_library generates a single
set of stubs per module, which is set by the default-"everything"
property `stubs_type`. This is because java_api_library is responsible
for both generation and the compilation of the stubs srcjar, and
compilation of the stubs srcjar are done in separate java_library
modules for from-source stubs.

Utilization of this feature will be done in a follow up change that
generates the "exportable" java_api_library modules in java_sdk_library.

Test: m nothing --no-skip-soong-tests
Bug: 318009570
Change-Id: I1051544ac3bcdb3ba1f78bfec28eba4e9fad9c2d
2024-02-28 07:55:32 +00:00
Spandan Das
3cf0463a47 Support mechanism to select a specific version of module sdk prebuilt
This CL is the java_(test_)_import equivalent of aosp/2928483.

With trunk stable, we will have
multiple prebuilts of the prebuilt java .jars in
prebuilts/module_sdk/art/<v>/test-exports/, and this CL introduces a
mechanism to use apex_contributions to select a specific versioned
prebuilt when building.

Implementation details: Create a new source_module_name property to
identify the root module. rdeps referring to the root module will get
redirected if necessary. This property also
becomes the stem, if `stem` is not set explicitly.

Bug: 322175508

Test: Added a unit test
Change-Id: I2dff38acdf2002355586dbb2be8c1f98af4741f7
2024-01-30 01:59:51 +00:00
Treehugger Robot
ec3887ad2f Merge "Replace panic with ModuleErrorf" into main 2024-01-10 00:16:52 +00:00
Spandan Das
59a4a2b8d2 Replace panic with ModuleErrorf
This is a followup cleanup for aosp/2876754 and replaces panic with
ctx.ModuleErrorf. The latter creates a more expressive build error.

Implementation details
- export moduleErrorf interface from build/soong/android. This minimal
  interface will be used as a parameter for `DexJarBuildPath`
- Add ModuleErrorf to the function signature of DexJarBuildPath. This
  parameter only gets used for Import and SdkLibraryImport structs.
  These two can have duplicate deapexer definitions, and ModuleErrorf
  will be used to report that error
- Create a minimal implementation of `ModuleErrorf` in tests of java and
  apex

Test: m nothing --no-skip-soong-tests
Change-Id: I0febec651f40c3f04deb957e64133c94b80fbd78
2024-01-09 22:53:52 +00:00
Jihoon Kang
3c89f04777 Generate "exportable" stubs in droidstubs
This change generates rules for "exportable" stubs in the droidstubs
module.

Given that there are a lot of overlap between the currently existing
"everything" stubs rule and the newly introducing "exportable" stubs
rule, the currently existing metalava rule commands are modularized to
be utilized in the "exportable" stubs rule commands.

The currently existing build actions are modularized in the followings:
- commonMetalavaStubCmd(...): metalava commands that are required for
  generation of both "everything", "exportable", and potentially
  "runtime" stubs
- everythingOptionalCmd(...): metalava commands that are dependent on
  "everything" stubs and not dependent on flagged apis annotations, such
  as api lint, released api check

Based on this modularization, the "everything" stubs are now generated
in everythingStubCmd(...), which calls commonMetalavaStubCmd(...) and
everythingOptionalCmd(...).
Similarly, the "exportable" stubs are generated in
optionalStubCmd(stubsType=Exportable, ...), which calls
commonMetalavaStubCmd(...) and appends additional flags. Runtime stubs
can be generated similarly in the future with
optionalStubCmd(stubsType=Runtime, ...).

"everything"-related artifacts will now  be created in
`everything/` subdirectory, and "exportable"-related artifacts will be
created in `exportable/` subdirectory. For example, the outdir of a
droidstubs module "foo" would look like below:
```
foo
  |-- everything
  | |-- foo_api.txt
  | |-- foo-stubs.srcjar
  |
  |-- exportable
    |-- foo_api.txt
    |-- foo-stubs.srcjar
```

The module generates the build rules for the "exportable" stubs
regardless of whether the module defines the `aconfig_declarations`
property or not. All APIs marked with `@FlaggedApis` annotations are
stripped out for the "exportable" stubs when the `aconfig_declarations`
property is not defined. On the other hand, only the `@FlaggedApis` that
are specified in the aconfig_declarations module and are enabled will be
included (and all others are stripped) when the `aconfig_declarations`
propety is defined.

Test: go test ./java && BUILD_FROM_SOURCE_STUBS=true m
Bug: 315490657
Change-Id: I300273cd2a62fa978b046c0268e3a67c35e22b08
2024-01-08 07:56:07 +00:00
Cole Faust
30e32f67fc Merge changes I8b352305,Iadf9e324 into main
* changes:
  Sandbox CtsApkVerityTestDebugFiles
  Include "soong" in sandboxed out paths
2023-12-20 01:35:40 +00:00
Cole Faust
e8561c6108 Include "soong" in sandboxed out paths
Previously, the path to built files in the sandbox would be
out/.intermediates/... instead of out/soong/.intermediates/....

After this cl, it will be out/soong/.intermediates/.... This makes
it more consistent with the non-sandboxed paths, which is easier for
developers.

CtsApkVerityTestDebugFiles is a genrule that's used to find the paths
to other modules. Developers were expected to build it, then copy all
the files listed in its output file to a temporary directory. Those
paths would be wrong before this change.

Bug: 307824623
Test: ./build/soong/tests/genrule_sandbox_test.py CtsApkVerityTestDebugFiles
Change-Id: Iadf9e3240a2c828567e46b6b02cc14004f30e8bf
2023-12-19 12:14:01 -08:00
Spandan Das
2069c3f74d Move dexpreopt processing from java_*_import to prebuilt_apex
dexpreopt of apex system server from prebuilts involves three soong
modules
1. prebuilt_apex / apex_set
2. an internal deapexer module created by the prebuilt apex
3. java_import/java_sdk_library

(3) acts as a shim for the deapexer to set the dexjar extracted from the
prebuilt apex. This methodolody requires a 1:1 correspondence across the
three modules

This breaks down when we have multiple versions of the same prebuilt
apex in the tree. In preparation for this, move the dexpreopt
processing from (3) to (1). Each prebuilt_apex will create the necessary
rules for dexpreopting the jars deapexed from itself. In the future,
apex_contributions will be used to pick which service-foo.{odex|.vdex} to
install depending on which prebuilt apex is selected.

Implementation details
- Embed dexpreopter in prebuiltApex structs so that this module type can
  register the dexpreopt rules. Since a single apex can have multiple
  system server jars, this also requires creating an additional scope in
  dexpreopt.go to prevent name collisions
- Add the dexpreopt modules as required in initApexFilesForAndroidMk
- Add the depreopt modules to androidMk in AndroidMkEntries. Drop the
  equivalent from java_import and java_sdk_library_import

Bug: 308790457
Test: existing soong unit tests
Test: lunch cf_x86_64_phone-next-userdebug && m out/target/product/vsoc_x86_64/system/apex/com.google.android.adservices.apex
Test: Verified that the above command installs
/out/target/product/vsoc_x86_64/system/framework/oat/x86_64/apex@com.android.adservices@javalib@service-adservices.jar@classes.{odex|vdex} and the equivalent files of service-sdksandbox

Test: presubmits

Change-Id: I01cea8956d2857fb864b415e73d3d2686d069b5e
2023-12-18 23:17:26 +00:00
Colin Cross
5a37718c95 Convert ModuleProvder to generic providers API
Convert all of the callers of ModuleProvider/ModuleHasProvider to use the
type-safe android.SingletonModuleProvider API.

Bug: 316410648
Test: builds
Change-Id: I6f11638546b64749e451cebbf33140248dc1d193
2023-12-14 16:12:22 -08:00
Colin Cross
8ff105860d Remove ConvertWithBp2build implementations
Remove the ConvertWithBp2build implementations from all the module
types, along with the related code.

Bug: 315353489
Test: m blueprint_tests
Change-Id: I212672286686a318893bc7348ddd5a5ec51e77a7
2023-12-08 13:51:05 -08:00
Jihoon Kang
84b2589e6d Add aconfig flag support for android_app
This change adds an overrideable property flags_packages to android_app,
which is used to list the aconfig_declarations module names that the app
depends on. The build action of android_app is modified to pass all
flags text file provided by the aconfig_declarations to aapt2 link as
--feature-flags arguments.

Test: m nothing --no-skip-soong-tests
Bug: 306024510
Change-Id: I4924f88b9954950cc1936a472cd7ac70f41add5d
2023-12-07 23:01:26 +00:00
Colin Cross
f61d03d241 Add TestContext parameter to ContentFromFileRuleForTests
The next CL will need a TestContext parameter in
ContentFromFileRuleForTests in order to retrieve the file rule contents
from the Config.  Add it and update all the tests that use it in order
to simply review of the next CL.

Bug: 306029038
Test: go test ./...
Change-Id: Ia4b4c9854017ea3472fa2f8ba42cf7f72720496e
2023-12-03 17:22:56 -08:00
Cole Faust
9bef67488d Remove sdkPreSingleton and overlaySingleton
These were the only 2 pre-singletons in soong. sdkPreSingleton is
totally unused. overlaySingleton can be done during
GenerateAndroidBuildActions instead.

Test: m nothing --no-skip-soong-tests
Change-Id: Ieb5ab92f18cb56be4049c0842f61df8aa02dc52c
2023-11-01 15:29:09 -07:00
Jihoon Kang
1975d3e326 Disable from-text stub build for coverage build
Coverage builds depend on `native` properties for API elements, which
are not included in the API signature files and consequently in
from-text stubs. As no robust solution for handling this has been
planned out at the moment, from-text stub build is disabled for
coverage builds.

Per go/android-code-coverage-quickstart , Java code coverage is
enabled by the three environment variables: `EMMA_INSTRUMENT`,
`EMMA_INSTRUMENT_STAIC` and `EMMA_INSTRUMENT_FRAMEWORK`. This change
disables from-text stub build if any of the three variables are set
to true.

Test: go test ./java && m EMMA_INSTRUMENT=true EMMA_INSTRUMENT_FRAMEWORK=true nothing --build-from-text-stub and inspect ninja query to verify that the stub java library module depends on the from-source stub module
Bug: 304271961
Change-Id: Ie485c784145de6c253611e698354c4f9e4a30685
2023-10-17 20:00:12 +00:00
Jihoon Kang
063ec003f9 Add current api check as validation for from-text stub generation
Currently, there is no build action ensuring that the API text files are
up to date, unless a user runs `m checkapi` or `m update-api`. This
means that the user must run `m update-api` after making a change that
modifies api surface(s), so that the API text file reflects the local
change. This adds additional layer of action to developers, and it is
not guaranteed that the developer will always run `m update-api` after
making an api surface-affecting changes.

To prevent such mistake, this change adds droidstub-level api check as
validation for from-text stub generation. With this change, the build
will fail if the API text file is not up to date and the user must run
`m update-api` when making api surface-affecting local changes.

The validation is done by adding all droidstubs modules associated with
the java_api_contributions passed to java_api_library via
`api_contributions` as dependency and setting the current api timestamp
files as the validations for the from-text stubs generating build rule.

The full api surface libraries will not run the validations to avoid
circular dependency. However, all java_sdk_library generated
java_api_library modules will run validations, mapped to the droidstubs
in the same api domaion.

If the user sets the environment variable `DISABLE_STUB_VALIDATION=true`, validation
actions are not run. Validation actions run by default.

Test: m nothing --build-from-text-stub and run ninja query to verify `check_current_api.timestamp`s are listed as validation \
      DISABLE_STUB_VALIDATION=true m nothing --build-from-text-stub and run ninja query to verify that validation actions are not added
Bug: 288624417
Change-Id: I329e6438fe8f3ac30d8c6a971d57853ed6b0d150
2023-10-13 18:24:41 +00:00
Jihoon Kang
4ec24870e0 Introduce system_modules property to java_api_library
System_modules property provides the jars passed as bootclasspath when
compiling the stubs in the java_api_library where its creating
java_sdk_library's sdk_version is none, as the jars will not be provided
from the full_surface_stub_libs but compiled by itself in the child
change.

The jar provided by the system_modules will also be passed to metalava
to resolve hierarchy coming from outer dependencies.

Test: m --build-from-text-stub
Bug: 288624417
Change-Id: I8f3b89efa24bceb070d7a37fae3c7334dd7f0868
2023-10-09 17:44:54 +00:00
Anton Hansson
0e73f9ee6d Collect transitive source files for java modules
This new entry in the JavaInfoProvider lists all the transitive source
files contained within the library. That is, the source files of the
module and all its static dependencies.

Bug: 151360309
Test: unit test in java_go + some manual testing
Change-Id: I7fe3035b9e46774095c0e9196cd77fa1027adf6d
2023-09-28 13:20:49 +00:00
Jihoon Kang
a96a7b1e13 Remove naming conventioned based file sorting in java_api_library
With api_files property being removed from java_api_library, all api
files are passed to java_api_library via java_api_contribution, which
provide api_surface information. Instead of relying on the naming
convention of the api files, java_api_library can utilize this
information to sort the api files from narrower api scope to the wider
api scope.

Test: m --build-from-text-stub
Bug: 295429988
Change-Id: Idd832778833c072c6b7e9d1f775533e5f4e2af00
2023-09-22 16:55:43 +00:00
Jihoon Kang
6be0f00671 Remove api_files property from java_api_library
java_api_contribution provides api_surface information, but files
directly passed to java_api_library do not possess such information.
Currently, the api surface is assumed via naming convention for api
files passed via api_files property, but this is fragile.

This change removes the api_files property from java_api_library and
enforce all api files to be passed via java_api_contribution

Test: m nothing --build-from-text-stub
Bug: 300964421
Change-Id: If01d9ed978fe469d4ee0d685582a51629ebecc56
2023-09-21 21:02:39 +00:00
Jihoon Kang
8fe1982e8b Sort api files by api surface in java_api_library
metalava requires api files to be sorted in the narrower api scope to
the wider api scope when passed as inputs. Previously, the api files
were sorted based on the naming convention, but some api files in
prebuilts do not necessarily follow the naming convention (i.e.
*-current.txt). Therefore, utilize the api surface information provided
by the java_api_contribution provider instead of the naming convention
to sort the api files.

Test: m nothing
Bug: 300175323
Change-Id: I8466db712bff8fef906186bd272d85682877533d
2023-09-18 19:33:01 +00:00
Jihoon Kang
fdf323697e Add java_api_contribution_import module type
java_api_contribution_import is a prebuilt module type of
java_api_contribution. It's build actions are identical to those of
java_api_contribution.

Test: m nothing
Bug: 300174357
Change-Id: I831806990b37b340af21858eb2bab5de62fdf7a9
2023-09-15 22:52:52 +00:00
Mark White
a15790ac1e java_library support for building headers-only
Flag for java_library modules to build just the Turbine headers and
skip building an impl jar.

Test: go test java
Bug: 289776578
Change-Id: Iad0babf951710476bc32df93c25d17065a14ab84
2023-08-22 21:29:05 +00:00
Jihoon Kang
84473f55d7 Sort api files by api scope in java_api_library
Recent changes in metalava (aosp/2704325) enforces api files passed as
inputs to generate stubs from txt to be sorted in the order from the
narrower api scope to the wider api scope. In order to comply with this
change, all api files passed as inputs to metalava invocations need to
be sorted in the respective order.

Test: m out/soong/.intermediates/packages/modules/IPsec/tests/cts/CtsIkeTestCases/android_common/e10894d3da5db41239526c9048962355/javac/CtsIkeTestCases.jar --build-from-text-stub --skip-soong-tests (Failing module from incorrect class hierarchy when building from text stub)
Bug: 295429988
Change-Id: I1eb1f4bf8fa34fd7dc8a0e4c04aa056258a975c5
2023-08-11 22:58:54 +00:00
Jihoon Kang
1bfb6f231e Fix stem to be propagated to output jar name in java_library
Currently, java_library.stem property is not correctly reflected in the
output jar name in java_library when the module specifies
java_resource_dirs property. This change fixes the unexpected behavior
so that setting the stem property behaves as expected.

Test: go test ./java && m
Bug: 285843207
Change-Id: I0941fcea83c92f4c42ae415aa6ad9125da5cf57b
2023-07-14 21:41:46 +00:00
Jihoon Kang
ca198c2639 Extract class files from dep_api_srcs instead of java files
Currently, stub java files are extracted from srcjar file provided from
dep_api_srcs in java_api_library module generated in java_sdk_library
per api scope. However, compiling the java files may lead to difference
in the content of the generated class files even if the stub java files
are equivalent, as javac may arbitrarily add overridden methods. Thus,
create a stub jar file instead of creating a stub srcjar file and
compiling it, in order to guarantee stub jar files content equivalence
and thus enable hiddenapi during from-text stub build.

Note that this change does not fully resolve differences between the
full api surface csv and the per sdk_library csv. Instead, it removes
the difference caused by methods arbitrarily added by javac.

This change also renames dep_api_srcs to full_api_surface_stubs to be
more intuitive.

Test: rebase on top of aosp/2617274 and `m --build-from-text-stub`
Bug: 275570206
Change-Id: I22b6d56624633681f5c3b000370b5782655c7b8d
2023-06-29 22:43:05 +00:00
Jihoon Kang
381c2fa27c Introduce "Exclude_static_libs" property for Java modules
Exclude_static_libs property can be used to specify static libs that
should not be used to build the module. The list acts as filter for
static_libs.

Bug: 285410821
Test: go test ./java
Change-Id: Iee7f160ba88b5f64bdd265c30d47c9f51feb0f5e
2023-06-05 21:42:48 +00:00
Dan Shi
ec7314336a Support test runnner option in auto generated test configs
Bug: 284179405
Bug: 236980335
Test: unittest
Change-Id: Ifae3d556ff79153ca6c3067347fc259b665fb2e1
2023-05-26 21:34:22 +00:00
Jihoon Kang
795319fadb Disallow missing api source files for java_api_library module
The purpose of this change is to enable filegroups to be taken as inputs
for `java_api_library` module `api_files` property. However, since
android.MaybeExistentPathForSource() does not support this, it needs to
be replaced with android.PathForModuleSrc(), which checks for the files'
existence.

Bug: 283006953
Test: go test ./java
Change-Id: I8a7d7f200f900219cc17243194a4c26071329ee6
2023-05-17 01:02:19 +00:00
Jiakai Zhang
b95998be73 Prepare tests for dexpreopt changes.
After this change, there is a clear separation between tests that are
related to dexpreopt and tests that are not. The former uses
PrepareForTestWithDexpreopt, while the latter uses
PrepareForTestWithJavaDefaultModules. The benefit is that the latter
will no longer affected by any dexpreopt changes.

Bug: 280776428
Test: m nothing
Change-Id: Ib957765b9287d51c082e0a33cee17a6bb56daeef
2023-05-11 18:24:44 +01:00
Jihoon Kang
01e522cac5 Add dep_api_srcs property to java_api_library module
Users can pass the jar-file creating module via dep_api_srcs property in
java_api_library to create the jar file not by compiling the stubs
generated from metalava but by extracting and zipping the class files
from the jar file of the input module.

Test: m android-non-updatable.stubs.from-text
Bug: 273381329
Change-Id: Id1b75179111cc7ff45faaff58388db1347bb18e5
2023-04-03 17:53:40 +00:00
Wei Li
598f92d704 Export Soong module type to LOCAL_SOONG_MODULE_TYPE to Make for SBOM generation.
Bug: 266726655
Test: CI

Change-Id: If5b1a77930a591b6061ca2749c9c5ad29b4491fb
2023-03-06 22:51:03 +00:00
Jihoon Kang
25857f5f42 Rename output stubs jar file in java_api_library
When generating framework.aidl, `android_*_stubs_current` are converted
to .aidl files (and created as targets) by replacing the extension from
`.jar` to `.aidl`.
Thus, when replacing `android_*_stubs_current` to java_api_library
modules, generating `android.jar` files leads to ninja error(multiple
rules for generating */android.aidl error).
Prevent this error by renaming the name of the artifact jar file as the
module name so that distinct-named ninja targets can be created.

Test: m
Change-Id: Iaa7248996d7bf5e7f98e1d1e2919870c3cccf5a6
2023-03-01 01:11:18 +00:00
Jihoon Kang
e30fff0b5c Add static_libs property in java_api_library soong module
Package private stub annotations are not part of any API surfaces, but
are included in the `android_<API_SURFACE_NAME>_stubs_current`. Since
these cannot be included in the java_api_library by api_contributions,
add static_libs property to statically include jars in the output jar
file.

Test: m
Change-Id: Icb4401f29079ba32df4c192943a7e8814599d9ba
2023-02-15 00:27:18 +00:00
Cole Faust
5c503d1c43 Precompile python sources
This signifigantly improves the startup time of soong-built
python binaries. For example, running
`m apexer && time out/host/linux-x86/bin/apexer` gives
0.734s before this cl, and 0.094s after.

Fixes: 259718110
Test: Presubmits
Change-Id: Ib19e83e2c60c39a849525be117279c318de3afa7
2023-01-27 15:43:38 -08:00
Jihoon Kang
3198f3cb52 Generate java_api_contribution module from droidstubs module
Context
- droidstubs module are either generated from the java_sdk_library
  module or defined in the bp files.
- Since droidstubs module contains API text file property,
  java_api_contribution module can by dynamically created from
  droidstubs.

Implementation
- Add `api_surface` property in droidstubs module. This property is
  either inherited from the java_sdk_library or written in the module
  definition in the bp file.
- Add defaultable hook in droidstubs module to generate the child
  java_api_contribution module.

Test: m
Change-Id: Ica43d65614723c623cd0c155266f9844e69e5d5e
2023-01-26 18:44:25 +00:00
Jihoon Kang
362aa9db12 Add libs property to java_api_library module
Module Lib API surface takes modules that are not part of the API
surface as classpath during compilation of the JAR file. Thus, add libs
property to add deps in bp module definition.

Test: m
Change-Id: I8967d53430fa4cc8e4aa431770ba4e97893f8c61
2023-01-24 00:44:22 +00:00
Jihoon Kang
1c51f50120 Add java_api_library properties to java_defaults
Context
- Some Java API surfaces have subset relationships (i.e. public API
  surface is a subset of system API surface). Thus, simply listing
  all API files that contributes to hierarchical API surfaces when
  defining java_api_library modules can lead to repetition of code in
  Android.bp files.
- Utilizing java_defaults can resolve this problem by
  grouping java_api_contribution modules by API surfaces, and reduce
  code repetition and enhance readability.

Implementation
- Modify java_api_library module to utilize java_defaults modules.

Test: m
Change-Id: I6adead208ca36c21de72ee39c4f532b84af8a153
2023-01-10 22:34:31 +00:00
Cole Faust
216805457c Allow adding extra tradefed options in the Android.bp file
Some tests need to add custom tradefed options, but still want to
keep most of the soong autogenerated tradefed xml file.

Expose a test_options: { tradefed_options: [...] } property that
will allow tests to add more options to the autogenerated xml file.

Fixes: 184895128
Test: go test, and verified that the ninja files did not change for aosp_arm64
Change-Id: I50d4ad139322e9e207202f1e1a50f5bbb424aa6f
2023-01-03 12:47:11 -08:00
Tahsin Loqman
77dc7d0839 Revert "Allow adding extra tradefed options in the Android.bp file"
This reverts commit 8ec823cba1.

Reason for revert: DroidMonitor: Potential culprit for Bug b/262965953 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.

Change-Id: I236cc36981d8b30527ca286632727f8ca267e969
2022-12-19 16:27:25 +00:00
Cole Faust
8ec823cba1 Allow adding extra tradefed options in the Android.bp file
Some tests need to add custom tradefed options, but still want to
keep most of the soong autogenerated tradefed xml file.

Expose a test_options: { tradefed_options: [...] } property that
will allow tests to add more options to the autogenerated xml file.

Fixes: 184895128
Test: go test, and verified that the ninja files did not change for aosp_arm64
Change-Id: I75f7eb002c8325ce7cdc76e12e76e16195320620
2022-12-09 15:23:26 -08:00
Spandan Das
c082eb8eac Add an api_files property in java_api_library
java_api_contribution is useful to java_api_library when the api files
are not colocated.

If they are colocated (e.g. in Multi-tree assembled api_surfaces
directory), it is useful to refer to them directly without nedding to
create a java_api_contribution module.

Test: In build/soong, go test ./java
Change-Id: I5b4e557068a1e5c71a80c76452030e72ec83a696
2022-12-05 22:27:06 +00:00