aboutsummaryrefslogtreecommitdiffstats
path: root/sdk/sdk_test.go
Commit message (Collapse)AuthorAgeFilesLines
* Fix special case when appending a visibility rule to //visibility:private.Martin Stjernholm2020-05-161-0/+24
| | | | | | | | Test: m nothing Bug: 151303681 Merged-In: Ibe7e953219e4660c653063e87cb08407a2cb513d Change-Id: Ibe7e953219e4660c653063e87cb08407a2cb513d (cherry picked from commit 64aeaaddef14cf83a6ffeca5c683a989c07fda7d)
* Add explicit visibility on the self package in EffectiveVisibilityRules.Martin Stjernholm2020-05-161-4/+16
| | | | | | | | | | | | | | | | Modules in a package is implicitly visible within the same package. When making effective visibility rules which work from another location that visibility needs to be mentioned explicitly. In practice this allows prebuilts to remain visible to other modules in the source package when the prebuilts are preferred. Test: m nothing Test: m conscrypt-module-sdk, check that the snapshot Soong modules give visibility to //external/conscrypt Bug: 151303681 Merged-In: I404f6e5ca7021974a8c7be5e4d6b4982c050b8a5 Change-Id: I404f6e5ca7021974a8c7be5e4d6b4982c050b8a5 (cherry picked from commit 0641d189d0cbf26cd23d584e621fc944c00abb46)
* Don't print :__pkg__ for package rules, since that's the default.Martin Stjernholm2020-05-161-5/+5
| | | | | | | | | | | | To reduce clutter a little. // Added for rvc-dev. Used this bug as it is the bug that needs all the build changes. Bug: 155164730 Test: m nothing Merged-In: I0d2d86f00c3d38e603d6f58c4b1dd9a4170bf819 Change-Id: I0d2d86f00c3d38e603d6f58c4b1dd9a4170bf819 (cherry picked from commit 01407c525aa0c6326049a4c9179d74188ef4f86b)
* Retry: Adds support for 'ignored-on-host'Paul Duffin2020-05-101-1/+4
| | | | | | | | | | | | | | | | | | | Adds a filter mechanism that can exclude property values from being included in the common value extraction. That is needed to prevent the snapshot mechanism from generating invalid output for properties that are ignored on host (and have their values cleared) and which are not tagged with `android:"arch_variant"`. Changes: * Updates the documentation of SdkMemberType to explain what effect the 'ignored-on-host' tag has. * Adds some tests for this new mechanism. Bug: 155628860 Test: m nothing Merged-In: Ibafdb6e921ba5abe505bd8a91ca5a1d9c9b5d0cb Change-Id: Ibafdb6e921ba5abe505bd8a91ca5a1d9c9b5d0cb (cherry picked from commit c459f89fb46e163eb57f1fc41e4a79383785db32)
* Retry: Detect invalid arch specific properties in snapshotPaul Duffin2020-05-101-5/+28
| | | | | | | | | | | | | | | | | | | Previously, the snapshot code did not know whether a specific property could be arch specific or not and assumed that they all were which meant that it could generate snapshots containing arch specific values for properties that are not arch specific and so would fail when unpacked. This change requires arch specific fields in SdkMemberProperties to be tagged as such using `android:"arch_variant"` (just as in module input property structures). Any property without that must have properties that are common across all variants. Bug: 155628860 Test: m nothing Merged-In: I3df60f0b53ba02ec2c55a80c7da058eac5909d26 Change-Id: I3df60f0b53ba02ec2c55a80c7da058eac5909d26 (cherry picked from commit 864e1b45dbf90e0b79b767be385e5f57f3dbdd25)
* Allow extractCommonProperties to return an errorPaul Duffin2020-05-071-1/+13
| | | | | | | | | | | | | | | | | | Refactoring in preparation for follow up changes. Also: * Adds a new AssertErrorMessageEquals() helper method. * Improved error reporting in the accessor and added name to extractorProperty to ensure meaningful errors are reported. * Added String() string method to propertiesContainer. * Reports errors using the field name as the errors are not really fixable by developers and it is more meaningful to the build team. Bug: 155628860 Test: m nothing Merged-In: I5c5b8436bcbc39e4e7cd35df2577b2dac53e702a Change-Id: I5c5b8436bcbc39e4e7cd35df2577b2dac53e702a (cherry picked from commit 4b8b79394fa5eeddc532aa9e38870dd1c3a291b5)
* Correct order of parameters to AssertDeepEqualsPaul Duffin2020-05-071-6/+9
| | | | | | | | | | The expected/actual were around the wrong way. Bug: 155628860 Test: m nothing Merged-In: I98b575b8b85dcbfd2075e77689f0329aa2eadbf0 Change-Id: I98b575b8b85dcbfd2075e77689f0329aa2eadbf0 (cherry picked from commit 1d6c0df597d939ae408ba90214f023086fb13aed)
* Encapsulate properties to be optimized in a containerPaul Duffin2020-05-071-1/+5
| | | | | | | | | | | | This allows additional metadata to be associated with a set of properties that will be used in a follow up change to filter properties that are ignored in some variants (e.g. host variants). Bug: 155628860 Test: m nothing Merged-In: Ie83c1ffbb71fd5d7a08d350571dad3e3209b1431 Change-Id: Ie83c1ffbb71fd5d7a08d350571dad3e3209b1431 (cherry picked from commit f34f6d853876b2a8e8e1b4d04e0b0e07dd007a04)
* Support extracting common values from embedded structuresPaul Duffin2020-04-221-0/+105
| | | | | | | | | | | | | | | | This change also added support for excluding properties from common value extraction by using a struct tag of `sdk:"keep"` That was needed to prevent the fields in SdkMemberPropertiesBase from having their values cleared. The purpose of this change is to make it easier to share functionality across sdk member types. Bug: 142935992 Bug: 153306490 Test: m nothing Merged-In: Ie5160a8f854056920e411801ca20721eab7c8578 Change-Id: Ie5160a8f854056920e411801ca20721eab7c8578
* Add a nice install paths for module SDKs and exports.Nicolas Geoffray2020-04-221-0/+16
| | | | | | | | | | Following how NDK also creates its own install path. Bug: 142935992 Bug: 153306490 Test: cc_sdk_test.go, java_sdk_test.go Merged-In: I98a3656903f37f6d7c90e6cf609431b2461a6161 Change-Id: I98a3656903f37f6d7c90e6cf609431b2461a6161
* Add CommonOS variant for sdkPaul Duffin2020-04-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Adds a CommonOS variant for sdk that depends on the os specific variants and is used to generate a single sdk for multiple OsTypes, e.g. host linux and android. At the minute the member types only support a single OsType but the basic mechanism for managing the CommonOS variant and collating the variants across all of them is there. The only visible effect of this change is that the location of the generated snapshot is changed, it is no longer os specific and instead is in the same location irrespective of which os it is built for. A lot of tests needed to be changed to specify "common_os" as the variant type instead of the specific os type. As that is the same across all tests it is hard coded in CheckSnapshot method. Bug: 153306490 Test: m nothing Bug: 150451422 Merged-In: If36be39b06d6910453649f7c288c2d34f688b2f4 Change-Id: If36be39b06d6910453649f7c288c2d34f688b2f4
* Fix apex_availableJooyung Han2020-03-111-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Checking apex_available was missing some corner cases. For example, the deps of share deps of cc_library modules are missed while those from cc_library_shared are correctly tracked. This was due to.. * calling DepIsInSameApex in WalkDeps: both work fine separately, but when they are used together, it fails to work. It's due to how WalkDeps works. (We might fix this bug too risky since it is used very widely) * incorrect receiver for DepIsInSameApex in apex_deps mutator: receiver is supposed to be parent, but child was used before. Interestingly lots of deps are within the same group of module types(cc to cc, java to java), it has worked. (note that receiver's DepIsInSameApex implementation can be different). This change fixes them by.. * walkPayloadDeps is now relying on ApexVariation, which is calculated correctly by TopDown apex_deps mutator. * use correct receiver for DepIsInSameApex in apex_deps mutator, which requires for java.SdkLibrary to override the method and for java.Library/Import to use passed dep instead of receiver to check its membership of sdk. Exempt-From-Owner-Approval: cherry-pick from aosp/master Bug: 151071238 Test: build/boot Merged-In: I0569ef4bb8e79635e4d97a89f421a8d8b7d26456 (cherry picked from commit 5e9013be2202effb500a0aa14d95f5fef70cc75e) Change-Id: I0569ef4bb8e79635e4d97a89f421a8d8b7d26456
* Simplify visibility rules that include //visibility:publicPaul Duffin2020-02-201-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | While it is invalid to mix //visibility:public with other rules in the visibility property in a .bp file tt was possible, by overriding defaults, to have //visibility:public mixed in with other rules in the effective visibility rules. That caused problems when those effective rules were used in an sdk snapshot. This change replaces any set of rules that include //visibility:public with just the //visibility:public rule. That simplifies those rules, making them cheaper to process and ensures that the effective rules are valid in the visibility property. Adding test support required some refactoring of the effectiveVisibilityRules(BaseModuleContext, ...) and underlying methods to take a Config instead of BaseModuleContext as the tests do not have access to BaseModuleContext. Bug: 142935992 Test: m nothing - new tests failed without change, work with it Add dex2oat to art-module-host-exports, build it and check the generated Android.bp file in the snapshot to ensure the visibility property for the dex2oat prebuilt does not mix //visibility:public with other rules. Change-Id: I08e7f0dcb40838d426fe88fedf69eae27b77473c
* Ensure prebuilt modules have same visibility as source modulesPaul Duffin2019-12-091-0/+120
| | | | | | | | | | | | | | | | | | | | | | | | | Exports visibility and package mutator registration functions so they can be used in sdk testing. Updates sdk test to support visibility and package modules. Adds EffectiveVisibility(...)[]string function to make the effective visibility rules available to sdk snapshot creation. Extracts compositeRule.Strings() []string from compositeRule.String() method so that it can be used by above func. Adds visibility property to sdk snapshot and prebuilt modules along with a test to ensure it works properly. Adds dir parameter to CheckSnapshot so that it can check the snapshot generated for a non-root package. That is required in order to ensure that visibility of :__subpackages__ on a source module in package <pkg> is resolved to an effective visibility of //<pkg>:__subpackages__ on its corresponding prebuilt. Test: m conscrypt-module-sdk Bug: 143678475 Change-Id: Icaacac5b9c04726d28e6fec93e49715ac45df7f4
* Support header and implementation jars in sdkPaul Duffin2019-12-061-2/+2
| | | | | | | | | | | | | | 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
* Extract the cc and java sdk related tests out into their own filePaul Duffin2019-12-061-524/+0
| | | | | | | | | Makes it easier for multiple people to work on different areas without conflicts. Bug: 143678475 Test: m conscrypt-module-sdk Change-Id: I93140450c0b049946a9d0432225bccff82f5a873
* Improve testing of sdk snapshot generationPaul Duffin2019-12-061-128/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds TestHelper to provide general test helper functionality for use by any test. Adds testSdkResult, composed with TestHelper that encapsulates the result of processing and sdk {..} definition and provides specialized support for testing the build rules. Dedups the analysis of the sdk build rules, and improves it to extract more information, and in different forms. That is represented by the snapshotBuildInfo struct. Adds a CheckSnapshot() method which checks the snapshot for a specified sdk version. It takes a list of functions that can each perform a check on a specific facet of the supplied snapshotBuildInfo. Methods are provided for tests to use to check the following facets: * Generated Android.bp contents. * Copy rules * Merge zip inputs This approach makes it possible for each test to customize what is being checked without either duplicating functionality, causing a proliferation of specialized forms of the CheckSnapshot method for different types of tests or adding arguments for every possible check that any test would need which would lead to lots of churn to existing tests when new arguments are added. The main testing improvement is for CheckSnapshot() to actually try and load the Android.bp that is generated. In order to do that it was necessary to create a mock filesystem populated with information from the build rules, i.e. the destination files from every Cp command as well as the destination directory from every repackage zip command. That helps detect a number of sources of errors: * Failing to copy a file/directory that is mentioned in the generated Android.bp file. * Invalid properties. * Invalid format of the .bp file. * Integrity issues within the .bp file. Bug: 143678475 Test: m conscrypt-module-sdk Change-Id: I4d3fe18f86698186d18e7e8b32d2e319183f7f0c
* Separate sdk testing infrastructure from sdk testsPaul Duffin2019-12-061-170/+3
| | | | | | Bug: 143678475 Test: m conscrypt-module-sdk Change-Id: Ib00870ddefc4c1dd9e42ca594e6ebe8e24c42e05
* Parameterize the sdk member processingPaul Duffin2019-12-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Use static build rules in snapshot generationPaul Duffin2019-12-061-31/+43
| | | | | | | | | | | | | | | | 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
* Disable TestHostSnapshot test for non-linux buildPaul Duffin2019-12-041-0/+10
| | | | | | | | | Building sdk snapshots on anything other than linux glibc is not supported at the moment. Bug: 145598135 Test: m nothing Change-Id: I34155252545e9f37c5361ed94a27a87024fcece2
* Add support for host sdkPaul Duffin2019-12-021-0/+192
| | | | | | | | | | | | Adds HostSupported() method to ModuleBase for use by sdk. Adds host_supported/device_supported to all prebuilt modules and the sdk snapshot (where necessary). Adds TestHostSnapshot to verify the behavior is correct. Bug: 143678475 Test: m nothing Change-Id: I8b4d097e46d5804f62cb8f651a83069299a3e639
* Add model to represent generated snapshot .bp filePaul Duffin2019-12-021-9/+3
| | | | | | | | | | | | | | | | | | | | | 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
* Remove unused methods from sdk/sdk_test.goPaul Duffin2019-11-291-23/+0
| | | | | | Bug: 143678475 Test: m conscrypt-module-sdk Change-Id: Ic011fd63b226beb455793e2df08114992b858698
* Dedup code for generating prebuilt_stubs_sources in snapshotPaul Duffin2019-11-261-1/+1
| | | | | | | | | | Removes duplicated code for generating a versioned and non-versioned form of the prebuilt_stubs_sources module in the snapshot. Bug: 143678475 Test: m nothing Change-Id: Ic431b6fcb6f3c7c85f1a04cb6f087424aaf0cffa
* Check the contents of an SDK snapshot's generated Android.bpPaul Duffin2019-11-261-1/+98
| | | | | | Test: m nothing Bug: 143678475 Change-Id: I407d83c79d6b1ad8082e560726f0bfa7cacab3f0
* Merge changes I0dcc9c7b,I9bc40642Colin Cross2019-11-251-1/+1
|\ | | | | | | | | | | * changes: Move cc.imageMutator into the android package Make CreateVariations return []android.Module
| * Move cc.imageMutator into the android packageColin Cross2019-11-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | 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
* | Make TestContext.RegisterModuleType take an android.ModuleFactoryColin Cross2019-11-251-16/+16
| | | | | | | | | | | | | | | | Avoid having to pass ModuleFactoryAdaptor to every call to RegisterModuleType in a test by wrapping RegisterModuleType. Test: all soong tests Change-Id: If8847d16487de0479cc3020b728256922b3cadba
* | Adds droidstubs support to sdk modulePaul Duffin2019-11-221-1/+63
|/ | | | | | | | | | | | | | | | | | | | | | | | | | 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
* SDK snapshot is dist'edJiyong Park2019-11-071-1/+69
| | | | | | | | | | | | | | `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
* sdk modules are by default compile_multilib: "both"Jiyong Park2019-11-061-0/+29
| | | | | | Bug: 143948100 Test: m (sdk_test.go amended) Change-Id: I7df1b96af49a6569012e44eeb3c0722fac63fa51
* Prohibit dependencies outside of uses_sdksJiyong Park2019-10-171-0/+74
| | | | | | | | | | | 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
* Create scripts to update and freeze a module SDKJiyong Park2019-10-151-10/+21
| | | | | | | | | | | | | | | | | | | | | | | `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
* Introduce module type 'sdk'Jiyong Park2019-09-221-0/+318
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