From db72f7ed803df370951f7a03bd6f6fcad1b357e2 Mon Sep 17 00:00:00 2001 From: Matthew Maurer Date: Tue, 21 Nov 2023 00:20:02 +0000 Subject: rust: Resolve crate roots outside rust-project Previously, we manually re-computed crate roots inside project_json for rendering rust-project.json. In addition to added complexity, this meant that generated sources and glob sources would not render correctly - it would select e.g. `src/**.rs` or `:foo` as a crate root. Use a centralized computation of crate roots instead. Bug: 309943184 Test: SOONG_GEN_RUST_PROJECT=1 m nothing, compare rust-project.json Change-Id: I0caddbf600d025a0041f45e69812cdd6f1761234 --- rust/compiler.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'rust/compiler.go') diff --git a/rust/compiler.go b/rust/compiler.go index e2415a4a7..9afaec587 100644 --- a/rust/compiler.go +++ b/rust/compiler.go @@ -44,6 +44,8 @@ type compiler interface { compile(ctx ModuleContext, flags Flags, deps PathDeps) buildOutput compilerDeps(ctx DepsContext, deps Deps) Deps crateName() string + edition() string + features() []string rustdoc(ctx ModuleContext, flags Flags, deps PathDeps) android.OptionalPath // Output directory in which source-generated code from dependencies is @@ -307,9 +309,13 @@ func (compiler *baseCompiler) cfgsToFlags() []string { return flags } +func (compiler *baseCompiler) features() []string { + return compiler.Properties.Features +} + func (compiler *baseCompiler) featuresToFlags() []string { flags := []string{} - for _, feature := range compiler.Properties.Features { + for _, feature := range compiler.features() { flags = append(flags, "--cfg 'feature=\""+feature+"\"'") } -- cgit v1.2.3-59-g8ed1b