sysprop.go 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // Copyright (C) 2019 The Android Open Source Project
  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 cc
  15. import (
  16. "android/soong/android"
  17. "android/soong/bazel"
  18. )
  19. // TODO(b/240463568): Additional properties will be added for API validation
  20. type bazelSyspropLibraryAttributes struct {
  21. Srcs bazel.LabelListAttribute
  22. Tags bazel.StringListAttribute
  23. }
  24. type bazelCcSyspropLibraryAttributes struct {
  25. Dep bazel.LabelAttribute
  26. Min_sdk_version *string
  27. Tags bazel.StringListAttribute
  28. }
  29. type SyspropLibraryLabels struct {
  30. SyspropLibraryLabel string
  31. SharedLibraryLabel string
  32. StaticLibraryLabel string
  33. }
  34. func Bp2buildSysprop(ctx android.Bp2buildMutatorContext, labels SyspropLibraryLabels, srcs bazel.LabelListAttribute, minSdkVersion *string) {
  35. apexAvailableTags := android.ApexAvailableTagsWithoutTestApexes(ctx.(android.TopDownMutatorContext), ctx.Module())
  36. ctx.CreateBazelTargetModule(
  37. bazel.BazelTargetModuleProperties{
  38. Rule_class: "sysprop_library",
  39. Bzl_load_location: "//build/bazel/rules/sysprop:sysprop_library.bzl",
  40. },
  41. android.CommonAttributes{Name: labels.SyspropLibraryLabel},
  42. &bazelSyspropLibraryAttributes{
  43. Srcs: srcs,
  44. Tags: apexAvailableTags,
  45. },
  46. )
  47. attrs := &bazelCcSyspropLibraryAttributes{
  48. Dep: *bazel.MakeLabelAttribute(":" + labels.SyspropLibraryLabel),
  49. Min_sdk_version: minSdkVersion,
  50. Tags: apexAvailableTags,
  51. }
  52. if labels.SharedLibraryLabel != "" {
  53. ctx.CreateBazelTargetModule(
  54. bazel.BazelTargetModuleProperties{
  55. Rule_class: "cc_sysprop_library_shared",
  56. Bzl_load_location: "//build/bazel/rules/cc:cc_sysprop_library.bzl",
  57. },
  58. android.CommonAttributes{Name: labels.SharedLibraryLabel},
  59. attrs)
  60. }
  61. ctx.CreateBazelTargetModule(
  62. bazel.BazelTargetModuleProperties{
  63. Rule_class: "cc_sysprop_library_static",
  64. Bzl_load_location: "//build/bazel/rules/cc:cc_sysprop_library.bzl",
  65. },
  66. android.CommonAttributes{Name: labels.StaticLibraryLabel},
  67. attrs)
  68. }