summaryrefslogtreecommitdiff
path: root/rust/toolchain_library.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/toolchain_library.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/toolchain_library.go')
-rw-r--r--rust/toolchain_library.go19
1 files changed, 13 insertions, 6 deletions
diff --git a/rust/toolchain_library.go b/rust/toolchain_library.go
index 801c0c271..e118f92be 100644
--- a/rust/toolchain_library.go
+++ b/rust/toolchain_library.go
@@ -40,8 +40,10 @@ func init() {
}
type toolchainLibraryProperties struct {
- // path to the toolchain source, relative to the top of the toolchain source
- Toolchain_src *string `android:"arch_variant"`
+ // path to the toolchain crate root, relative to the top of the toolchain source
+ Toolchain_crate_root *string `android:"arch_variant"`
+ // path to the rest of the toolchain srcs, relative to the top of the toolchain source
+ Toolchain_srcs []string `android:"arch_variant"`
}
type toolchainLibraryDecorator struct {
@@ -87,15 +89,20 @@ func initToolchainLibrary(module *Module, library *libraryDecorator) android.Mod
func rustSetToolchainSource(ctx android.LoadHookContext) {
if toolchainLib, ok := ctx.Module().(*Module).compiler.(*toolchainLibraryDecorator); ok {
prefix := "linux-x86/" + GetRustPrebuiltVersion(ctx)
- newSrcs := []string{path.Join(prefix, android.String(toolchainLib.Properties.Toolchain_src))}
+ versionedCrateRoot := path.Join(prefix, android.String(toolchainLib.Properties.Toolchain_crate_root))
+ versionedSrcs := make([]string, len(toolchainLib.Properties.Toolchain_srcs))
+ for i, src := range toolchainLib.Properties.Toolchain_srcs {
+ versionedSrcs[i] = path.Join(prefix, src)
+ }
type props struct {
- Srcs []string
+ Crate_root *string
+ Srcs []string
}
p := &props{}
- p.Srcs = newSrcs
+ p.Crate_root = &versionedCrateRoot
+ p.Srcs = versionedSrcs
ctx.AppendProperties(p)
-
} else {
ctx.ModuleErrorf("Called rustSetToolchainSource on a non-Rust Module.")
}