summaryrefslogtreecommitdiff
path: root/android/androidmk_test.go
AgeCommit message (Collapse)Author
2025-02-25Divorce disting from androidmk Cole Faust
Change AndroidMkEntries.getDistContributions and AndroidMkInfo.getDistContributions into a freestanding getDistContributions. This enables us to not call the AndroidMk related functions in soong-only builds. Bug: 398938465 Test: Diff'd the ninja files from "m nothing dist" before/after this cl, no changes Change-Id: I2f9d537c0d66f0ae3715f083e2f55436e4c0a59f
2025-02-24Remove DistFiles from AndroidMk datastructures Cole Faust
The code that collects dists also supports getting them from OutputFiles. Switch the few remaining usages of AndroidMk-based disted files over to OutputFiles, and remove DistFiles from the AndroidMk datastructures. This should allow us to clean up more AndroidMk code in a followup cl. Bug: 398938465 Test: Confirmed that the ninja files for "m nothing dist" don't change after this cl. Change-Id: I9eaed21018ef73ec36276556e7daa7201b272009
2025-02-12Don't panic in ModuleForTests and friends Colin Cross
Panicking in ModuleForTests and similar test helper functions was a mistake. Go's test runner stops running tests as soon as any test panics, which means debugging multiple tests panicking requires rerunning all the tests after fixing each panic to find the next one. Pass the *testing.T into ModuleForTests and friends so that it can call t.Fatalf instead. Test: all soong tests pass Change-Id: I5d0f2424eaf04fb795079e6d1e4b9469d8c7033c
2024-10-29Revert^2 "Convert cc modules to use AndroidMkInfoProvider." Yu Liu
This reverts commit 37e6794ad44926e64c1f733dbe32bbf5a40efe77. Reason for revert: reland with fix to the test Bug: 358427516 Test: Unit tests and manually compare generated mk files. Change-Id: Iddc34471f15cfe0c8ed863d05a1344e295925565
2024-10-17Revert "Convert cc modules to use AndroidMkInfoProvider." Priyanka Advani (xWF)
This reverts commit 5640008749795a6ebfb2680e28daa6b067207ce8. Reason for revert: Droidmonitor created revert due to b/374130363. Will be verifying through ABTD before submission. Change-Id: Iced10a8b71766826465966e9370cdd5e347e7b79
2024-10-15Convert cc modules to use AndroidMkInfoProvider. Yu Liu
Bug: 358427516 Test: Unit tests and manually compare generated mk files. Change-Id: I90d8ecb3580d6324ed53212d01d7c24b6e4bb700
2024-08-27Remove licenseMetadataFile and installFiles from ModuleBase. Yu Liu
Bug: 358425833 Test: Manually verified all the generated ninja and mk files and CI. Change-Id: I447ec74b7f9c3b8c686ed41511e2051f40ac88f8
2024-07-01Use OutputFilesProvider on some android test modules mrziwang
In the context of incremental soong, the output files inter-module-communication will be through OutputFilesProvider. The OutputFileProducer interface will be deprecated. Test: CI Bug: 339477385 Change-Id: I036323d390ec0a60911deba271a79f37c9c51fda
2024-06-27Revert "Use OutputFilesProvider on buildinfo_prop and some android test modules" Zi Wang
This reverts commit 89e4ff60d361cc7e0542f5da7a31c64f90b6d3b8. Reason for revert: build breakage on aosp-main/mainline_modules_sdks-trunk_staging-userdebug Change-Id: I5ddac59f66a0e7a96fab39647d406499e3875f6a
2024-06-27Use OutputFilesProvider on buildinfo_prop and some android test modules mrziwang
In the context of incremental soong, the output files inter-module-communication will be through OutputFilesProvider. The OutputFileProducer interface will be deprecated. Test: CI Bug: 339477385 Change-Id: Ic0c1217f3651b14ae3ac58a0ce4a25e8ab8d4dda
2022-06-01Make sure dist files have license metadata. Bob Badour
Bug: 151177513 Bug: 210912771 Test: m droid dist reportmissinglicenses Change-Id: I0c85f6c49a3e9d9bb3219ed6ddfb939d90f80656
2022-03-24Allow appending artifact in dist with product name Trevor Radcliffe
Some modules need to have their artifacts copied to dist with the product name appended. This CL enables that functionality in a boolean Soong property called append_artifact_with_product. Fixes: 224561567 Test: Unit tests and build relevant target/modules Change-Id: I4b824d4001679cebf0a9059be2d090d33a310933
2021-10-18Reduce modules exposed to Make in Mac builds Dan Willemsen
Device builds are no longer supported on Mac, but we do support building various host tools, including the SDK build-tools and platform-tools packages. These have dependencies on [java] device modules, so we don't completely disable device modules, only hide them from Make (which makes them more difficult to trigger from the command line). Also fix the mac build of multiproduct_kati, so that `m blueprint_tools` works on Mac. Bug: 187222815 Test: `m`, `m dist`, etc on Mac Change-Id: I92f16605d5cd173d431cbcb79081234d45cc6e2e
2021-03-22Remove uses of FixtureFactory from android package Paul Duffin
Bug: 183235980 Test: m nothing Change-Id: I72898ada020ee1a73fd534c61afb5c22fa00c1e5
2021-03-17Convert android/androidmk_test.go to test fixtures Paul Duffin
Bug: 182885307 Test: m nothing Change-Id: Ic3969988a6fa642be3e8fc23c8d008f13128b846
2021-02-19Add ctx to AndroidMkExtraEntriesFunc Colin Cross
Add a ctx parameter to AndroidMkExtraEntriesFunc to allow them to access providers. Test: m checkbuild Change-Id: Id6becc1e425c3c3d8519248f8c0ce80777fac7cc Merged-In: Id6becc1e425c3c3d8519248f8c0ce80777fac7cc
2020-11-27Generalize the handling of dist tags Paul Duffin
Previously in order to make use of dist entries with tag properties it was necessary for each module type to be modified to store the results of GenerateTaggedDistFiles(module) in the AndroidMkEntry.DistFiles property. This change generalizes that mechanism to work across all module types. This change does improve the behavior of a couple of tests where previously a dist with tag property was ignored because tagged dist files were not available now it is used correctly. Some module types do not implement OutputFileProducer interface and so they cannot handle dist with tag properties. This change makes it an error to attempt to do that. That necessitated adding OutputFiles(tag) method to customModule in queryview_test.go as some of the tests in that file used dist entries with tag properties. Follow up changes will remove the code that was made redundant by this. 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: Ifc54d67db10ce0d0fe8179c05b97a2be2113be4e
2020-11-27Differentiate between no dist tag and an empty dist tag Paul 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-27Improve test coverage of dist processing code Paul Duffin
This change adds some additional tests to cover the different combinations of setting OutputFile and DistFiles properties in the AndroidMkEntry. These tests will prevent follow up changes from inadvertently changing the behavior that some modules rely on. Test: m nothing Bug: 174226317 Change-Id: I6ab6f2711a5fa416ea2b84a1e0b8754d525d7a0c
2020-11-27Remove duplicate tests from TestGetDistForGoals Paul Duffin
A previous change duplicated the test cases from TestGetDistForGoals() to test the getDistContributions() method. This change removes the duplicate tests and leaves a single test to verify that GetDistForGoals() uses getDistContributions() and generateDistContributionsForMake() correctly. Test: m nothing Bug: 174226317 Change-Id: I545501016b932f9af0d5fda2f452a3a09932d3fb
2020-11-27Separate dist processing from make specific output Paul Duffin
Previously, the GetDistForGoals(Module) func combined the processing of the dist properties with generating the make specific rules for generating that dist. That has a couple of problems: 1. It combines two pieces of functionality into one method which is bad practice. 2. It makes it hard to test because the make specific output ends up containing absolute paths to temporary directories created by the test. 3. It makes switching to a non-make output difficult and fragile as changing the output will also require changing the tests. This change adds an intermediate data structure to contain the result of the dist processing. That processing is done by the new method getDistContributions(Module) which returns the new intermediate structure. It also adds generateDistContributionsForMake(..) to generate the make output. The GetDistForGoals(Module) func uses them to implement the previous behavior. It adds identical tests to those in TestGetDistForGoals() but leaves those tests alone to show that this refactoring does not change the behavior. Follow up changes will clean up TestGetDistForGoals(). It also adds a test for generateDistContributionsForMake(..). Bug: 174226317 Test: m nothing m dist sdk - before and after this change, compare result to make sure that there are no significant differences. Change-Id: I458b7c8e4485bf66d3498f50df85a8d65fc2ee00
2020-11-27Extract method to process bp file for androidmk_test.go Paul Duffin
Test: m nothing Bug: 174226317 Change-Id: Ifc9ee5088fe766d971718fc112d1e95719a2b825
2020-11-25Improve TestGetDistForGoals debuggability Paul Duffin
Previously, TestGetDistForGoals tested multiple test cases within a single test so when it failed it was difficult to determine which test case was the cause. This change runs each test case as its own nested test. It also corrects the order of expectedLine and line format parameters to match the order in the message. Test: m nothing Bug: 174226317 Change-Id: I1408ec4125afc5c0b392cd7643dd3f630fe468e5
2020-11-23Refactor 'in_make' to mean Kati is not skipped. Jingwen Chen
In Nougat and before, Make wrote a marker file to indicate that soong_build was invoked from Make to change certain behaviors of Soong at build time. https://cs.android.com/android/platform/superproject/+/android-7.1.2_r36:build/core/soong.mk;l=70-73;drc=ae18638b0406ad107b0882a02a13cdd8b92f2a4e Things have changed, and now soong_build is invoked from soong_ui, which supports a --skip-make configuration flag: https://cs.android.com/android/platform/superproject/+/master:build/soong/ui/build/build.go;l=31-33;drc=680387bf1d3ce7cbc77f535be7c42cec411b1687 Thus, the various remnants of 'EmbeddedInMake' and 'inMake' configuration are misleading, since soong_build is no longer invoked from Make. This CL refactors all instances to actually mean that Kati is enabled (not skipped with --skip-make), and will run after soong_build finishes, so Kati-specific behavior like the AndroidMk singleton should run. Test: TH presubmit Change-Id: I576ab8e54f99f5c8ddf9feaf9a828019b279e266
2020-11-12Pass Config to NewTestContext instead of ctx.Register Colin 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-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-06Make lots of tests run in parallel Colin 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-07-21Fix dist(s)-with-tag and add tests to prevent regression. Jingwen Chen
While AndroidMkEntries' DistFiles were populated from java_library properly, there was a bug in the conditionals that dropped the tagged DistFiles. Fixes b/152834186 Fixes b/161339864 Test: soong tests, m sdk dist (creates out/dist/test.jar with aosp/1363578) Signed-off-by: Jingwen Chen <jingwen@google.com> Change-Id: Id895282256fd367b2f46dcb7a643465fa66c9456
2020-06-25Support multiple dists per Android.bp module, and dist output selection. Jingwen Chen
This CL adds "dists" to the base property struct to support multiple dist file configurations, and generic tag support to dist tagged outputs of modules. Fixes: b/152834186 Test: soong tests and `m sdk dist` Change-Id: I80c86bc9b7b09e671f640a4480c45d438bdd9a2a Signed-off-by: Jingwen Chen <jingwen@google.com>
2019-12-18Move filesystem into Config Colin Cross
The filesystem object was available through ModuleContext.Fs(), but gives too much access to the filesystem without enforicing correct dependencies. In order to support sandboxing the soong_build process move the filesystem into the Config. The next change will make it private. Bug: 146437378 Test: all Soong tests Change-Id: I5d3ae9108f120fd335b21efd612aefa078378813
2019-11-25Make TestContext.RegisterModuleType take an android.ModuleFactory Colin Cross
Avoid having to pass ModuleFactoryAdaptor to every call to RegisterModuleType in a test by wrapping RegisterModuleType. Test: all soong tests Change-Id: If8847d16487de0479cc3020b728256922b3cadba
2019-07-16soong: Fix AndroidMk with *Required properties Jooyung Han
java.Module is using "Custom" function to write Android.mk. And if "hostdex" is set to "true", it writes "hostdex" module definition as well as original module. As of now, Required/Host_required/Target_required props are filled in the AndroidMkEntries structure(aosp/939505). But these are not passed to old AndroidMkData.Custom function. So, if a java_library declares "hostdex:true" and "required:[...]" together, "required" is not applied to the "hostdex" variant. This change copies *Required props from AndroidMkEntries to AndroidMkData before calling its Custom callback. Test: m (runs soong unit tests) Change-Id: I5f85714f721a2a0917ab18072dbea52294c770e7