summaryrefslogtreecommitdiff
path: root/sdk/sdk.go
AgeCommit message (Collapse)Author
2019-12-12Added support for using static libraries in sdk snapshot Paul Duffin
Parameterized the cc.librarySdkMemberType to allow it to support both static and shared libraries. Created two instances, one for shared and one for static libraries. A follow up change will add support for libraries that can be both. Added *librarySdkMemberType to nativeMemberInfo as information from there is needed when generating the snapshot. Made organizeVariants() func a method of *librarySdkMemberType so that it can initialize the new field. Moved it to be with all the other methods of that type. Added host and device tests for the new module type. Bug: 142918168 Test: m nothing Change-Id: I00b1e8424b9d81f7d15edc4883971d10668ec2cc
2019-12-12Sort sdkProperties by package and then name Paul Duffin
Bug: 143678475 Test: m nothing Change-Id: Ib610b799e7d86b413f4321239535a1caf4775ed9
2019-12-11AndroidMkEntries() returns multiple AndroidMkEntries structs Jiyong Park
AndroidMkEntries now returns multiple AndroidMkEntires so that a module can emit multiple Make modules if needed. Bug: 128708192 Test: m Change-Id: I56b6f76d22943b80329951c5acb80a1b932441ad
2019-12-06Support header and implementation jars in sdk Paul 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-06Organize sdk member properties Paul Duffin
Grouping in alphabetical order by package and then by name within the package should minimize conflicts when making changes. Bug: 143678475 Test: m conscrypt-module-sdk Change-Id: Ia7dbcd41ce8b8dd8675a90b1b6868fcaeaf72ee4
2019-12-06Parameterize the sdk member processing Paul 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-06Use static build rules in snapshot generation Paul Duffin
It is easier to extract information out of static build rules than it is out of custom build rules built using the builder as the former provides access to the in/out and args separate from the rule whereas the latter only provides access to in/out. Also, cleans up some warnings that appear in Intellij. There is a lot of duplication in the testing code. That will be resolved in a follow up change. Bug: 143678475 Test: m conscrypt-module-sdk Change-Id: I973bc0c90b0affd84487f1b222dd3e6c22c07ec0
2019-11-28Remove unused frozenVersions() method Paul Duffin
Bug: 143678475 Test: m nothing Change-Id: Ia5d417cfccfcd90b02a95b5b806b211b97e340db
2019-11-26Check the contents of an SDK snapshot's generated Android.bp Paul Duffin
Test: m nothing Bug: 143678475 Change-Id: I407d83c79d6b1ad8082e560726f0bfa7cacab3f0
2019-11-25Merge changes I0dcc9c7b,I9bc40642 Colin Cross
* changes: Move cc.imageMutator into the android package Make CreateVariations return []android.Module
2019-11-22Adds droidstubs support to sdk module Paul Duffin
Adds stubs_sources property to sdk and unzips the droidstubs srcjar into the snapshot directory. Adds an UnzipToSnapshot method to the SnapshotBuilder which creates a rule that uses zip2zip to repackage the supplied zip content into a temporary zip file that matches what the required snapshot structure. e.g. if the supplied zip contains foo/Foo.java and that needs to be in the snapshot directory java/foo/stubs then it will create a zip that contains java/foo/stubs/foo/Foo.java. The temporary zip that is the output of that rule is added to the zipsToMerge field for merging later. If the zipsToMerge is empty then the snapshot zip is created as before. Otherwise, a temporary zip file is created. That is then merged with the other zip files in zipsToMerge to create the final snapshot zip. Adds prebuilt_stubs_sources for use by the generated .bp module. Bug: 143678475 Test: added conscrypt sdk module and attempted to build it Change-Id: Ie274263af3a08e36a73c61c0dbf0c341fd6967e2
2019-11-22Simplify building an SDK snapshot from the command line Paul Duffin
Adds a phony target for each sdk module that builds the snapshot zip. Test: built an sdk module from command line and checked the zip was created. Bug: 143678475 Change-Id: I4599332443b8da9adea0a16f00f569ffbd421602
2019-11-20Move cc.imageMutator into the android package Colin Cross
Prepare for making the image mutator available to all modules and moving it between the os and arch mutators by moving it into the android package and using an interface implemented by the module types to control it. Bug: 142286466 Test: No unexpected changes to out/soong/build.ninja Change-Id: I0dcc9c7b5ec80edffade340c367f6ae4da34151b
2019-11-07SDK snapshot is dist'ed Jiyong Park
`m module_sdk dist` produces snapshots of all SDKs in the source tree. A snapshot is a zip file consists of Android.bp, exported headers, exported AIDL files, stubs for native libs and jars. The zip file is expected to be downloaded from the build server and extracted to a directory (which probably will be /prebuilts/module_sdks/<module_name>/current). Bug: 138182343 Test: m (sdk_test.go updated) Change-Id: Idbe4bc24795fe08f26fc1cf7497028f9d162053a
2019-11-06sdk modules are by default compile_multilib: "both" Jiyong Park
Bug: 143948100 Test: m (sdk_test.go amended) Change-Id: I7df1b96af49a6569012e44eeb3c0722fac63fa51
2019-10-29native shared libs in an SDK can be snapshotted Jiyong Park
The snapshot script can now handle native shared libs in an SDK. Bug: 138182343 Test: create following sdk module: sdk { name: "mysdk", native_shared_libs: ["libc", "libdl"], } , then execute `m mysdk` and execute the update_prebuilt-1.sh as prompted. Following directories are generated under the directory where mysdk is defined at: 1 ├── aidl ├── Android.bp ├── arm64 │   ├── include │   ├── include_gen │   └── lib │   ├── libc.so │   └── libdl.so ├── include │   └── bionic │   └── libc │   └── include │   ├── alloca.h │   ├── android │   │   ├── api-level.h <omitted> Change-Id: Ia1dcc5564c1cd17c6ccf441d06d5995af55db9ee
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_sdks Jiyong 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 Target Colin 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-15Create scripts to update and freeze a module SDK Jiyong Park
`m <sdk_name>` generates two scripts each of which is use to update the current snapshot of the SDK and to freeze ToT as a new version, respectively. Executing the scripts will copy necessary files (stub libraries, AIDL files, etc.) along with Android.bp into the ./<apiver> directory under the directory where the sdk is defined. This change also introduces a new module type 'sdk_snapshot' that represents a snapshot of an SDK. It will be auto-generated by the above scripts, so developers are not expected to write this manually. The module type 'sdk' is now used to simply specify the list of modules that an SDK has. Finally, this change changes the version separator from '#' to '@' because '#' confuses Make. Bug: 138182343 Test: m Change-Id: Ifcbc3a39a2f6ad5b4f4b200ba55a1ce3281498cf
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