2022-09-06 21:31:25 +02:00
|
|
|
// Copyright (C) 2019 The Android Open Source Project
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package cc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"android/soong/android"
|
|
|
|
"android/soong/bazel"
|
|
|
|
)
|
|
|
|
|
|
|
|
// TODO(b/240463568): Additional properties will be added for API validation
|
|
|
|
type bazelSyspropLibraryAttributes struct {
|
|
|
|
Srcs bazel.LabelListAttribute
|
2023-03-23 16:51:22 +01:00
|
|
|
Tags bazel.StringListAttribute
|
2022-09-06 21:31:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type bazelCcSyspropLibraryAttributes struct {
|
|
|
|
Dep bazel.LabelAttribute
|
|
|
|
Min_sdk_version *string
|
2023-03-23 16:51:22 +01:00
|
|
|
Tags bazel.StringListAttribute
|
2022-09-06 21:31:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type SyspropLibraryLabels struct {
|
|
|
|
SyspropLibraryLabel string
|
|
|
|
SharedLibraryLabel string
|
|
|
|
StaticLibraryLabel string
|
|
|
|
}
|
|
|
|
|
|
|
|
func Bp2buildSysprop(ctx android.Bp2buildMutatorContext, labels SyspropLibraryLabels, srcs bazel.LabelListAttribute, minSdkVersion *string) {
|
2023-04-12 21:05:49 +02:00
|
|
|
apexAvailableTags := android.ApexAvailableTagsWithoutTestApexes(ctx.(android.TopDownMutatorContext), ctx.Module())
|
2022-09-06 21:31:25 +02:00
|
|
|
ctx.CreateBazelTargetModule(
|
|
|
|
bazel.BazelTargetModuleProperties{
|
|
|
|
Rule_class: "sysprop_library",
|
|
|
|
Bzl_load_location: "//build/bazel/rules/sysprop:sysprop_library.bzl",
|
|
|
|
},
|
|
|
|
android.CommonAttributes{Name: labels.SyspropLibraryLabel},
|
|
|
|
&bazelSyspropLibraryAttributes{
|
|
|
|
Srcs: srcs,
|
2023-03-23 16:51:22 +01:00
|
|
|
Tags: apexAvailableTags,
|
|
|
|
},
|
|
|
|
)
|
2022-09-06 21:31:25 +02:00
|
|
|
|
|
|
|
attrs := &bazelCcSyspropLibraryAttributes{
|
|
|
|
Dep: *bazel.MakeLabelAttribute(":" + labels.SyspropLibraryLabel),
|
|
|
|
Min_sdk_version: minSdkVersion,
|
2023-03-23 16:51:22 +01:00
|
|
|
Tags: apexAvailableTags,
|
2022-09-06 21:31:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if labels.SharedLibraryLabel != "" {
|
|
|
|
ctx.CreateBazelTargetModule(
|
|
|
|
bazel.BazelTargetModuleProperties{
|
|
|
|
Rule_class: "cc_sysprop_library_shared",
|
|
|
|
Bzl_load_location: "//build/bazel/rules/cc:cc_sysprop_library.bzl",
|
|
|
|
},
|
|
|
|
android.CommonAttributes{Name: labels.SharedLibraryLabel},
|
|
|
|
attrs)
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx.CreateBazelTargetModule(
|
|
|
|
bazel.BazelTargetModuleProperties{
|
|
|
|
Rule_class: "cc_sysprop_library_static",
|
|
|
|
Bzl_load_location: "//build/bazel/rules/cc:cc_sysprop_library.bzl",
|
|
|
|
},
|
|
|
|
android.CommonAttributes{Name: labels.StaticLibraryLabel},
|
|
|
|
attrs)
|
|
|
|
}
|