api_domain_conversion_test.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Copyright 2022 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 bp2build
  15. import (
  16. "testing"
  17. "android/soong/android"
  18. "android/soong/cc"
  19. )
  20. func registerApiDomainModuleTypes(ctx android.RegistrationContext) {
  21. android.RegisterApiDomainBuildComponents(ctx)
  22. cc.RegisterNdkModuleTypes(ctx)
  23. cc.RegisterLibraryBuildComponents(ctx)
  24. }
  25. func TestApiDomainContributionsTest(t *testing.T) {
  26. bp := `
  27. api_domain {
  28. name: "system",
  29. cc_api_contributions: [
  30. "libfoo.ndk",
  31. "libbar",
  32. ],
  33. }
  34. `
  35. fs := map[string]string{
  36. "libfoo/Android.bp": `
  37. ndk_library {
  38. name: "libfoo",
  39. }
  40. `,
  41. "libbar/Android.bp": `
  42. cc_library {
  43. name: "libbar",
  44. }
  45. `,
  46. }
  47. expectedBazelTarget := MakeBazelTargetNoRestrictions(
  48. "api_domain",
  49. "system",
  50. AttrNameToString{
  51. "cc_api_contributions": `[
  52. "//libfoo:libfoo.ndk.contribution",
  53. "//libbar:libbar.contribution",
  54. ]`,
  55. "target_compatible_with": `["//build/bazel/platforms/os:android"]`,
  56. },
  57. )
  58. RunApiBp2BuildTestCase(t, registerApiDomainModuleTypes, Bp2buildTestCase{
  59. Blueprint: bp,
  60. ExpectedBazelTargets: []string{expectedBazelTarget},
  61. Filesystem: fs,
  62. })
  63. }