diff options
Diffstat (limited to 'rust/compiler.go')
-rw-r--r-- | rust/compiler.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/rust/compiler.go b/rust/compiler.go index c1bdbeb91..03fdf2b7a 100644 --- a/rust/compiler.go +++ b/rust/compiler.go @@ -75,6 +75,8 @@ type compiler interface { strippedOutputFilePath() android.OptionalPath checkedCrateRootPath() (android.Path, error) + + Aliases() map[string]string } func (compiler *baseCompiler) edition() string { @@ -140,6 +142,12 @@ type BaseCompilerProperties struct { // flags to pass to the linker Ld_flags []string `android:"arch_variant"` + // Rust crate dependencies to rename. Each entry should be a string of the form "dependencyname:alias". + // + // "dependencyname" here should be the name of the crate, not the Android module. This is + // equivalent to writing `alias = { package = "dependencyname" }` in a `Cargo.toml`. + Aliases []string + // list of rust rlib crate dependencies Rlibs []string `android:"arch_variant"` @@ -281,6 +289,18 @@ func (compiler *baseCompiler) preferRlib() bool { return Bool(compiler.Properties.Prefer_rlib) } +func (compiler *baseCompiler) Aliases() map[string]string { + aliases := map[string]string{} + for _, entry := range compiler.Properties.Aliases { + dep, alias, found := strings.Cut(entry, ":") + if !found { + panic(fmt.Errorf("invalid aliases entry %q missing ':'", entry)) + } + aliases[dep] = alias + } + return aliases +} + func (compiler *baseCompiler) stdLinkage(ctx *depsContext) RustLinkage { // For devices, we always link stdlibs in as dylibs by default. if compiler.preferRlib() { |