summaryrefslogtreecommitdiff
path: root/java/java.go
AgeCommit message (Collapse)Author
2019-12-16Also package recursive jni_libs deps of android_apps as well as direct deps.Peter Collingbourne
Previously, android_app targets for which a.shouldEmbedJnis(ctx) = true (e.g. CtsSelinuxTargetSdk25TestCases) would need to specify all of their recursive library dependencies, including for example libc++ when depending on the platform libc++. This means unnecessary churn when we add a new dependency to libc++ (e.g. libunwind [1]). To avoid the churn and allow jni_libs clauses to be simplified, make the build system search for the recursive dependencies and automatically include them. This change allows us to remove code that was previously adding NDK libc++ as a special case, as it is now covered by the generic code. Also fix some improper quoting that was exposed as a result of this change causing more files to be packaged than before. [1] https://android-review.googlesource.com/q/topic:%22libunwind-so%22 Bug: 144430859 Change-Id: I3d6fbcce75bc108a982eb7483992a4b202056339
2019-12-16hostdex:true modules are available for platformJiyong Park
Java libraries with hostdex: true are available for the platform even if it doesn't have "//apex_available:platform" in the apex_available property. Note that the java libraries are still prevented from being installed to the device. Bug: 128708192 Test: m Change-Id: I6463ebc59cf7fd861b812999d7a79c387bbb3335
2019-12-13Decouple addition of new sdk member types from sdk codePaul Duffin
Previously, adding a new SdkMemberType would require adding a new sdkMemberListProperty instance to the sdkMemberListProperties as well as adding a new property into the sdkProperties struct. They are potential sources of conflict and couple the sdk code with all the packages that add members to it. This change switched to a registration model that allows each package to register its sdk member types decoupling them from the sdk code. Adds an SdkPropertyName() method to SdkMemberType that specifies the name of the property to use in the sdk/sdk_snapshot. Also provides an SdkMemberTypeBase struct to be used by providers of SdkMemberType implementations. SdkMemberType instances are registered using the RegisterSdkMemberType() func which sorts the registered instances by their SdkPropertyName() to ensure the behavior is consistent and not affected by order of registration. When creating a new sdk module a dynamicSdkMemberTypes instance is created that contains the following: * A properties struct is created dynamically that contains a field for each registered SdkMemberType, corresponding to that type's SdkPropertyName(). * A list of sdkMemberListProperty instances is also created, one for each registered SdkMemberType. The dynamicSdkMemberTypes instance is cached using a key that uniquely identifies the set of registered types just in case new types are registered after one has been created, e.g. by tests. Bug: 142918168 Test: m checkbuild Change-Id: I4bf2bf56a2a49025aa41454048bc1e8ccc6baca2
2019-12-09Pass SdkMember to AddPrebuiltModule instead of the namePaul Duffin
This is needed for a follow up change that makes sure that the prebuilt modules have the same visibility as the source modules. Bug: 143678475 Test: m conscrypt-module-sdk Change-Id: I9461c8c094ab19ee9ececb5e5fd50565789f2fa2
2019-12-07Merge "Cleanup java.DefaultsFactory()"Treehugger Robot
2019-12-07Merge "Support header and implementation jars in sdk"Treehugger Robot
2019-12-06Merge "Link type checking for java_library"Treehugger Robot
2019-12-06Cleanup java.DefaultsFactory()Paul Duffin
This function took a props varargs parameter but it was only ever called with no parameters. The props parameter meant it could not be used directly with RegisterModuleType() so the defaultsFactory() func was added which simply called through to DefaultsFactory(). Removing the props varargs parameter allowed it to be used directly with RegisterModuleType() and so the defaultsFactory() could be removed. This was needed because a follow up change adds a test in another package that uses java_defaults and so it needs the factory method (defaultsFactory()) to be exported. Test: m nothing Change-Id: I33d5c4d4ce8f349b1e6fc706d5e9656faf303b4f
2019-12-06Support header and implementation jars in sdkPaul Duffin
Add a new java_header_libs property that exports header jars (as java_libs currently does) and switch java_libs to export implementation jars instead. Refactors implementation of the existing library sdk member type so both properties can be supported from common code as they differ only on the jar being exported. Bug: 143678475 Test: m nothing Change-Id: I04642122f72d083bbdfd3290624f957b71ee8875
2019-12-07Link type checking for java_libraryJeongik Cha
Link type checking for java_library has not been working unintentionally. So turn on link type checking for these types. And also add tests for link type checking. Bug: 145799020 Test: cherry-pick aosp/1182522 and check if build fails Test: m nothing and there is no error(soong unittest) Change-Id: Ifc347f657885de1028ac0076ddd103c0387b597a
2019-12-06Parameterize the sdk member processingPaul Duffin
Extracts the type specific functionality into the SdkMemberType interface which has to be implemented by each module type that can be added as a member of the sdk. It provides functionality to add the required dependencies for the module type, check to see if a resolved module is the correct instance and build the snapshot. The latter was previously part of SdkAware but was moved because it has to be able to process multiple SdkAware variants so delegating it to a single instance did not make sense. The custom code for handling each member type specific property, e.g. java_libs, has been replaced with common code that processes a list of sdkMemberListProperty struct which associates the property (name and getter) with the SdkMemberType and a special DependencyTag which is passed to the SdkMemberType when it has to add dependencies. The DependencyTag contains a reference to the appropriate sdkMemberListProperty which allows the resolved dependencies to be grouped by type. Previously, the dependency collection methods would ignore a module if it was an unsupported type because they did not have a way of determining which property it was initially listed in. That meant it was possible to add say a droidstubs module to the java_libs property (and because they had the same variants) it would work as if it was added to the stubs_sources property. Or alternatively, a module of an unsupported type could be added to any property and it would just be ignored. However, the DependencyTag provides information about which property a resolved module was referenced in and so it can detect when the resolved module is of the wrong type and report an error. That check identified a bug in one of the tests where the sdk referenced a java_import module (which is not allowed in an sdk) instead of a java_library module (which is allowed). That test was fixed as part of this. A list of sdkMemberListProperty structs defines the member properties supported by the sdk and are processed in order to ensure consistent behaviour. The resolved dependencies are grouped by type and each group is then processed in defined order. Within each type dependencies are grouped by name and encapsulated behind an SdkMember interface which includes the name and the list of variants. The Droidstubs and java.Library types can only support one variant and will fail if given more. The processing for the native_shared_libs property has been moved into the cc/library.go file so the sdk package code should now have no type specific information in it apart from what is if the list of sdkMemberListProperty structs. Bug: 143678475 Test: m conscrypt-module-sdk Change-Id: I10203594d33dbf53441f655aff124f9ab3538d87
2019-12-03Merge "Add model to represent generated snapshot .bp file"Paul Duffin
2019-12-03Merge "Link type will be check in android_library also"Treehugger Robot
2019-12-02Add model to represent generated snapshot .bp filePaul Duffin
Having each module type generate the contents of the snapshot's .bp file results in lots of duplicated code. This adds an intermediate model for use by the module types and then generates the .bp file contents from that. This not only removes the duplicated formatting code but it also allows consistent handling of shared properties such as name further reducing duplication. It also makes it possible to duplicate the versioned and unversioned prebuilt modules from the same model. Extracts generatedContents from generatedFile to allow the contents to be populated without creating an output file, for testing. Cleans up unused code. Bug: 143678475 Test: m nothing Change-Id: If21b84db0ef3fdfb5dc11ea0973ce6cb73603ea3
2019-11-27Merge "Add exported_plugins to java.Library."Treehugger Robot
2019-11-26Add exported_plugins to java.Library.Artur Satayev
The behaviour is similar to go/be#java_library.exported_plugins. Plugins added to exported_plugins of library X are not applied to the library itself, but rather to libraries that directly depend on the library X. Test: m checkbuild Bug: 139740873 Change-Id: I4042bd482ad9cb12d6fbaac51f039d38b1b7a428
2019-11-26Dedup code for generating java_import in snapshotPaul Duffin
Removes duplicated code for generating a versioned and non-versioned form of the java_import module in the snapshot. Bug: 143678475 Test: m nothing and check output for dummy sdk Change-Id: Ia8d05c3bf9ef79953a817b168dd9d59f2af2d2ce
2019-11-14Refactor sdk update mechanismPaul Duffin
Creates a SnapshotBuilder and GeneratedSnapshotFile interfaces to allow the java library snapshot work to be moved into the java package. Test: m -j60 checkbuild Change-Id: I857167616026149d5e85885621b53876b419ba9b
2019-11-13make ApexProperties defaultableJooyung Han
ApexPropreties are added in InitApexModule() and they are supposed to be defaultable. To be defaultable, InitApexModule() should be called before InitDefaultableModule(). Bug: 144332048 Test: m (soong test added) Change-Id: I6c90ed3b66a086292a4c0ecb37c61f83769e62bd
2019-11-11Merge "Enforce hidden apis usage in product(soong)"Treehugger Robot
2019-11-09Merge "APEX now correctly tracks jni_lib dependencies"Treehugger Robot
2019-11-08APEX now correctly tracks jni_lib dependenciesJiyong Park
Bug: 144135069 Test: m (apex_test.go amended) Change-Id: If9dde4e2e62c2642267dbcac68bab76a032682c0
2019-11-07Silence dep-ann warningsColin Cross
Silence the dep-ann warnings until there is an effort to do something about them. Test: m framework-minus-apex doesn't print dep-ann warnings. Change-Id: Ic172e840dded4564fecfb91e96cba0c54358e20a
2019-11-06Enforce hidden apis usage in product(soong)Jeongik Cha
Only if PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE is set, every app and java library in product cannot use hidden APIs anymore. checkSdkVersion() checks if sdk_version of app and library is narrow enough, checkLinkType() checks every library that app links agianst Bug: 132780927 Test: m Test: set PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE, and check whether build error occurs. Change-Id: Ic630503b875040f730feda4fef826ed6d71da111
2019-11-01Link type will be check in android_library alsoJeongik Cha
For now, Soong checks link-type in java_library, so it cannot block hidden api usage from android_library that app links with. So we should add check in 'android_library' Test: m nothing Change-Id: Ic040270ec668bdd693b690ac8a88be1048922c3b
2019-10-31stem property of java modules are propagated to MakeJiyong Park
62c7829595c0df53e96addcd347c11ac01012eee introduced the new stem property to java modules, but it wasn't propagated to Make. Fixing the problem. This change also fixes a problem that (module name) == (file name) is assumed in dexpreopt_config.go, which no longer is the case. A mutator runs to build a map from module name to its stem. The map is then used when filling up the file paths in the bootImageConfig struct. Bug: 139391334 Bug: 143494499 Test: m Test: BootImageProfileTest Change-Id: Idbc894f877692401471130de6cbfe5e0dd129da9
2019-10-29Use java language 1.9 for sdk_version: "current"Colin Cross
Java language was set for 1.8 for anything building against the current SDK because the stubs were not built in Soong, so the system modules could not be built. The stubs have been built in Soong since Iabd32b30954b3f4a6d9a779fde52a032b684807e, but I5e870c34dd0ebc8ae3f888ec627da590c846a76f missed updating this TODO. Use 1.9 when building against the stubs, but continue using 1.8 for unbundled builds until we have prebuilt system modules. Always use the core-current-stubs-system-modules to avoid splitting android.* packages between the system modules and the classpath, which would cause new classes in android.* packages in classpath jars to be ignored. Add a new java9Classpath field to sdkDep that will contain the stubs jar when targeting Java language level 1.9, and plumb it through to javac and turbine. Rename the modules field to bootclasspath. Bug: 142896162 Test: m checkbuild Change-Id: Icfd32d0a863b2303a997c7cf03cb3708aade4724
2019-10-29Remove special case for sdk_version: "none"Colin Cross
The dependency handling for sdk_version: "none" (which propagated to !sdkDep.hasStandardLibs()) was very similar to the normal useModule case. Combine the cases by making decodeSdkDep set useModule: true and put the system modules in modules for the sdk_version: "none" case. Test: TestClasspath Change-Id: Icc9ff4d43a38da25cc0e3628be95951d61773ad5
2019-10-28Make javaVersion an enumColin Cross
Remove the hardcoded checks against "1.9" by making javaVersion an enum and implementing javaVersion.usesJavaModules(). Test: TestClasspath Change-Id: I559eeb1f45880bb8177269c6d977ee4dfbadce57
2019-10-28Merge "Remove support for EXPERIMENTAL_JAVA_LANGUAGE_LEVEL_9."Pete Gillin
2019-10-25Remove support for EXPERIMENTAL_JAVA_LANGUAGE_LEVEL_9.Pete Gillin
Prior to this change, setting that to "false" turned the default Java language level back to 8. This change removes that option. Bug: 115604102 Test: m java droid docs tests cts Change-Id: I97bfd0dc8d941008b4071c6efe1c0c24950c4f1f
2019-10-25add stem property to java modulesJiyong Park
java_library, java_import and dex_import now support stem property to set the output file name. Bug: 139391334 Test: m Merged-In: I11146badf558e524a973806114b9cb1344db4a6e (cherry picked from commit 62c7829595c0df53e96addcd347c11ac01012eee) Change-Id: I11146badf558e524a973806114b9cb1344db4a6e
2019-10-19Merge "Add tradefed_java_library_host"Treehugger Robot
2019-10-18Add tradefed_java_library_hostColin Cross
Add a module type for tradefed libraries that causes an additional copy to be installed at out/host/linux-x86/tradefed. Bug: 122332235 Bug: 141877526 Test: m tradefed Change-Id: Ib7160dd060ad83d2dfb81d6a7106cb0dac98553e
2019-10-18Merge "Prohibit dependencies outside of uses_sdks"Treehugger Robot
2019-10-17Merge "Add method to determine variations from a Target"Colin Cross
2019-10-17Prohibit dependencies outside of uses_sdksJiyong Park
When an APEX is built with uses_sdks, any depedndency from the APEX to the outside of the APEX should be from the SDKs that the APEX is built against. Bug: 138182343 Test: m Change-Id: I1c2ffe8d28ccf648d928ea59652c2d0070bf10eb
2019-10-16Add method to determine variations from a TargetColin Cross
The arch variants are hardcoded in every module type. Refactor them out into a Target.Variations() method in preparation for splitting the arch mutator into two, which will require using different variations. Test: m checkbuild Change-Id: I28ef7cd5168095ac888fe77f04e27f9ad81978c0
2019-10-15Merge "AIDEGen: Remove the duplicate *.srcjar from srcs"Treehugger Robot
2019-10-14AIDEGen: Remove the duplicate *.srcjar from srcspatricktu
AIDEGen collects the complied sources which are generated from build system, the sources includes not only java/kt files but also srcjar files. Since the srcjar files are record in srcjars parameter in json file, we should keep only java or kt files in the srcs parameter. The size diff of module_bp_java_deps.json: Without this patch: 15,298,369 Bytes With this patch: 15,044,804 Bytes The build time diff: Without this patch: 2m31.345 With this patch: 2m32.662 Bug: 141528361 Test: 1. m clean -j 2. aidegen tradefed 3. Open out/soong/module_bp_java_deps.json 4. Find the module CtsSyncManagerCommon and check the sync_manager_cts.srcjar files doesn't exist in srcs but exists in srcjars section. Change-Id: I43fc5c05b657473054e632cae4795220907dc711
2019-10-11Add system_modules to droidstubsPaul Duffin
This allows droidstubs to use the same system modules to create the stubs that will be used to compile them. It improves consistency and avoids droidstubs having to duplicate the libraries that make up the system modules on its libs property. Adds systemModules() to the sdkContext which allows consistent error checking behavior between droidstubs and java_library. Bug: 142534789 Test: m checkbuild Change-Id: Ib2006906d9528a900f16851f50b62152ffb51a1b
2019-10-03Separate InstallPath from OutputPathColin Cross
Create a new type InstallPath that is similar to OutputPath to differentiate intermediates output paths from installed output paths. RelPathString is a poorly defined, undocumented function that is primarily used to get an install path relative to out/soong to generate an equivalent install path for Make relative to $(OUT_DIR). Move it to InstallPath for now, and fix the one remaining user on OutputPath. Add a method to create an NDK install path so that ndk_sysroot.go doesn't have to do it manually with PathForOutput. Bug: 141877526 Test: m checkbuild Change-Id: I83c5a0bd1fd6c3dba8d3b6d20d039f64f353ddd5
2019-09-29Move sharding functions for reuseColin Cross
Move shardPaths and shardTests to android.ShardPaths and android.ShardStrings for reuse in other packages. Test: m checkbuild Change-Id: I868802872c73616b80f56cbf11f959c01a8b793a
2019-09-26Allow test to specify whether or not to auto-generate test configDan Shi
Attribute `auto_gen_config` is added to test modules. Test config will be generated if: the attribute is not set and AndroidTest.xml doesn't exists or the attribute is set to true, whether or not AndroidTest.xml exists. Test config will NOT be auto-generated if: the attribute is not set and AndroidTest.xml exists or the attribute is set to false, whether or not AndroidTest.xml exists. Bug: 141684102 Test: build test module with auto_gen_config set to true Change-Id: I64fb003a83d8c32a967835e5f8d12fe4476043be
2019-09-23Merge "Move sysprop gen code to sysprop module"Treehugger Robot
2019-09-23Merge "Add custom SystemModules to bootclasspath to reduce duplication"Paul Duffin
2019-09-23Move sysprop gen code to sysprop moduleInseob Kim
sysprop_library now generates srcjar itself, effectively cutting the implicit dependency from java module to sysprop module. Bug: 131637873 Test: m {sysprop_library}-dump-api Test: m (with no arguments) performs API check Change-Id: Ia11a744e74b6f733ff0e30d194fbba22505ed644
2019-09-23Merge "Introduce module type 'sdk'"Treehugger Robot
2019-09-22Introduce module type 'sdk'Jiyong Park
This change introduces a new module type named 'sdk'. It is a logical group of prebuilt modules that together provide a context (e.g. APIs) in which Mainline modules (such as APEXes) are built. A prebuilt module (e.g. java_import) can join an sdk by adding it to the sdk module as shown below: sdk { name: "mysdk#20", java_libs: ["myjavalib_mysdk_20"], } java_import { name: "myjavalib_mysdk_20", srcs: ["myjavalib-v20.jar"], sdk_member_name: "myjavalib", } sdk { name: "mysdk#21", java_libs: ["myjavalib_mysdk_21"], } java_import { name: "myjavalib_mysdk_21", srcs: ["myjavalib-v21.jar"], sdk_member_name: "myjavalib", } java_library { name: "myjavalib", srcs: ["**/*/*.java"], } An APEX can specify the SDK(s) that it wants to build with via the new 'uses_sdks' property. apex { name: "myapex", java_libs: ["libX", "libY"], uses_sdks: ["mysdk#20"], } With this, libX, libY, and their transitive dependencies are all built with the version 20 of myjavalib (the first java_import module) instead of the other one (which is for version 21) and java_library having the same name (which is for ToT). Bug: 138182343 Test: m (sdk_test.go added) Change-Id: I7e14c524a7d6a0d9f575fb20822080f39818c01e
2019-09-20Add custom SystemModules to bootclasspath to reduce duplicationPaul Duffin
Adds a library dependency to each of the dummy system modules created by testing.go so that any changes in the behavior were detected by the existing tests which were then fixed. Bug: 141359858 Test: m checkbuild Change-Id: Id4442f4aa3931ac93049f3367b96a5b49cc075e1