summaryrefslogtreecommitdiff
path: root/rust/compiler.go
diff options
context:
space:
mode:
author Sam Delmerico <delmerico@google.com> 2023-07-13 11:15:37 -0400
committer Sam Delmerico <delmerico@google.com> 2023-08-31 18:03:33 +0000
commit553edff9dda3369612b20c75fa0640b5db17a30d (patch)
tree78ab15847041d5de0764216f636b2a54e92b1536 /rust/compiler.go
parentb45c844ce78b3f636996ead7e88aee9c220e5a92 (diff)
add crate_root property to rust modules
The crate_root property will be used to specify the entry point for a rustc compilation. This will allow the srcs property to be used to collect all src inputs to rustc rather than just the entry point. Bug: 286077158 Test: m libnum_traits Change-Id: I1a167182305dcc11cc927d562ceed622153111d3
Diffstat (limited to 'rust/compiler.go')
-rw-r--r--rust/compiler.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/rust/compiler.go b/rust/compiler.go
index e6a7a9356..d6c52e8d4 100644
--- a/rust/compiler.go
+++ b/rust/compiler.go
@@ -73,6 +73,15 @@ type BaseCompilerProperties struct {
// If no source file is defined, a single generated source module can be defined to be used as the main source.
Srcs []string `android:"path,arch_variant"`
+ // Entry point that is passed to rustc to begin the compilation. E.g. main.rs or lib.rs.
+ // When this property is set,
+ // * sandboxing is enabled for this module, and
+ // * the srcs attribute is interpreted as a list of all source files potentially
+ // used in compilation, including the entrypoint, and
+ // * compile_data can be used to add additional files used in compilation that
+ // not directly used as source files.
+ Crate_root *string `android:"path,arch_variant"`
+
// name of the lint set that should be used to validate this module.
//
// Possible values are "default" (for using a sensible set of lints
@@ -511,6 +520,8 @@ func srcPathFromModuleSrcs(ctx ModuleContext, srcs []string) (android.Path, andr
ctx.PropertyErrorf("srcs", "only a single generated source module can be defined without a main source file.")
}
+ // TODO: b/297264540 - once all modules are sandboxed, we need to select the proper
+ // entry point file from Srcs rather than taking the first one
paths := android.PathsForModuleSrc(ctx, srcs)
return paths[srcIndex], paths[1:]
}