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
diff --git a/rust/project_json_test.go b/rust/project_json_test.go
index ba66215..289bcb8 100644
--- a/rust/project_json_test.go
+++ b/rust/project_json_test.go
@@ -190,8 +190,8 @@
 				}
 			}
 		}
-		// 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 @@
 				}
 			}
 			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)
+			}
+
 		}
 	}
 }