aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-12-12 02:23:28 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-12-12 02:23:28 +0000
commit54bbeac9b38bbb697c19d73acdf385c087ac6e53 (patch)
treed8dacf705a4a3e927ddf4078f5ac5c838a501de2
parent95e03f1cd2805e7820c1e4340322d60674f32124 (diff)
parented2e0d8286c055bffe388fd579acd71d157c04ce (diff)
downloadhidl-android14-qpr2-s1-release.tar.gz
Change-Id: I3ab64700fa3513d3419715bf17a1264b216c23f7
-rw-r--r--build/Android.bp4
-rw-r--r--build/go.mod2
-rw-r--r--build/hidl_interface.go147
-rw-r--r--build/hidl_interface_conversion_test.go127
-rw-r--r--build/hidl_package_root.go26
-rw-r--r--build/properties.go8
6 files changed, 9 insertions, 305 deletions
diff --git a/build/Android.bp b/build/Android.bp
index bebdd9db..963a6904 100644
--- a/build/Android.bp
+++ b/build/Android.bp
@@ -28,7 +28,6 @@ bootstrap_go_package {
"blueprint",
"soong",
"soong-android",
- "soong-bp2build",
"soong-cc",
"soong-genrule",
"soong-java",
@@ -40,9 +39,6 @@ bootstrap_go_package {
"properties.go",
"utils.go",
],
- testSrcs: [
- "hidl_interface_conversion_test.go",
- ],
pluginFor: ["soong_build"],
}
diff --git a/build/go.mod b/build/go.mod
index 2d75c6eb..6e3342ee 100644
--- a/build/go.mod
+++ b/build/go.mod
@@ -22,6 +22,6 @@ exclude github.com/golang/protobuf v1.5.0
replace github.com/google/go-cmp v0.5.5 => ../../../../external/go-cmp
// Indirect dep from go-cmp
-exclude golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543
+exclude golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f
go 1.18
diff --git a/build/hidl_interface.go b/build/hidl_interface.go
index d0b5386b..ab8c52a7 100644
--- a/build/hidl_interface.go
+++ b/build/hidl_interface.go
@@ -22,11 +22,9 @@ import (
"github.com/google/blueprint/proptools"
"android/soong/android"
- "android/soong/bazel"
"android/soong/cc"
"android/soong/genrule"
"android/soong/java"
- "android/soong/ui/metrics/bp2build_metrics_proto"
)
var (
@@ -212,7 +210,6 @@ type hidlGenProperties struct {
type hidlGenRule struct {
android.ModuleBase
- android.BazelModuleBase
properties hidlGenProperties
@@ -352,21 +349,10 @@ func (g *hidlGenRule) DepsMutator(ctx android.BottomUpMutatorContext) {
ctx.AddReverseDependency(ctx.Module(), nil, hidlMetadataSingletonName)
}
-func (g *hidlGenRule) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
- hidlLang := g.properties.Language
- switch hidlLang {
- case "c++-sources", "c++-headers":
- panic(fmt.Errorf("Conversion of %q is handled via macros in Bazel", ctx.ModuleName()))
- default:
- ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_PROPERTY_UNSUPPORTED, fmt.Sprintf("Lang: %q", hidlLang))
- }
-}
-
func hidlGenFactory() android.Module {
g := &hidlGenRule{}
g.AddProperties(&g.properties)
android.InitAndroidModule(g)
- android.InitBazelModule(g)
return g
}
@@ -447,7 +433,6 @@ type hidlInterfaceProperties struct {
type hidlInterface struct {
android.ModuleBase
- android.BazelModuleBase
properties hidlInterfaceProperties
}
@@ -568,41 +553,11 @@ This corresponds to the "-r%s:<some path>" option that would be passed into hidl
vendorAvailable = proptools.BoolPtr(true)
}
- var bp2build bool
- // TODO: b/295566168 - this will need to change once build files are checked in to account for
- // checked in modules in mixed builds
- if b, ok := mctx.Module().(android.Bazelable); ok {
- bp2build = b.ShouldConvertWithBp2build(mctx)
- }
-
- var fgBp2build *bool
- var fgLabel *string
- if bp2build {
- fgLabel = proptools.StringPtr(fmt.Sprintf("//%s:%s", mctx.ModuleDir(), name.fileGroupName()))
- } else {
- fgBp2build = proptools.BoolPtr(false)
- }
-
// TODO(b/69002743): remove filegroups
mctx.CreateModule(android.FileGroupFactory, &fileGroupProperties{
Name: proptools.StringPtr(name.fileGroupName()),
Srcs: i.properties.Srcs,
- },
- &bazelProperties{
- &Bazel_module{
- Label: fgLabel,
- Bp2build_available: fgBp2build,
- }},
- )
-
- var ccBp2build *bool
- var ccHeadersLabel, ccSourcesLabel *string
- if bp2build {
- ccHeadersLabel = proptools.StringPtr(fmt.Sprintf("//%s:%s", mctx.ModuleDir(), name.headersName()))
- ccSourcesLabel = proptools.StringPtr(fmt.Sprintf("//%s:%s", mctx.ModuleDir(), name.sourcesName()))
- } else {
- ccBp2build = proptools.BoolPtr(false)
- }
+ })
mctx.CreateModule(hidlGenFactory, &nameProperties{
Name: proptools.StringPtr(name.sourcesName()),
@@ -613,13 +568,8 @@ This corresponds to the "-r%s:<some path>" option that would be passed into hidl
Interfaces: i.properties.Interfaces,
Inputs: i.properties.Srcs,
Outputs: concat(wrap(name.dir(), interfaces, "All.cpp"), wrap(name.dir(), types, ".cpp")),
- },
- &bazelProperties{
- &Bazel_module{
- Label: ccSourcesLabel,
- Bp2build_available: ccBp2build,
- }},
- )
+ })
+
mctx.CreateModule(hidlGenFactory, &nameProperties{
Name: proptools.StringPtr(name.headersName()),
}, &hidlGenProperties{
@@ -635,19 +585,9 @@ This corresponds to the "-r%s:<some path>" option that would be passed into hidl
wrap(name.dir()+"IHw", interfaces, ".h"),
wrap(name.dir(), types, ".h"),
wrap(name.dir()+"hw", types, ".h")),
- },
- &bazelProperties{
- &Bazel_module{
- Label: ccHeadersLabel,
- Bp2build_available: ccBp2build,
- }},
- )
+ })
if shouldGenerateLibrary {
- var label *string
- if bp2build {
- label = proptools.StringPtr(fmt.Sprintf("//%s:%s", mctx.ModuleDir(), name.string()))
- }
mctx.CreateModule(cc.LibraryFactory, &ccProperties{
Name: proptools.StringPtr(name.string()),
Host_supported: proptools.BoolPtr(true),
@@ -672,13 +612,7 @@ This corresponds to the "-r%s:<some path>" option that would be passed into hidl
Export_generated_headers: []string{name.headersName()},
Apex_available: i.properties.Apex_available,
Min_sdk_version: getMinSdkVersion(name.string()),
- }, &i.properties.VndkProperties,
- &bazelProperties{
- &Bazel_module{
- Label: label,
- Bp2build_available: ccBp2build,
- }},
- )
+ }, &i.properties.VndkProperties)
}
if shouldGenerateJava {
@@ -711,21 +645,11 @@ This corresponds to the "-r%s:<some path>" option that would be passed into hidl
mctx.CreateModule(java.LibraryFactory, &javaProperties{
Name: proptools.StringPtr(name.javaName()),
Static_libs: javaDependencies,
- }, &commonJavaProperties,
- &bazelProperties{
- &Bazel_module{
- Bp2build_available: proptools.BoolPtr(false),
- }},
- )
+ }, &commonJavaProperties)
mctx.CreateModule(java.LibraryFactory, &javaProperties{
Name: proptools.StringPtr(name.javaSharedName()),
Libs: javaDependencies,
- }, &commonJavaProperties,
- &bazelProperties{
- &Bazel_module{
- Bp2build_available: proptools.BoolPtr(false),
- }},
- )
+ }, &commonJavaProperties)
}
if shouldGenerateJavaConstants {
@@ -746,12 +670,7 @@ This corresponds to the "-r%s:<some path>" option that would be passed into hidl
Srcs: []string{":" + name.javaConstantsSourcesName()},
Apex_available: i.properties.Apex_available,
Min_sdk_version: getMinSdkVersion(name.string()),
- },
- &bazelProperties{
- &Bazel_module{
- Bp2build_available: proptools.BoolPtr(false),
- }},
- )
+ })
}
mctx.CreateModule(hidlGenFactory, &nameProperties{
@@ -803,60 +722,10 @@ func HidlInterfaceFactory() android.Module {
i.AddProperties(&i.properties)
android.InitAndroidModule(i)
android.AddLoadHook(i, func(ctx android.LoadHookContext) { hidlInterfaceMutator(ctx, i) })
- android.InitBazelModule(i)
return i
}
-type hidlInterfaceAttributes struct {
- Srcs bazel.LabelListAttribute
- Deps bazel.LabelListAttribute
- Root bazel.Label
- Min_sdk_version *string
- Tags []string
-}
-
-func (m *hidlInterface) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
- srcs := bazel.MakeLabelListAttribute(
- android.BazelLabelForModuleSrc(ctx, m.properties.Srcs))
-
- // The interface dependencies are added earlier with the suffix of "_interface",
- // so we need to look for them with the hidlInterfaceSuffix added to the names.
- // Later we trim the "_interface" suffix. Here is an example:
- // hidl_interface(
- // name = "android.hardware.nfc@1.1",
- // deps = [
- // "//hardware/interfaces/nfc/1.0:android.hardware.nfc@1.0",
- // "//system/libhidl/transport/base/1.0:android.hidl.base@1.0",
- // ],
- // )
- deps := android.BazelLabelForModuleDeps(ctx, wrap("", m.properties.Interfaces, hidlInterfaceSuffix))
- var dep_labels []bazel.Label
- for _, label := range deps.Includes {
- dep_labels = append(dep_labels,
- bazel.Label{Label: strings.TrimSuffix(label.Label, hidlInterfaceSuffix)})
- }
-
- root := android.BazelLabelForModuleDepSingle(ctx, m.properties.Root)
-
- bazel_hidl_interface_name := strings.TrimSuffix(m.Name(), hidlInterfaceSuffix)
-
- attrs := &hidlInterfaceAttributes{
- Srcs: srcs,
- Deps: bazel.MakeLabelListAttribute(bazel.MakeLabelList(dep_labels)),
- Root: root,
- Min_sdk_version: getMinSdkVersion(bazel_hidl_interface_name),
- Tags: android.ConvertApexAvailableToTagsWithoutTestApexes(ctx, m.properties.Apex_available),
- }
-
- props := bazel.BazelTargetModuleProperties{
- Rule_class: "hidl_interface",
- Bzl_load_location: "//build/bazel/rules/hidl:hidl_interface.bzl",
- }
-
- ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: bazel_hidl_interface_name}, attrs)
-}
-
var minSdkVersion = map[string]string{
"android.hardware.audio.common@5.0": "30",
"android.hardware.audio.common@6.0": "31",
diff --git a/build/hidl_interface_conversion_test.go b/build/hidl_interface_conversion_test.go
deleted file mode 100644
index fed5abda..00000000
--- a/build/hidl_interface_conversion_test.go
+++ /dev/null
@@ -1,127 +0,0 @@
-// Copyright 2022 Google Inc. All rights reserved.
-//
-// 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 hidl
-
-import (
- "testing"
-
- "android/soong/android"
- "android/soong/bp2build"
- "android/soong/cc"
-)
-
-func runHidlInterfaceTestCase(t *testing.T, tc bp2build.Bp2buildTestCase) {
- t.Helper()
- bp2build.RunBp2BuildTestCase(
- t,
- func(ctx android.RegistrationContext) {
- ctx.RegisterModuleType("cc_defaults", func() android.Module { return cc.DefaultsFactory() })
- ctx.RegisterModuleType("hidl_interface", HidlInterfaceFactory)
- ctx.RegisterModuleType("hidl_package_root", HidlPackageRootFactory)
- },
- tc,
- )
-}
-
-func TestHidlInterface(t *testing.T) {
- runHidlInterfaceTestCase(t, bp2build.Bp2buildTestCase{
- Description: `hidl_interface with common usage of properties`,
- Filesystem: map[string]string{
- "current.txt": "",
- },
- Blueprint: `
-hidl_package_root {
- name: "android.hardware",
- use_current: true,
-}
-cc_defaults {
- name: "hidl-module-defaults",
-}
-hidl_interface {
- name: "android.hardware.nfc@1.0",
- srcs: ["types.hal", "IBase.hal"],
- root: "android.hardware",
- gen_java: false,
-}
-hidl_interface {
- name: "android.hardware.nfc@1.1",
- srcs: ["types.hal", "INfc.hal"],
- interfaces: ["android.hardware.nfc@1.0"],
- root: "android.hardware",
- gen_java: false,
-}`,
- ExpectedBazelTargets: []string{
- bp2build.MakeBazelTargetNoRestrictions("hidl_interface", "android.hardware.nfc@1.0", bp2build.AttrNameToString{
- "min_sdk_version": `"29"`,
- "root": `":android.hardware"`,
- "srcs": `[
- "types.hal",
- "IBase.hal",
- ]`,
- }),
- bp2build.MakeBazelTargetNoRestrictions("hidl_interface", "android.hardware.nfc@1.1", bp2build.AttrNameToString{
- "deps": `[":android.hardware.nfc@1.0"]`,
- "min_sdk_version": `"29"`,
- "root": `":android.hardware"`,
- "srcs": `[
- "types.hal",
- "INfc.hal",
- ]`,
- }),
- bp2build.MakeBazelTargetNoRestrictions("hidl_package_root", "android.hardware", bp2build.AttrNameToString{
- "current": `"current.txt"`,
- }),
- },
- })
-}
-
-func TestHidlInterfacePackageRootInAnotherBp(t *testing.T) {
- runHidlInterfaceTestCase(t, bp2build.Bp2buildTestCase{
- Description: `hidl_interface with common usage of properties`,
- Filesystem: map[string]string{
- "foo/bar/Android.bp": `
-hidl_package_root {
- name: "android.hardware",
- use_current: true,
-}`,
- "foo/bar/current.txt": "",
- },
- Blueprint: `
-cc_defaults {
- name: "hidl-module-defaults",
-}
-hidl_package_root{
- name: "foo",
-}
-hidl_interface {
- name: "android.hardware.neuralnetworks@1.0",
- srcs: ["types.hal", "IBase.hal"],
- root: "android.hardware",
- gen_java: false,
-}`,
- StubbedBuildDefinitions: []string{"//foo/bar:android.hardware"},
- ExpectedBazelTargets: []string{
- bp2build.MakeBazelTargetNoRestrictions("hidl_interface", "android.hardware.neuralnetworks@1.0", bp2build.AttrNameToString{
- "min_sdk_version": `"30"`,
- "root": `"//foo/bar:android.hardware"`,
- "srcs": `[
- "types.hal",
- "IBase.hal",
- ]`,
- }),
- bp2build.MakeBazelTargetNoRestrictions("hidl_package_root", "foo", bp2build.AttrNameToString{}),
- },
- })
-}
diff --git a/build/hidl_package_root.go b/build/hidl_package_root.go
index 6e9a1557..628c210d 100644
--- a/build/hidl_package_root.go
+++ b/build/hidl_package_root.go
@@ -21,7 +21,6 @@ import (
"github.com/google/blueprint/proptools"
"android/soong/android"
- "android/soong/bazel"
)
var (
@@ -51,7 +50,6 @@ func init() {
type hidlPackageRoot struct {
android.ModuleBase
- android.BazelModuleBase
properties hidlPackageRootProperties
@@ -95,29 +93,6 @@ func (r *hidlPackageRoot) Srcs() android.Paths {
return r.genOutputs
}
-type hidlPackageRootAttributes struct {
- Path *string
- Current bazel.LabelAttribute
-}
-
-func (r *hidlPackageRoot) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
- attrs := &hidlPackageRootAttributes{
- Path: r.properties.Path,
- }
- currentPath := android.ExistentPathForSource(ctx, ctx.ModuleDir(), "current.txt")
- if currentPath.Valid() {
- attrs.Current = *bazel.MakeLabelAttribute("current.txt")
- }
-
- props := bazel.BazelTargetModuleProperties{
- Rule_class: "hidl_package_root",
- Bzl_load_location: "//build/bazel/rules/hidl:hidl_package_root.bzl",
- }
-
- ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: ctx.ModuleName()}, attrs)
-
-}
-
func (r *hidlPackageRoot) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if r.properties.Path == nil {
r.properties.Path = proptools.StringPtr(ctx.ModuleDir())
@@ -150,7 +125,6 @@ func HidlPackageRootFactory() android.Module {
r := &hidlPackageRoot{}
r.AddProperties(&r.properties)
android.InitAndroidModule(r)
- android.InitBazelModule(r)
packageRootsMutex.Lock()
packageRoots = append(packageRoots, r)
diff --git a/build/properties.go b/build/properties.go
index 087530db..6d67033b 100644
--- a/build/properties.go
+++ b/build/properties.go
@@ -66,11 +66,3 @@ type fuzzProperties struct {
Data []string
Fuzz_config *fuzzConfig
}
-
-type Bazel_module struct {
- Bp2build_available *bool
- Label *string
-}
-type bazelProperties struct {
- *Bazel_module
-}