diff options
author | ThiƩbaud Weksteen <tweek@google.com> | 2021-02-25 16:30:57 +0100 |
---|---|---|
committer | ThiƩbaud Weksteen <tweek@google.com> | 2021-03-15 08:13:20 +0000 |
commit | ee6a89ba440aedbf7f1c89333f5046418e6e3459 (patch) | |
tree | cd1cf61bbecbbbf14605233ffcf02b133d322558 /rust/project_json.go | |
parent | aa52d66cd572d2cc62573078c02cad062e7ddeb5 (diff) |
Export OUT_DIR variable to rust-project.json
This variable is required by rust-analyzer to correctly process crates
that uses the include!(concat!(env!("OUT_DIR"), ...)) pattern.
Adds an initialize method to baseCompiler to save the computed path for
this directory. It is not possible to use the BeginMutator as the
BaseModuleContext does not contain enough information to use
PathForModuleOut.
Bug: 175004835
Test: SOONG_GEN_RUST_PROJECT=1 m nothing; inspect rust-project.json
Change-Id: If47b3832d3cca5712ae87773c174a61f5ee27bf8
Diffstat (limited to 'rust/project_json.go')
-rw-r--r-- | rust/project_json.go | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/rust/project_json.go b/rust/project_json.go index 32ce6f4b0..8d3d250ce 100644 --- a/rust/project_json.go +++ b/rust/project_json.go @@ -45,11 +45,12 @@ type rustProjectDep struct { } type rustProjectCrate struct { - DisplayName string `json:"display_name"` - RootModule string `json:"root_module"` - Edition string `json:"edition,omitempty"` - Deps []rustProjectDep `json:"deps"` - Cfgs []string `json:"cfgs"` + DisplayName string `json:"display_name"` + RootModule string `json:"root_module"` + Edition string `json:"edition,omitempty"` + Deps []rustProjectDep `json:"deps"` + Cfgs []string `json:"cfgs"` + Env map[string]string `json:"env"` } type rustProjectJson struct { @@ -136,7 +137,7 @@ func sourceProviderSource(ctx android.SingletonContext, rModule *Module) (string } }) if !foundSource { - fmt.Errorf("No valid source for source provider found: %v\n", rModule) + ctx.Errorf("No valid source for source provider found: %v\n", rModule) } return sourceSrc, foundSource } @@ -220,7 +221,7 @@ func isModuleSupported(ctx android.SingletonContext, module android.Module) (*Mo func (singleton *projectGeneratorSingleton) addCrate(ctx android.SingletonContext, rModule *Module, comp *baseCompiler) (int, bool) { rootModule, ok := crateSource(ctx, rModule, comp) if !ok { - fmt.Errorf("Unable to find source for valid module: %v", rModule) + ctx.Errorf("Unable to find source for valid module: %v", rModule) return 0, false } @@ -230,6 +231,11 @@ func (singleton *projectGeneratorSingleton) addCrate(ctx android.SingletonContex Edition: comp.edition(), Deps: make([]rustProjectDep, 0), Cfgs: make([]string, 0), + Env: make(map[string]string), + } + + if comp.CargoOutDir().Valid() { + crate.Env["OUT_DIR"] = comp.CargoOutDir().String() } deps := make(map[string]int) |