diff options
Diffstat (limited to 'rust/toolchain_library.go')
-rw-r--r-- | rust/toolchain_library.go | 67 |
1 files changed, 6 insertions, 61 deletions
diff --git a/rust/toolchain_library.go b/rust/toolchain_library.go index e118f92be..326d52924 100644 --- a/rust/toolchain_library.go +++ b/rust/toolchain_library.go @@ -21,8 +21,6 @@ import ( "android/soong/android" "android/soong/rust/config" - - "github.com/google/blueprint/proptools" ) // This module is used to compile the rust toolchain libraries @@ -35,15 +33,11 @@ func init() { rustToolchainLibraryRlibFactory) android.RegisterModuleType("rust_toolchain_library_dylib", rustToolchainLibraryDylibFactory) - android.RegisterModuleType("rust_toolchain_rustc_prebuilt", - rustToolchainRustcPrebuiltFactory) } type toolchainLibraryProperties struct { - // 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"` + // path to the toolchain source, relative to the top of the toolchain source + Toolchain_src *string `android:"arch_variant"` } type toolchainLibraryDecorator struct { @@ -89,20 +83,15 @@ 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) - 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) - } + newSrcs := []string{path.Join(prefix, android.String(toolchainLib.Properties.Toolchain_src))} type props struct { - Crate_root *string - Srcs []string + Srcs []string } p := &props{} - p.Crate_root = &versionedCrateRoot - p.Srcs = versionedSrcs + p.Srcs = newSrcs ctx.AppendProperties(p) + } else { ctx.ModuleErrorf("Called rustSetToolchainSource on a non-Rust Module.") } @@ -112,47 +101,3 @@ func rustSetToolchainSource(ctx android.LoadHookContext) { func GetRustPrebuiltVersion(ctx android.LoadHookContext) string { return ctx.AConfig().GetenvWithDefault("RUST_PREBUILTS_VERSION", config.RustDefaultVersion) } - -type toolchainRustcPrebuiltProperties struct { - // path to rustc prebuilt, relative to the top of the toolchain source - Toolchain_prebuilt_src *string - // path to deps, relative to the top of the toolchain source - Toolchain_deps []string - // path to deps, relative to module directory - Deps []string -} - -func rustToolchainRustcPrebuiltFactory() android.Module { - module := android.NewPrebuiltBuildTool() - module.AddProperties(&toolchainRustcPrebuiltProperties{}) - android.AddLoadHook(module, func(ctx android.LoadHookContext) { - var toolchainProps *toolchainRustcPrebuiltProperties - for _, p := range ctx.Module().GetProperties() { - toolchainProperties, ok := p.(*toolchainRustcPrebuiltProperties) - if ok { - toolchainProps = toolchainProperties - } - } - - if toolchainProps.Toolchain_prebuilt_src == nil { - ctx.PropertyErrorf("toolchain_prebuilt_src", "must set path to rustc prebuilt") - } - - prefix := "linux-x86/" + GetRustPrebuiltVersion(ctx) - deps := make([]string, 0, len(toolchainProps.Toolchain_deps)+len(toolchainProps.Deps)) - for _, d := range toolchainProps.Toolchain_deps { - deps = append(deps, path.Join(prefix, d)) - } - deps = append(deps, toolchainProps.Deps...) - - props := struct { - Src *string - Deps []string - }{ - Src: proptools.StringPtr(path.Join(prefix, *toolchainProps.Toolchain_prebuilt_src)), - Deps: deps, - } - ctx.AppendProperties(&props) - }) - return module -} |