Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 06cf460f authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Build mk2rbc and rbcrun during bootstrap"

parents 6d58321f 7ae80a70
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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)
+21 −14
Original line number Diff line number Diff line
@@ -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.