summaryrefslogtreecommitdiff
path: root/rust/rust.go
diff options
context:
space:
mode:
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
commitee6a89ba440aedbf7f1c89333f5046418e6e3459 (patch)
treecd1cf61bbecbbbf14605233ffcf02b133d322558 /rust/rust.go
parentaa52d66cd572d2cc62573078c02cad062e7ddeb5 (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/rust.go')
-rw-r--r--rust/rust.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/rust/rust.go b/rust/rust.go
index dc23abb8d..8ebdb727c 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -320,12 +320,16 @@ type RustLibrary struct {
}
type compiler interface {
+ initialize(ctx ModuleContext)
compilerFlags(ctx ModuleContext, flags Flags) Flags
compilerProps() []interface{}
compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Path
compilerDeps(ctx DepsContext, deps Deps) Deps
crateName() string
+ // Output directory in which source-generated code from dependencies is
+ // copied. This is equivalent to Cargo's OUT_DIR variable.
+ CargoOutDir() android.OptionalPath
inData() bool
install(ctx ModuleContext)
relativeInstallPath() string
@@ -711,6 +715,7 @@ func (mod *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
}
if mod.compiler != nil && !mod.compiler.Disabled() {
+ mod.compiler.initialize(ctx)
outputFile := mod.compiler.compile(ctx, flags, deps)
mod.outputFile = android.OptionalPathForPath(outputFile)