Merge changes from topic "rust-made-to-order-staticlibs" into main

* changes:
  rust: made-to-order rust staticlibs
  rust: refactored transformSrctoCrate
This commit is contained in:
Ivan Lozano
2024-05-17 12:40:36 +00:00
committed by Gerrit Code Review
23 changed files with 832 additions and 241 deletions

View File

@@ -39,6 +39,9 @@ type BaseLinkerProperties struct {
// the dependency's .a file will be linked into this module using -Wl,--whole-archive.
Whole_static_libs []string `android:"arch_variant,variant_prepend"`
// list of Rust libs that should be statically linked into this module.
Static_rlibs []string `android:"arch_variant"`
// list of modules that should be statically linked into this module.
Static_libs []string `android:"arch_variant,variant_prepend"`
@@ -116,10 +119,14 @@ type BaseLinkerProperties struct {
// product variant of the C/C++ module.
Static_libs []string
// list of ehader libs that only should be used to build vendor or product
// list of header libs that only should be used to build vendor or product
// variant of the C/C++ module.
Header_libs []string
// list of Rust libs that should be statically linked to build vendor or product
// variant.
Static_rlibs []string
// list of shared libs that should not be used to build vendor or
// product variant of the C/C++ module.
Exclude_shared_libs []string
@@ -148,6 +155,10 @@ type BaseLinkerProperties struct {
// variant of the C/C++ module.
Static_libs []string
// list of Rust libs that should be statically linked to build the recovery
// variant.
Static_rlibs []string
// list of shared libs that should not be used to build
// the recovery variant of the C/C++ module.
Exclude_shared_libs []string
@@ -165,10 +176,14 @@ type BaseLinkerProperties struct {
Exclude_runtime_libs []string
}
Ramdisk struct {
// list of static libs that only should be used to build the recovery
// list of static libs that only should be used to build the ramdisk
// variant of the C/C++ module.
Static_libs []string
// list of Rust libs that should be statically linked to build the ramdisk
// variant.
Static_rlibs []string
// list of shared libs that should not be used to build
// the ramdisk variant of the C/C++ module.
Exclude_shared_libs []string
@@ -183,9 +198,13 @@ type BaseLinkerProperties struct {
}
Vendor_ramdisk struct {
// list of shared libs that should not be used to build
// the recovery variant of the C/C++ module.
// the vendor ramdisk variant of the C/C++ module.
Exclude_shared_libs []string
// list of Rust libs that should be statically linked to build the vendor ramdisk
// variant.
Static_rlibs []string
// list of static libs that should not be used to build
// the vendor ramdisk variant of the C/C++ module.
Exclude_static_libs []string
@@ -201,6 +220,10 @@ type BaseLinkerProperties struct {
// variants.
Shared_libs []string
// list of Rust libs that should be statically linked to build the vendor ramdisk
// variant.
Static_rlibs []string
// list of ehader libs that only should be used to build platform variant of
// the C/C++ module.
Header_libs []string
@@ -295,6 +318,7 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps.WholeStaticLibs = append(deps.WholeStaticLibs, linker.Properties.Whole_static_libs...)
deps.HeaderLibs = append(deps.HeaderLibs, linker.Properties.Header_libs...)
deps.StaticLibs = append(deps.StaticLibs, linker.Properties.Static_libs...)
deps.Rlibs = append(deps.Rlibs, linker.Properties.Static_rlibs...)
deps.SharedLibs = append(deps.SharedLibs, linker.Properties.Shared_libs...)
deps.RuntimeLibs = append(deps.RuntimeLibs, linker.Properties.Runtime_libs...)
@@ -338,6 +362,7 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps.ReexportStaticLibHeaders = removeListFromList(deps.ReexportStaticLibHeaders, linker.Properties.Target.Vendor.Exclude_static_libs)
deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, linker.Properties.Target.Vendor.Exclude_static_libs)
deps.RuntimeLibs = removeListFromList(deps.RuntimeLibs, linker.Properties.Target.Vendor.Exclude_runtime_libs)
deps.Rlibs = append(deps.Rlibs, linker.Properties.Target.Vendor.Static_rlibs...)
}
if ctx.inProduct() {
@@ -351,6 +376,7 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps.ReexportStaticLibHeaders = removeListFromList(deps.ReexportStaticLibHeaders, linker.Properties.Target.Product.Exclude_static_libs)
deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, linker.Properties.Target.Product.Exclude_static_libs)
deps.RuntimeLibs = removeListFromList(deps.RuntimeLibs, linker.Properties.Target.Product.Exclude_runtime_libs)
deps.Rlibs = append(deps.Rlibs, linker.Properties.Target.Product.Static_rlibs...)
}
if ctx.inRecovery() {
@@ -364,6 +390,7 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps.ReexportStaticLibHeaders = removeListFromList(deps.ReexportStaticLibHeaders, linker.Properties.Target.Recovery.Exclude_static_libs)
deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, linker.Properties.Target.Recovery.Exclude_static_libs)
deps.RuntimeLibs = removeListFromList(deps.RuntimeLibs, linker.Properties.Target.Recovery.Exclude_runtime_libs)
deps.Rlibs = append(deps.Rlibs, linker.Properties.Target.Recovery.Static_rlibs...)
}
if ctx.inRamdisk() {
@@ -374,6 +401,7 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps.ReexportStaticLibHeaders = removeListFromList(deps.ReexportStaticLibHeaders, linker.Properties.Target.Ramdisk.Exclude_static_libs)
deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, linker.Properties.Target.Ramdisk.Exclude_static_libs)
deps.RuntimeLibs = removeListFromList(deps.RuntimeLibs, linker.Properties.Target.Ramdisk.Exclude_runtime_libs)
deps.Rlibs = append(deps.Rlibs, linker.Properties.Target.Ramdisk.Static_rlibs...)
}
if ctx.inVendorRamdisk() {
@@ -383,6 +411,7 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps.ReexportStaticLibHeaders = removeListFromList(deps.ReexportStaticLibHeaders, linker.Properties.Target.Vendor_ramdisk.Exclude_static_libs)
deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, linker.Properties.Target.Vendor_ramdisk.Exclude_static_libs)
deps.RuntimeLibs = removeListFromList(deps.RuntimeLibs, linker.Properties.Target.Vendor_ramdisk.Exclude_runtime_libs)
deps.Rlibs = append(deps.Rlibs, linker.Properties.Target.Vendor_ramdisk.Static_rlibs...)
}
if !ctx.useSdk() {