diff --git a/ui/build/dumpvars.go b/ui/build/dumpvars.go index f3c442ec8..3d160730a 100644 --- a/ui/build/dumpvars.go +++ b/ui/build/dumpvars.go @@ -261,6 +261,12 @@ func runMakeProductConfig(ctx Context, config Config) { "BUILD_BROKEN_USES_BUILD_STATIC_LIBRARY", }, exportEnvVars...), BannerVars...) + // We need Roboleaf converter and runner in the mixed mode + runMicrofactory(ctx, config, ".bootstrap/bin/mk2rbc", "android/soong/mk2rbc/cmd", + map[string]string{"android/soong": "build/soong"}) + runMicrofactory(ctx, config, ".bootstrap/bin/rbcrun", "rbcrun/cmd", + map[string]string{"go.starlark.net": "external/starlark-go", "rbcrun": "build/make/tools/rbcrun"}) + makeVars, err := dumpMakeVars(ctx, config, config.Arguments(), allVars, true, "") if err != nil { ctx.Fatalln("Error dumping make vars:", err) diff --git a/ui/build/soong.go b/ui/build/soong.go index a40457fc6..3fe7b0adb 100644 --- a/ui/build/soong.go +++ b/ui/build/soong.go @@ -265,20 +265,8 @@ func runSoong(ctx Context, config Config) { } }() - var cfg microfactory.Config - cfg.Map("github.com/google/blueprint", "build/blueprint") - - cfg.TrimPath = absPath(ctx, ".") - - func() { - ctx.BeginTrace(metrics.RunSoong, "bpglob") - defer ctx.EndTrace() - - bpglob := filepath.Join(config.SoongOutDir(), ".minibootstrap/bpglob") - if _, err := microfactory.Build(&cfg, bpglob, "github.com/google/blueprint/bootstrap/bpglob"); err != nil { - ctx.Fatalln("Failed to build bpglob:", err) - } - }() + runMicrofactory(ctx, config, ".minibootstrap/bpglob", "github.com/google/blueprint/bootstrap/bpglob", + map[string]string{"github.com/google/blueprint": "build/blueprint"}) ninja := func(name, file string) { ctx.BeginTrace(metrics.RunSoong, name) @@ -332,6 +320,25 @@ func runSoong(ctx Context, config Config) { } } +func runMicrofactory(ctx Context, config Config, relExePath string, pkg string, mapping map[string]string) { + name := filepath.Base(relExePath) + ctx.BeginTrace(metrics.RunSoong, name) + defer ctx.EndTrace() + cfg := microfactory.Config{TrimPath: absPath(ctx, ".")} + for pkgPrefix, pathPrefix := range mapping { + cfg.Map(pkgPrefix, pathPrefix) + } + + exePath := filepath.Join(config.SoongOutDir(), relExePath) + dir := filepath.Dir(exePath) + if err := os.MkdirAll(dir, 0777); err != nil { + ctx.Fatalf("cannot create %s: %s", dir, err) + } + if _, err := microfactory.Build(&cfg, exePath, pkg); err != nil { + ctx.Fatalf("failed to build %s: %s", name, err) + } +} + func shouldCollectBuildSoongMetrics(config Config) bool { // Do not collect metrics protobuf if the soong_build binary ran as the // bp2build converter or the JSON graph dump.