Merge changes from topic "rust-flex"
* changes: rust: Suppress default sysroot unconditionally rust: Mutate prebuilt modules dylib/rlib rust: Add rustlibs auto dependency selection rust: Change default variants rust: Fix Properties inheritance for prebuilts
This commit is contained in:
commit
367c01b19b
|
@ -131,3 +131,11 @@ func (binary *binaryDecorator) compile(ctx ModuleContext, flags Flags, deps Path
|
|||
func (binary *binaryDecorator) coverageOutputZipPath() android.OptionalPath {
|
||||
return binary.coverageOutputZipFile
|
||||
}
|
||||
|
||||
func (binary *binaryDecorator) autoDep() autoDep {
|
||||
if binary.preferDynamic() {
|
||||
return dylibAutoDep
|
||||
} else {
|
||||
return rlibAutoDep
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,37 +70,37 @@ func init() {
|
|||
}
|
||||
|
||||
func TransformSrcToBinary(ctx ModuleContext, mainSrc android.Path, deps PathDeps, flags Flags,
|
||||
outputFile android.WritablePath, includeDirs []string) buildOutput {
|
||||
outputFile android.WritablePath, linkDirs []string) buildOutput {
|
||||
flags.RustFlags = append(flags.RustFlags, "-C lto")
|
||||
|
||||
return transformSrctoCrate(ctx, mainSrc, deps, flags, outputFile, "bin", includeDirs)
|
||||
return transformSrctoCrate(ctx, mainSrc, deps, flags, outputFile, "bin", linkDirs)
|
||||
}
|
||||
|
||||
func TransformSrctoRlib(ctx ModuleContext, mainSrc android.Path, deps PathDeps, flags Flags,
|
||||
outputFile android.WritablePath, includeDirs []string) buildOutput {
|
||||
return transformSrctoCrate(ctx, mainSrc, deps, flags, outputFile, "rlib", includeDirs)
|
||||
outputFile android.WritablePath, linkDirs []string) buildOutput {
|
||||
return transformSrctoCrate(ctx, mainSrc, deps, flags, outputFile, "rlib", linkDirs)
|
||||
}
|
||||
|
||||
func TransformSrctoDylib(ctx ModuleContext, mainSrc android.Path, deps PathDeps, flags Flags,
|
||||
outputFile android.WritablePath, includeDirs []string) buildOutput {
|
||||
return transformSrctoCrate(ctx, mainSrc, deps, flags, outputFile, "dylib", includeDirs)
|
||||
outputFile android.WritablePath, linkDirs []string) buildOutput {
|
||||
return transformSrctoCrate(ctx, mainSrc, deps, flags, outputFile, "dylib", linkDirs)
|
||||
}
|
||||
|
||||
func TransformSrctoStatic(ctx ModuleContext, mainSrc android.Path, deps PathDeps, flags Flags,
|
||||
outputFile android.WritablePath, includeDirs []string) buildOutput {
|
||||
outputFile android.WritablePath, linkDirs []string) buildOutput {
|
||||
flags.RustFlags = append(flags.RustFlags, "-C lto")
|
||||
return transformSrctoCrate(ctx, mainSrc, deps, flags, outputFile, "staticlib", includeDirs)
|
||||
return transformSrctoCrate(ctx, mainSrc, deps, flags, outputFile, "staticlib", linkDirs)
|
||||
}
|
||||
|
||||
func TransformSrctoShared(ctx ModuleContext, mainSrc android.Path, deps PathDeps, flags Flags,
|
||||
outputFile android.WritablePath, includeDirs []string) buildOutput {
|
||||
outputFile android.WritablePath, linkDirs []string) buildOutput {
|
||||
flags.RustFlags = append(flags.RustFlags, "-C lto")
|
||||
return transformSrctoCrate(ctx, mainSrc, deps, flags, outputFile, "cdylib", includeDirs)
|
||||
return transformSrctoCrate(ctx, mainSrc, deps, flags, outputFile, "cdylib", linkDirs)
|
||||
}
|
||||
|
||||
func TransformSrctoProcMacro(ctx ModuleContext, mainSrc android.Path, deps PathDeps,
|
||||
flags Flags, outputFile android.WritablePath, includeDirs []string) buildOutput {
|
||||
return transformSrctoCrate(ctx, mainSrc, deps, flags, outputFile, "proc-macro", includeDirs)
|
||||
flags Flags, outputFile android.WritablePath, linkDirs []string) buildOutput {
|
||||
return transformSrctoCrate(ctx, mainSrc, deps, flags, outputFile, "proc-macro", linkDirs)
|
||||
}
|
||||
|
||||
func rustLibsToPaths(libs RustLibraries) android.Paths {
|
||||
|
@ -112,7 +112,7 @@ func rustLibsToPaths(libs RustLibraries) android.Paths {
|
|||
}
|
||||
|
||||
func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, flags Flags,
|
||||
outputFile android.WritablePath, crate_type string, includeDirs []string) buildOutput {
|
||||
outputFile android.WritablePath, crate_type string, linkDirs []string) buildOutput {
|
||||
|
||||
var inputs android.Paths
|
||||
var implicits android.Paths
|
||||
|
@ -137,16 +137,10 @@ func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, fl
|
|||
rustcFlags = append(rustcFlags, "--target="+targetTriple)
|
||||
linkFlags = append(linkFlags, "-target "+targetTriple)
|
||||
}
|
||||
// TODO(b/159718669): Once we have defined static libraries in the host
|
||||
// prebuilts Blueprint file, sysroot should be unconditionally sourced
|
||||
// from /dev/null. Explicitly set sysroot to avoid clippy-driver to
|
||||
// internally call rustc.
|
||||
if ctx.Host() && ctx.TargetPrimary() {
|
||||
rustcFlags = append(rustcFlags, "--sysroot=${config.RustPath}")
|
||||
} else {
|
||||
// If we're not targeting the host primary arch, do not use a sysroot.
|
||||
rustcFlags = append(rustcFlags, "--sysroot=/dev/null")
|
||||
}
|
||||
|
||||
// Suppress an implicit sysroot
|
||||
rustcFlags = append(rustcFlags, "--sysroot=/dev/null")
|
||||
|
||||
// Collect linker flags
|
||||
linkFlags = append(linkFlags, flags.GlobalLinkFlags...)
|
||||
linkFlags = append(linkFlags, flags.LinkFlags...)
|
||||
|
@ -162,7 +156,7 @@ func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, fl
|
|||
libFlags = append(libFlags, "--extern "+proc_macro.CrateName+"="+proc_macro.Path.String())
|
||||
}
|
||||
|
||||
for _, path := range includeDirs {
|
||||
for _, path := range linkDirs {
|
||||
libFlags = append(libFlags, "-L "+path)
|
||||
}
|
||||
|
||||
|
|
|
@ -32,14 +32,14 @@ func TestClippy(t *testing.T) {
|
|||
clippy: false,
|
||||
}`)
|
||||
|
||||
ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_shared").Output("libfoo.so")
|
||||
fooClippy := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_shared").MaybeRule("clippy")
|
||||
ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_dylib").Output("libfoo.dylib.so")
|
||||
fooClippy := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_dylib").MaybeRule("clippy")
|
||||
if fooClippy.Rule.String() != "android/soong/rust.clippy" {
|
||||
t.Errorf("Clippy output (default) for libfoo was not generated: %+v", fooClippy)
|
||||
}
|
||||
|
||||
ctx.ModuleForTests("libfoobar", "android_arm64_armv8-a_shared").Output("libfoobar.so")
|
||||
foobarClippy := ctx.ModuleForTests("libfoobar", "android_arm64_armv8-a_shared").MaybeRule("clippy")
|
||||
ctx.ModuleForTests("libfoobar", "android_arm64_armv8-a_dylib").Output("libfoobar.dylib.so")
|
||||
foobarClippy := ctx.ModuleForTests("libfoobar", "android_arm64_armv8-a_dylib").MaybeRule("clippy")
|
||||
if foobarClippy.Rule != nil {
|
||||
t.Errorf("Clippy output for libfoobar is not empty")
|
||||
}
|
||||
|
|
|
@ -67,6 +67,9 @@ type BaseCompilerProperties struct {
|
|||
// list of rust dylib crate dependencies
|
||||
Dylibs []string `android:"arch_variant"`
|
||||
|
||||
// list of rust automatic crate dependencies
|
||||
Rustlibs []string `android:"arch_variant"`
|
||||
|
||||
// list of rust proc_macro crate dependencies
|
||||
Proc_macros []string `android:"arch_variant"`
|
||||
|
||||
|
@ -100,8 +103,6 @@ type BaseCompilerProperties struct {
|
|||
|
||||
type baseCompiler struct {
|
||||
Properties BaseCompilerProperties
|
||||
depFlags []string
|
||||
linkDirs []string
|
||||
coverageFile android.Path //rustc generates a single gcno file
|
||||
|
||||
// Install related
|
||||
|
@ -178,6 +179,7 @@ func (compiler *baseCompiler) compile(ctx ModuleContext, flags Flags, deps PathD
|
|||
func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps {
|
||||
deps.Rlibs = append(deps.Rlibs, compiler.Properties.Rlibs...)
|
||||
deps.Dylibs = append(deps.Dylibs, compiler.Properties.Dylibs...)
|
||||
deps.Rustlibs = append(deps.Rustlibs, compiler.Properties.Rustlibs...)
|
||||
deps.ProcMacros = append(deps.ProcMacros, compiler.Properties.Proc_macros...)
|
||||
deps.StaticLibs = append(deps.StaticLibs, compiler.Properties.Static_libs...)
|
||||
deps.SharedLibs = append(deps.SharedLibs, compiler.Properties.Shared_libs...)
|
||||
|
@ -189,17 +191,7 @@ func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps {
|
|||
stdlib = stdlib + "_" + ctx.toolchain().RustTriple()
|
||||
}
|
||||
|
||||
// This check is technically insufficient - on the host, where
|
||||
// static linking is the default, if one of our static
|
||||
// dependencies uses a dynamic library, we need to dynamically
|
||||
// link the stdlib as well.
|
||||
if (len(deps.Dylibs) > 0) || ctx.Device() {
|
||||
// Dynamically linked stdlib
|
||||
deps.Dylibs = append(deps.Dylibs, stdlib)
|
||||
} else if ctx.Host() && !ctx.TargetPrimary() {
|
||||
// Otherwise use the static in-tree stdlib for host secondary arch
|
||||
deps.Rlibs = append(deps.Rlibs, stdlib+".static")
|
||||
}
|
||||
deps.Rustlibs = append(deps.Rustlibs, stdlib)
|
||||
}
|
||||
}
|
||||
return deps
|
||||
|
|
|
@ -15,13 +15,15 @@ var (
|
|||
"rust_library",
|
||||
"rust_library_dylib",
|
||||
"rust_library_rlib",
|
||||
"rust_library_shared",
|
||||
"rust_library_static",
|
||||
"rust_ffi",
|
||||
"rust_ffi_shared",
|
||||
"rust_ffi_static",
|
||||
"rust_library_host",
|
||||
"rust_library_host_dylib",
|
||||
"rust_library_host_rlib",
|
||||
"rust_library_host_shared",
|
||||
"rust_library_host_static",
|
||||
"rust_ffi_host",
|
||||
"rust_ffi_host_shared",
|
||||
"rust_ffi_host_static",
|
||||
"rust_proc_macro",
|
||||
"rust_test",
|
||||
"rust_test_host",
|
||||
|
|
|
@ -105,6 +105,12 @@ func TestCoverageZip(t *testing.T) {
|
|||
rlibs: ["librlib"],
|
||||
crate_name: "foo",
|
||||
}
|
||||
rust_ffi_static {
|
||||
name: "libbaz",
|
||||
srcs: ["foo.rs"],
|
||||
rlibs: ["librlib"],
|
||||
crate_name: "baz",
|
||||
}
|
||||
rust_library_rlib {
|
||||
name: "librlib",
|
||||
srcs: ["foo.rs"],
|
||||
|
@ -113,17 +119,17 @@ func TestCoverageZip(t *testing.T) {
|
|||
rust_binary {
|
||||
name: "fizz",
|
||||
rlibs: ["librlib"],
|
||||
static_libs: ["libfoo"],
|
||||
static_libs: ["libbaz"],
|
||||
srcs: ["foo.rs"],
|
||||
}
|
||||
cc_binary {
|
||||
name: "buzz",
|
||||
static_libs: ["libfoo"],
|
||||
static_libs: ["libbaz"],
|
||||
srcs: ["foo.c"],
|
||||
}
|
||||
cc_library {
|
||||
name: "libbar",
|
||||
static_libs: ["libfoo"],
|
||||
static_libs: ["libbaz"],
|
||||
compile_multilib: "64",
|
||||
srcs: ["foo.c"],
|
||||
}`)
|
||||
|
@ -149,7 +155,7 @@ func TestCoverageZip(t *testing.T) {
|
|||
|
||||
// Make sure the expected inputs are provided to the zip rule.
|
||||
if !android.SuffixInList(fizzZipInputs, "android_arm64_armv8-a_rlib_cov/librlib.gcno") ||
|
||||
!android.SuffixInList(fizzZipInputs, "android_arm64_armv8-a_static_cov/libfoo.gcno") ||
|
||||
!android.SuffixInList(fizzZipInputs, "android_arm64_armv8-a_static_cov/libbaz.gcno") ||
|
||||
!android.SuffixInList(fizzZipInputs, "android_arm64_armv8-a_cov/fizz.gcno") {
|
||||
t.Fatalf("missing expected coverage files for rust 'fizz' binary: %#v", fizzZipInputs)
|
||||
}
|
||||
|
@ -158,11 +164,11 @@ func TestCoverageZip(t *testing.T) {
|
|||
t.Fatalf("missing expected coverage files for rust 'fizz' binary: %#v", libfooZipInputs)
|
||||
}
|
||||
if !android.SuffixInList(buzzZipInputs, "android_arm64_armv8-a_cov/obj/foo.gcno") ||
|
||||
!android.SuffixInList(buzzZipInputs, "android_arm64_armv8-a_static_cov/libfoo.gcno") {
|
||||
!android.SuffixInList(buzzZipInputs, "android_arm64_armv8-a_static_cov/libbaz.gcno") {
|
||||
t.Fatalf("missing expected coverage files for cc 'buzz' binary: %#v", buzzZipInputs)
|
||||
}
|
||||
if !android.SuffixInList(libbarZipInputs, "android_arm64_armv8-a_static_cov/obj/foo.gcno") ||
|
||||
!android.SuffixInList(libbarZipInputs, "android_arm64_armv8-a_static_cov/libfoo.gcno") {
|
||||
!android.SuffixInList(libbarZipInputs, "android_arm64_armv8-a_static_cov/libbaz.gcno") {
|
||||
t.Fatalf("missing expected coverage files for cc 'libbar' library: %#v", libbarZipInputs)
|
||||
}
|
||||
}
|
||||
|
|
130
rust/library.go
130
rust/library.go
|
@ -19,7 +19,6 @@ import (
|
|||
"strings"
|
||||
|
||||
"android/soong/android"
|
||||
"android/soong/rust/config"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -29,14 +28,17 @@ func init() {
|
|||
android.RegisterModuleType("rust_library_host", RustLibraryHostFactory)
|
||||
android.RegisterModuleType("rust_library_host_dylib", RustLibraryDylibHostFactory)
|
||||
android.RegisterModuleType("rust_library_host_rlib", RustLibraryRlibHostFactory)
|
||||
android.RegisterModuleType("rust_library_shared", RustLibrarySharedFactory)
|
||||
android.RegisterModuleType("rust_library_static", RustLibraryStaticFactory)
|
||||
android.RegisterModuleType("rust_library_host_shared", RustLibrarySharedHostFactory)
|
||||
android.RegisterModuleType("rust_library_host_static", RustLibraryStaticHostFactory)
|
||||
android.RegisterModuleType("rust_ffi", RustFFIFactory)
|
||||
android.RegisterModuleType("rust_ffi_shared", RustFFISharedFactory)
|
||||
android.RegisterModuleType("rust_ffi_static", RustFFIStaticFactory)
|
||||
android.RegisterModuleType("rust_ffi_host", RustFFIHostFactory)
|
||||
android.RegisterModuleType("rust_ffi_host_shared", RustFFISharedHostFactory)
|
||||
android.RegisterModuleType("rust_ffi_host_static", RustFFIStaticHostFactory)
|
||||
}
|
||||
|
||||
type VariantLibraryProperties struct {
|
||||
Enabled *bool `android:"arch_variant"`
|
||||
Enabled *bool `android:"arch_variant"`
|
||||
Srcs []string `android:"path,arch_variant"`
|
||||
}
|
||||
|
||||
type LibraryCompilerProperties struct {
|
||||
|
@ -71,6 +73,7 @@ type LibraryMutatedProperties struct {
|
|||
|
||||
type libraryDecorator struct {
|
||||
*baseCompiler
|
||||
*flagExporter
|
||||
|
||||
Properties LibraryCompilerProperties
|
||||
MutatedProperties LibraryMutatedProperties
|
||||
|
@ -96,6 +99,8 @@ type libraryInterface interface {
|
|||
setStatic()
|
||||
|
||||
// Build a specific library variant
|
||||
BuildOnlyFFI()
|
||||
BuildOnlyRust()
|
||||
BuildOnlyRlib()
|
||||
BuildOnlyDylib()
|
||||
BuildOnlyStatic()
|
||||
|
@ -106,22 +111,6 @@ func (library *libraryDecorator) nativeCoverage() bool {
|
|||
return true
|
||||
}
|
||||
|
||||
func (library *libraryDecorator) exportedDirs() []string {
|
||||
return library.linkDirs
|
||||
}
|
||||
|
||||
func (library *libraryDecorator) exportedDepFlags() []string {
|
||||
return library.depFlags
|
||||
}
|
||||
|
||||
func (library *libraryDecorator) reexportDirs(dirs ...string) {
|
||||
library.linkDirs = android.FirstUniqueStrings(append(library.linkDirs, dirs...))
|
||||
}
|
||||
|
||||
func (library *libraryDecorator) reexportDepFlags(flags ...string) {
|
||||
library.depFlags = android.FirstUniqueStrings(append(library.depFlags, flags...))
|
||||
}
|
||||
|
||||
func (library *libraryDecorator) rlib() bool {
|
||||
return library.MutatedProperties.VariantIsRlib
|
||||
}
|
||||
|
@ -182,12 +171,31 @@ func (library *libraryDecorator) setStatic() {
|
|||
library.MutatedProperties.VariantIsDylib = false
|
||||
}
|
||||
|
||||
func (library *libraryDecorator) autoDep() autoDep {
|
||||
if library.rlib() || library.static() {
|
||||
return rlibAutoDep
|
||||
} else if library.dylib() || library.shared() {
|
||||
return dylibAutoDep
|
||||
} else {
|
||||
return rlibAutoDep
|
||||
}
|
||||
}
|
||||
|
||||
var _ compiler = (*libraryDecorator)(nil)
|
||||
var _ libraryInterface = (*libraryDecorator)(nil)
|
||||
var _ exportedFlagsProducer = (*libraryDecorator)(nil)
|
||||
|
||||
// rust_library produces all variants.
|
||||
// rust_library produces all rust variants.
|
||||
func RustLibraryFactory() android.Module {
|
||||
module, _ := NewRustLibrary(android.HostAndDeviceSupported)
|
||||
module, library := NewRustLibrary(android.HostAndDeviceSupported)
|
||||
library.BuildOnlyRust()
|
||||
return module.Init()
|
||||
}
|
||||
|
||||
// rust_ffi produces all ffi variants.
|
||||
func RustFFIFactory() android.Module {
|
||||
module, library := NewRustLibrary(android.HostAndDeviceSupported)
|
||||
library.BuildOnlyFFI()
|
||||
return module.Init()
|
||||
}
|
||||
|
||||
|
@ -205,23 +213,31 @@ func RustLibraryRlibFactory() android.Module {
|
|||
return module.Init()
|
||||
}
|
||||
|
||||
// rust_library_shared produces a shared library.
|
||||
func RustLibrarySharedFactory() android.Module {
|
||||
// rust_ffi_shared produces a shared library.
|
||||
func RustFFISharedFactory() android.Module {
|
||||
module, library := NewRustLibrary(android.HostAndDeviceSupported)
|
||||
library.BuildOnlyShared()
|
||||
return module.Init()
|
||||
}
|
||||
|
||||
// rust_library_static produces a static library.
|
||||
func RustLibraryStaticFactory() android.Module {
|
||||
// rust_ffi_static produces a static library.
|
||||
func RustFFIStaticFactory() android.Module {
|
||||
module, library := NewRustLibrary(android.HostAndDeviceSupported)
|
||||
library.BuildOnlyStatic()
|
||||
return module.Init()
|
||||
}
|
||||
|
||||
// rust_library_host produces all variants.
|
||||
// rust_library_host produces all rust variants.
|
||||
func RustLibraryHostFactory() android.Module {
|
||||
module, _ := NewRustLibrary(android.HostSupported)
|
||||
module, library := NewRustLibrary(android.HostSupported)
|
||||
library.BuildOnlyRust()
|
||||
return module.Init()
|
||||
}
|
||||
|
||||
// rust_ffi_host produces all FFI variants.
|
||||
func RustFFIHostFactory() android.Module {
|
||||
module, library := NewRustLibrary(android.HostSupported)
|
||||
library.BuildOnlyFFI()
|
||||
return module.Init()
|
||||
}
|
||||
|
||||
|
@ -239,44 +255,60 @@ func RustLibraryRlibHostFactory() android.Module {
|
|||
return module.Init()
|
||||
}
|
||||
|
||||
// rust_library_static_host produces a static library.
|
||||
func RustLibraryStaticHostFactory() android.Module {
|
||||
// rust_ffi_static_host produces a static library.
|
||||
func RustFFIStaticHostFactory() android.Module {
|
||||
module, library := NewRustLibrary(android.HostSupported)
|
||||
library.BuildOnlyStatic()
|
||||
return module.Init()
|
||||
}
|
||||
|
||||
// rust_library_shared_host produces an shared library.
|
||||
func RustLibrarySharedHostFactory() android.Module {
|
||||
// rust_ffi_shared_host produces an shared library.
|
||||
func RustFFISharedHostFactory() android.Module {
|
||||
module, library := NewRustLibrary(android.HostSupported)
|
||||
library.BuildOnlyShared()
|
||||
return module.Init()
|
||||
}
|
||||
|
||||
func (library *libraryDecorator) BuildOnlyFFI() {
|
||||
library.MutatedProperties.BuildDylib = false
|
||||
library.MutatedProperties.BuildRlib = false
|
||||
library.MutatedProperties.BuildShared = true
|
||||
library.MutatedProperties.BuildStatic = true
|
||||
}
|
||||
|
||||
func (library *libraryDecorator) BuildOnlyRust() {
|
||||
library.MutatedProperties.BuildDylib = true
|
||||
library.MutatedProperties.BuildRlib = true
|
||||
library.MutatedProperties.BuildShared = false
|
||||
library.MutatedProperties.BuildStatic = false
|
||||
}
|
||||
|
||||
func (library *libraryDecorator) BuildOnlyDylib() {
|
||||
library.MutatedProperties.BuildDylib = true
|
||||
library.MutatedProperties.BuildRlib = false
|
||||
library.MutatedProperties.BuildShared = false
|
||||
library.MutatedProperties.BuildStatic = false
|
||||
|
||||
}
|
||||
|
||||
func (library *libraryDecorator) BuildOnlyRlib() {
|
||||
library.MutatedProperties.BuildDylib = false
|
||||
library.MutatedProperties.BuildRlib = true
|
||||
library.MutatedProperties.BuildShared = false
|
||||
library.MutatedProperties.BuildStatic = false
|
||||
}
|
||||
|
||||
func (library *libraryDecorator) BuildOnlyStatic() {
|
||||
library.MutatedProperties.BuildShared = false
|
||||
library.MutatedProperties.BuildRlib = false
|
||||
library.MutatedProperties.BuildDylib = false
|
||||
|
||||
library.MutatedProperties.BuildShared = false
|
||||
library.MutatedProperties.BuildStatic = true
|
||||
}
|
||||
|
||||
func (library *libraryDecorator) BuildOnlyShared() {
|
||||
library.MutatedProperties.BuildStatic = false
|
||||
library.MutatedProperties.BuildRlib = false
|
||||
library.MutatedProperties.BuildDylib = false
|
||||
library.MutatedProperties.BuildStatic = false
|
||||
library.MutatedProperties.BuildShared = true
|
||||
}
|
||||
|
||||
func NewRustLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) {
|
||||
|
@ -284,12 +316,13 @@ func NewRustLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorat
|
|||
|
||||
library := &libraryDecorator{
|
||||
MutatedProperties: LibraryMutatedProperties{
|
||||
BuildDylib: true,
|
||||
BuildRlib: true,
|
||||
BuildShared: true,
|
||||
BuildStatic: true,
|
||||
BuildDylib: false,
|
||||
BuildRlib: false,
|
||||
BuildShared: false,
|
||||
BuildStatic: false,
|
||||
},
|
||||
baseCompiler: NewBaseCompiler("lib", "lib64", InstallInSystem),
|
||||
flagExporter: NewFlagExporter(),
|
||||
}
|
||||
|
||||
module.compiler = library
|
||||
|
@ -304,15 +337,6 @@ func (library *libraryDecorator) compilerProps() []interface{} {
|
|||
}
|
||||
|
||||
func (library *libraryDecorator) compilerDeps(ctx DepsContext, deps Deps) Deps {
|
||||
|
||||
// TODO(b/155498724) Remove if C static libraries no longer require libstd as an rlib dependency.
|
||||
if !ctx.Host() && library.static() {
|
||||
library.setNoStdlibs()
|
||||
for _, stdlib := range config.Stdlibs {
|
||||
deps.Rlibs = append(deps.Rlibs, stdlib+".static")
|
||||
}
|
||||
}
|
||||
|
||||
deps = library.baseCompiler.compilerDeps(ctx, deps)
|
||||
|
||||
if ctx.toolchain().Bionic() && (library.dylib() || library.shared()) {
|
||||
|
@ -391,8 +415,8 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa
|
|||
library.coverageOutputZipFile = TransformCoverageFilesToZip(ctx, coverageFiles, library.getStem(ctx))
|
||||
|
||||
if library.rlib() || library.dylib() {
|
||||
library.reexportDirs(deps.linkDirs...)
|
||||
library.reexportDepFlags(deps.depFlags...)
|
||||
library.exportLinkDirs(deps.linkDirs...)
|
||||
library.exportDepFlags(deps.depFlags...)
|
||||
}
|
||||
library.unstrippedOutputFile = outputFile
|
||||
|
||||
|
|
|
@ -29,13 +29,18 @@ func TestLibraryVariants(t *testing.T) {
|
|||
name: "libfoo",
|
||||
srcs: ["foo.rs"],
|
||||
crate_name: "foo",
|
||||
}`)
|
||||
}
|
||||
rust_ffi_host {
|
||||
name: "libfoo.ffi",
|
||||
srcs: ["foo.rs"],
|
||||
crate_name: "foo"
|
||||
}`)
|
||||
|
||||
// Test all variants are being built.
|
||||
libfooRlib := ctx.ModuleForTests("libfoo", "linux_glibc_x86_64_rlib").Output("libfoo.rlib")
|
||||
libfooDylib := ctx.ModuleForTests("libfoo", "linux_glibc_x86_64_dylib").Output("libfoo.dylib.so")
|
||||
libfooStatic := ctx.ModuleForTests("libfoo", "linux_glibc_x86_64_static").Output("libfoo.a")
|
||||
libfooShared := ctx.ModuleForTests("libfoo", "linux_glibc_x86_64_shared").Output("libfoo.so")
|
||||
libfooStatic := ctx.ModuleForTests("libfoo.ffi", "linux_glibc_x86_64_static").Output("libfoo.ffi.a")
|
||||
libfooShared := ctx.ModuleForTests("libfoo.ffi", "linux_glibc_x86_64_shared").Output("libfoo.ffi.so")
|
||||
|
||||
rlibCrateType := "rlib"
|
||||
dylibCrateType := "dylib"
|
||||
|
@ -119,7 +124,7 @@ func TestValidateLibraryStem(t *testing.T) {
|
|||
|
||||
func TestSharedLibrary(t *testing.T) {
|
||||
ctx := testRust(t, `
|
||||
rust_library {
|
||||
rust_ffi_shared {
|
||||
name: "libfoo",
|
||||
srcs: ["foo.rs"],
|
||||
crate_name: "foo",
|
||||
|
@ -138,3 +143,50 @@ func TestSharedLibrary(t *testing.T) {
|
|||
libfoo.Module().(*Module).Properties.AndroidMkDylibs)
|
||||
}
|
||||
}
|
||||
|
||||
// Test that variants pull in the right type of rustlib autodep
|
||||
func TestAutoDeps(t *testing.T) {
|
||||
|
||||
ctx := testRust(t, `
|
||||
rust_library_host {
|
||||
name: "libbar",
|
||||
srcs: ["bar.rs"],
|
||||
crate_name: "bar",
|
||||
}
|
||||
rust_library_host {
|
||||
name: "libfoo",
|
||||
srcs: ["foo.rs"],
|
||||
crate_name: "foo",
|
||||
rustlibs: ["libbar"],
|
||||
}
|
||||
rust_ffi_host {
|
||||
name: "libfoo.ffi",
|
||||
srcs: ["foo.rs"],
|
||||
crate_name: "foo",
|
||||
rustlibs: ["libbar"],
|
||||
}`)
|
||||
|
||||
libfooRlib := ctx.ModuleForTests("libfoo", "linux_glibc_x86_64_rlib")
|
||||
libfooDylib := ctx.ModuleForTests("libfoo", "linux_glibc_x86_64_dylib")
|
||||
libfooStatic := ctx.ModuleForTests("libfoo.ffi", "linux_glibc_x86_64_static")
|
||||
libfooShared := ctx.ModuleForTests("libfoo.ffi", "linux_glibc_x86_64_shared")
|
||||
|
||||
for _, static := range []android.TestingModule{libfooRlib, libfooStatic} {
|
||||
if !android.InList("libbar", static.Module().(*Module).Properties.AndroidMkRlibs) {
|
||||
t.Errorf("libbar not present as static dependency in static lib")
|
||||
}
|
||||
if android.InList("libbar", static.Module().(*Module).Properties.AndroidMkDylibs) {
|
||||
t.Errorf("libbar present as dynamic dependency in static lib")
|
||||
}
|
||||
}
|
||||
|
||||
for _, dyn := range []android.TestingModule{libfooDylib, libfooShared} {
|
||||
if !android.InList("libbar", dyn.Module().(*Module).Properties.AndroidMkDylibs) {
|
||||
t.Errorf("libbar not present as dynamic dependency in dynamic lib")
|
||||
}
|
||||
if android.InList("libbar", dyn.Module().(*Module).Properties.AndroidMkRlibs) {
|
||||
t.Errorf("libbar present as static dependency in dynamic lib")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,12 +19,16 @@ import (
|
|||
)
|
||||
|
||||
func init() {
|
||||
android.RegisterModuleType("rust_prebuilt_library", PrebuiltLibraryFactory)
|
||||
android.RegisterModuleType("rust_prebuilt_dylib", PrebuiltDylibFactory)
|
||||
android.RegisterModuleType("rust_prebuilt_rlib", PrebuiltRlibFactory)
|
||||
}
|
||||
|
||||
type PrebuiltProperties struct {
|
||||
// path to the prebuilt file
|
||||
Srcs []string `android:"path,arch_variant"`
|
||||
// directories containing associated rlib dependencies
|
||||
Link_dirs []string `android:"path,arch_variant"`
|
||||
}
|
||||
|
||||
type prebuiltLibraryDecorator struct {
|
||||
|
@ -33,32 +37,65 @@ type prebuiltLibraryDecorator struct {
|
|||
}
|
||||
|
||||
var _ compiler = (*prebuiltLibraryDecorator)(nil)
|
||||
var _ exportedFlagsProducer = (*prebuiltLibraryDecorator)(nil)
|
||||
|
||||
func PrebuiltLibraryFactory() android.Module {
|
||||
module, _ := NewPrebuiltLibrary(android.HostAndDeviceSupported)
|
||||
return module.Init()
|
||||
}
|
||||
|
||||
func PrebuiltDylibFactory() android.Module {
|
||||
module, _ := NewPrebuiltDylib(android.HostAndDeviceSupported)
|
||||
return module.Init()
|
||||
}
|
||||
|
||||
func NewPrebuiltDylib(hod android.HostOrDeviceSupported) (*Module, *prebuiltLibraryDecorator) {
|
||||
func PrebuiltRlibFactory() android.Module {
|
||||
module, _ := NewPrebuiltRlib(android.HostAndDeviceSupported)
|
||||
return module.Init()
|
||||
}
|
||||
|
||||
func NewPrebuiltLibrary(hod android.HostOrDeviceSupported) (*Module, *prebuiltLibraryDecorator) {
|
||||
module, library := NewRustLibrary(hod)
|
||||
library.BuildOnlyDylib()
|
||||
library.BuildOnlyRust()
|
||||
library.setNoStdlibs()
|
||||
prebuilt := &prebuiltLibraryDecorator{
|
||||
libraryDecorator: library,
|
||||
}
|
||||
module.compiler = prebuilt
|
||||
return module, prebuilt
|
||||
}
|
||||
|
||||
func NewPrebuiltDylib(hod android.HostOrDeviceSupported) (*Module, *prebuiltLibraryDecorator) {
|
||||
module, library := NewRustLibrary(hod)
|
||||
library.BuildOnlyDylib()
|
||||
library.setNoStdlibs()
|
||||
prebuilt := &prebuiltLibraryDecorator{
|
||||
libraryDecorator: library,
|
||||
}
|
||||
module.compiler = prebuilt
|
||||
return module, prebuilt
|
||||
}
|
||||
|
||||
func NewPrebuiltRlib(hod android.HostOrDeviceSupported) (*Module, *prebuiltLibraryDecorator) {
|
||||
module, library := NewRustLibrary(hod)
|
||||
library.BuildOnlyRlib()
|
||||
library.setNoStdlibs()
|
||||
library.setDylib()
|
||||
prebuilt := &prebuiltLibraryDecorator{
|
||||
libraryDecorator: library,
|
||||
}
|
||||
module.compiler = prebuilt
|
||||
module.AddProperties(&library.Properties)
|
||||
return module, prebuilt
|
||||
}
|
||||
|
||||
func (prebuilt *prebuiltLibraryDecorator) compilerProps() []interface{} {
|
||||
return append(prebuilt.baseCompiler.compilerProps(),
|
||||
return append(prebuilt.libraryDecorator.compilerProps(),
|
||||
&prebuilt.Properties)
|
||||
}
|
||||
|
||||
func (prebuilt *prebuiltLibraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Path {
|
||||
srcPath := srcPathFromModuleSrcs(ctx, prebuilt.Properties.Srcs)
|
||||
prebuilt.exportLinkDirs(android.PathsForModuleSrc(ctx, prebuilt.Properties.Link_dirs).Strings()...)
|
||||
|
||||
srcPath := srcPathFromModuleSrcs(ctx, prebuilt.prebuiltSrcs())
|
||||
|
||||
prebuilt.unstrippedOutputFile = srcPath
|
||||
|
||||
|
@ -73,3 +110,15 @@ func (prebuilt *prebuiltLibraryDecorator) compilerDeps(ctx DepsContext, deps Dep
|
|||
func (prebuilt *prebuiltLibraryDecorator) nativeCoverage() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (prebuilt *prebuiltLibraryDecorator) prebuiltSrcs() []string {
|
||||
srcs := prebuilt.Properties.Srcs
|
||||
if prebuilt.rlib() {
|
||||
srcs = append(srcs, prebuilt.libraryDecorator.Properties.Rlib.Srcs...)
|
||||
}
|
||||
if prebuilt.dylib() {
|
||||
srcs = append(srcs, prebuilt.libraryDecorator.Properties.Dylib.Srcs...)
|
||||
}
|
||||
|
||||
return srcs
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ type ProcMacroCompilerProperties struct {
|
|||
|
||||
type procMacroDecorator struct {
|
||||
*baseCompiler
|
||||
*flagExporter
|
||||
|
||||
Properties ProcMacroCompilerProperties
|
||||
}
|
||||
|
@ -35,6 +36,7 @@ type procMacroInterface interface {
|
|||
}
|
||||
|
||||
var _ compiler = (*procMacroDecorator)(nil)
|
||||
var _ exportedFlagsProducer = (*procMacroDecorator)(nil)
|
||||
|
||||
func ProcMacroFactory() android.Module {
|
||||
module, _ := NewProcMacro(android.HostSupportedNoCross)
|
||||
|
@ -46,6 +48,7 @@ func NewProcMacro(hod android.HostOrDeviceSupported) (*Module, *procMacroDecorat
|
|||
|
||||
procMacro := &procMacroDecorator{
|
||||
baseCompiler: NewBaseCompiler("lib", "lib64", InstallInSystem),
|
||||
flagExporter: NewFlagExporter(),
|
||||
}
|
||||
|
||||
module.compiler = procMacro
|
||||
|
@ -76,3 +79,7 @@ func (procMacro *procMacroDecorator) getStem(ctx ModuleContext) string {
|
|||
|
||||
return stem + String(procMacro.baseCompiler.Properties.Suffix)
|
||||
}
|
||||
|
||||
func (procMacro *procMacroDecorator) autoDep() autoDep {
|
||||
return rlibAutoDep
|
||||
}
|
||||
|
|
89
rust/rust.go
89
rust/rust.go
|
@ -217,6 +217,7 @@ func (mod *Module) StubDecorator() bool {
|
|||
type Deps struct {
|
||||
Dylibs []string
|
||||
Rlibs []string
|
||||
Rustlibs []string
|
||||
ProcMacros []string
|
||||
SharedLibs []string
|
||||
StaticLibs []string
|
||||
|
@ -261,6 +262,43 @@ type compiler interface {
|
|||
nativeCoverage() bool
|
||||
}
|
||||
|
||||
type exportedFlagsProducer interface {
|
||||
exportedLinkDirs() []string
|
||||
exportedDepFlags() []string
|
||||
exportLinkDirs(...string)
|
||||
exportDepFlags(...string)
|
||||
}
|
||||
|
||||
type flagExporter struct {
|
||||
depFlags []string
|
||||
linkDirs []string
|
||||
}
|
||||
|
||||
func (flagExporter *flagExporter) exportedLinkDirs() []string {
|
||||
return flagExporter.linkDirs
|
||||
}
|
||||
|
||||
func (flagExporter *flagExporter) exportedDepFlags() []string {
|
||||
return flagExporter.depFlags
|
||||
}
|
||||
|
||||
func (flagExporter *flagExporter) exportLinkDirs(dirs ...string) {
|
||||
flagExporter.linkDirs = android.FirstUniqueStrings(append(flagExporter.linkDirs, dirs...))
|
||||
}
|
||||
|
||||
func (flagExporter *flagExporter) exportDepFlags(flags ...string) {
|
||||
flagExporter.depFlags = android.FirstUniqueStrings(append(flagExporter.depFlags, flags...))
|
||||
}
|
||||
|
||||
var _ exportedFlagsProducer = (*flagExporter)(nil)
|
||||
|
||||
func NewFlagExporter() *flagExporter {
|
||||
return &flagExporter{
|
||||
depFlags: []string{},
|
||||
linkDirs: []string{},
|
||||
}
|
||||
}
|
||||
|
||||
func (mod *Module) isCoverageVariant() bool {
|
||||
return mod.coverage.Properties.IsCoverageVariant
|
||||
}
|
||||
|
@ -415,7 +453,7 @@ func (mod *Module) Module() android.Module {
|
|||
func (mod *Module) StubsVersions() []string {
|
||||
// For now, Rust has no stubs versions.
|
||||
if mod.compiler != nil {
|
||||
if _, ok := mod.compiler.(*libraryDecorator); ok {
|
||||
if _, ok := mod.compiler.(libraryInterface); ok {
|
||||
return []string{}
|
||||
}
|
||||
}
|
||||
|
@ -439,6 +477,9 @@ func (mod *Module) HasStaticVariant() bool {
|
|||
|
||||
func (mod *Module) CoverageFiles() android.Paths {
|
||||
if mod.compiler != nil {
|
||||
if !mod.compiler.nativeCoverage() {
|
||||
return android.Paths{}
|
||||
}
|
||||
if library, ok := mod.compiler.(*libraryDecorator); ok {
|
||||
if library.coverageFile != nil {
|
||||
return android.Paths{library.coverageFile}
|
||||
|
@ -617,6 +658,7 @@ func (mod *Module) deps(ctx DepsContext) Deps {
|
|||
|
||||
deps.Rlibs = android.LastUniqueStrings(deps.Rlibs)
|
||||
deps.Dylibs = android.LastUniqueStrings(deps.Dylibs)
|
||||
deps.Rustlibs = android.LastUniqueStrings(deps.Rustlibs)
|
||||
deps.ProcMacros = android.LastUniqueStrings(deps.ProcMacros)
|
||||
deps.SharedLibs = android.LastUniqueStrings(deps.SharedLibs)
|
||||
deps.StaticLibs = android.LastUniqueStrings(deps.StaticLibs)
|
||||
|
@ -639,6 +681,20 @@ var (
|
|||
testPerSrcDepTag = dependencyTag{name: "rust_unit_tests"}
|
||||
)
|
||||
|
||||
type autoDep struct {
|
||||
variation string
|
||||
depTag dependencyTag
|
||||
}
|
||||
|
||||
var (
|
||||
rlibAutoDep = autoDep{variation: "rlib", depTag: rlibDepTag}
|
||||
dylibAutoDep = autoDep{variation: "dylib", depTag: dylibDepTag}
|
||||
)
|
||||
|
||||
type autoDeppable interface {
|
||||
autoDep() autoDep
|
||||
}
|
||||
|
||||
func (mod *Module) begin(ctx BaseModuleContext) {
|
||||
if mod.coverage != nil {
|
||||
mod.coverage.begin(ctx)
|
||||
|
@ -689,19 +745,15 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
|||
}
|
||||
|
||||
//Append the dependencies exportedDirs
|
||||
if lib, ok := rustDep.compiler.(*libraryDecorator); ok {
|
||||
depPaths.linkDirs = append(depPaths.linkDirs, lib.exportedDirs()...)
|
||||
if lib, ok := rustDep.compiler.(exportedFlagsProducer); ok {
|
||||
depPaths.linkDirs = append(depPaths.linkDirs, lib.exportedLinkDirs()...)
|
||||
depPaths.depFlags = append(depPaths.depFlags, lib.exportedDepFlags()...)
|
||||
}
|
||||
|
||||
// Append this dependencies output to this mod's linkDirs so they can be exported to dependencies
|
||||
// This can be probably be refactored by defining a common exporter interface similar to cc's
|
||||
if depTag == dylibDepTag || depTag == rlibDepTag || depTag == procMacroDepTag {
|
||||
linkDir := linkPathFromFilePath(linkFile.Path())
|
||||
if lib, ok := mod.compiler.(*libraryDecorator); ok {
|
||||
lib.linkDirs = append(lib.linkDirs, linkDir)
|
||||
} else if procMacro, ok := mod.compiler.(*procMacroDecorator); ok {
|
||||
procMacro.linkDirs = append(procMacro.linkDirs, linkDir)
|
||||
if lib, ok := mod.compiler.(exportedFlagsProducer); ok {
|
||||
lib.exportLinkDirs(linkDir)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -752,14 +804,10 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
|||
}
|
||||
|
||||
// Make sure these dependencies are propagated
|
||||
if lib, ok := mod.compiler.(*libraryDecorator); ok && exportDep {
|
||||
lib.linkDirs = append(lib.linkDirs, linkPath)
|
||||
lib.depFlags = append(lib.depFlags, depFlag)
|
||||
} else if procMacro, ok := mod.compiler.(*procMacroDecorator); ok && exportDep {
|
||||
procMacro.linkDirs = append(procMacro.linkDirs, linkPath)
|
||||
procMacro.depFlags = append(procMacro.depFlags, depFlag)
|
||||
if lib, ok := mod.compiler.(exportedFlagsProducer); ok && exportDep {
|
||||
lib.exportLinkDirs(linkPath)
|
||||
lib.exportDepFlags(depFlag)
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -844,6 +892,15 @@ func (mod *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
|||
{Mutator: "link", Variation: ""}}...),
|
||||
dylibDepTag, deps.Dylibs...)
|
||||
|
||||
if deps.Rustlibs != nil {
|
||||
autoDep := mod.compiler.(autoDeppable).autoDep()
|
||||
actx.AddVariationDependencies(
|
||||
append(commonDepVariations, []blueprint.Variation{
|
||||
{Mutator: "rust_libraries", Variation: autoDep.variation},
|
||||
{Mutator: "link", Variation: ""}}...),
|
||||
autoDep.depTag, deps.Rustlibs...)
|
||||
}
|
||||
|
||||
actx.AddVariationDependencies(append(commonDepVariations,
|
||||
blueprint.Variation{Mutator: "link", Variation: "shared"}),
|
||||
cc.SharedDepTag, deps.SharedLibs...)
|
||||
|
|
|
@ -164,12 +164,12 @@ func TestLinkPathFromFilePath(t *testing.T) {
|
|||
// Test to make sure dependencies are being picked up correctly.
|
||||
func TestDepsTracking(t *testing.T) {
|
||||
ctx := testRust(t, `
|
||||
rust_library_host_static {
|
||||
rust_ffi_host_static {
|
||||
name: "libstatic",
|
||||
srcs: ["foo.rs"],
|
||||
crate_name: "static",
|
||||
}
|
||||
rust_library_host_shared {
|
||||
rust_ffi_host_shared {
|
||||
name: "libshared",
|
||||
srcs: ["foo.rs"],
|
||||
crate_name: "shared",
|
||||
|
|
|
@ -105,6 +105,10 @@ func (test *testDecorator) compilerFlags(ctx ModuleContext, flags Flags) Flags {
|
|||
return flags
|
||||
}
|
||||
|
||||
func (test *testDecorator) autoDep() autoDep {
|
||||
return rlibAutoDep
|
||||
}
|
||||
|
||||
func init() {
|
||||
// Rust tests are binary files built with --test.
|
||||
android.RegisterModuleType("rust_test", RustTestFactory)
|
||||
|
|
|
@ -21,14 +21,26 @@ import (
|
|||
|
||||
func GatherRequiredDepsForTest() string {
|
||||
bp := `
|
||||
rust_prebuilt_dylib {
|
||||
rust_prebuilt_library {
|
||||
name: "libstd_x86_64-unknown-linux-gnu",
|
||||
srcs: [""],
|
||||
crate_name: "std",
|
||||
rlib: {
|
||||
srcs: ["libstd.rlib"],
|
||||
},
|
||||
dylib: {
|
||||
srcs: ["libstd.so"],
|
||||
},
|
||||
host_supported: true,
|
||||
}
|
||||
rust_prebuilt_dylib {
|
||||
rust_prebuilt_library {
|
||||
name: "libtest_x86_64-unknown-linux-gnu",
|
||||
srcs: [""],
|
||||
crate_name: "test",
|
||||
rlib: {
|
||||
srcs: ["libtest.rlib"],
|
||||
},
|
||||
dylib: {
|
||||
srcs: ["libtest.so"],
|
||||
},
|
||||
host_supported: true,
|
||||
}
|
||||
|
||||
|
@ -41,34 +53,21 @@ func GatherRequiredDepsForTest() string {
|
|||
nocrt: true,
|
||||
system_shared_libs: [],
|
||||
}
|
||||
rust_library_dylib {
|
||||
rust_library {
|
||||
name: "libstd",
|
||||
crate_name: "std",
|
||||
srcs: ["foo.rs"],
|
||||
no_stdlibs: true,
|
||||
host_supported: true,
|
||||
native_coverage: false,
|
||||
}
|
||||
rust_library_rlib {
|
||||
name: "libstd.static",
|
||||
crate_name: "std",
|
||||
srcs: ["foo.rs"],
|
||||
no_stdlibs: true,
|
||||
host_supported: true,
|
||||
}
|
||||
rust_library_dylib {
|
||||
rust_library {
|
||||
name: "libtest",
|
||||
crate_name: "test",
|
||||
srcs: ["foo.rs"],
|
||||
no_stdlibs: true,
|
||||
host_supported: true,
|
||||
|
||||
}
|
||||
rust_library_rlib {
|
||||
name: "libtest.static",
|
||||
crate_name: "test",
|
||||
srcs: ["foo.rs"],
|
||||
no_stdlibs: true,
|
||||
host_supported: true,
|
||||
native_coverage: false,
|
||||
}
|
||||
|
||||
` + cc.GatherRequiredDepsForTest(android.NoOsType)
|
||||
|
@ -83,17 +82,21 @@ func CreateTestContext() *android.TestContext {
|
|||
ctx.RegisterModuleType("rust_test", RustTestFactory)
|
||||
ctx.RegisterModuleType("rust_test_host", RustTestHostFactory)
|
||||
ctx.RegisterModuleType("rust_library", RustLibraryFactory)
|
||||
ctx.RegisterModuleType("rust_library_host", RustLibraryHostFactory)
|
||||
ctx.RegisterModuleType("rust_library_host_rlib", RustLibraryRlibHostFactory)
|
||||
ctx.RegisterModuleType("rust_library_host_dylib", RustLibraryDylibHostFactory)
|
||||
ctx.RegisterModuleType("rust_library_rlib", RustLibraryRlibFactory)
|
||||
ctx.RegisterModuleType("rust_library_dylib", RustLibraryDylibFactory)
|
||||
ctx.RegisterModuleType("rust_library_shared", RustLibrarySharedFactory)
|
||||
ctx.RegisterModuleType("rust_library_static", RustLibraryStaticFactory)
|
||||
ctx.RegisterModuleType("rust_library_host_shared", RustLibrarySharedHostFactory)
|
||||
ctx.RegisterModuleType("rust_library_host_static", RustLibraryStaticHostFactory)
|
||||
ctx.RegisterModuleType("rust_library_rlib", RustLibraryRlibFactory)
|
||||
ctx.RegisterModuleType("rust_library_host", RustLibraryHostFactory)
|
||||
ctx.RegisterModuleType("rust_library_host_dylib", RustLibraryDylibHostFactory)
|
||||
ctx.RegisterModuleType("rust_library_host_rlib", RustLibraryRlibHostFactory)
|
||||
ctx.RegisterModuleType("rust_ffi", RustFFIFactory)
|
||||
ctx.RegisterModuleType("rust_ffi_shared", RustFFISharedFactory)
|
||||
ctx.RegisterModuleType("rust_ffi_static", RustFFIStaticFactory)
|
||||
ctx.RegisterModuleType("rust_ffi_host", RustFFIHostFactory)
|
||||
ctx.RegisterModuleType("rust_ffi_host_shared", RustFFISharedHostFactory)
|
||||
ctx.RegisterModuleType("rust_ffi_host_static", RustFFIStaticHostFactory)
|
||||
ctx.RegisterModuleType("rust_proc_macro", ProcMacroFactory)
|
||||
ctx.RegisterModuleType("rust_prebuilt_library", PrebuiltLibraryFactory)
|
||||
ctx.RegisterModuleType("rust_prebuilt_dylib", PrebuiltDylibFactory)
|
||||
ctx.RegisterModuleType("rust_prebuilt_rlib", PrebuiltRlibFactory)
|
||||
ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
|
||||
// rust mutators
|
||||
ctx.BottomUp("rust_libraries", LibraryMutator).Parallel()
|
||||
|
|
Loading…
Reference in New Issue