Commit graph

46 commits

Author SHA1 Message Date
Rico Wind
a9fd59a7f2 Revert "Use R8 for resource shrinking"
Revert submission 2816534-r8resourceshrinking

Reason for revert: b/309075997

Reverted changes: /q/submissionid:2816534-r8resourceshrinking

Change-Id: Ic173491eaf22967fbad14fbcc85f6ddb2cf54d23
2023-11-03 10:26:38 +00:00
Rico Wind
b56fe2825d Use R8 for resource shrinking
We are moving the resource shinking pipeline into r8 (gennerally, not just for platform)

This disables the usage of the resource shrinker cli from cmd-line tools

Bug: 308710394

Test: Existing, validated that resource table on SystemUI was byte<>byte equal.
Change-Id: Ia36b5e5970cbdcff519a5f05d672b44dc145ea32
2023-11-02 20:35:20 +01:00
Colin Cross
02bccdf37c Add test for manifest merger
Add a test for the manifest merger command line that would have prevented
b/291252863.

Bug: 291252863
Test: TestManifestMerger
Change-Id: I8c025efe7ccb06ad97b405e2927a4df07f9d3f27
2023-07-14 11:24:54 -07:00
Joe Onorato
175073c472 Make aconfig flags generate a library instead of a srcjar.
Also add unit tests for the rest of device_config

Bug: 283475679
Test: m nothing (soong unit tests)
Change-Id: Iee18a1f2f2cbb23e8c8d84c54e903b32be29a693
2023-06-09 06:16:06 -07: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
Treehugger Robot
cdea74d96c Merge "Support testing for resource shrinking" 2022-12-01 06:09:29 +00:00
Jihoon Kang
5cb82e36be Add java/fuzz_test.go to test sources
Context
- fuzz_test.go is not listed in the soong/java test sources and is not
  running on CI.

Implementation
- Fix fuzz_test.go and add to test sources

Test: m
Change-Id: If2685c646dec4885fc42d7760992309bfa9da382
2022-11-17 21:46:48 +00:00
Paul Duffin
8eb4573b23 Test bootImageConfig/Variant fields
Most of the fields in the bootImageConfig/Variant structs are assigned
inside a Once func so are guaranteed to be only set once. However, some
are assigned outside. This change adds comprehensive tests for those
structs and verifies that the constant fields are preserved and the
mutated fields have the correct value.

The check for the constant fields is added in a new TestBootImageConfig
test.

The check for the mutated fields is added into
TestSnapshotWithBootclasspathFragment_ImageName as that test checks an
art bootclasspath_fragment in the following configurations:
* source on its own
* prebuilt on its own
* source and prebuilt with source preferred
* source and prebuilt with prebuilt

It reveals a couple of interesting facts:
* All the *installs fields are set to the same value irrespective of
  whether the source or prebuilt is preferred. The information is
  constructed solely from information already within the
  bootImageConfig/Variant and so can be moved within Once.

* The licenseMetadataFile is incorrect when prebuilt is preferred.
  That is due to both the source and prebuilt modules setting it and
  the source module always wins as the source module depends on the
  prebuilt so always runs its GenerateAndroidBuildActions after it.

Those issues will be cleaned up in following changes.

Bug: 245956352
Test: m nothing
Change-Id: If917cfbcb3b1c842a8682d51cc1ee1fed1c51add
2022-10-06 11:06:51 +01:00
Jared Duke
51b0a10229 Support testing for resource shrinking
Add a simple test and add necessary mock dependencies to allow future
resoure shrinking use with platform targets.

Test: m
Bug: 202959019
Change-Id: Id2dd44d52ce5ea62c06784caab0af6276248cb3f
2022-09-28 09:46:35 -07:00
Rico Wind
351bac996c Add soong support for resource shrinking
This adds a new flag to the optimize section to allow invoking the resource shrinker

Bug: 246217952
Test: m
Change-Id: I2e7851af1189db2a6adf6f9f9f444a1d7f3a8d60
2022-09-23 19:11:11 +02:00
Sam Delmerico
82602492fc copy JNI from AAR files to android_app APK
JNI libs present in AAR files are ignored in the build. If those
libraries are necessary, they must be manually extracted and a
prebuilt_cc_library module must be created for them. Instead, we can
extract these libraries and copy them to an output APK as part of the build.

Bug: 228848794
Test: created android_app that depends on an android_library_import with
  JNI embedded, and verified that .so libs are present in APK
Test: created android_app that depends on an android_library which
  depends on android_library_import with JNI embedded, and verified
  that .so libs are present in APK
Test: verified that multiple .so's from a single architecture are copied
  to APK
Test: verified that the absence of a jni/<arch> folder or files in the
  folder will cause the Ninja action to error
Change-Id: I242a862d7bd881f7a4a8c23493924d8fe441ea25
2022-08-02 16:12:06 -04:00
Sam Delmerico
974c6229e2 add missing java/*_test.go files
fuzz_test.go is not included for now because there is a fix in progress
to make tests pass again.

Test: go test ./java
Change-Id: Idd44fb95c1dda728659ebfc58381252ab49c8230
2022-05-31 18:07:03 +00:00
Wei Li
340ee8e699 Export provenance metadata for prebuilt APKs and APEXes.
Bug: 217434690
Test: atest --host gen_provenance_metadata_test
Test: m provenance_metadata

Change-Id: I91c184b6e6fe5ccfc3fc65b55b09e7a3da9502a0
2022-04-05 16:16:16 -07:00
Colin Cross
9bb9bfb349 Don't pass static libs to r8
r8 gets the static libs in the program jar, it shouldn't also get
them as library jars.  Keep a separate classpath for dexing that
includes libs but not static_libs.

Bug: 222468116
Test: m checkbuild
Test: TestD8
Test: TestR8
Change-Id: Icca3393f496cbcadcc633f3b156761e6c145f975
2022-03-18 20:48:27 +00:00
Muhammad Haseeb Ahmad
aa1d0cf775 Add java_fuzz module to build java fuzzers
This change adds a new module to soong to be able to build Java fuzz
targets be able to run using Jazzer. Jazzer is an open source fuzzing engine
supported by OSS-Fuzz.

Bug: 211671266
Test: go test -run TestJavaFuzz
Change-Id: Id7c346694f5986f6e15210c359fd533fbb7001eb
2022-01-06 02:17:34 +00:00
Paul Duffin
6d448b7a0a Add test for prebuilt_apis creation of system modules
Previously, there were no tests for this (outside uses in other tests).
This change adds a test that uses the fixture preparers that create a
prebuilt_api in order to make prebuilt APIs available. That ensures
that both the prebuilt_api is working as expected and the preparer
creates a realistic test environment.

Bug: 204189791
Test: m nothing
Change-Id: I57352aa00f7b268e5286be92f177764dd63ba7e8
2021-11-01 16:36:02 +00:00
Jiakai Zhang
0a0a2fbea9 Add a build-time check for dexpreopting system server jars.
This change adds a Soong module that stores the paths to the compilation
artifacts of system server jars in a variable, which will then be
consumed by Make to check if the artifacts are installed. When the check
fails, it means that dexpreopting is not working for some system server
jars and needs to be fixed.

Bug: 201371822
Test: m nothing
Test: manual -
  1. Add "service-permission" to DEXPREOPT_DISABLED_MODULES (https://cs.android.com/android/platform/superproject/+/master:build/make/core/product_config.mk?q=DEXPREOPT_DISABLED_MODULES)
  2. m nothing
  3. See the error:
    Missing compilation artifacts. Dexpreopting is not working for some system server jars
    Offending entries:
    system/framework/oat/x86_64/apex@com.android.permission@javalib@service-permission.jar@classes.odex
    system/framework/oat/x86_64/apex@com.android.permission@javalib@service-permission.jar@classes.vdex
Change-Id: I4816f19668f1dae180a34adafdbfa448c97aa0db
2021-10-29 11:55:20 +00:00
Rupert Shuttleworth
5c4881c8ec Add initial bp2build support for converting android_app_certificate modules.
Test: Added unit test.

Change-Id: Ib5bf1711eca5be772e1bed73663dcb86252e0b4a
2021-07-28 06:51:07 -04:00
Paul Duffin
9fc208ee54 Add sdk_library_test.go to Android.bp file
When this file was initially created by extracting the test from the
java_test.go file it was not added to Android.bp file so was not being
built and tested as it should. That lead to a recent change that left
it unable to compile. This change corrects both those issues.

Bug: 186723288
Bug: 179354495
Test: m nothing
Change-Id: I06f32bb572f57b6df3c772f1d9d21fe323fbf353
2021-06-27 20:42:48 +01:00
Paul Duffin
e245b61aa2 Add ClasspathElement support
The configuration of the bootclasspath, e.g. PRODUCT_BOOT_JARS,
includes libraries that are standalone and libraries that are part of
an APEX. All libraries that are part of an APEX must also be part of a
bootclasspath_fragment. Currently, the libraries and fragments are
handled separately but that is limiting as it does not make it easy to
process all the libraries while treating those from fragments
differently to standalone libraries. That is needed for hidden API
processing as it needs to use classesJars from standalone libraries
but pre-generated flag files from fragments.

This change adds support for ClasspathElements which is represents the
classpath as a whole while differentiating between standalone libraries
and fragments.

Bug: 177892522
Test: m nothing
Change-Id: I7a4adc67164a46079eb8ec0a17fc755044b4949d
2021-06-18 11:46:52 +01:00
Paul Duffin
438eb57a27 Separate monolithic hidden API processing from hiddenAPIFlagFileInfo
The hiddenAPIFlagFileInfo was being used for both the input and output
of bootclasspath_fragment and platform_bootclasspath and also to pass
information around to various hidden API rule methods. Supporting
multiple different uses in this way made it hard to reason about.

This change creates a separate structure for use by the
platform_bootclasspath. Follow up changes will split out other
functionality into separate types.

Bug: 179354495
Test: m com.android.art com.android.ipsec com.android.os.statsd com.android.conscrypt
      - verify that this does not change the contents of the apex files
Change-Id: Ia5c5f65ae5645486c42819c669a8601588217f88
2021-05-24 13:32:55 +01:00
satayev
95e9c5bbfa Split SYSTEMSERVERCLASSPATH entries from platform_bootclasspath.
Boot jars are different to system server jars at build level, due to
added complexity of dexpreopt. As a logical separation add a new
classpath fragment type and split existing classpaths.proto generation
into relevant pieces.

Bug: 180105615
Test: m && launch_cvd; atest CtsClasspathsTestCases
Change-Id: I88bec09fc920166ffd0092faef980754ddeb6593
2021-05-07 13:24:16 +01:00
Paul Duffin
7771eba88e Rename BootImageModule to BootclasspathFragmentModule
Also renames files, tests, module types in a similar fashion.

There are still some references to image and boot image. They are kept
for the following reasons:
* image_name - this is the name of an ART boot image, i.e. the
  collection of .art/.oat/.vdex files.
* BootImageInfo - again this is related to the ART boot image.
* .../art_boot_images/... paths - ditto.

Bug: 177892522
Test: m nothing
Change-Id: Ie1f4738061d131fee75de48bc26a7601481bad4d
2021-04-23 16:59:26 +01:00
Paul Duffin
b67d878b80 Extract general bootclasspath related code into java/bootclasspath.go
The platform_bootclasspath and bootclasspath_fragment modules provide
different capabilities but are related and so have some common
functionality. This change moves some platform_bootclasspath code that
will be of use for bootclasspath_fragment in future into a separate
file.

Bug: 177892522
Test: m nothing
Change-Id: I827b85e33d16155fcc920d553100c9e99267dc4e
2021-04-23 09:32:14 +01:00
Jaewoong Jung
d6599f5573 Merge changes Ia74a2b83,I30a46c8f,Iac7c0149
* changes:
  Add lint.strict_updatability_linting
  Move Java lint tests to lint_test.go
  Forbid bypassing updatability lint checks.
2021-04-22 15:39:41 +00:00
Jaewoong Jung
79e6f6bfcc Forbid bypassing updatability lint checks.
Test: lint_test.go
Bug: 182349282
Change-Id: Iac7c01493b449c2ddd6df6c68f8a74dfe72dfd7a
2021-04-21 16:56:19 -07:00
Rupert Shuttleworth
b7e30760af Add various test files as testSrcs, so that they run on CI.
Test: go test
Test: TH (now that these are hooked up to TH)

Change-Id: Ia199794ef1a64074f3f9159f8c160ba3e45fd181
2021-04-21 11:23:57 -04:00
Artur Satayev
eabf2c175f Introduce classpath_fragment.go.
A skeleton of a classpath fragment's interface and base to be used by
any modules that provide entries for *CLASSPATH variables at runtime.

In follow up changes, this would be extended to generate
packages/modules/SdkExtensions/proto/classpaths.proto configs for such
modules to be bundled into system and individual apex binaries.

Bug: 180105615
Test: m
Change-Id: I2df550862e97222c5650c4d0480c90231fd78ef0
2021-04-13 08:58:18 +01:00
Paul Duffin
c6bb7cf8d7 Extract ruleToGenerateHiddenApiFlags
Extracts the code for creating the rule that creates the monolithic
hidden API flags file which is encoded into dex implementation jars.
This refactoring is in preparation for moving the functionality from
the hiddenapi_singleton into the platform_bootclasspath.

A follow up change will move the method into the new
hiddenapi_modular.go alongside the hiddenAPIAugmentationInfo as they
will both be used to perform hidden API processing for a
bootclasspath_fragment.

Bug: 177892522
Test: verified that the out/soong/hiddenapi/... files are unchanged
      by this change
Change-Id: I2729afa80cdfd2d1d4717365001648453d65632f
2021-04-12 11:04:09 +01:00
Paul Duffin
bb7f1ac794 Add a new platform_bootclasspath module type
Initially, this is just a placeholder but functionality will be added
in follow up changes.

Bug: 177892522
Test: m nothing
Change-Id: I890b0d5a117c51a19c9ac5df98c766761d3aa16c
2021-03-31 22:44:34 +01:00
Colin Cross
2207f87756 Split droidstubs out of droiddoc.go
Split part of droiddoc.go into droidstubs.go.  Also split droiddoc_test.go
and droidstubs_test.go out of java_test.go.

Test: go test ./java
Change-Id: Iea742e75b6925b135016f7bbf3a168c696a6c433
2021-03-25 11:11:34 -07:00
Jaewoong Jung
2406d689bf Merge "Take Module implementations out of java/java.go." 2021-03-20 15:29:32 +00:00
Jaewoong Jung
263426431a Take Module implementations out of java/java.go.
Test: TreeHugger
Change-Id: I5c39915ad2cadf5981c201a2b412916524d4c3e2
2021-03-19 15:46:38 -07:00
Paul Duffin
29072a9c1e Separate metadata provider from apex contents provider
The platform_compat_config_singleton only needs access to the metadata
so this separates that method into its own interface, distinct from the
one needed by the apex. This also adds a test to ensure that the merging
still works.

Bug: 182402754
Test: m nothing
Change-Id: I5212239786810e5fc5eb99831b1122db93d1329f
2021-03-17 18:16:28 +00:00
Paul Duffin
db284be913 Separate system modules tests into their own file
java_test.go is getting too big.

Bug: 182402568
Test: m nothing
Change-Id: I9c3818f1d747a230fcb66687319a3a14d557a57c
2021-03-11 08:21:49 +00:00
Colin Cross
75ce9eccf3 Remove global state from sysprop libraries
Sysprop libraries use a global list to rewrite dependencies from
implementation libraries to public stub libraries when appropriate.
Remove the global list, and instead add a dependency from the
implementation to the public stub that forwards the JavaInfo.

Bug: 181367697
Test: sysprop_test.go
Change-Id: Ia7995feb3c079ca9bb6a403daaae3e3329fd7f6a
2021-02-26 16:28:12 -08:00
Bob Badour
02040de891 Add LOCAL_LICENSE_KINDS to build/soong
Added SPDX-license-identifier-Apache-2.0 to:
  Android.bp
  android/Android.bp
  android/soongconfig/Android.bp
  androidmk/Android.bp
  apex/Android.bp
  bazel/Android.bp
  bp2build/Android.bp
  bpf/Android.bp
  bpfix/Android.bp
  cc/Android.bp
  cc/config/Android.bp
  cc/libbuildversion/Android.bp
  cc/libbuildversion/tests/Android.bp
  cc/ndk_api_coverage_parser/Android.bp
  cc/ndkstubgen/Android.bp
  cc/symbolfile/Android.bp
  cmd/dep_fixer/Android.bp
  cmd/diff_target_files/Android.bp
  cmd/extract_apks/Android.bp
  cmd/extract_jar_packages/Android.bp
  cmd/extract_linker/Android.bp
  cmd/fileslist/Android.bp
  cmd/host_bionic_inject/Android.bp
  cmd/javac_wrapper/Android.bp
  cmd/merge_zips/Android.bp
  cmd/multiproduct_kati/Android.bp
  cmd/path_interposer/Android.bp
  cmd/pom2bp/Android.bp
  cmd/pom2mk/Android.bp
  cmd/sbox/Android.bp
  cmd/soong_build/Android.bp
  cmd/soong_env/Android.bp
  cmd/soong_ui/Android.bp
  cmd/zip2zip/Android.bp
  cmd/zipsync/Android.bp
  cuj/Android.bp
  dexpreopt/Android.bp
  dexpreopt/dexpreopt_gen/Android.bp
  env/Android.bp
  etc/Android.bp
  filesystem/Android.bp
  finder/Android.bp
  finder/cmd/Android.bp
  genrule/Android.bp
  jar/Android.bp
  java/Android.bp
  java/config/Android.bp
  kernel/Android.bp
  linkerconfig/Android.bp
  linkerconfig/proto/Android.bp
  makedeps/Android.bp
  partner/Android.bp
  phony/Android.bp
  python/Android.bp
  python/tests/Android.bp
  remoteexec/Android.bp
  rust/Android.bp
  rust/config/Android.bp
  scripts/Android.bp
  sdk/Android.bp
  sh/Android.bp
  shared/Android.bp
  symbol_inject/Android.bp
  symbol_inject/cmd/Android.bp
  sysprop/Android.bp
  tradefed/Android.bp
  ui/build/Android.bp
  ui/logger/Android.bp
  ui/metrics/Android.bp
  ui/metrics/proc/Android.bp
  ui/status/Android.bp
  ui/terminal/Android.bp
  ui/tracer/Android.bp
  xml/Android.bp
  zip/Android.bp
  zip/cmd/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD to:
  finder/fs/Android.bp
  third_party/zip/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work

Change-Id: Ia47ca14f16b8c9f84f9d533a07e5b00e2c04e8d4
2021-02-06 04:23:21 +00:00
Paul Duffin
3451e1600f Add boot_image module type
Adds a boot_image module type. Follow on changes will add instances of
boot_image to represent the ART and framework boot images in the art
and frameworks/base repositories respectively.

For the moment they retrieve their associated boot image configuration
from the map returned by genBootImageConfigs() and leave the actual
work of creating the ninja rules to create the boot images to the
dex_bootjars singleton.

Bug: 177892522
Test: m droid
Change-Id: Ib69701de0d24d996bb8e8be7a20b941be907390e
2021-01-26 13:00:07 +00:00
Jaewoong Jung
f9b44657c8 Break up app.go.
Test: m nothing + TreeHugger
Change-Id: I64c6d7f10530c424bc282d8111dfaf9159426f00
2020-12-21 12:31:51 -08:00
JaeMan Park
ff71556a53 Add java sdk library enforcement flag
Add java sdk library enforcement for inter-partition library
dependency, for ensuring backward-compatible libraries for
inter-partition dependencies.

Test: m nothing
Bug: 168180538
Change-Id: I6bfac54c3499b03003a3bc6c2bb62b165b4ce5f9
2020-11-24 17:56:15 +09:00
Paul Duffin
9a89a2a0ea Move boot jars package check from make
Adds a singleton that traverses the module variants finding the ones
that are in the list (updatable and non-updatable) of boot jars and
add a ninja rule to ensure that they only contain packages from an
allowed list.

Replaces a hack that ignored any prebuilt boot jars supplied as dex
file with an equivalent one to ensure that they are still ignored.
A follow up change that switches to checking dex jars will allow the
hack to be removed.

The boot jars check can be strict or lax. If strict then all the boot
jars listed in the configuration must be found, otherwise it will only
check the ones it finds. It is strict by default unless
TARGET_BUILD_UNBUNDLED=true or ALLOW_MISSING_DEPENDENCIES=true.

Moves the script and data file from build/make.

Test: m check-boot-jars - for failing and passing cases
      SKIP_BOOT_JARS_CHECK=true - no check-boot-jars target created
	  ALLOW_MISSING_DEPENDENCIES=true - not strict
	  TARGET_BUILD_UNBUNDLED=true - not strict
      verified manually that apart from path differences the same
      files (same check sum) were checked in both old make checks and
      the new Soong ones
      EMMA_INSTRUMENT=true EMMA_INSTRUMENT_FRAMEWORK=true m check-boot-jars
Bug: 171479578
Change-Id: I9d81d6650ba64fc0d48d2dab4ba5a3ba8dd03dec
2020-10-29 17:20:06 +00:00
Liz Kammer
5ca3a6293e Add hidden_api for java_import
Test: go java tests
Test: m
Bug: 160455085
Change-Id: Ib6e826e32ca73ceea0799b26145ad06b1e62a1bf
2020-09-10 07:56:03 -07:00
Liz Kammer
dd849a81f3 Add data_native_bins property to java_test_host
When multiple os/arch variants are supported, java_test_host could not
find a matching arch due to java having arch:common, whereas native
binaries support a specific architecture. This change adds the property
`data_native_bins` in order to support binaries with the appropriate
os/arch variants.

Test: m FirmwareDtboVerification with data_native_bins
Test: forrest
Bug: 153848038
Change-Id: I45adebff0fde2811d5ef5620c697b97b768c951f
2020-07-27 09:14:06 -07:00
Pete Gillin
84c3807b99 Enforce the legacy core/platform API restriction.
This change silently decides whether modules which depend on either
sdkPrivate or sdkCorePlatform get the legacy or the stable version of
the core/platform API, based on whether the module's name is on a
hard-coded list or not.

Test: m java
Test: make a target from the list when its entry is commented out, which correctly fails
Bug: 157640067
Change-Id: I15e5a6c2f07e73718803501d705de0d7ab9bec90
Merged-In: I15e5a6c2f07e73718803501d705de0d7ab9bec90
Merged-In: Iaa97ddaa015e8079fcb3426585c5101c7ec9e22a
(cherry picked from commit c0f4373106)
2020-07-23 09:06:52 +01:00
Colin Cross
014489c1e6 Add support for running Android lint on java and android modules.
Add a rule that runs Android lint on each java and android module
and produces reports in xml, html and text formats.

Bug: 153485543
Test: m out/soong/.intermediates/packages/apps/Settings/Settings-core/android_common/lint-report.html
Change-Id: I5a530975b73ba767fef45b257d4f9ec901a19fcb
2020-06-16 15:44:16 -07:00
Jaewoong Jung
4b79e98a6e Soong package structure refactoring
Give prebuilt_etc and sh_binary their own packages and split the
gigantic main Android.bp up to small, per-package ones.

Test: m nothing, TreeHugger
Bug: 156980228
Change-Id: I7b00cd344b9f16861f1ff39edf0029f016b853d0
2020-06-01 13:44:48 -07:00