summaryrefslogtreecommitdiff
path: root/java/java_test.go
AgeCommit message (Collapse)Author
2021-03-01Avoid hiddenapi ignoring prebuilt with missing dex implementation jarPaul Duffin
Previously, when a prebuilt was preferred but did not provide a suitable boot dex jar both the source and the prebuilt were silently ignored which meant that the "hiddenapi list" command was not given a complete set of boot dex jars. That could either lead to incorrect hiddenapi flags being set or the "hiddenapi list" command failing if it could not find a class. Debugging the cause of either of those cases can be very time consuming so this change fails early and makes the cause very explicit. Bug: 181267622 Test: m nothing Change-Id: I6763ddb9ba90ed2e501d0cf7984f6655237e905d
2021-02-24Allow pre-singleton types to be registered in RegistrationContextPaul Duffin
Bug: 181070625 Test: m droid Change-Id: I708b78ed0b42ec55b0442307f40531cfe1233c2b
2021-02-22Merge "Add ctx to AndroidMkExtraEntriesFunc"Treehugger Robot
2021-02-19Add ctx to AndroidMkExtraEntriesFuncColin Cross
Add a ctx parameter to AndroidMkExtraEntriesFunc to allow them to access providers. Test: m checkbuild Change-Id: Id6becc1e425c3c3d8519248f8c0ce80777fac7cc Merged-In: Id6becc1e425c3c3d8519248f8c0ce80777fac7cc
2021-02-18Add support for lint baseline filesPedro Loureiro
Test: m droid Test: go test ^TestJavaLint # (from soong/build/java) Change-Id: I249a0a0597b0bf8495460ed283b476ad2eb36edc
2021-01-25Make dexpreopt tools available for all java testsPaul Duffin
Bug: 177892522 Test: m nothing Change-Id: I594bddae692ef76dc8c3da504934d0151b13d4c9
2021-01-21Allow createGlobalSoongConfig() to be used from testsPaul Duffin
Previously, the createGlobalSoongConfig() function was explicitly prevented from being used in tests because it would fail. However, it turns out that is no longer the case and it does now work. That allows the following changes to be made: * Tests no longer need to use GlobalSoongConfigForTests() to prepopulate the cache. * GlobalSoongConfigForTests() is only needed in the dexpreopt package. Bug: 177892522 Test: m nothing Change-Id: Ifcbb1a44254c5d2d10c1d02ab23227488d1d1ed1
2021-01-21Add java.RegisterRequiredBuildComponentsForTest functionPaul Duffin
Insulate tests that exercise code in the java package from having to register the build components provided by the java package by providing a single function that registers them all. This follows the pattern currently used in the cc and rust packages. This change is in preparation for switching the dex_bootjars singleton from a singleton, which does not require a module definition in order to be instantiated, to a singleton module which does. That will require adding a module definition into java.GatherRequiredDepsForTest() and this change ensures that the required components will have been registered in every test. Bug: 177892522 Test: m nothing Change-Id: I6475db8240894947dd07c89a940a3e4f201aa598
2021-01-15Make TestJavaSdkLibraryEnforce fasterJaeMan Park
TestJavaSdkLibraryEnforce is too slow because it tests all combinations of options. Change TestJavaSdkLibraryEnforce to run test on specific test cases, not all combinations. Bug: 177323052 Test: go test -timeout 10s -run ^TestJavaSdkLibraryEnforce$ android/soong/java Change-Id: Ie7fe4e22b570a3e25259a6ad4bd37936805c6604
2021-01-05Add "aidl.flags:" property for cc_/java_ modulesJooyung Han
The property can be used to pass additional flags to the AIDL compiler. For example, cc_library { .. srcs: ["Foo.aidl"], aidl: { flags: [ "-Werror", // warnings as error "-Weverything", // turn on all warnings ], }, } Bug: 168028537 Test: soong test Change-Id: I8120eeae7cd7b1acdd34c554af996a29e760a368
2020-12-28Merge "Break up app.go."Jaewoong Jung
2020-12-21Break up app.go.Jaewoong Jung
Test: m nothing + TreeHugger Change-Id: I64c6d7f10530c424bc282d8111dfaf9159426f00
2020-12-21Add attribute to disable last-api compat trackingAnton Hansson
Setting this to true by default is dangerous as it can mask bugs. Create a dedicated attribute for java_sdk_library to enable this behavior instead. The default will be flipped in a future CL when all the current offenders have been fixed. Fix all the tests to have the right API files. Bug: 176092454 Test: m nothing Change-Id: Ieab94bcb74abf8d018365a56fb447fe3dbd46957
2020-12-02Merge "Add java sdk library enforcement flag"JaeMan Park
2020-11-24Merge "Annotate dependency tags for dependencies of installed files"Colin Cross
2020-11-24Add java sdk library enforcement flagJaeMan Park
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-23Annotate dependency tags for dependencies of installed filesColin Cross
Relands Ic22603a5c0718b5a21686672a7471f952b4d1017 with a minor change to track libc++ dependencies for python hosts and after a fix to an internal genrule that depended on transitively installed java libraries (ag/13068670). Soong currently assumes that installed files should depend on installed files of all transitive dependencies, which results in extra installed file dependencies through genrules, static libs, etc. Annotate dependency tags for dependencies for which the installed files are necessary such as shared libraries and JNI libraries. This avoids extra installed files, and is also a first step towards genrules using their own copy of tools instead of the installed copy. Bug: 124313442 Test: m checkbuild Test: java.TestBinary Test: cc.TestInstallSharedLibs Test: deptag_test.go Change-Id: I725871249d561428e6f67bba6a7c65b580012b72
2020-11-23Remove restriction on exported plugins that generate APIsColin Cross
hilt_android requires seven separate annotation processors, which is only feasible to support using exported_plugins to avoid having to list all seven in every module that uses it. Unfortunately they all set generates_api: true. Turbine is already disabled for modules that directly use a plugin that sets generates_api: true, because turbine doesn't run annotation processors. Also add support for disabling turbine if a module transitively uses a plugin that generates APIs via exported_plugins. Bug: 173397767 Test: TestExportedPlugins Change-Id: If70354a3dd67efb4ce88bc9c934d41ccb6241b28
2020-11-19Merge changes from topic "fix-stubs-source-snapshot"Paul Duffin
* changes: Fix prebuilt_stubs_sources to work with no stubs sources Revert "Use glob for java_sdk_library_import stub_srcs"
2020-11-19Merge "java link time error improve"Treehugger Robot
2020-11-19Fix prebuilt_stubs_sources to work with no stubs sourcesPaul Duffin
The framework-sdkextension java_sdk_library module defines an API for public, system and module_lib API surfaces but the public API is empty. The empty public API results in an empty .srcjar being repackaged and merged into the sdkextension-sdk snapshot and results in no directory for the public API stubs sources being created. Unfortunately, the Android.bp file in the snapshot is created by Soong and it does not know that the public API will be empty and so it creates an Android.bp file that references the directory into which the stubs sources should be added but which ends up not existing in the snapshot. Referencing a non-existent directory causes a build failure. This change fixes that issue by using PathForModuleSrc with no path components to get the path to the module directory (which must exist) and then resolving the module relative local src directory against that. The local src directory is globbed to find all the files, which will return an empty set of paths if the directory does not exist. Finally, the file paths are passed as an rsp file to soong_zip to avoid exceeding any command line limits. Many other different approaches were considered: * Adding a property to the java_sdk_library to indicate that the public API was actually empty. That would require extra maintenance by developers and would require some extra checks to be performed after generating the stubs source to ensure that it was empty which would complicate the build process. * Creating a directory with some placeholder file (empty directories don't work well with git) that would force the creation of the directory. That file would most likely be created whether the API was empty or not, would need to be stored in git alongside the source and could be quite confusing to reviewers. Bug: 173508731 Test: m nothing - to run new tests Build sdkextension-sdk, unpack it and then build the .srcjar files for the public, system and module_lib API surfaces. Without this change the build failed, reporting that the stubs_sources directory for the public API did not exist. With this change the build succeeded. Checked the contents of the resulting .srcjar files and made sure that the public one was empty and the others contained the SdkExtensions.java class and a package-info.java file. Change-Id: Ia468a3f37349f2dbc21db67744bda6461498d515
2020-11-18Merge changes Iba57c949,Ief43ff51,Ib1809a4d,I2ab64f36Treehugger Robot
* changes: Store ndkKnownLibs in the config Register the kythe singleton on the Context instead of globally Store ninja file deps from PackageVarContext in the config Store SingletonMakeVarsProviders in the config
2020-11-17java link time error improveSteven Moreland
Asked about error message including "against private API.Adjust sdk_version", which is a bit hard to parse due to missing space. Also tried to make error message less verbose, so that it is more clear what to do, and fixed a grammar mistake. Bug: N/A Test: N/A Change-Id: Ib9a30d86b5cb0e9b3b7d5576ecb9498a9b316042
2020-11-17Move genrule on top of RuleBuilderColin Cross
In preparation for more complicated sandboxing support in sbox, use a single implementation of the sbox sandboxing by moving genrule to use RuleBuilder's sbox support instead of creating an sbox rule directly. Also move genrule's input list hash support into RuleBuilder. Test: genrule_test.go Test: rule_builder_test.go Change-Id: I292184d02743c7e6887ebbcd232ba565db2ab0cc
2020-11-17Store SingletonMakeVarsProviders in the configColin Cross
Store SingletonMakeVarsProviders in the config instead of a global variable to avoid races between tests running in parallel. Test: all soong tests Change-Id: I2ab64f368b5ac673fd985399d4421ed018abc562
2020-11-17Merge changes Iebfbf2ff,Ibd974268Ulyana Trafimovich
* changes: Rename fields and methods to reflect class loader context changes. Do not add dependencies of shared SDK libraries to manifest_fixer.
2020-11-17Merge "Revert "Annotate dependency tags for dependencies of installed files""Colin Cross
2020-11-17Revert "Annotate dependency tags for dependencies of installed files"Colin Cross
This reverts commit 62a0cfd05460d0e760ce9133690e48861bb57eee. Reason for revert: b/173475545 Change-Id: I4e834200c8e68dfa1b8144dfd1fa95ca68554980
2020-11-16Merge changes Ic22603a5,I5330b571Colin Cross
* changes: Annotate dependency tags for dependencies of installed files Use the the preferred architecture symlink as the tool path if it exists
2020-11-16Rename fields and methods to reflect class loader context changes.Ulya Trafimovich
Test: lunch aosp_cf_x86_phone-userdebug && m Bug: 132357300 Change-Id: Iebfbf2ffdac5ee48476d2aac312b3b8f4471fc85
2020-11-16Merge "Rework class loader context implementation."Ulyana Trafimovich
2020-11-14Annotate dependency tags for dependencies of installed filesColin Cross
Soong currently assumes that installed files should depend on installed files of all transitive dependencies, which results in extra installed file dependencies through genrules, static libs, etc. Annotate dependency tags for dependencies for which the installed files are necessary such as shared libraries and JNI libraries. This avoids extra installed files, and is also a first step towards genrules using their own copy of tools instead of the installed copy. Bug: 124313442 Test: m checkbuild Test: java.TestBinary Test: cc.TestInstallSharedLibs Test: deptag_test.go Change-Id: Ic22603a5c0718b5a21686672a7471f952b4d1017
2020-11-12Pass Config to NewTestContext instead of ctx.RegisterColin Cross
Prepare for using Config when adding singletons by passing Config to NewTestContext and NewContext instead of to ctx.Register. This will enable a followup change to store SingletonMakeVarsProviders registered on the Context in the Config, which is necessary to run multiple tests in parallel without data races. Test: all soong tests Change-Id: Id229629a4e42ff4487d317241673837726c075fc
2020-11-03Rework class loader context implementation.Ulya Trafimovich
The old representation consisted of a list of libraries (UsesLibraries), a list of optional libraries (OptionalUsesLibraries) and a mapping from library name to its build/install paths (LibraryPaths). The separation into lists and map was necessary because of special handling of compatibility libraries, which is now unified with normal libraries. The new representation is a mapping from target SDK version to a tree structure ClassLoaderContext. Each node of the tree represents a library and contains library name, build/install paths and a slice of subcontexts for dependencies. The same library may occur in the tree multiple times in case it is a dependency of multiple libraries. The order in which libraries are added matters (the resulting tree shape may be different). Test results have to be updated, as the resulting <uses-library> list is reodered (previously it was a sorted list of map keys, and now it is formed by a depth-first preorder traversal of the class loader tree). Test: lunch aosp_cf_x86_phone-userdebug && m Bug: 132357300 Bug: 168686456 Change-Id: I11be8cd2967f004fd58753d7c5fb99fed179cd63
2020-11-02Add ctx.ModuleDir and top level module dirs of input sources to JDK9Jingwen Chen
--patch-module lookup. javac --patch-module accepts a list of directories and/or jars for JDK9 module patching (see bug for more details). In Bazel-Ninja execution, Bazel executes the javac action in its own execution root working directory, unlike Ninja, which works in the Android top level directory. The Bazel execution root is formed of a symlink forest of top level directories. This symlink forest is a problem for javac because it doesn't traverse into symlinks. To support Bazel executing these javac actions, we explicitly encode the module directory, and the top level directory of any other source file inputs into the --patch-module javac flag. For example, the "core-all" libcore module compiles into `java.base`, and depends on filegroups outside of `libcore` (`tools`). This CL adds `tools` to the --patch-module lookup dir, on top of `libcore`. See java_test.go for more details. Bug: 150878007 Fixes: 150878007 Test: m Test: bazel build droid (aosp_flame) Change-Id: Id95b0a9a675fc75678f7b5e600344b4403f0c518
2020-10-26Make highmem classification of metalava optionalAnton Hansson
We have added a lot of metalava invocations since the highmem differentation was added, most of which do not use a lot of memory. By collecting data of max rss per process we have narrowed down the set of highmem modules to a smaller set, and will annotate the relevant modules as such. Bug: 170701554 Test: NINJA_HIGHMEM_NUM_JOBS=3 m checkapi (no long tail of metalava) Change-Id: Ic9c8c91388b02889111ef596fc6fd8bde9b42b9d
2020-10-13Merge changes Ieeca3c39,Iddeea2d0,I8d66a5d3Colin Cross
* changes: Add jni_libs to host java binaries Make java_binary common variant a dependency Replace jniDependencyTag with a value
2020-10-12Merge "Apply PRODUCT_ENFORCE_RRO_TARGETS to dependencies."Jaewoong Jung
2020-10-12Apply PRODUCT_ENFORCE_RRO_TARGETS to dependencies.Jaewoong Jung
With this change, users don't need to figure out which libraries actually hold the resources to be overlaid when targetting apps with a core lib dependency (e.g. Settings, SystemUI). Fixes: 169898727 Test: app_test.go Change-Id: I3c3b9dc0a377b1828db1199858a73d080a173205
2020-10-12Merge "Add a Impl_only_libs prop for sdk_library"Anton Hansson
2020-10-09Add jni_libs to host java binariesColin Cross
Add a property to support dependencies on JNI libraries for host java binaries. Fixes: 170389375 Test: TestBinary Change-Id: Ieeca3c3997615f0b17ae1f058b94e6c9ba929cab
2020-10-09Make java_binary common variant a dependencyColin Cross
ctx.PrimaryModule() is wrong in the case of a java_binary that supports both host and device, use an explicit dependency instead. Once the dependency exists there is no need to manually request the jar be installed, it will automatically be installed by the host installation rules for dependencies. Test: TestBinary Change-Id: Iddeea2d08bc574c79d42139020558cd70d718ca1
2020-10-09Revert "Make lots of tests run in parallel"Colin Cross
This reverts commit 323dc60712491c71ccdc5363c42df61f0a192487. Reason for revert: Possible cause of test instability Bug: 170513220 Test: soong tests Change-Id: Iee168e9fbb4210569e6cffcc23e60d111403abb8
2020-10-09Add a Impl_only_libs prop for sdk_libraryAnton Hansson
Similar to Stubs_only_libs, this allows being a bit more specific about what libs compile against what. In my usecase, it allows removing a platform dependency from the appsearch stubs, which allows the platform to depends on the stubs. Bug: 169304493 Test: m Change-Id: Ie997462819cd5266a761b2d415e81806c7877967 Merged-In: Ie997462819cd5266a761b2d415e81806c7877967
2020-10-07Merge "Make lots of tests run in parallel"Colin Cross
2020-10-06Make lots of tests run in parallelColin Cross
Putting t.Parallel() in each test makes them run in parallel. Additional t.Parallel() could be added to each subtest, although that requires making a local copy of the loop variable for table driven tests. Test: m checkbuild Change-Id: I5d9869ead441093f4d7c5757f2447385333a95a4
2020-10-06Allow access to the class jar for java_import using {.jar} tagPaul Duffin
Layoutlib requires access to the jar file (containing .class) files for a number of libraries including "core-libart". It does that using the {.jar} output tag, e.g. "core-libart{.jar}". This change makes sure that works when "core-libart" is provided as a java_import instead of a java_library. Bug: 142938164 Test: m nothing Change-Id: I605019d680c28e4a33f0ca14279d63fa62b9774b
2020-09-30Add support for using sdk_version: "module_<ver>"Paul Duffin
Fixes a panic when trying to build something with sdk_version: "module_30". Test: m nothing Change-Id: I9b2ce50957f59e2bead335ffa58888e15cda1f78
2020-09-10Merge "Revert "Revert "Remove create_stubs and checkapi from droiddoc"""Treehugger Robot
2020-09-10Revert "Revert "Remove create_stubs and checkapi from droiddoc""Liz Kammer
This reverts commit 3666c7023f129fa4c38a11918e6e9e9a3a554b31. Reason for revert: This was originally reverted because it caused a breakage (b/167405890) in a branch that is no longer relevant. Change-Id: I81063cd47b816b5b3c0ab8427432730d6b881a3f