blob: 2b1e354d3c7d668d293f6886a7529104084ab4fb [file] [log] [blame]
Trevor Radcliffecee4e052022-09-06 19:31:25 +00001// 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}
26
27type bazelCcSyspropLibraryAttributes struct {
28 Dep bazel.LabelAttribute
29 Min_sdk_version *string
30}
31
32type SyspropLibraryLabels struct {
33 SyspropLibraryLabel string
34 SharedLibraryLabel string
35 StaticLibraryLabel string
36}
37
38func Bp2buildSysprop(ctx android.Bp2buildMutatorContext, labels SyspropLibraryLabels, srcs bazel.LabelListAttribute, minSdkVersion *string) {
39 ctx.CreateBazelTargetModule(
40 bazel.BazelTargetModuleProperties{
41 Rule_class: "sysprop_library",
42 Bzl_load_location: "//build/bazel/rules/sysprop:sysprop_library.bzl",
43 },
44 android.CommonAttributes{Name: labels.SyspropLibraryLabel},
45 &bazelSyspropLibraryAttributes{
46 Srcs: srcs,
47 })
48
49 attrs := &bazelCcSyspropLibraryAttributes{
50 Dep: *bazel.MakeLabelAttribute(":" + labels.SyspropLibraryLabel),
51 Min_sdk_version: minSdkVersion,
52 }
53
54 if labels.SharedLibraryLabel != "" {
55 ctx.CreateBazelTargetModule(
56 bazel.BazelTargetModuleProperties{
57 Rule_class: "cc_sysprop_library_shared",
58 Bzl_load_location: "//build/bazel/rules/cc:cc_sysprop_library.bzl",
59 },
60 android.CommonAttributes{Name: labels.SharedLibraryLabel},
61 attrs)
62 }
63
64 ctx.CreateBazelTargetModule(
65 bazel.BazelTargetModuleProperties{
66 Rule_class: "cc_sysprop_library_static",
67 Bzl_load_location: "//build/bazel/rules/cc:cc_sysprop_library.bzl",
68 },
69 android.CommonAttributes{Name: labels.StaticLibraryLabel},
70 attrs)
71}