summaryrefslogtreecommitdiff
path: root/java/java.go
AgeCommit message (Collapse)Author
2021-03-04Revert "Attempt to run all java_test_host that look unit tests"Julien Desprez
Revert submission 1597083-java_test_host_default Reason for revert: Getting ready for b/181888225 just in case Reverted Changes: I220551549:Attempt to run all java_test_host that look unit t... I29dbbbf46:Exclude some tests for java_test_host onboarding Change-Id: Iaa89f9b7e9ad72ed962cef285c70a6263e63ffd5
2021-03-04Merge "Attempt to run all java_test_host that look unit tests"Julien Desprez
2021-02-26Remove global state from sysprop librariesColin Cross
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-26Propagate java resources in apps with no codeColin Cross
Use the java resources jar as the dex jar when building apps that have no code. Also remove maybeStrippedDexJar, the dex jar is never stripped now. Fixes: 176305357 Test: TestAppJavaResources Change-Id: Ic8b1165bd35d71237d307e7f5f895764e203a10d
2021-02-25Attempt to run all java_test_host that look unit testsJulien Desprez
Currently includes some heuristic for the first round of onboarding. Test: presubmit Bug: 180736967 Change-Id: I220551549ed3c1468390655cb911f3b8c0f8880d
2021-02-23Fix infinite recursion when printing unrecognized linktypeJiyong Park
Bug: N/A Test: remove some cases from String() so that some linktypes go to the default path. Then run m nothing. No infinite recursion. Error is correctly shown. PANIC=String method: unrecognized linktype: 5 Change-Id: I424755bc89871fc2144ff22d6391f57157cd434d Change-Id: Ice791025dc50f44ffabd1050bafc5ea35023d32c
2021-02-18Further simplify the link type check routineJiyong Park
Bug: 180477804 Test: m nothing Change-Id: I216be96cf844fe42ba0cec467eea8520ff4ef4f2
2021-02-18Linktype check error message becomes more correctJiyong Park
The type linkType has String() method and the error message is created using it. Bug: 180477804 Test: m nothing Change-Id: I74fe9c93b74904177dbe9d29cd3aa3304b67ba4f
2021-02-16Merge changes from topic "mkboot"Treehugger Robot
* changes: prebuilt_etc is OutputFileProducer Revert "`data` dependency of java_test_host can be arch-specific"
2021-02-16Allow explicitly specified additional annotations for hiddenapiPaul Duffin
Adds the hiddenapi_additional_annotations to allow a library to list the libraries that provided additional hiddenapi related annotations for a library. Modifies merge_csv.py so it can process multiple zip files at the same time and uses that to merge the embedded .uau files from a module and those it depends upon. Bug: 180102243 Test: m droid Verified that hiddenapi files (both aggregated ones and for the individual modules) are not affected by this change. Change-Id: I796520021c7357398a9e2a09f1029e4a578b05b3
2021-02-16Revert "`data` dependency of java_test_host can be arch-specific"Jiyong Park
This reverts commit cdd9b8392d669731fef6e1415496b181ae80ede9. Reason: this doesn't work. java_test_host is a multi target module. Therefore, `arch.<arhc>.data` is not collapsed to `data` by the arch mutator. Bug: N/A Test: N/A Change-Id: I755b06718bacfe1513f6ad1e734e5a0d0ac57cd8
2021-02-13Merge "Convert java.Dependency to JavaInfo provider"Colin Cross
2021-02-11Move logic for selecting the primary module into initHiddenAPI()Paul Duffin
Bug: 178361284 Test: m droid Verified that hiddenapi files (both aggregated ones and for the individual modules) are not affected by this change. Also verified that the hiddenapi files created when using the prebuilts (using SOONG_CONFIG_art_module_source_build=false) are the same as when using the source. There is a slight difference in the order but otherwise identical. Change-Id: I831da5fa41eb7668b07bbdc4dd08ec2cdb8803d0
2021-02-09Convert java.Dependency to JavaInfo providerColin Cross
Export information about java dependencies through a Provider instead of accessing the module directly. Test: java_test.go Test: no changes to build.ninja Change-Id: Ifc5d566bf6f6ebc0ad399e948effaa1ef6a22876
2021-02-09Merge "Add android_test_helper_app properties to java_defaults"Treehugger Robot
2021-02-09Add android_test_helper_app properties to java_defaultsColin Cross
Allows android_test_helper_apps to get their test_suites and auto_gen_config properties from a java_defaults module. Fixes: 179744452 Test: m checkbuild Change-Id: Ifa09f9fd0a51d3a9682401e4c6bd2f82cd4f1b8a
2021-02-08Allow dex jars from prebuilt_apex to be used by hiddenapiPaul Duffin
Invokes hiddenAPIExtractInformation() on the dex jar provided by the deapexer (on behalf of prebuilt_apex) so that hiddenAPI can extract the information it needs, if anything, from the dex file (and accompanying classes implementation file). The dex file provided by deapexer has already had the hiddenapi information encoded into it so it does not need to do that again. This change adds the primary parameter to hiddenAPIExtractInformation() and checks it (and also the hiddenAPI.active property) before it does anything. That ensures that it behaves correctly when called directly as well as when called from hiddenAPIExtractAndEncode(). Bug: 178361284 Test: m droid Verified that hiddenapi files (both aggregated ones and for the individual modules) are not affected by this change. Also verified that the hiddenapi files created when using the prebuilts (using SOONG_CONFIG_art_module_source_build=false) are the same as when using the source. There is a slight difference in the order but otherwise identical. Change-Id: I7abb63fd310bb94787ab7f4821e5fd283dc03046
2021-02-08Refactor the hiddenAPI() method for reusabilityPaul Duffin
A follow up change needs to be able to contribute to the information the hiddenapi process collates without having a dex file encoded. This change pushes all the functionality related to information gathering into the hiddenAPIGenerateCSV() method and then renames it and the hiddenAPI() method to make it clearer what they do. Bug: 178361284 Test: m droid Verified that hiddenapi files (both aggregated ones and for the individual modules) are not affected by this change. Change-Id: I04417720216a0fbadcd88e6185e7de6570af6216
2021-02-08Extract initHiddenAPI() from hiddenapi()Paul Duffin
Previously, the hiddenapi() method combined both checks to determine whether a module contributed to/was modified by the hiddenapi process and logic to create ninja rules to perform those tasks. This change separates the former out into a new initHiddenAPI() method. The main purpose of this is to simplify the process of allowing the CSV generation to be separated from the encoding. That is required because when a java_import retrieves its dex file from the apex it has already been encoded. The initHiddenAPI() method is only called for java.Library (and indirectly for java.SdkLibrary) and java.Import modules which means that the hiddenapi() method does nothing for any other module type. That is consistent with the previous behaviour because while the hiddenapi() method is called for other module types they fail because the boot image jars only support java_library, java_sdk_library, and java_import at the moment. While it will need to support java_sdk_library_import once any of the libraries that are currently provided as java_sdk_library modules switches to providing prebuilts that is outside the scope of this work. Bug: 178361284 Test: m droid Verified that hiddenapi files (both aggregated ones and for the individual modules) are not affected by this change. Change-Id: Iaa91e0a8e2bffec03296dd894e9662556f4464c0
2021-02-07Merge changes I9e94662d,I4b4e0dc8Paul Duffin
* changes: Export implementation class jars for java_boot_libs Improve module filtering in hiddenapi stubFlagsRule()
2021-02-05Merge "bp2build: convert paths/module refs to Bazel label"Liz Kammer
2021-02-05Export implementation class jars for java_boot_libsPaul Duffin
Hiddenapi processing currently requires access to the class implementation jars for libraries on the bootclasspath which means that they need to be provided as part of the prebuilts. This change modifies the java_boot_libs property on the sdk to make those files available. Modularization of the hiddenapi processing will hopefully remove the need for these to be exported so this should be temporary. Bug: 178361284 Test: m art-module-sdk check generated snapshot zip contains implementation jars Change-Id: I9e94662dddb0ddb85a477ae6d27e533085147e88
2021-02-04bp2build: convert paths/module refs to Bazel labelLiz Kammer
This currently expands all globs, still need to support converting glob syntax. Test: go build_conversion_test Test: GENERATE_BAZEL_FILES=true m nothing Test: m nothing Bug: 165114590 Change-Id: If7b26e8e663d17566fad9614ca87a8da1f095284
2021-02-05`data` dependency of java_test_host can be arch-specificJiyong Park
This allows java_test_host to have arch-specific data files. Currently, VirtualizationHostTestCases needs this to have arch-specific kernels as its data. Bug: N/A Test: m VirtualizationHostTestCases Change-Id: Ib5680ef48b613955ad92c9bc212184ac75900d3e
2021-02-02Switch hiddenapi to use OutputPath instead of ModuleOutPathPaul Duffin
In order to allow the hiddenapi code which expects its inputs to be ModuleOutPath to consume the output from the deapexer module type (used by prebuilt_apex) this change converts the hiddenapi from using ModuleOutPath to use OutputPath instead. This is part of a general cleanup to remove ModuleOutPath that is separated out in order to avoid having the hiddenapi work dependent upon and possibly delayed by issues with that general cleanup. Bug: 178361284 Bug: 179124768 Test: m droid Change-Id: I890f775bf5e33528dbaa62b95fa4198185ff8bf8
2021-01-19Enable an apex to include a java_import.Bill Peckham
With the addition of the compile_dex property to the java_import module it becomes possible to include a java_import module in an apex. This change allows the dependency and adds a test. Bug: 177228901 Test: m nothing Test: new TestApexWithJavaImport Change-Id: I9336dade1857109e2fd21f7d57e1dc4abc4a402c
2021-01-15Export dex implementation jars from prebuilt_apexPaul Duffin
Dexpreopt and boot jars package check all require access to dex implementation jars created for java_library and java_sdk_library. They were available when building from source but not when building from prebuilts, even though they are embedded within the .apex files that are referenced from prebuilt_apex. This changes adds support to prebuilt_apex to export the dex implementation jars and updates java_import to use those exported dex implementation jars. In a source build dexpreopt/boot jars package check access the apex (or platform) specific variant of a java_library, e.g. core-oj, from which it retrieves the dex implementation jar path. After this change in a prebuilt build dexpreopt/boot jars package check behave in the same way except in this case they retrieve the dex implementation jar path from the apex (or platform) specific variant of the java_import, e.g. core-oj. The work to export files from a `.apex` file for use by other modules is performed by a new `deapexer` module type. It is not used directly in an `Android.bp` file but instead is created implicitly by `prebuilt_apex`, In order to do that this contains the following changes: * Adds a new `dexapexer` module type to handle the exporting of files from the `.apex` file. * Adds an exported_java_libs property to prebuilt_apex to specify the set of libraries whose dex implementation jars need exporting. * Creates apex specific variants of the libraries listed in the exported_java_libs property. * Adds the set of exported files to the ApexInfo to make them available to the apex specific variants. * Prevents the prebuilt_apex variants from being merged together as they will not be compatible. * Modifies java_import to use the exported file for variants of a prebuilt_apex. * Adds a ninja rule to unpack (using deapexer) the contents of the prebuilt_apex's apex file, verify that the required files are present and make them available as outputs for other rules to use. * Some minor refactorings to support these changes. * Adds tests to cover prebuilt only, prebuilt with source preferred, and prebuilt preferred with source. Test: m nothing Bug: 171061220 Change-Id: Ic9bed81fb65b92f0d59f64c0bce168a9ed44cfac
2021-01-15Add java_boot_libs to sdkPaul Duffin
The build has some implicit dependencies (via the boot jars configuration) on a number of modules, e.g. core-oj, apache-xml, that are part of the java boot class path and which are provided by mainline modules (e.g. art, conscrypt, runtime-i18n) but which are not otherwise used outside those mainline modules. As they are not needed outside the mainline modules adding them to the sdk/module-exports as either java_libs, or java_header_libs would end up exporting more information than was strictly necessary. This change adds the java_boot_libs property to allow those modules to be exported as part of the sdk/module_exports without exposing any unnecessary information. Some points to note: * The java_import has to have a valid file for the src property otherwise it will be disabled. * The src property is supposed to reference a jar file but the java_boot_libs property will make it reference an empty file (not an empty jar) so that any attempt to use that file as a jar, e.g. compiling against it, will cause a build failure. * The name of the file passed to the src property should make it clear that the file is not intended to be used. * The test makes sure that only the jar file is copied to the snapshot. Test: m nothing Bug: 171061220 Change-Id: I175331e4c8e3874ab70a67cdc2f76ed1576e41eb
2021-01-08Merge "Remove obsolete class loader context API and update unit tests."Ulyana Trafimovich
2021-01-05Remove obsolete class loader context API and update unit tests.Ulya Trafimovich
The removed API has been unused since https://r.android.com/1533342 (except for unit tests). Changes in the unit tests reflect the change of API in https://r.android.com/1533342: early errors caused by unknown library paths at CLC construction time have been replaced with late errors at the time of CLC validation. Bug: 132357300 Test: m nothing Change-Id: I739c7c41b6f882b7e28cdd6acd05961d754d8687
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-23Automatically set uncompress_dex for java_import.Bill Peckham
Setting uncompress_dex for java_import in the same way as java_library enables using a java_import as an art jar or a boot jar. Bug: 175619567 Test: m nothing Test: TestHiddenAPISingletonWithPrebuilt Change-Id: I0b552a11d1630a014cf978520ccc5977fdf74066
2020-12-22Remove unnecessary snake case variables.Jaewoong Jung
Test: m nothing + TreeHugger Change-Id: I99f7162944daa6c57c6ae4763261e108bb5cb6b1
2020-12-22Merge changes I6a512209,I56437f26Ulyana Trafimovich
* changes: Unify addition of class loader subcontext from dependencies. Move ClassLoaderContexts() method to UsesLibraryDependency interface.
2020-12-21Unify addition of class loader subcontext from dependencies.Ulya Trafimovich
Previously CLC construction was scattered across different module types and dependency tags. This CL moves all logic to one function, which handles all special cases. This will allow to simplify CLC API and reduce the number of different ways in which CLC is constructed. Previously some of the cases failed early (at the time when a library is added to CLC) if the build/install paths were unknown. Other cases did not fail early, but were validated later before CLC was used. Late failures are necessary because some of the libraries with unknown paths still have to be processed by manifest_fixer (which doesn't need library paths), but they do not use dexpreopt (which needs library paths). This CL removes the early failures (all paths are still validated later). The CLC tests do not fail because they use a private method that toggles the "strict" flag (that enforces early/late failure mode) manually in the method call. The CL also makes a functional change in the way CLC is constructed for component libraries that have an OptionalImplicitSdkLibrary(), or libraries that are disguised as SDK libraries via `provides_uses_lib`. Previously such a component/disguised library X was added to its own CLC as a sibling element of X's own <uses-library> dependencies, which created incorrect CLC structure. Now this is handled by addCLCFromDep, when X is processed as dependency and added as a top-level CLC element with its sub-CLC properly nested under it. Bug: 132357300 Test: lunch aosp_cf_x86_phone-userdebug && m Change-Id: I6a512209b87b81d785875f10f76b21c81b2ed579
2020-12-17Remove the return value from dexpreoptJaewoong Jung
dexpreopt doesn't strip dex files from the input jar anymore, so there's no point returning the input jar path untouched. Test: m nothing + TreeHugger Change-Id: I8fde6cdc19e85a2fbc946513696417b945c5de0f
2020-12-17Move ClassLoaderContexts() method to UsesLibraryDependency interface.Ulya Trafimovich
This method logically belongs with other UsesLibraryDependency methods, as it is used in the same context when computing class loader context. Previously it was part of Dependency interface, which doesn't cover SDK libraries. We do not currently have the necessary information for SdkLibraryImport (so ClassLoaderContexts() returns nil for it), but we do have it for SdkLibrary (via Library). Bug: 132357300 Test: m nothing Change-Id: I56437f260efc6a9af3f45b334e84e915244ccce1
2020-12-15Assert android.ApexModule interface for types having ApexModuleBaseJiyong Park
Bug: 173472337 Test: m nothing Change-Id: Idf1c6cb9fff6c18e34c4636e38a662ba4ff7d538
2020-12-07Merge changes I697a65e4,Iaac6aaf6Ulyana Trafimovich
* changes: Do not propagate <uses-library> deps through static SDK component libs. Make error message more precise.
2020-12-04Merge "Dogfood the new IR Kotlin compiler backend."Treehugger Robot
2020-12-03Merge "Pass pctx and ctx to NewRuleBuilder"Colin Cross
2020-12-03Do not propagate <uses-library> deps through static SDK component libs.Ulya Trafimovich
If some Java library/app depends on an SDK component library (e.g. stubs library), then it transitively depends on the SDK library itself (because the component library has a dependency on its SDK library). Previously having this transitive dependency resulted in adding the SDK library to the <uses-library> dependencies of the library/app. However, this doesn't make sense if the app has a *static* dependency on the component library. This patch stops adding <uses-library> dependency in that case. Bug: 132357300 Test: m nothing Test: added new Soong test that would previously fail with an error: invalid build path for <uses-library> "fred" Change-Id: I697a65e461037c95ec56b6c321afa4ec52ccbbec
2020-12-03Dogfood the new IR Kotlin compiler backend.Mads Ager
Test: make Test: atest com.android.systemui Change-Id: I610058001bde19554c55dee5a79ad1782abc3186
2020-12-02Merge "Add java sdk library enforcement flag"JaeMan Park
2020-12-01Pass pctx and ctx to NewRuleBuilderColin Cross
Enable the RuleBuilder and RuleBuilderCommand methods to access the BuilderContext by passing it to NewRuleBuilder instead of RuleBuilder.Build. Test: genrule_test.go Test: rule_builder_test.go Test: m checkbuild Change-Id: I63e6597e19167393876dc2259d6f521363b7dabc
2020-11-27Remove redundant setting of DistFiles by java.LibraryPaul Duffin
A previous change handles dist properties automatically for all module types and as a result has made the java.Library setting of DistFiles redundant so this change removes that and the tests that duplicate tests of the general mechanism. Test: m nothing m dist sdk - before and after this change, compare result to make sure that there are no significant differences. Bug: 174226317 Change-Id: Ib79a3bdd46897efd84a9c456c37c374bd6036303
2020-11-27Differentiate between no dist tag and an empty dist tagPaul Duffin
Change https://r.android.com/1335521 added tag property to the Dist struct so that it could be used to select one of a number of different output files to copy to the dist instead of the single file that the module type made available for dist. The output files were selected by passing the tag to OutputFiles(tag). Module types that wanted to support this new approach had to explicitly set AndroidMkEntries.DistFiles = GenerateTaggedDistFiles(module). Unfortunately, doing that had a side effect of changing the behavior of dist entries without a tag. That was because the change treated a tag that was not specified, as being the same as "". So, prior to the change no tag meant use the default dist file but after it meant use the paths returned by OutputFiles(""). That changed the behavior of the java.Library type which affected the behavior of the android_app module type. Prior to the change the java_library would make the Library.outputFile available for dist when no tag was specified. After that change it would make Library.outputFile plus Library.extraOutputFiles. The latter is usually empty except for android_app which adds some extra files into there which will now be copied to the dist. That change may have been intentional but there was no mention of it in the change or the bug. Even if it wasn't intentional it may still be beneficial. Any module type that wants to add support for tags in dist runs the risk of introducing similar changes in behavior. This change differentiates between the tag not being set and the tag being set to "" to avoid that possibility and to make the default behavior explicit for those module types that have switched. It does so as follows: * Adds a DefaultDistTag constant that is used when the tag is not set. It is a string that is unlikely to be used as an actual tag as it does not start with a . and uses some special characters. * The DefaultDistTag is used in MakeDefaultDistFiles(paths) to indicate that the supplied paths are the default ones and and also in GenerateTaggedDistFiles() for Dist structures that have no tag property set. * The DefaultDistTag is passed to OutputFiles(tag) just in case the module type has explicitly defined the paths to associate with that tag in there. If it has then it overrides the legacy behavior. If it has not then it is just ignored and falls back to using the previous behavior. * The java.Library.OutputFiles(tag) method explicitly handles the DefaultDistTag and returns Library.outputFile for it which restores the behavior from before the change that added dist.tag support. * Similar change was made to apexBundle.OutputFiles(tag) in order to preserve its previous behaviour. * The customModule used by TestGetDistContributions has been modified to also preserve its previous behavior after this change. Test: m nothing m dist sdk - before and after this change, compare result to make sure that there are no significant differences. Test the effect on the apex by following instructions in http://b/172951145 Bug: 174226317 Change-Id: Ib8f0d9307751cc2ed34e3d9a5538d3c144666f6d
2020-11-27Merge "Assume any <uses-library> is shared, add only toplevel ones to manifest."Ulyana Trafimovich
2020-11-25Assume any <uses-library> is shared, add only toplevel ones to manifest.Ulya Trafimovich
This patch reworks the approach introduced in https://r.android.com/1450819. That patch based the decision which libraries should be added to the manifest <uses-library> tags by the manifest_fixer on the "shared" status of the library. That approach is incorrect for two reasons: - It doesn't make sense to have a non-shared library in class loader context ("shared" libraries are those specified in frameworks/base/data/etc/platform.xml, and they are the only ones that PackageManager knows about). - It doesn't make sense to add anything but the top-level of the class loader context tree to the manifest, because this part of the tree is flattened to a sequence, and PackageManager cannot restore it to the previous tree shape (there is an information loss). This patch removes the "shared" bit of information from class loader context elements and assumes that all libraries that end up in class loader context are shared. Consequently, only the top-level libraries should be passed to manifest_fixer. Test: lunch aosp_cf_x86_phone-userdebug && m Bug: 132357300 Bug: 168686456 Change-Id: I902690f0f38f1047fa79cf6ccbe956077eceaab0
2020-11-24Merge "Annotate dependency tags for dependencies of installed files"Colin Cross