diff options
| author | 2023-06-16 10:28:04 -0400 | |
|---|---|---|
| committer | 2023-09-15 22:46:56 +0000 | |
| commit | a588d153c85485336e0509f475a4eec653be339b (patch) | |
| tree | f95a13945dd147c12c7ae5323763b8e14a2172f0 /rust/library.go | |
| parent | d96a60685a3147d6d6f15daf4a5cad419e737430 (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/library.go')
| -rw-r--r-- | rust/library.go | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/rust/library.go b/rust/library.go index 7432a12be..87b25cb9c 100644 --- a/rust/library.go +++ b/rust/library.go @@ -485,6 +485,23 @@ func (library *libraryDecorator) compilerFlags(ctx ModuleContext, flags Flags) F return flags } +func (library *libraryDecorator) compilationSourcesAndData(ctx ModuleContext) android.Paths { + var extraSrcs android.Paths + if library.rlib() { + extraSrcs = android.PathsForModuleSrc(ctx, library.Properties.Rlib.Srcs) + } else if library.dylib() { + extraSrcs = android.PathsForModuleSrc(ctx, library.Properties.Dylib.Srcs) + } else if library.static() { + extraSrcs = android.PathsForModuleSrc(ctx, library.Properties.Static.Srcs) + } else if library.shared() { + extraSrcs = android.PathsForModuleSrc(ctx, library.Properties.Shared.Srcs) + } + return android.Concat( + library.baseCompiler.compilationSourcesAndData(ctx), + extraSrcs, + ) +} + func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) buildOutput { var outputFile android.ModuleOutPath var ret buildOutput @@ -525,7 +542,6 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa flags.RustFlags = append(flags.RustFlags, deps.depFlags...) flags.LinkFlags = append(flags.LinkFlags, deps.depLinkFlags...) - flags.LinkFlags = append(flags.LinkFlags, deps.linkObjects.Strings()...) if library.dylib() { // We need prefer-dynamic for now to avoid linking in the static stdlib. See: @@ -536,13 +552,13 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa // Call the appropriate builder for this library type if library.rlib() { - ret.kytheFile = TransformSrctoRlib(ctx, crateRootPath, deps, flags, outputFile).kytheFile + ret.kytheFile = TransformSrctoRlib(ctx, library, crateRootPath, deps, flags, outputFile).kytheFile } else if library.dylib() { - ret.kytheFile = TransformSrctoDylib(ctx, crateRootPath, deps, flags, outputFile).kytheFile + ret.kytheFile = TransformSrctoDylib(ctx, library, crateRootPath, deps, flags, outputFile).kytheFile } else if library.static() { - ret.kytheFile = TransformSrctoStatic(ctx, crateRootPath, deps, flags, outputFile).kytheFile + ret.kytheFile = TransformSrctoStatic(ctx, library, crateRootPath, deps, flags, outputFile).kytheFile } else if library.shared() { - ret.kytheFile = TransformSrctoShared(ctx, crateRootPath, deps, flags, outputFile).kytheFile + ret.kytheFile = TransformSrctoShared(ctx, library, crateRootPath, deps, flags, outputFile).kytheFile } if library.rlib() || library.dylib() { |