diff options
-rw-r--r-- | android/bazel.go | 7 | ||||
-rw-r--r-- | bp2build/Android.bp | 1 | ||||
-rw-r--r-- | bp2build/android_app_conversion_test.go | 4 | ||||
-rw-r--r-- | bp2build/build_conversion.go | 11 | ||||
-rw-r--r-- | bp2build/cc_genrule_conversion_test.go | 235 | ||||
-rw-r--r-- | bp2build/genrule_conversion_test.go | 449 | ||||
-rw-r--r-- | bp2build/metrics.go | 28 | ||||
-rw-r--r-- | cc/config/bp2build.go | 5 | ||||
-rw-r--r-- | cc/ndk_library.go | 33 | ||||
-rw-r--r-- | cc/sanitize.go | 1 | ||||
-rw-r--r-- | genrule/genrule.go | 2 | ||||
-rwxr-xr-x | java/app.go | 4 | ||||
-rw-r--r-- | java/genrule.go | 14 | ||||
-rw-r--r-- | java/genrule_test.go | 118 | ||||
-rw-r--r-- | java/java_test.go | 54 | ||||
-rw-r--r-- | ui/metrics/bp2build_metrics_proto/bp2build_metrics.pb.go | 81 | ||||
-rw-r--r-- | ui/metrics/bp2build_metrics_proto/bp2build_metrics.proto | 6 |
17 files changed, 606 insertions, 447 deletions
diff --git a/android/bazel.go b/android/bazel.go index 7971451c2..528c7b110 100644 --- a/android/bazel.go +++ b/android/bazel.go @@ -285,6 +285,7 @@ var ( "development/samples/USB/MissileLauncher": Bp2BuildDefaultTrue, "development/samples/VoiceRecognitionService": Bp2BuildDefaultTrue, "development/samples/VoicemailProviderDemo": Bp2BuildDefaultTrue, + "development/samples/WiFiDirectDemo": Bp2BuildDefaultTrue, "development/sdk": Bp2BuildDefaultTrueRecursively, "external/arm-optimized-routines": Bp2BuildDefaultTrueRecursively, "external/boringssl": Bp2BuildDefaultTrueRecursively, @@ -468,9 +469,13 @@ var ( "libdexfiled", // depends on unconverted modules: dexfile_operator_srcs, libartbased, libartpalette // go deps: - "apex-protos", // depends on unconverted modules: soong_zip + "apex-protos", // depends on soong_zip, a go binary + "robolectric_tzdata", // depends on soong_zip, a go binary "host_bionic_linker_asm", // depends on extract_linker, a go binary. "host_bionic_linker_script", // depends on extract_linker, a go binary. + + // java deps + "bin2c_fastdeployagent", // depends on deployagent, a java binary } // Per-module denylist of cc_library modules to only generate the static diff --git a/bp2build/Android.bp b/bp2build/Android.bp index ae0fb11a5..4bcfa6110 100644 --- a/bp2build/Android.bp +++ b/bp2build/Android.bp @@ -38,7 +38,6 @@ bootstrap_go_package { "build_conversion_test.go", "bzl_conversion_test.go", "cc_binary_conversion_test.go", - "cc_genrule_conversion_test.go", "cc_library_conversion_test.go", "cc_library_headers_conversion_test.go", "cc_library_shared_conversion_test.go", diff --git a/bp2build/android_app_conversion_test.go b/bp2build/android_app_conversion_test.go index 153817b08..28de06c00 100644 --- a/bp2build/android_app_conversion_test.go +++ b/bp2build/android_app_conversion_test.go @@ -66,7 +66,7 @@ func TestAndroidAppAllSupportedFields(t *testing.T) { "resb/res.png": "", "manifest/AndroidManifest.xml": "", }, - blueprint: ` + blueprint: simpleModuleDoNotConvertBp2build("android_app", "static_lib_dep") + ` android_app { name: "TestApp", srcs: ["app.java"], @@ -74,6 +74,7 @@ android_app { package_name: "com.google", resource_dirs: ["resa", "resb"], manifest: "manifest/AndroidManifest.xml", + static_libs: ["static_lib_dep"] } `, expectedBazelTargets: []string{ @@ -85,6 +86,7 @@ android_app { "resb/res.png", ]`, "custom_package": `"com.google"`, + "deps": `[":static_lib_dep"]`, }), }}) } diff --git a/bp2build/build_conversion.go b/bp2build/build_conversion.go index 5887d06c2..b3bec65da 100644 --- a/bp2build/build_conversion.go +++ b/bp2build/build_conversion.go @@ -259,7 +259,9 @@ func GenerateBazelTargets(ctx *CodegenContext, generateFilegroups bool) (convers // Simple metrics tracking for bp2build metrics := CodegenMetrics{ - ruleClassCount: make(map[string]uint64), + ruleClassCount: make(map[string]uint64), + convertedModuleTypeCount: make(map[string]uint64), + totalModuleTypeCount: make(map[string]uint64), } dirs := make(map[string]bool) @@ -269,6 +271,7 @@ func GenerateBazelTargets(ctx *CodegenContext, generateFilegroups bool) (convers bpCtx := ctx.Context() bpCtx.VisitAllModules(func(m blueprint.Module) { dir := bpCtx.ModuleDir(m) + moduleType := bpCtx.ModuleType(m) dirs[dir] = true var targets []BazelTarget @@ -292,7 +295,7 @@ func GenerateBazelTargets(ctx *CodegenContext, generateFilegroups bool) (convers // targets in the same BUILD file (or package). // Log the module. - metrics.AddConvertedModule(m.Name(), Handcrafted) + metrics.AddConvertedModule(m, moduleType, Handcrafted) pathToBuildFile := getBazelPackagePath(b) if _, exists := buildFileToAppend[pathToBuildFile]; exists { @@ -312,7 +315,7 @@ func GenerateBazelTargets(ctx *CodegenContext, generateFilegroups bool) (convers // Handle modules converted to generated targets. // Log the module. - metrics.AddConvertedModule(m.Name(), Generated) + metrics.AddConvertedModule(aModule, moduleType, Generated) // Handle modules with unconverted deps. By default, emit a warning. if unconvertedDeps := aModule.GetUnconvertedBp2buildDeps(); len(unconvertedDeps) > 0 { @@ -340,7 +343,7 @@ func GenerateBazelTargets(ctx *CodegenContext, generateFilegroups bool) (convers metrics.IncrementRuleClassCount(t.ruleClass) } } else { - metrics.IncrementUnconvertedCount() + metrics.AddUnconvertedModule(moduleType) return } case QueryView: diff --git a/bp2build/cc_genrule_conversion_test.go b/bp2build/cc_genrule_conversion_test.go deleted file mode 100644 index 440b462b9..000000000 --- a/bp2build/cc_genrule_conversion_test.go +++ /dev/null @@ -1,235 +0,0 @@ -// Copyright 2021 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 ( - "testing" - - "android/soong/android" - "android/soong/cc" -) - -var otherCcGenruleBp = map[string]string{ - "other/Android.bp": `cc_genrule { - name: "foo.tool", - out: ["foo_tool.out"], - srcs: ["foo_tool.in"], - cmd: "cp $(in) $(out)", -} -cc_genrule { - name: "other.tool", - out: ["other_tool.out"], - srcs: ["other_tool.in"], - cmd: "cp $(in) $(out)", -}`, -} - -func runCcGenruleTestCase(t *testing.T, tc bp2buildTestCase) { - t.Helper() - (&tc).moduleTypeUnderTest = "cc_genrule" - (&tc).moduleTypeUnderTestFactory = cc.GenRuleFactory - runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, tc) -} - -func TestCliVariableReplacement(t *testing.T) { - runCcGenruleTestCase(t, bp2buildTestCase{ - description: "cc_genrule with command line variable replacements", - blueprint: `cc_genrule { - name: "foo.tool", - out: ["foo_tool.out"], - srcs: ["foo_tool.in"], - cmd: "cp $(in) $(out)", - bazel_module: { bp2build_available: true }, -} - -cc_genrule { - name: "foo", - out: ["foo.out"], - srcs: ["foo.in"], - tools: [":foo.tool"], - cmd: "$(location :foo.tool) --genDir=$(genDir) arg $(in) $(out)", - bazel_module: { bp2build_available: true }, -}`, - expectedBazelTargets: []string{ - makeBazelTarget("genrule", "foo", attrNameToString{ - "cmd": `"$(location :foo.tool) --genDir=$(RULEDIR) arg $(SRCS) $(OUTS)"`, - "outs": `["foo.out"]`, - "srcs": `["foo.in"]`, - "tools": `[":foo.tool"]`, - }), - makeBazelTarget("genrule", "foo.tool", attrNameToString{ - "cmd": `"cp $(SRCS) $(OUTS)"`, - "outs": `["foo_tool.out"]`, - "srcs": `["foo_tool.in"]`, - }), - }, - }) -} - -func TestUsingLocationsLabel(t *testing.T) { - runCcGenruleTestCase(t, bp2buildTestCase{ - description: "cc_genrule using $(locations :label)", - blueprint: `cc_genrule { - name: "foo.tools", - out: ["foo_tool.out", "foo_tool2.out"], - srcs: ["foo_tool.in"], - cmd: "cp $(in) $(out)", - bazel_module: { bp2build_available: true }, -} - -cc_genrule { - name: "foo", - out: ["foo.out"], - srcs: ["foo.in"], - tools: [":foo.tools"], - cmd: "$(locations :foo.tools) -s $(out) $(in)", - bazel_module: { bp2build_available: true }, -}`, - expectedBazelTargets: []string{ - makeBazelTarget("genrule", "foo", attrNameToString{ - "cmd": `"$(locations :foo.tools) -s $(OUTS) $(SRCS)"`, - "outs": `["foo.out"]`, - "srcs": `["foo.in"]`, - "tools": `[":foo.tools"]`, - }), - makeBazelTarget("genrule", "foo.tools", attrNameToString{ - "cmd": `"cp $(SRCS) $(OUTS)"`, - "outs": `[ - "foo_tool.out", - "foo_tool2.out", - ]`, - "srcs": `["foo_tool.in"]`, - }), - }, - }) -} - -func TestUsingLocationsAbsoluteLabel(t *testing.T) { - runCcGenruleTestCase(t, bp2buildTestCase{ - description: "cc_genrule using $(locations //absolute:label)", - blueprint: `cc_genrule { - name: "foo", - out: ["foo.out"], - srcs: ["foo.in"], - tool_files: [":foo.tool"], - cmd: "$(locations :foo.tool) -s $(out) $(in)", - bazel_module: { bp2build_available: true }, -}`, - filesystem: otherCcGenruleBp, - expectedBazelTargets: []string{ - makeBazelTarget("genrule", "foo", attrNameToString{ - "cmd": `"$(locations //other:foo.tool) -s $(OUTS) $(SRCS)"`, - "outs": `["foo.out"]`, - "srcs": `["foo.in"]`, - "tools": `["//other:foo.tool"]`, - }), - }, - }) -} - -func TestSrcsUsingAbsoluteLabel(t *testing.T) { - runCcGenruleTestCase(t, bp2buildTestCase{ - description: "cc_genrule srcs using $(locations //absolute:label)", - blueprint: `cc_genrule { - name: "foo", - out: ["foo.out"], - srcs: [":other.tool"], - tool_files: [":foo.tool"], - cmd: "$(locations :foo.tool) -s $(out) $(location :other.tool)", - bazel_module: { bp2build_available: true }, -}`, - filesystem: otherCcGenruleBp, - expectedBazelTargets: []string{ - makeBazelTarget("genrule", "foo", attrNameToString{ - "cmd": `"$(locations //other:foo.tool) -s $(OUTS) $(location //other:other.tool)"`, - "outs": `["foo.out"]`, - "srcs": `["//other:other.tool"]`, - "tools": `["//other:foo.tool"]`, - }), - }, - }) -} - -func TestLocationsLabelUsesFirstToolFile(t *testing.T) { - runCcGenruleTestCase(t, bp2buildTestCase{ - description: "cc_genrule using $(location) label should substitute first tool label automatically", - blueprint: `cc_genrule { - name: "foo", - out: ["foo.out"], - srcs: ["foo.in"], - tool_files: [":foo.tool", ":other.tool"], - cmd: "$(location) -s $(out) $(in)", - bazel_module: { bp2build_available: true }, -}`, - filesystem: otherCcGenruleBp, - expectedBazelTargets: []string{ - makeBazelTarget("genrule", "foo", attrNameToString{ - "cmd": `"$(location //other:foo.tool) -s $(OUTS) $(SRCS)"`, - "outs": `["foo.out"]`, - "srcs": `["foo.in"]`, - "tools": `[ - "//other:foo.tool", - "//other:other.tool", - ]`, - }), - }, - }) -} - -func TestLocationsLabelUsesFirstTool(t *testing.T) { - runCcGenruleTestCase(t, bp2buildTestCase{ - description: "cc_genrule using $(locations) label should substitute first tool label automatically", - blueprint: `cc_genrule { - name: "foo", - out: ["foo.out"], - srcs: ["foo.in"], - tools: [":foo.tool", ":other.tool"], - cmd: "$(locations) -s $(out) $(in)", - bazel_module: { bp2build_available: true }, -}`, - filesystem: otherCcGenruleBp, - expectedBazelTargets: []string{ - makeBazelTarget("genrule", "foo", attrNameToString{ - "cmd": `"$(locations //other:foo.tool) -s $(OUTS) $(SRCS)"`, - "outs": `["foo.out"]`, - "srcs": `["foo.in"]`, - "tools": `[ - "//other:foo.tool", - "//other:other.tool", - ]`, - }), - }, - }) -} - -func TestWithoutToolsOrToolFiles(t *testing.T) { - runCcGenruleTestCase(t, bp2buildTestCase{ - description: "cc_genrule without tools or tool_files can convert successfully", - blueprint: `cc_genrule { - name: "foo", - out: ["foo.out"], - srcs: ["foo.in"], - cmd: "cp $(in) $(out)", - bazel_module: { bp2build_available: true }, -}`, - expectedBazelTargets: []string{ - makeBazelTarget("genrule", "foo", attrNameToString{ - "cmd": `"cp $(SRCS) $(OUTS)"`, - "outs": `["foo.out"]`, - "srcs": `["foo.in"]`, - }), - }, - }) -} diff --git a/bp2build/genrule_conversion_test.go b/bp2build/genrule_conversion_test.go index fd631a53b..0666da778 100644 --- a/bp2build/genrule_conversion_test.go +++ b/bp2build/genrule_conversion_test.go @@ -16,7 +16,10 @@ package bp2build import ( "android/soong/android" + "android/soong/cc" "android/soong/genrule" + "android/soong/java" + "fmt" "testing" ) @@ -31,58 +34,114 @@ func runGenruleTestCase(t *testing.T, tc bp2buildTestCase) { runBp2BuildTestCase(t, registerGenruleModuleTypes, tc) } -func TestGenruleBp2Build(t *testing.T) { - otherGenruleBp := map[string]string{ - "other/Android.bp": `genrule { +func otherGenruleBp(genruleTarget string) map[string]string { + return map[string]string{ + "other/Android.bp": fmt.Sprintf(`%s { name: "foo.tool", out: ["foo_tool.out"], srcs: ["foo_tool.in"], cmd: "cp $(in) $(out)", } -genrule { +%s { name: "other.tool", out: ["other_tool.out"], srcs: ["other_tool.in"], cmd: "cp $(in) $(out)", -}`, +}`, genruleTarget, genruleTarget), } +} - testCases := []bp2buildTestCase{ +func TestGenruleCliVariableReplacement(t *testing.T) { + testCases := []struct { + moduleType string + factory android.ModuleFactory + genDir string + }{ + { + moduleType: "genrule", + factory: genrule.GenRuleFactory, + genDir: "$(GENDIR)", + }, + { + moduleType: "cc_genrule", + factory: cc.GenRuleFactory, + genDir: "$(RULEDIR)", + }, + { + moduleType: "java_genrule", + factory: java.GenRuleFactory, + genDir: "$(RULEDIR)", + }, { - description: "genrule with command line variable replacements", - blueprint: `genrule { + moduleType: "java_genrule_host", + factory: java.GenRuleFactoryHost, + genDir: "$(RULEDIR)", + }, + } + + bp := `%s { name: "foo.tool", out: ["foo_tool.out"], srcs: ["foo_tool.in"], cmd: "cp $(in) $(out)", - bazel_module: { bp2build_available: true }, + bazel_module: { bp2build_available: false }, } -genrule { +%s { name: "foo", out: ["foo.out"], srcs: ["foo.in"], tools: [":foo.tool"], cmd: "$(location :foo.tool) --genDir=$(genDir) arg $(in) $(out)", bazel_module: { bp2build_available: true }, -}`, - expectedBazelTargets: []string{ - makeBazelTarget("genrule", "foo", attrNameToString{ - "cmd": `"$(location :foo.tool) --genDir=$(GENDIR) arg $(SRCS) $(OUTS)"`, - "outs": `["foo.out"]`, - "srcs": `["foo.in"]`, - "tools": `[":foo.tool"]`, - }), - makeBazelTarget("genrule", "foo.tool", attrNameToString{ - "cmd": `"cp $(SRCS) $(OUTS)"`, - "outs": `["foo_tool.out"]`, - "srcs": `["foo_tool.in"]`, - }), - }, +}` + + for _, tc := range testCases { + expectedBazelTargets := []string{ + makeBazelTarget("genrule", "foo", attrNameToString{ + "cmd": fmt.Sprintf(`"$(location :foo.tool) --genDir=%s arg $(SRCS) $(OUTS)"`, tc.genDir), + "outs": `["foo.out"]`, + "srcs": `["foo.in"]`, + "tools": `[":foo.tool"]`, + }), + } + + t.Run(tc.moduleType, func(t *testing.T) { + runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, + bp2buildTestCase{ + moduleTypeUnderTest: tc.moduleType, + moduleTypeUnderTestFactory: tc.factory, + blueprint: fmt.Sprintf(bp, tc.moduleType, tc.moduleType), + expectedBazelTargets: expectedBazelTargets, + }) + }) + } +} + +func TestGenruleLocationsLabel(t *testing.T) { + testCases := []struct { + moduleType string + factory android.ModuleFactory + }{ + { + moduleType: "genrule", + factory: genrule.GenRuleFactory, }, { - description: "genrule using $(locations :label)", - blueprint: `genrule { + moduleType: "cc_genrule", + factory: cc.GenRuleFactory, + }, + { + moduleType: "java_genrule", + factory: java.GenRuleFactory, + }, + { + moduleType: "java_genrule_host", + factory: java.GenRuleFactoryHost, + }, + } + + bp := `%s { name: "foo.tools", out: ["foo_tool.out", "foo_tool2.out"], srcs: ["foo_tool.in"], @@ -90,144 +149,322 @@ genrule { bazel_module: { bp2build_available: true }, } -genrule { +%s { name: "foo", out: ["foo.out"], srcs: ["foo.in"], tools: [":foo.tools"], cmd: "$(locations :foo.tools) -s $(out) $(in)", bazel_module: { bp2build_available: true }, -}`, - expectedBazelTargets: []string{ - makeBazelTarget("genrule", "foo", attrNameToString{ - "cmd": `"$(locations :foo.tools) -s $(OUTS) $(SRCS)"`, - "outs": `["foo.out"]`, - "srcs": `["foo.in"]`, - "tools": `[":foo.tools"]`, - }), - makeBazelTarget("genrule", "foo.tools", attrNameToString{ - "cmd": `"cp $(SRCS) $(OUTS)"`, - "outs": `[ +}` + + expectedBazelTargets := + []string{ + makeBazelTarget("genrule", "foo", attrNameToString{ + "cmd": `"$(locations :foo.tools) -s $(OUTS) $(SRCS)"`, + "outs": `["foo.out"]`, + "srcs": `["foo.in"]`, + "tools": `[":foo.tools"]`, + }), + makeBazelTarget("genrule", "foo.tools", attrNameToString{ + "cmd": `"cp $(SRCS) $(OUTS)"`, + "outs": `[ "foo_tool.out", "foo_tool2.out", ]`, - "srcs": `["foo_tool.in"]`, - }), - }, + "srcs": `["foo_tool.in"]`, + }), + } + + for _, tc := range testCases { + t.Run(tc.moduleType, func(t *testing.T) { + runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, + bp2buildTestCase{ + moduleTypeUnderTest: tc.moduleType, + moduleTypeUnderTestFactory: tc.factory, + blueprint: fmt.Sprintf(bp, tc.moduleType, tc.moduleType), + expectedBazelTargets: expectedBazelTargets, + }) + }) + } +} + +func TestGenruleLocationsAbsoluteLabel(t *testing.T) { + testCases := []struct { + moduleType string + factory android.ModuleFactory + }{ + { + moduleType: "genrule", + factory: genrule.GenRuleFactory, + }, + { + moduleType: "cc_genrule", + factory: cc.GenRuleFactory, + }, + { + moduleType: "java_genrule", + factory: java.GenRuleFactory, }, { - description: "genrule using $(locations //absolute:label)", - blueprint: `genrule { + moduleType: "java_genrule_host", + factory: java.GenRuleFactoryHost, + }, + } + + bp := `%s { name: "foo", out: ["foo.out"], srcs: ["foo.in"], tool_files: [":foo.tool"], cmd: "$(locations :foo.tool) -s $(out) $(in)", bazel_module: { bp2build_available: true }, -}`, - expectedBazelTargets: []string{ - makeBazelTarget("genrule", "foo", attrNameToString{ - "cmd": `"$(locations //other:foo.tool) -s $(OUTS) $(SRCS)"`, - "outs": `["foo.out"]`, - "srcs": `["foo.in"]`, - "tools": `["//other:foo.tool"]`, - }), - }, - filesystem: otherGenruleBp, +}` + + expectedBazelTargets := []string{ + makeBazelTarget("genrule", "foo", attrNameToString{ + "cmd": `"$(locations //other:foo.tool) -s $(OUTS) $(SRCS)"`, + "outs": `["foo.out"]`, + "srcs": `["foo.in"]`, + "tools": `["//other:foo.tool"]`, + }), + } + + for _, tc := range testCases { + t.Run(tc.moduleType, func(t *testing.T) { + runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, + bp2buildTestCase{ + moduleTypeUnderTest: tc.moduleType, + moduleTypeUnderTestFactory: tc.factory, + blueprint: fmt.Sprintf(bp, tc.moduleType), + expectedBazelTargets: expectedBazelTargets, + filesystem: otherGenruleBp(tc.moduleType), + }) + }) + } +} + +func TestGenruleSrcsLocationsAbsoluteLabel(t *testing.T) { + testCases := []struct { + moduleType string + factory android.ModuleFactory + }{ + { + moduleType: "genrule", + factory: genrule.GenRuleFactory, + }, + { + moduleType: "cc_genrule", + factory: cc.GenRuleFactory, + }, + { + moduleType: "java_genrule", + factory: java.GenRuleFactory, }, { - description: "genrule srcs using $(locations //absolute:label)", - blueprint: `genrule { + moduleType: "java_genrule_host", + factory: java.GenRuleFactoryHost, + }, + } + + bp := `%s { name: "foo", out: ["foo.out"], srcs: [":other.tool"], tool_files: [":foo.tool"], cmd: "$(locations :foo.tool) -s $(out) $(location :other.tool)", bazel_module: { bp2build_available: true }, -}`, - expectedBazelTargets: []string{ - makeBazelTarget("genrule", "foo", attrNameToString{ - "cmd": `"$(locations //other:foo.tool) -s $(OUTS) $(location //other:other.tool)"`, - "outs": `["foo.out"]`, - "srcs": `["//other:other.tool"]`, - "tools": `["//other:foo.tool"]`, - }), - }, - filesystem: otherGenruleBp, +}` + + expectedBazelTargets := []string{ + makeBazelTarget("genrule", "foo", attrNameToString{ + "cmd": `"$(locations //other:foo.tool) -s $(OUTS) $(location //other:other.tool)"`, + "outs": `["foo.out"]`, + "srcs": `["//other:other.tool"]`, + "tools": `["//other:foo.tool"]`, + }), + } + + for _, tc := range testCases { + t.Run(tc.moduleType, func(t *testing.T) { + runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, + bp2buildTestCase{ + moduleTypeUnderTest: tc.moduleType, + moduleTypeUnderTestFactory: tc.factory, + blueprint: fmt.Sprintf(bp, tc.moduleType), + expectedBazelTargets: expectedBazelTargets, + filesystem: otherGenruleBp(tc.moduleType), + }) + }) + } +} + +func TestGenruleLocationLabelShouldSubstituteFirstToolLabel(t *testing.T) { + testCases := []struct { + moduleType string + factory android.ModuleFactory + }{ + { + moduleType: "genrule", + factory: genrule.GenRuleFactory, + }, + { + moduleType: "cc_genrule", + factory: cc.GenRuleFactory, }, { - description: "genrule using $(location) label should substitute first tool label automatically", - blueprint: `genrule { + moduleType: "java_genrule", + factory: java.GenRuleFactory, + }, + { + moduleType: "java_genrule_host", + factory: java.GenRuleFactoryHost, + }, + } + + bp := `%s { name: "foo", out: ["foo.out"], srcs: ["foo.in"], tool_files: [":foo.tool", ":other.tool"], cmd: "$(location) -s $(out) $(in)", bazel_module: { bp2build_available: true }, -}`, - expectedBazelTargets: []string{ - makeBazelTarget("genrule", "foo", attrNameToString{ - "cmd": `"$(location //other:foo.tool) -s $(OUTS) $(SRCS)"`, - "outs": `["foo.out"]`, - "srcs": `["foo.in"]`, - "tools": `[ +}` + + expectedBazelTargets := []string{ + makeBazelTarget("genrule", "foo", attrNameToString{ + "cmd": `"$(location //other:foo.tool) -s $(OUTS) $(SRCS)"`, + "outs": `["foo.out"]`, + "srcs": `["foo.in"]`, + "tools": `[ "//other:foo.tool", "//other:other.tool", ]`, - }), - }, - filesystem: otherGenruleBp, + })} + + for _, tc := range testCases { + t.Run(tc.moduleType, func(t *testing.T) { + runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, + bp2buildTestCase{ + moduleTypeUnderTest: tc.moduleType, + moduleTypeUnderTestFactory: tc.factory, + blueprint: fmt.Sprintf(bp, tc.moduleType), + expectedBazelTargets: expectedBazelTargets, + filesystem: otherGenruleBp(tc.moduleType), + }) + }) + } +} + +func TestGenruleLocationsLabelShouldSubstituteFirstToolLabel(t *testing.T) { + testCases := []struct { + moduleType string + factory android.ModuleFactory + }{ + { + moduleType: "genrule", + factory: genrule.GenRuleFactory, + }, + { + moduleType: "cc_genrule", + factory: cc.GenRuleFactory, }, { - description: "genrule using $(locations) label should substitute first tool label automatically", - blueprint: `genrule { + moduleType: "java_genrule", + factory: java.GenRuleFactory, + }, + { + moduleType: "java_genrule_host", + factory: java.GenRuleFactoryHost, + }, + } + + bp := `%s { name: "foo", out: ["foo.out"], srcs: ["foo.in"], - tools: [":foo.tool", ":other.tool"], + tool_files: [":foo.tool", ":other.tool"], cmd: "$(locations) -s $(out) $(in)", bazel_module: { bp2build_available: true }, -}`, - expectedBazelTargets: []string{ - makeBazelTarget("genrule", "foo", attrNameToString{ - "cmd": `"$(locations //other:foo.tool) -s $(OUTS) $(SRCS)"`, - "outs": `["foo.out"]`, - "srcs": `["foo.in"]`, - "tools": `[ +}` + + expectedBazelTargets := []string{ + makeBazelTarget("genrule", "foo", attrNameToString{ + "cmd": `"$(locations //other:foo.tool) -s $(OUTS) $(SRCS)"`, + "outs": `["foo.out"]`, + "srcs": `["foo.in"]`, + "tools": `[ "//other:foo.tool", "//other:other.tool", ]`, - }), - }, - filesystem: otherGenruleBp, + })} + + for _, tc := range testCases { + t.Run(tc.moduleType, func(t *testing.T) { + runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, + bp2buildTestCase{ + moduleTypeUnderTest: tc.moduleType, + moduleTypeUnderTestFactory: tc.factory, + blueprint: fmt.Sprintf(bp, tc.moduleType), + expectedBazelTargets: expectedBazelTargets, + filesystem: otherGenruleBp(tc.moduleType), + }) + }) + } +} + +func TestGenruleWithoutToolsOrToolFiles(t *testing.T) { + testCases := []struct { + moduleType string + factory android.ModuleFactory + }{ + { + moduleType: "genrule", + factory: genrule.GenRuleFactory, }, { - description: "genrule without tools or tool_files can convert successfully", - blueprint: `genrule { + moduleType: "cc_genrule", + factory: cc.GenRuleFactory, + }, + { + moduleType: "java_genrule", + factory: java.GenRuleFactory, + }, + { + moduleType: "java_genrule_host", + factory: java.GenRuleFactoryHost, + }, + } + + bp := `%s { name: "foo", out: ["foo.out"], srcs: ["foo.in"], cmd: "cp $(in) $(out)", bazel_module: { bp2build_available: true }, -}`, - expectedBazelTargets: []string{ - makeBazelTarget("genrule", "foo", attrNameToString{ - "cmd": `"cp $(SRCS) $(OUTS)"`, - "outs": `["foo.out"]`, - "srcs": `["foo.in"]`, - }), - }, - }, - } +}` - for _, testCase := range testCases { - t.Run(testCase.description, func(t *testing.T) { - runGenruleTestCase(t, testCase) + expectedBazelTargets := []string{ + makeBazelTarget("genrule", "foo", attrNameToString{ + "cmd": `"cp $(SRCS) $(OUTS)"`, + "outs": `["foo.out"]`, + "srcs": `["foo.in"]`, + })} + + for _, tc := range testCases { + t.Run(tc.moduleType, func(t *testing.T) { + runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, + bp2buildTestCase{ + moduleTypeUnderTest: tc.moduleType, + moduleTypeUnderTestFactory: tc.factory, + blueprint: fmt.Sprintf(bp, tc.moduleType), + expectedBazelTargets: expectedBazelTargets, + }) }) } } -func TestBp2BuildInlinesDefaults(t *testing.T) { +func TestGenruleBp2BuildInlinesDefaults(t *testing.T) { testCases := []bp2buildTestCase{ { description: "genrule applies properties from a genrule_defaults dependency if not specified", diff --git a/bp2build/metrics.go b/bp2build/metrics.go index 557ea994c..8a0b1c96e 100644 --- a/bp2build/metrics.go +++ b/bp2build/metrics.go @@ -9,6 +9,7 @@ import ( "android/soong/android" "android/soong/shared" "android/soong/ui/metrics/bp2build_metrics_proto" + "github.com/google/blueprint" ) // Simple metrics struct to collect information about a Blueprint to BUILD @@ -36,16 +37,24 @@ type CodegenMetrics struct { // List of converted modules convertedModules []string + + // Counts of converted modules by module type. + convertedModuleTypeCount map[string]uint64 + + // Counts of total modules by module type. + totalModuleTypeCount map[string]uint64 } // Serialize returns the protoized version of CodegenMetrics: bp2build_metrics_proto.Bp2BuildMetrics func (metrics *CodegenMetrics) Serialize() bp2build_metrics_proto.Bp2BuildMetrics { return bp2build_metrics_proto.Bp2BuildMetrics{ - GeneratedModuleCount: metrics.generatedModuleCount, - HandCraftedModuleCount: metrics.handCraftedModuleCount, - UnconvertedModuleCount: metrics.unconvertedModuleCount, - RuleClassCount: metrics.ruleClassCount, - ConvertedModules: metrics.convertedModules, + GeneratedModuleCount: metrics.generatedModuleCount, + HandCraftedModuleCount: metrics.handCraftedModuleCount, + UnconvertedModuleCount: metrics.unconvertedModuleCount, + RuleClassCount: metrics.ruleClassCount, + ConvertedModules: metrics.convertedModules, + ConvertedModuleTypeCount: metrics.convertedModuleTypeCount, + TotalModuleTypeCount: metrics.totalModuleTypeCount, } } @@ -113,8 +122,9 @@ func (metrics *CodegenMetrics) IncrementRuleClassCount(ruleClass string) { metrics.ruleClassCount[ruleClass] += 1 } -func (metrics *CodegenMetrics) IncrementUnconvertedCount() { +func (metrics *CodegenMetrics) AddUnconvertedModule(moduleType string) { metrics.unconvertedModuleCount += 1 + metrics.totalModuleTypeCount[moduleType] += 1 } func (metrics *CodegenMetrics) TotalModuleCount() uint64 { @@ -136,10 +146,12 @@ const ( Handcrafted ) -func (metrics *CodegenMetrics) AddConvertedModule(moduleName string, conversionType ConversionType) { +func (metrics *CodegenMetrics) AddConvertedModule(m blueprint.Module, moduleType string, conversionType ConversionType) { // Undo prebuilt_ module name prefix modifications - moduleName = android.RemoveOptionalPrebuiltPrefix(moduleName) + moduleName := android.RemoveOptionalPrebuiltPrefix(m.Name()) metrics.convertedModules = append(metrics.convertedModules, moduleName) + metrics.convertedModuleTypeCount[moduleType] += 1 + metrics.totalModuleTypeCount[moduleType] += 1 if conversionType == Handcrafted { metrics.handCraftedModuleCount += 1 diff --git a/cc/config/bp2build.go b/cc/config/bp2build.go index 4797acca1..982b43648 100644 --- a/cc/config/bp2build.go +++ b/cc/config/bp2build.go @@ -22,6 +22,7 @@ import ( "strings" "android/soong/android" + "github.com/google/blueprint" ) @@ -162,6 +163,10 @@ func exportStringListStaticVariable(name string, value []string) { exportedStringListVars.Set(name, value) } +func ExportStringList(name string, value []string) { + exportedStringListVars.Set(name, value) +} + type exportedStringListDictVariables map[string]map[string][]string func (m exportedStringListDictVariables) Set(k string, v map[string][]string) { diff --git a/cc/ndk_library.go b/cc/ndk_library.go index 7879a7d98..7efe134d2 100644 --- a/cc/ndk_library.go +++ b/cc/ndk_library.go @@ -25,6 +25,7 @@ import ( "github.com/google/blueprint/proptools" "android/soong/android" + "android/soong/cc/config" ) func init() { @@ -208,20 +209,26 @@ func (c *stubDecorator) compilerInit(ctx BaseModuleContext) { *ndkKnownLibs = append(*ndkKnownLibs, name) } +var stubLibraryCompilerFlags = []string{ + // We're knowingly doing some otherwise unsightly things with builtin + // functions here. We're just generating stub libraries, so ignore it. + "-Wno-incompatible-library-redeclaration", + "-Wno-incomplete-setjmp-declaration", + "-Wno-builtin-requires-header", + "-Wno-invalid-noreturn", + "-Wall", + "-Werror", + // These libraries aren't actually used. Don't worry about unwinding + // (avoids the need to link an unwinder into a fake library). + "-fno-unwind-tables", +} + +func init() { + config.ExportStringList("StubLibraryCompilerFlags", stubLibraryCompilerFlags) +} + func addStubLibraryCompilerFlags(flags Flags) Flags { - flags.Global.CFlags = append(flags.Global.CFlags, - // We're knowingly doing some otherwise unsightly things with builtin - // functions here. We're just generating stub libraries, so ignore it. - "-Wno-incompatible-library-redeclaration", - "-Wno-incomplete-setjmp-declaration", - "-Wno-builtin-requires-header", - "-Wno-invalid-noreturn", - "-Wall", - "-Werror", - // These libraries aren't actually used. Don't worry about unwinding - // (avoids the need to link an unwinder into a fake library). - "-fno-unwind-tables", - ) + flags.Global.CFlags = append(flags.Global.CFlags, stubLibraryCompilerFlags...) // All symbols in the stubs library should be visible. if inList("-fvisibility=hidden", flags.Local.CFlags) { flags.Local.CFlags = append(flags.Local.CFlags, "-fvisibility=default") diff --git a/cc/sanitize.go b/cc/sanitize.go index 6c6882217..a054c9148 100644 --- a/cc/sanitize.go +++ b/cc/sanitize.go @@ -42,6 +42,7 @@ var ( "-fno-omit-frame-pointer", "-Wno-frame-larger-than=", "-fsanitize-hwaddress-abi=platform", + "-mllvm", "-hwasan-use-after-scope=1", } // ThinLTO performs codegen during link time, thus these flags need to diff --git a/genrule/genrule.go b/genrule/genrule.go index c3e3ba518..1679a57f6 100644 --- a/genrule/genrule.go +++ b/genrule/genrule.go @@ -862,7 +862,7 @@ func (m *Module) ConvertWithBp2build(ctx android.TopDownMutatorContext) { cmd = strings.Replace(*m.properties.Cmd, "$(in)", "$(SRCS)", -1) cmd = strings.Replace(cmd, "$(out)", "$(OUTS)", -1) genDir := "$(GENDIR)" - if ctx.ModuleType() == "cc_genrule" { + if t := ctx.ModuleType(); t == "cc_genrule" || t == "java_genrule" || t == "java_genrule_host" { genDir = "$(RULEDIR)" } cmd = strings.Replace(cmd, "$(genDir)", genDir, -1) diff --git a/java/app.go b/java/app.go index f57459902..7ae73f797 100755 --- a/java/app.go +++ b/java/app.go @@ -1436,6 +1436,7 @@ type bazelAndroidAppAttributes struct { Manifest bazel.Label Custom_package *string Resource_files bazel.LabelListAttribute + Deps bazel.LabelListAttribute } // ConvertWithBp2build is used to convert android_app to Bazel. @@ -1453,12 +1454,15 @@ func (a *AndroidApp) ConvertWithBp2build(ctx android.TopDownMutatorContext) { resourceFiles.Includes = append(resourceFiles.Includes, files...) } + deps := bazel.MakeLabelListAttribute(android.BazelLabelForModuleDeps(ctx, a.properties.Static_libs)) + attrs := &bazelAndroidAppAttributes{ Srcs: srcs, Manifest: android.BazelLabelForModuleSrcSingle(ctx, manifest), // TODO(b/209576404): handle package name override by product variable PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES Custom_package: a.overridableAppProperties.Package_name, Resource_files: bazel.MakeLabelListAttribute(resourceFiles), + Deps: deps, } props := bazel.BazelTargetModuleProperties{Rule_class: "android_binary", Bzl_load_location: "@rules_android//rules:rules.bzl"} diff --git a/java/genrule.go b/java/genrule.go index 16743b357..5047c412f 100644 --- a/java/genrule.go +++ b/java/genrule.go @@ -24,8 +24,8 @@ func init() { } func RegisterGenRuleBuildComponents(ctx android.RegistrationContext) { - ctx.RegisterModuleType("java_genrule", genRuleFactory) - ctx.RegisterModuleType("java_genrule_host", genRuleFactoryHost) + ctx.RegisterModuleType("java_genrule", GenRuleFactory) + ctx.RegisterModuleType("java_genrule_host", GenRuleFactoryHost) } // java_genrule is a genrule that can depend on other java_* objects. @@ -33,7 +33,7 @@ func RegisterGenRuleBuildComponents(ctx android.RegistrationContext) { // By default a java_genrule has a single variant that will run against the device variant of its dependencies and // produce an output that can be used as an input to a device java rule. // -// Specifying `host_supported: true` will produce two variants, one that uses device dependencie sand one that uses +// Specifying `host_supported: true` will produce two variants, one that uses device dependencies and one that uses // host dependencies. Each variant will run the command. // // Use a java_genrule instead of a genrule when it needs to depend on or be depended on by other java modules, unless @@ -44,7 +44,7 @@ func RegisterGenRuleBuildComponents(ctx android.RegistrationContext) { // Use a java_genrule to package generated java resources: // // java_genrule { -// name: "generated_resources", +// name: "generated_resources", // tools: [ // "generator", // "soong_zip", @@ -60,11 +60,12 @@ func RegisterGenRuleBuildComponents(ctx android.RegistrationContext) { // srcs: ["src/**/*.java"], // static_libs: ["generated_resources"], // } -func genRuleFactory() android.Module { +func GenRuleFactory() android.Module { module := genrule.NewGenRule() android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon) android.InitDefaultableModule(module) + android.InitBazelModule(module) return module } @@ -73,11 +74,12 @@ func genRuleFactory() android.Module { // // A java_genrule_host has a single variant that will run against the host variant of its dependencies and // produce an output that can be used as an input to a host java rule. -func genRuleFactoryHost() android.Module { +func GenRuleFactoryHost() android.Module { module := genrule.NewGenRule() android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon) android.InitDefaultableModule(module) + android.InitBazelModule(module) return module } diff --git a/java/genrule_test.go b/java/genrule_test.go new file mode 100644 index 000000000..1c294b286 --- /dev/null +++ b/java/genrule_test.go @@ -0,0 +1,118 @@ +// Copyright 2018 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 java + +import ( + "reflect" + "strings" + "testing" + + "android/soong/android" +) + +func testGenruleContext(config android.Config) *android.TestContext { + ctx := android.NewTestArchContext(config) + ctx.RegisterModuleType("java_genrule", GenRuleFactory) + ctx.Register() + + return ctx +} + +func TestGenruleCmd(t *testing.T) { + fs := map[string][]byte{ + "tool": nil, + "foo": nil, + } + bp := ` + java_genrule { + name: "gen", + tool_files: ["tool"], + cmd: "$(location tool) $(in) $(out)", + srcs: ["foo"], + out: ["out"], + } + ` + config := android.TestArchConfig(t.TempDir(), nil, bp, fs) + + ctx := testGenruleContext(config) + + _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) + if errs == nil { + _, errs = ctx.PrepareBuildActions(config) + } + if errs != nil { + t.Fatal(errs) + } + + gen := ctx.ModuleForTests("gen", "android_common").Output("out") + expected := []string{"foo"} + if !reflect.DeepEqual(expected, gen.Implicits.Strings()[:len(expected)]) { + t.Errorf(`want arm inputs %v, got %v`, expected, gen.Implicits.Strings()) + } +} + +func TestJarGenrules(t *testing.T) { + ctx, _ := testJava(t, ` + java_library { + name: "foo", + srcs: ["a.java"], + } + + java_genrule { + name: "jargen", + tool_files: ["b.java"], + cmd: "$(location b.java) $(in) $(out)", + out: ["jargen.jar"], + srcs: [":foo"], + } + + java_library { + name: "bar", + static_libs: ["jargen"], + srcs: ["c.java"], + } + + java_library { + name: "baz", + libs: ["jargen"], + srcs: ["c.java"], + } + `) + + foo := ctx.ModuleForTests("foo", "android_common").Output("javac/foo.jar") + jargen := ctx.ModuleForTests("jargen", "android_common").Output("jargen.jar") + bar := ctx.ModuleForTests("bar", "android_common").Output("javac/bar.jar") + baz := ctx.ModuleForTests("baz", "android_common").Output("javac/baz.jar") + barCombined := ctx.ModuleForTests("bar", "android_common").Output("combined/bar.jar") + + if g, w := jargen.Implicits.Strings(), foo.Output.String(); !android.InList(w, g) { + t.Errorf("expected jargen inputs [%q], got %q", w, g) + } + + if !strings.Contains(bar.Args["classpath"], jargen.Output.String()) { + t.Errorf("bar classpath %v does not contain %q", bar.Args["classpath"], jargen.Output.String()) + } + + if !strings.Contains(baz.Args["classpath"], jargen.Output.String()) { + t.Errorf("baz classpath %v does not contain %q", baz.Args["classpath"], jargen.Output.String()) + } + + if len(barCombined.Inputs) != 2 || + barCombined.Inputs[0].String() != bar.Output.String() || + barCombined.Inputs[1].String() != jargen.Output.String() { + t.Errorf("bar combined jar inputs %v is not [%q, %q]", + barCombined.Inputs.Strings(), bar.Output.String(), jargen.Output.String()) + } +} diff --git a/java/java_test.go b/java/java_test.go index 6e4e673ec..3a51981e6 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -997,60 +997,6 @@ func TestSharding(t *testing.T) { } } -func TestJarGenrules(t *testing.T) { - ctx, _ := testJava(t, ` - java_library { - name: "foo", - srcs: ["a.java"], - } - - java_genrule { - name: "jargen", - tool_files: ["b.java"], - cmd: "$(location b.java) $(in) $(out)", - out: ["jargen.jar"], - srcs: [":foo"], - } - - java_library { - name: "bar", - static_libs: ["jargen"], - srcs: ["c.java"], - } - - java_library { - name: "baz", - libs: ["jargen"], - srcs: ["c.java"], - } - `) - - foo := ctx.ModuleForTests("foo", "android_common").Output("javac/foo.jar") - jargen := ctx.ModuleForTests("jargen", "android_common").Output("jargen.jar") - bar := ctx.ModuleForTests("bar", "android_common").Output("javac/bar.jar") - baz := ctx.ModuleForTests("baz", "android_common").Output("javac/baz.jar") - barCombined := ctx.ModuleForTests("bar", "android_common").Output("combined/bar.jar") - - if g, w := jargen.Implicits.Strings(), foo.Output.String(); !android.InList(w, g) { - t.Errorf("expected jargen inputs [%q], got %q", w, g) - } - - if !strings.Contains(bar.Args["classpath"], jargen.Output.String()) { - t.Errorf("bar classpath %v does not contain %q", bar.Args["classpath"], jargen.Output.String()) - } - - if !strings.Contains(baz.Args["classpath"], jargen.Output.String()) { - t.Errorf("baz classpath %v does not contain %q", baz.Args["classpath"], jargen.Output.String()) - } - - if len(barCombined.Inputs) != 2 || - barCombined.Inputs[0].String() != bar.Output.String() || - barCombined.Inputs[1].String() != jargen.Output.String() { - t.Errorf("bar combined jar inputs %v is not [%q, %q]", - barCombined.Inputs.Strings(), bar.Output.String(), jargen.Output.String()) - } -} - func TestExcludeFileGroupInSrcs(t *testing.T) { ctx, _ := testJava(t, ` java_library { diff --git a/ui/metrics/bp2build_metrics_proto/bp2build_metrics.pb.go b/ui/metrics/bp2build_metrics_proto/bp2build_metrics.pb.go index 11177e4d5..95f02caba 100644 --- a/ui/metrics/bp2build_metrics_proto/bp2build_metrics.pb.go +++ b/ui/metrics/bp2build_metrics_proto/bp2build_metrics.pb.go @@ -49,6 +49,10 @@ type Bp2BuildMetrics struct { RuleClassCount map[string]uint64 `protobuf:"bytes,4,rep,name=ruleClassCount,proto3" json:"ruleClassCount,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // List of converted modules ConvertedModules []string `protobuf:"bytes,5,rep,name=convertedModules,proto3" json:"convertedModules,omitempty"` + // Counts of converted modules by module type. + ConvertedModuleTypeCount map[string]uint64 `protobuf:"bytes,6,rep,name=convertedModuleTypeCount,proto3" json:"convertedModuleTypeCount,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` + // Counts of total modules by module type. + TotalModuleTypeCount map[string]uint64 `protobuf:"bytes,7,rep,name=totalModuleTypeCount,proto3" json:"totalModuleTypeCount,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` } func (x *Bp2BuildMetrics) Reset() { @@ -118,13 +122,27 @@ func (x *Bp2BuildMetrics) GetConvertedModules() []string { return nil } +func (x *Bp2BuildMetrics) GetConvertedModuleTypeCount() map[string]uint64 { + if x != nil { + return x.ConvertedModuleTypeCount + } + return nil +} + +func (x *Bp2BuildMetrics) GetTotalModuleTypeCount() map[string]uint64 { + if x != nil { + return x.TotalModuleTypeCount + } + return nil +} + var File_bp2build_metrics_proto protoreflect.FileDescriptor var file_bp2build_metrics_proto_rawDesc = []byte{ 0x0a, 0x16, 0x62, 0x70, 0x32, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1c, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x5f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x62, 0x70, 0x32, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x6d, - 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x22, 0x8f, 0x03, 0x0a, 0x0f, 0x42, 0x70, 0x32, 0x42, 0x75, + 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x22, 0xac, 0x06, 0x0a, 0x0f, 0x42, 0x70, 0x32, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x12, 0x32, 0x0a, 0x14, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x14, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, @@ -145,15 +163,40 @@ var file_bp2build_metrics_proto_rawDesc = []byte{ 0x6c, 0x61, 0x73, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2a, 0x0a, 0x10, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x65, 0x64, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x65, 0x64, 0x4d, 0x6f, - 0x64, 0x75, 0x6c, 0x65, 0x73, 0x1a, 0x41, 0x0a, 0x13, 0x52, 0x75, 0x6c, 0x65, 0x43, 0x6c, 0x61, - 0x73, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, - 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, - 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x31, 0x5a, 0x2f, 0x61, 0x6e, 0x64, 0x72, - 0x6f, 0x69, 0x64, 0x2f, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x2f, 0x75, 0x69, 0x2f, 0x6d, 0x65, 0x74, - 0x72, 0x69, 0x63, 0x73, 0x2f, 0x62, 0x70, 0x32, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x6d, 0x65, - 0x74, 0x72, 0x69, 0x63, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x64, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x87, 0x01, 0x0a, 0x18, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, + 0x74, 0x65, 0x64, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x43, 0x6f, 0x75, + 0x6e, 0x74, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x4b, 0x2e, 0x73, 0x6f, 0x6f, 0x6e, 0x67, + 0x5f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x62, 0x70, 0x32, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, + 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x42, 0x70, 0x32, 0x42, 0x75, 0x69, 0x6c, 0x64, + 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x65, + 0x64, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x18, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x65, 0x64, + 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, + 0x7b, 0x0a, 0x14, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x54, 0x79, + 0x70, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x47, 0x2e, + 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x5f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x62, 0x70, 0x32, 0x62, + 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x42, 0x70, 0x32, + 0x42, 0x75, 0x69, 0x6c, 0x64, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x54, 0x6f, 0x74, + 0x61, 0x6c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x43, 0x6f, 0x75, 0x6e, + 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x14, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x4d, 0x6f, 0x64, + 0x75, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x1a, 0x41, 0x0a, 0x13, + 0x52, 0x75, 0x6c, 0x65, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x45, 0x6e, + 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, + 0x4b, 0x0a, 0x1d, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x65, 0x64, 0x4d, 0x6f, 0x64, 0x75, + 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, + 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x47, 0x0a, 0x19, + 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x43, + 0x6f, 0x75, 0x6e, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x31, 0x5a, 0x2f, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, + 0x2f, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x2f, 0x75, 0x69, 0x2f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, + 0x73, 0x2f, 0x62, 0x70, 0x32, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, + 0x63, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -168,18 +211,22 @@ func file_bp2build_metrics_proto_rawDescGZIP() []byte { return file_bp2build_metrics_proto_rawDescData } -var file_bp2build_metrics_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_bp2build_metrics_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_bp2build_metrics_proto_goTypes = []interface{}{ (*Bp2BuildMetrics)(nil), // 0: soong_build_bp2build_metrics.Bp2BuildMetrics nil, // 1: soong_build_bp2build_metrics.Bp2BuildMetrics.RuleClassCountEntry + nil, // 2: soong_build_bp2build_metrics.Bp2BuildMetrics.ConvertedModuleTypeCountEntry + nil, // 3: soong_build_bp2build_metrics.Bp2BuildMetrics.TotalModuleTypeCountEntry } var file_bp2build_metrics_proto_depIdxs = []int32{ 1, // 0: soong_build_bp2build_metrics.Bp2BuildMetrics.ruleClassCount:type_name -> soong_build_bp2build_metrics.Bp2BuildMetrics.RuleClassCountEntry - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 2, // 1: soong_build_bp2build_metrics.Bp2BuildMetrics.convertedModuleTypeCount:type_name -> soong_build_bp2build_metrics.Bp2BuildMetrics.ConvertedModuleTypeCountEntry + 3, // 2: soong_build_bp2build_metrics.Bp2BuildMetrics.totalModuleTypeCount:type_name -> soong_build_bp2build_metrics.Bp2BuildMetrics.TotalModuleTypeCountEntry + 3, // [3:3] is the sub-list for method output_type + 3, // [3:3] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name } func init() { file_bp2build_metrics_proto_init() } @@ -207,7 +254,7 @@ func file_bp2build_metrics_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_bp2build_metrics_proto_rawDesc, NumEnums: 0, - NumMessages: 2, + NumMessages: 4, NumExtensions: 0, NumServices: 0, }, diff --git a/ui/metrics/bp2build_metrics_proto/bp2build_metrics.proto b/ui/metrics/bp2build_metrics_proto/bp2build_metrics.proto index 5e88966b2..6d98a3df5 100644 --- a/ui/metrics/bp2build_metrics_proto/bp2build_metrics.proto +++ b/ui/metrics/bp2build_metrics_proto/bp2build_metrics.proto @@ -32,4 +32,10 @@ message Bp2BuildMetrics { // List of converted modules repeated string convertedModules = 5; + + // Counts of converted modules by module type. + map<string, uint64> convertedModuleTypeCount = 6; + + // Counts of total modules by module type. + map<string, uint64> totalModuleTypeCount = 7; } |