rust: Support new rust_stdlib_prebuilt_host type
Refactor Rust prebuilts to support the new rust_stdlib_prebuilt_host module type, and change the format for depending on the prebuilt host stdlibs. Bug: 140642453 Test: m Change-Id: Ifbc4741818777934e917631c788b20911856c44a
This commit is contained in:
@@ -147,6 +147,7 @@ func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.An
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (procMacro *procMacroDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkEntries) {
|
func (procMacro *procMacroDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkEntries) {
|
||||||
ctx.SubAndroidMk(ret, procMacro.baseCompiler)
|
ctx.SubAndroidMk(ret, procMacro.baseCompiler)
|
||||||
|
|
||||||
|
@@ -363,9 +363,9 @@ func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps {
|
|||||||
|
|
||||||
if !Bool(compiler.Properties.No_stdlibs) {
|
if !Bool(compiler.Properties.No_stdlibs) {
|
||||||
for _, stdlib := range config.Stdlibs {
|
for _, stdlib := range config.Stdlibs {
|
||||||
// If we're building for the primary arch of the build host, use the compiler's stdlibs
|
// If we're building for the build host, use the prebuilt stdlibs
|
||||||
if ctx.Target().Os == ctx.Config().BuildOS {
|
if ctx.Target().Os == ctx.Config().BuildOS {
|
||||||
stdlib = stdlib + "_" + ctx.toolchain().RustTriple()
|
stdlib = "prebuilt_" + stdlib
|
||||||
}
|
}
|
||||||
deps.Stdlibs = append(deps.Stdlibs, stdlib)
|
deps.Stdlibs = append(deps.Stdlibs, stdlib)
|
||||||
}
|
}
|
||||||
|
@@ -32,6 +32,8 @@ type PrebuiltProperties struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type prebuiltLibraryDecorator struct {
|
type prebuiltLibraryDecorator struct {
|
||||||
|
android.Prebuilt
|
||||||
|
|
||||||
*libraryDecorator
|
*libraryDecorator
|
||||||
Properties PrebuiltProperties
|
Properties PrebuiltProperties
|
||||||
}
|
}
|
||||||
@@ -54,6 +56,13 @@ func PrebuiltRlibFactory() android.Module {
|
|||||||
return module.Init()
|
return module.Init()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func addSrcSupplier(module android.PrebuiltInterface, prebuilt *prebuiltLibraryDecorator) {
|
||||||
|
srcsSupplier := func(_ android.BaseModuleContext, _ android.Module) []string {
|
||||||
|
return prebuilt.prebuiltSrcs()
|
||||||
|
}
|
||||||
|
android.InitPrebuiltModuleWithSrcSupplier(module, srcsSupplier, "srcs")
|
||||||
|
}
|
||||||
|
|
||||||
func NewPrebuiltLibrary(hod android.HostOrDeviceSupported) (*Module, *prebuiltLibraryDecorator) {
|
func NewPrebuiltLibrary(hod android.HostOrDeviceSupported) (*Module, *prebuiltLibraryDecorator) {
|
||||||
module, library := NewRustLibrary(hod)
|
module, library := NewRustLibrary(hod)
|
||||||
library.BuildOnlyRust()
|
library.BuildOnlyRust()
|
||||||
@@ -62,6 +71,9 @@ func NewPrebuiltLibrary(hod android.HostOrDeviceSupported) (*Module, *prebuiltLi
|
|||||||
libraryDecorator: library,
|
libraryDecorator: library,
|
||||||
}
|
}
|
||||||
module.compiler = prebuilt
|
module.compiler = prebuilt
|
||||||
|
|
||||||
|
addSrcSupplier(module, prebuilt)
|
||||||
|
|
||||||
return module, prebuilt
|
return module, prebuilt
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,6 +85,9 @@ func NewPrebuiltDylib(hod android.HostOrDeviceSupported) (*Module, *prebuiltLibr
|
|||||||
libraryDecorator: library,
|
libraryDecorator: library,
|
||||||
}
|
}
|
||||||
module.compiler = prebuilt
|
module.compiler = prebuilt
|
||||||
|
|
||||||
|
addSrcSupplier(module, prebuilt)
|
||||||
|
|
||||||
return module, prebuilt
|
return module, prebuilt
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,6 +99,9 @@ func NewPrebuiltRlib(hod android.HostOrDeviceSupported) (*Module, *prebuiltLibra
|
|||||||
libraryDecorator: library,
|
libraryDecorator: library,
|
||||||
}
|
}
|
||||||
module.compiler = prebuilt
|
module.compiler = prebuilt
|
||||||
|
|
||||||
|
addSrcSupplier(module, prebuilt)
|
||||||
|
|
||||||
return module, prebuilt
|
return module, prebuilt
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,3 +148,7 @@ func (prebuilt *prebuiltLibraryDecorator) prebuiltSrcs() []string {
|
|||||||
|
|
||||||
return srcs
|
return srcs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (prebuilt *prebuiltLibraryDecorator) prebuilt() *android.Prebuilt {
|
||||||
|
return &prebuilt.Prebuilt
|
||||||
|
}
|
||||||
|
@@ -1019,6 +1019,13 @@ func (mod *Module) begin(ctx BaseModuleContext) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (mod *Module) Prebuilt() *android.Prebuilt {
|
||||||
|
if p, ok := mod.compiler.(*prebuiltLibraryDecorator); ok {
|
||||||
|
return p.prebuilt()
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
||||||
var depPaths PathDeps
|
var depPaths PathDeps
|
||||||
|
|
||||||
|
@@ -53,74 +53,14 @@ var PrepareForTestWithRustIncludeVndk = android.GroupFixturePreparers(
|
|||||||
func GatherRequiredDepsForTest() string {
|
func GatherRequiredDepsForTest() string {
|
||||||
bp := `
|
bp := `
|
||||||
rust_prebuilt_library {
|
rust_prebuilt_library {
|
||||||
name: "libstd_x86_64-unknown-linux-gnu",
|
name: "libstd",
|
||||||
crate_name: "std",
|
crate_name: "std",
|
||||||
rlib: {
|
rlib: {
|
||||||
srcs: ["libstd.rlib"],
|
srcs: ["libstd.rlib"],
|
||||||
},
|
},
|
||||||
dylib: {
|
dylib: {
|
||||||
srcs: ["libstd.so"],
|
srcs: ["libstd.so"],
|
||||||
},
|
},
|
||||||
host_supported: true,
|
|
||||||
sysroot: true,
|
|
||||||
}
|
|
||||||
rust_prebuilt_library {
|
|
||||||
name: "libtest_x86_64-unknown-linux-gnu",
|
|
||||||
crate_name: "test",
|
|
||||||
rlib: {
|
|
||||||
srcs: ["libtest.rlib"],
|
|
||||||
},
|
|
||||||
dylib: {
|
|
||||||
srcs: ["libtest.so"],
|
|
||||||
},
|
|
||||||
host_supported: true,
|
|
||||||
sysroot: true,
|
|
||||||
}
|
|
||||||
rust_prebuilt_library {
|
|
||||||
name: "libstd_i686-unknown-linux-gnu",
|
|
||||||
crate_name: "std",
|
|
||||||
rlib: {
|
|
||||||
srcs: ["libstd.rlib"],
|
|
||||||
},
|
|
||||||
dylib: {
|
|
||||||
srcs: ["libstd.so"],
|
|
||||||
},
|
|
||||||
host_supported: true,
|
|
||||||
sysroot: true,
|
|
||||||
}
|
|
||||||
rust_prebuilt_library {
|
|
||||||
name: "libtest_i686-unknown-linux-gnu",
|
|
||||||
crate_name: "test",
|
|
||||||
rlib: {
|
|
||||||
srcs: ["libtest.rlib"],
|
|
||||||
},
|
|
||||||
dylib: {
|
|
||||||
srcs: ["libtest.so"],
|
|
||||||
},
|
|
||||||
host_supported: true,
|
|
||||||
sysroot: true,
|
|
||||||
}
|
|
||||||
rust_prebuilt_library {
|
|
||||||
name: "libstd_x86_64-apple-darwin",
|
|
||||||
crate_name: "std",
|
|
||||||
rlib: {
|
|
||||||
srcs: ["libstd.rlib"],
|
|
||||||
},
|
|
||||||
dylib: {
|
|
||||||
srcs: ["libstd.so"],
|
|
||||||
},
|
|
||||||
host_supported: true,
|
|
||||||
sysroot: true,
|
|
||||||
}
|
|
||||||
rust_prebuilt_library {
|
|
||||||
name: "libtest_x86_64-apple-darwin",
|
|
||||||
crate_name: "test",
|
|
||||||
rlib: {
|
|
||||||
srcs: ["libtest.rlib"],
|
|
||||||
},
|
|
||||||
dylib: {
|
|
||||||
srcs: ["libtest.so"],
|
|
||||||
},
|
|
||||||
host_supported: true,
|
host_supported: true,
|
||||||
sysroot: true,
|
sysroot: true,
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user