Merge "Bp2build-convert droiddoc_exported_dir" into main am: 4e86d7a342
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2734933 Change-Id: I27cccf8626c2ae3a29816b5fa4a94b9c67f7182d Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
committed by
Automerger Merge Worker
commit
8ae2b77eaa
@@ -903,6 +903,7 @@ var (
|
|||||||
"aidl_interface_headers",
|
"aidl_interface_headers",
|
||||||
"bpf",
|
"bpf",
|
||||||
"combined_apis",
|
"combined_apis",
|
||||||
|
"droiddoc_exported_dir",
|
||||||
"license",
|
"license",
|
||||||
"linker_config",
|
"linker_config",
|
||||||
"java_import",
|
"java_import",
|
||||||
|
@@ -62,6 +62,7 @@ bootstrap_go_package {
|
|||||||
"cc_test_conversion_test.go",
|
"cc_test_conversion_test.go",
|
||||||
"cc_yasm_conversion_test.go",
|
"cc_yasm_conversion_test.go",
|
||||||
"conversion_test.go",
|
"conversion_test.go",
|
||||||
|
"droiddoc_exported_dir_conversion_test.go",
|
||||||
"filegroup_conversion_test.go",
|
"filegroup_conversion_test.go",
|
||||||
"genrule_conversion_test.go",
|
"genrule_conversion_test.go",
|
||||||
"gensrcs_conversion_test.go",
|
"gensrcs_conversion_test.go",
|
||||||
|
60
bp2build/droiddoc_exported_dir_conversion_test.go
Normal file
60
bp2build/droiddoc_exported_dir_conversion_test.go
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
// Copyright 2023 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 bp2build
|
||||||
|
|
||||||
|
import (
|
||||||
|
"regexp"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"android/soong/java"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestDroiddocExportedDir(t *testing.T) {
|
||||||
|
bp := `
|
||||||
|
droiddoc_exported_dir {
|
||||||
|
name: "test-module",
|
||||||
|
path: "docs",
|
||||||
|
}
|
||||||
|
`
|
||||||
|
p := regexp.MustCompile(`\t*\|`)
|
||||||
|
dedent := func(s string) string {
|
||||||
|
return p.ReplaceAllString(s, "")
|
||||||
|
}
|
||||||
|
expectedBazelTargets := []string{
|
||||||
|
MakeBazelTargetNoRestrictions(
|
||||||
|
"droiddoc_exported_dir",
|
||||||
|
"test-module",
|
||||||
|
AttrNameToString{
|
||||||
|
"dir": `"docs"`,
|
||||||
|
"srcs": dedent(`[
|
||||||
|
| "docs/android/1.txt",
|
||||||
|
| "docs/android/nested-1/2.txt",
|
||||||
|
| "//docs/android/nested-2:3.txt",
|
||||||
|
| "//docs/android/nested-2:Android.bp",
|
||||||
|
| ]`),
|
||||||
|
}),
|
||||||
|
//note we are not excluding Android.bp files from subpackages for now
|
||||||
|
}
|
||||||
|
RunBp2BuildTestCase(t, java.RegisterDocsBuildComponents, Bp2buildTestCase{
|
||||||
|
Blueprint: bp,
|
||||||
|
ExpectedBazelTargets: expectedBazelTargets,
|
||||||
|
Filesystem: map[string]string{
|
||||||
|
"docs/android/1.txt": "",
|
||||||
|
"docs/android/nested-1/2.txt": "",
|
||||||
|
"docs/android/nested-2/Android.bp": "",
|
||||||
|
"docs/android/nested-2/3.txt": "",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
@@ -22,6 +22,7 @@ import (
|
|||||||
"github.com/google/blueprint/proptools"
|
"github.com/google/blueprint/proptools"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
|
"android/soong/bazel"
|
||||||
"android/soong/java/config"
|
"android/soong/java/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -844,6 +845,7 @@ type ExportedDroiddocDirProperties struct {
|
|||||||
|
|
||||||
type ExportedDroiddocDir struct {
|
type ExportedDroiddocDir struct {
|
||||||
android.ModuleBase
|
android.ModuleBase
|
||||||
|
android.BazelModuleBase
|
||||||
|
|
||||||
properties ExportedDroiddocDirProperties
|
properties ExportedDroiddocDirProperties
|
||||||
|
|
||||||
@@ -856,6 +858,7 @@ func ExportedDroiddocDirFactory() android.Module {
|
|||||||
module := &ExportedDroiddocDir{}
|
module := &ExportedDroiddocDir{}
|
||||||
module.AddProperties(&module.properties)
|
module.AddProperties(&module.properties)
|
||||||
android.InitAndroidModule(module)
|
android.InitAndroidModule(module)
|
||||||
|
android.InitBazelModule(module)
|
||||||
return module
|
return module
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -867,6 +870,28 @@ func (d *ExportedDroiddocDir) GenerateAndroidBuildActions(ctx android.ModuleCont
|
|||||||
d.deps = android.PathsForModuleSrc(ctx, []string{filepath.Join(path, "**/*")})
|
d.deps = android.PathsForModuleSrc(ctx, []string{filepath.Join(path, "**/*")})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ConvertWithBp2build implements android.BazelModule.
|
||||||
|
func (d *ExportedDroiddocDir) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
||||||
|
props := bazel.BazelTargetModuleProperties{
|
||||||
|
// Use the native py_library rule.
|
||||||
|
Rule_class: "droiddoc_exported_dir",
|
||||||
|
Bzl_load_location: "//build/bazel/rules/droiddoc:droiddoc_exported_dir.bzl",
|
||||||
|
}
|
||||||
|
|
||||||
|
type BazelAttrs struct {
|
||||||
|
Dir *string
|
||||||
|
Srcs bazel.LabelListAttribute
|
||||||
|
}
|
||||||
|
|
||||||
|
attrs := &BazelAttrs{
|
||||||
|
Dir: proptools.StringPtr(*d.properties.Path),
|
||||||
|
Srcs: bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, []string{filepath.Join(*d.properties.Path, "**/*")})),
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: d.Name()}, attrs)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Defaults
|
// Defaults
|
||||||
type DocDefaults struct {
|
type DocDefaults struct {
|
||||||
android.ModuleBase
|
android.ModuleBase
|
||||||
|
Reference in New Issue
Block a user