Merge "add bp2build subevents" into main
This commit is contained in:
@@ -15,7 +15,6 @@
|
|||||||
package bp2build
|
package bp2build
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"android/soong/starlark_import"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -24,6 +23,7 @@ import (
|
|||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
"android/soong/bazel"
|
"android/soong/bazel"
|
||||||
"android/soong/shared"
|
"android/soong/shared"
|
||||||
|
"android/soong/starlark_import"
|
||||||
)
|
)
|
||||||
|
|
||||||
func deleteFilesExcept(ctx *CodegenContext, rootOutputPath android.OutputPath, except []BazelFile) {
|
func deleteFilesExcept(ctx *CodegenContext, rootOutputPath android.OutputPath, except []BazelFile) {
|
||||||
@@ -67,6 +67,8 @@ func deleteFilesExcept(ctx *CodegenContext, rootOutputPath android.OutputPath, e
|
|||||||
// writing .bzl files that are equivalent to Android.bp files that are capable
|
// writing .bzl files that are equivalent to Android.bp files that are capable
|
||||||
// of being built with Bazel.
|
// of being built with Bazel.
|
||||||
func Codegen(ctx *CodegenContext) *CodegenMetrics {
|
func Codegen(ctx *CodegenContext) *CodegenMetrics {
|
||||||
|
ctx.Context().BeginEvent("Codegen")
|
||||||
|
defer ctx.Context().EndEvent("Codegen")
|
||||||
// This directory stores BUILD files that could be eventually checked-in.
|
// This directory stores BUILD files that could be eventually checked-in.
|
||||||
bp2buildDir := android.PathForOutput(ctx, "bp2build")
|
bp2buildDir := android.PathForOutput(ctx, "bp2build")
|
||||||
|
|
||||||
@@ -79,7 +81,10 @@ func Codegen(ctx *CodegenContext) *CodegenMetrics {
|
|||||||
fmt.Printf("ERROR: Encountered %d error(s): \nERROR: %s", len(errs), strings.Join(errMsgs, "\n"))
|
fmt.Printf("ERROR: Encountered %d error(s): \nERROR: %s", len(errs), strings.Join(errMsgs, "\n"))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
bp2buildFiles := CreateBazelFiles(ctx.Config(), nil, res.buildFileToTargets, ctx.mode)
|
var bp2buildFiles []BazelFile
|
||||||
|
ctx.Context().EventHandler.Do("CreateBazelFile", func() {
|
||||||
|
bp2buildFiles = CreateBazelFiles(ctx.Config(), nil, res.buildFileToTargets, ctx.mode)
|
||||||
|
})
|
||||||
injectionFiles, additionalBp2buildFiles, err := CreateSoongInjectionDirFiles(ctx, res.metrics)
|
injectionFiles, additionalBp2buildFiles, err := CreateSoongInjectionDirFiles(ctx, res.metrics)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("%s\n", err.Error())
|
fmt.Printf("%s\n", err.Error())
|
||||||
|
@@ -653,6 +653,8 @@ func generateBazelTargetsGoBinary(ctx *android.Context, g *bootstrap.GoBinary, g
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GenerateBazelTargets(ctx *CodegenContext, generateFilegroups bool) (conversionResults, []error) {
|
func GenerateBazelTargets(ctx *CodegenContext, generateFilegroups bool) (conversionResults, []error) {
|
||||||
|
ctx.Context().BeginEvent("GenerateBazelTargets")
|
||||||
|
defer ctx.Context().EndEvent("GenerateBazelTargets")
|
||||||
buildFileToTargets := make(map[string]BazelTargets)
|
buildFileToTargets := make(map[string]BazelTargets)
|
||||||
|
|
||||||
// Simple metrics tracking for bp2build
|
// Simple metrics tracking for bp2build
|
||||||
|
@@ -814,9 +814,7 @@ func runBp2Build(ctx *android.Context, extraNinjaDeps []string, metricsDir strin
|
|||||||
// Run the code-generation phase to convert BazelTargetModules to BUILD files
|
// Run the code-generation phase to convert BazelTargetModules to BUILD files
|
||||||
// and print conversion codegenMetrics to the user.
|
// and print conversion codegenMetrics to the user.
|
||||||
codegenContext := bp2build.NewCodegenContext(ctx.Config(), ctx, bp2build.Bp2Build, topDir)
|
codegenContext := bp2build.NewCodegenContext(ctx.Config(), ctx, bp2build.Bp2Build, topDir)
|
||||||
ctx.EventHandler.Do("codegen", func() {
|
|
||||||
codegenMetrics = bp2build.Codegen(codegenContext)
|
codegenMetrics = bp2build.Codegen(codegenContext)
|
||||||
})
|
|
||||||
|
|
||||||
ninjaDeps = append(ninjaDeps, codegenContext.AdditionalNinjaDeps()...)
|
ninjaDeps = append(ninjaDeps, codegenContext.AdditionalNinjaDeps()...)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user