From ee6a89ba440aedbf7f1c89333f5046418e6e3459 Mon Sep 17 00:00:00 2001 From: ThiƩbaud Weksteen Date: Thu, 25 Feb 2021 16:30:57 +0100 Subject: 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 --- rust/project_json_test.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'rust/project_json_test.go') diff --git a/rust/project_json_test.go b/rust/project_json_test.go index ba66215c5..289bcb81d 100644 --- a/rust/project_json_test.go +++ b/rust/project_json_test.go @@ -190,8 +190,8 @@ func TestProjectJsonBindGen(t *testing.T) { } } } - // Check that liba depends on libbindings1 if strings.Contains(rootModule, "d/src/lib.rs") { + // Check that libd depends on libbindings1 found := false for _, depName := range validateDependencies(t, crate) { if depName == "bindings1" { @@ -200,8 +200,17 @@ func TestProjectJsonBindGen(t *testing.T) { } } if !found { - t.Errorf("liba does not depend on libbindings1: %v", crate) + t.Errorf("libd does not depend on libbindings1: %v", crate) } + // Check that OUT_DIR is populated. + env, ok := crate["env"].(map[string]interface{}) + if !ok { + t.Errorf("libd does not have its environment variables set: %v", crate) + } + if _, ok = env["OUT_DIR"]; !ok { + t.Errorf("libd does not have its OUT_DIR set: %v", env) + } + } } } -- cgit v1.2.3-59-g8ed1b