ndk_library_conversion_test.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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/cc"
  18. )
  19. func TestNdkLibraryContributionSymbolFile(t *testing.T) {
  20. bp := `
  21. ndk_library {
  22. name: "libfoo",
  23. symbol_file: "libfoo.map.txt",
  24. }
  25. `
  26. expectedBazelTarget := MakeBazelTargetNoRestrictions(
  27. "cc_api_contribution",
  28. "libfoo.ndk.contribution",
  29. AttrNameToString{
  30. "api": `"libfoo.map.txt"`,
  31. "api_surfaces": `["publicapi"]`,
  32. "library_name": `"libfoo"`,
  33. "target_compatible_with": `["//build/bazel/platforms/os:android"]`,
  34. },
  35. )
  36. RunApiBp2BuildTestCase(t, cc.RegisterNdkModuleTypes, Bp2buildTestCase{
  37. Blueprint: bp,
  38. ExpectedBazelTargets: []string{expectedBazelTarget},
  39. })
  40. }
  41. func TestNdkLibraryContributionHeaders(t *testing.T) {
  42. bp := `
  43. ndk_library {
  44. name: "libfoo",
  45. symbol_file: "libfoo.map.txt",
  46. export_header_libs: ["libfoo_headers"],
  47. }
  48. `
  49. fs := map[string]string{
  50. "header_directory/Android.bp": `
  51. ndk_headers {
  52. name: "libfoo_headers",
  53. }
  54. `,
  55. }
  56. expectedBazelTarget := MakeBazelTargetNoRestrictions(
  57. "cc_api_contribution",
  58. "libfoo.ndk.contribution",
  59. AttrNameToString{
  60. "api": `"libfoo.map.txt"`,
  61. "api_surfaces": `["publicapi"]`,
  62. "library_name": `"libfoo"`,
  63. "hdrs": `["//header_directory:libfoo_headers.contribution"]`,
  64. "target_compatible_with": `["//build/bazel/platforms/os:android"]`,
  65. },
  66. )
  67. RunApiBp2BuildTestCase(t, cc.RegisterNdkModuleTypes, Bp2buildTestCase{
  68. Blueprint: bp,
  69. Filesystem: fs,
  70. ExpectedBazelTargets: []string{expectedBazelTarget},
  71. })
  72. }