summaryrefslogtreecommitdiff
path: root/rust/compiler.go
diff options
context:
space:
mode:
author Sam Delmerico <delmerico@google.com> 2023-06-16 10:28:04 -0400
committer Sam Delmerico <delmerico@google.com> 2023-09-15 22:46:56 +0000
commita588d153c85485336e0509f475a4eec653be339b (patch)
treef95a13945dd147c12c7ae5323763b8e14a2172f0 /rust/compiler.go
parentd96a60685a3147d6d6f15daf4a5cad419e737430 (diff)
support sandboxed rust rules
This commit adds support for compiling rust rules inside the sbox sandbox. To compile a rust module with sandboxing enabled, the entry point to the crate must be specified via the `crate_root` property, and all input sources and compile-time data must be specified via the `srcs` and `compile_data` properties. Bug: 286077158 Change-Id: I8c9dc5cf7578037a583b4be2e2f73cf20ffd4408
Diffstat (limited to 'rust/compiler.go')
-rw-r--r--rust/compiler.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/rust/compiler.go b/rust/compiler.go
index d6c52e8d4..3fa3ccd69 100644
--- a/rust/compiler.go
+++ b/rust/compiler.go
@@ -82,6 +82,9 @@ type BaseCompilerProperties struct {
// not directly used as source files.
Crate_root *string `android:"path,arch_variant"`
+ // Additional data files that are used during compilation only. These are not accessible at runtime.
+ Compile_data []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
@@ -343,6 +346,23 @@ func (compiler *baseCompiler) compile(ctx ModuleContext, flags Flags, deps PathD
panic(fmt.Errorf("baseCrater doesn't know how to crate things!"))
}
+func (compile *baseCompiler) crateRoot(ctx ModuleContext) android.Path {
+ if compile.Properties.Crate_root != nil {
+ return android.PathForModuleSrc(ctx, *compile.Properties.Crate_root)
+ }
+ return nil
+}
+
+// compilationSourcesAndData returns a list of files necessary to complete the compilation.
+// This includes the rust source files as well as any other data files that
+// are referenced during the build.
+func (compile *baseCompiler) compilationSourcesAndData(ctx ModuleContext) android.Paths {
+ return android.PathsForModuleSrc(ctx, android.Concat(
+ compile.Properties.Srcs,
+ compile.Properties.Compile_data,
+ ))
+}
+
func (compiler *baseCompiler) rustdoc(ctx ModuleContext, flags Flags,
deps PathDeps) android.OptionalPath {