sysprop.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. }
  23. type bazelCcSyspropLibraryAttributes struct {
  24. Dep bazel.LabelAttribute
  25. Min_sdk_version *string
  26. }
  27. type SyspropLibraryLabels struct {
  28. SyspropLibraryLabel string
  29. SharedLibraryLabel string
  30. StaticLibraryLabel string
  31. }
  32. func Bp2buildSysprop(ctx android.Bp2buildMutatorContext, labels SyspropLibraryLabels, srcs bazel.LabelListAttribute, minSdkVersion *string) {
  33. ctx.CreateBazelTargetModule(
  34. bazel.BazelTargetModuleProperties{
  35. Rule_class: "sysprop_library",
  36. Bzl_load_location: "//build/bazel/rules/sysprop:sysprop_library.bzl",
  37. },
  38. android.CommonAttributes{Name: labels.SyspropLibraryLabel},
  39. &bazelSyspropLibraryAttributes{
  40. Srcs: srcs,
  41. })
  42. attrs := &bazelCcSyspropLibraryAttributes{
  43. Dep: *bazel.MakeLabelAttribute(":" + labels.SyspropLibraryLabel),
  44. Min_sdk_version: minSdkVersion,
  45. }
  46. if labels.SharedLibraryLabel != "" {
  47. ctx.CreateBazelTargetModule(
  48. bazel.BazelTargetModuleProperties{
  49. Rule_class: "cc_sysprop_library_shared",
  50. Bzl_load_location: "//build/bazel/rules/cc:cc_sysprop_library.bzl",
  51. },
  52. android.CommonAttributes{Name: labels.SharedLibraryLabel},
  53. attrs)
  54. }
  55. ctx.CreateBazelTargetModule(
  56. bazel.BazelTargetModuleProperties{
  57. Rule_class: "cc_sysprop_library_static",
  58. Bzl_load_location: "//build/bazel/rules/cc:cc_sysprop_library.bzl",
  59. },
  60. android.CommonAttributes{Name: labels.StaticLibraryLabel},
  61. attrs)
  62. }