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