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

Commit 5524b5b7 authored by Matthew Maurer's avatar Matthew Maurer
Browse files

rust-project.json: Set sysroot in generated file

Bug: 372634041
Test: Go-to-definition for `.expect()` ends up in the prebuilt sources
Change-Id: I4b86b2e1714f1835f8be71850d3fea4b1b815853
parent 2b3da463
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
package config

import (
	"fmt"
	"strings"

	"android/soong/android"
@@ -93,6 +94,16 @@ var (
	}
)

func RustPath(ctx android.PathContext) string {
	// I can't see any way to flatten the static variable inside Soong, so this
	// reproduces the init logic.
	var RustBase string = RustDefaultBase
	if override := ctx.Config().Getenv("RUST_PREBUILTS_BASE"); override != "" {
		RustBase = override
	}
	return fmt.Sprintf("%s/%s/%s", RustBase, HostPrebuiltTag(ctx.Config()), GetRustVersion(ctx))
}

func init() {
	pctx.SourcePathVariable("RustDefaultBase", RustDefaultBase)
	pctx.VariableConfigMethod("HostPrebuiltTag", HostPrebuiltTag)
+5 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ import (
	"fmt"

	"android/soong/android"
	"android/soong/rust/config"
)

// This singleton collects Rust crate definitions and generates a JSON file
@@ -55,6 +56,7 @@ type rustProjectCrate struct {
}

type rustProjectJson struct {
	Sysroot string             `json:"sysroot"`
	Crates  []rustProjectCrate `json:"crates"`
}

@@ -203,6 +205,8 @@ func (singleton *projectGeneratorSingleton) GenerateBuildActions(ctx android.Sin
		return
	}

	singleton.project.Sysroot = config.RustPath(ctx)

	singleton.knownCrates = make(map[string]crateInfo)
	ctx.VisitAllModules(func(module android.Module) {
		singleton.appendCrateAndDependencies(ctx, module)