csuite_config.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Copyright 2019 Google Inc. All rights reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package android
  15. func init() {
  16. registerCSuiteBuildComponents(InitRegistrationContext)
  17. }
  18. func registerCSuiteBuildComponents(ctx RegistrationContext) {
  19. ctx.RegisterModuleType("csuite_config", CSuiteConfigFactory)
  20. }
  21. type csuiteConfigProperties struct {
  22. // Override the default (AndroidTest.xml) test manifest file name.
  23. Test_config *string
  24. }
  25. type CSuiteConfig struct {
  26. ModuleBase
  27. properties csuiteConfigProperties
  28. OutputFilePath OutputPath
  29. }
  30. func (me *CSuiteConfig) GenerateAndroidBuildActions(ctx ModuleContext) {
  31. me.OutputFilePath = PathForModuleOut(ctx, me.BaseModuleName()).OutputPath
  32. }
  33. func (me *CSuiteConfig) AndroidMkEntries() []AndroidMkEntries {
  34. androidMkEntries := AndroidMkEntries{
  35. Class: "FAKE",
  36. Include: "$(BUILD_SYSTEM)/suite_host_config.mk",
  37. OutputFile: OptionalPathForPath(me.OutputFilePath),
  38. }
  39. androidMkEntries.ExtraEntries = []AndroidMkExtraEntriesFunc{
  40. func(ctx AndroidMkExtraEntriesContext, entries *AndroidMkEntries) {
  41. if me.properties.Test_config != nil {
  42. entries.SetString("LOCAL_TEST_CONFIG", *me.properties.Test_config)
  43. }
  44. entries.AddCompatibilityTestSuites("csuite")
  45. },
  46. }
  47. return []AndroidMkEntries{androidMkEntries}
  48. }
  49. func InitCSuiteConfigModule(me *CSuiteConfig) {
  50. me.AddProperties(&me.properties)
  51. }
  52. // csuite_config generates an App Compatibility Test Suite (C-Suite) configuration file from the
  53. // <test_config> xml file and stores it in a subdirectory of $(HOST_OUT).
  54. func CSuiteConfigFactory() Module {
  55. module := &CSuiteConfig{}
  56. InitCSuiteConfigModule(module)
  57. InitAndroidArchModule(module, HostSupported, MultilibFirst)
  58. return module
  59. }