diff options
author | 2024-11-01 17:36:10 +0000 | |
---|---|---|
committer | 2024-11-01 22:28:41 +0000 | |
commit | 2b3da4636af97ef6fe349d503473db6f60d02550 (patch) | |
tree | 7059ecfa8e108eb9933222f7a22d5ae47a14e813 /rust/project_json.go | |
parent | f7a1f6418ce3fa6b5685ab97cf76d5f9c94e5c14 (diff) |
rust-project.json: Generate proc-macro paths
`rust-analyzer` can expand and reason about code if paths to the built
proc macro files are provided. Generate these from Soong.
Bug: 372634041
Test: Check that rust-project.json contains proc-macro paths
Test: Open system/security/mls/mls-rs-crypto-boringssl/src/lib.rs (for #[derive(Error)])
Change-Id: Ie0985540f1efdf1bbce6a7433ec414bdcad45ea3
Diffstat (limited to 'rust/project_json.go')
-rw-r--r-- | rust/project_json.go | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/rust/project_json.go b/rust/project_json.go index 6c1e32047..6cf492b49 100644 --- a/rust/project_json.go +++ b/rust/project_json.go @@ -44,13 +44,14 @@ 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"` - Cfg []string `json:"cfg"` - Env map[string]string `json:"env"` - ProcMacro bool `json:"is_proc_macro"` + DisplayName string `json:"display_name"` + RootModule string `json:"root_module"` + Edition string `json:"edition,omitempty"` + Deps []rustProjectDep `json:"deps"` + Cfg []string `json:"cfg"` + Env map[string]string `json:"env"` + ProcMacro bool `json:"is_proc_macro"` + ProcMacroDylib *string `json:"proc_macro_dylib_path"` } type rustProjectJson struct { @@ -135,16 +136,21 @@ func (singleton *projectGeneratorSingleton) addCrate(ctx android.SingletonContex return 0, false } - _, procMacro := rModule.compiler.(*procMacroDecorator) + var procMacroDylib *string = nil + if procDec, procMacro := rModule.compiler.(*procMacroDecorator); procMacro { + procMacroDylib = new(string) + *procMacroDylib = procDec.baseCompiler.unstrippedOutputFilePath().String() + } crate := rustProjectCrate{ - DisplayName: rModule.Name(), - RootModule: rootModule.String(), - Edition: rModule.compiler.edition(), - Deps: make([]rustProjectDep, 0), - Cfg: make([]string, 0), - Env: make(map[string]string), - ProcMacro: procMacro, + DisplayName: rModule.Name(), + RootModule: rootModule.String(), + Edition: rModule.compiler.edition(), + Deps: make([]rustProjectDep, 0), + Cfg: make([]string, 0), + Env: make(map[string]string), + ProcMacro: procMacroDylib != nil, + ProcMacroDylib: procMacroDylib, } if rModule.compiler.cargoOutDir().Valid() { |