diff options
Diffstat (limited to 'rust/rust.go')
-rw-r--r-- | rust/rust.go | 108 |
1 files changed, 57 insertions, 51 deletions
diff --git a/rust/rust.go b/rust/rust.go index 6cbcd7dc0..3d701210f 100644 --- a/rust/rust.go +++ b/rust/rust.go @@ -65,7 +65,16 @@ type BaseProperties struct { AndroidMkSharedLibs []string AndroidMkStaticLibs []string - SubName string `blueprint:"mutated"` + ImageVariationPrefix string `blueprint:"mutated"` + VndkVersion string `blueprint:"mutated"` + SubName string `blueprint:"mutated"` + + // Set by imageMutator + CoreVariantNeeded bool `blueprint:"mutated"` + ExtraVariants []string `blueprint:"mutated"` + + // Minimum sdk version that the artifact should support when it runs as part of mainline modules(APEX). + Min_sdk_version *string PreventInstall bool HideFromMake bool @@ -76,11 +85,15 @@ type Module struct { android.DefaultableModuleBase android.ApexModuleBase + VendorProperties cc.VendorProperties + Properties BaseProperties hod android.HostOrDeviceSupported multilib android.Multilib + makeLinkType string + compiler compiler coverage *coverage clippy *clippy @@ -109,33 +122,6 @@ func (mod *Module) OutputFiles(tag string) (android.Paths, error) { } } -var _ android.ImageInterface = (*Module)(nil) - -func (mod *Module) ImageMutatorBegin(ctx android.BaseModuleContext) {} - -func (mod *Module) CoreVariantNeeded(ctx android.BaseModuleContext) bool { - return true -} - -func (mod *Module) RamdiskVariantNeeded(android.BaseModuleContext) bool { - return mod.InRamdisk() -} - -func (mod *Module) VendorRamdiskVariantNeeded(android.BaseModuleContext) bool { - return mod.InVendorRamdisk() -} - -func (mod *Module) RecoveryVariantNeeded(android.BaseModuleContext) bool { - return mod.InRecovery() -} - -func (mod *Module) ExtraImageVariations(android.BaseModuleContext) []string { - return nil -} - -func (c *Module) SetImageVariation(ctx android.BaseModuleContext, variant string, module android.Module) { -} - func (mod *Module) SelectedStl() string { return "" } @@ -176,24 +162,18 @@ func (mod *Module) Toc() android.OptionalPath { panic(fmt.Errorf("Toc() called on non-library module: %q", mod.BaseModuleName())) } -func (mod *Module) OnlyInRamdisk() bool { - return false -} - -func (mod *Module) OnlyInVendorRamdisk() bool { - return false -} - -func (mod *Module) OnlyInRecovery() bool { - return false -} - func (mod *Module) UseSdk() bool { return false } +// Returns true if the module is using VNDK libraries instead of the libraries in /system/lib or /system/lib64. +// "product" and "vendor" variant modules return true for this function. +// When BOARD_VNDK_VERSION is set, vendor variants of "vendor_available: true", "vendor: true", +// "soc_specific: true" and more vendor installed modules are included here. +// When PRODUCT_PRODUCT_VNDK_VERSION is set, product variants of "vendor_available: true" or +// "product_specific: true" modules are included here. func (mod *Module) UseVndk() bool { - return false + return mod.Properties.VndkVersion != "" } func (mod *Module) MustUseVendorVariant() bool { @@ -201,10 +181,15 @@ func (mod *Module) MustUseVendorVariant() bool { } func (mod *Module) IsVndk() bool { + // TODO(b/165791368) return false } -func (mod *Module) HasVendorVariant() bool { +func (mod *Module) IsVndkExt() bool { + return false +} + +func (c *Module) IsVndkPrivate(config android.Config) bool { return false } @@ -377,6 +362,7 @@ func DefaultsFactory(props ...interface{}) android.Module { module.AddProperties(props...) module.AddProperties( &BaseProperties{}, + &cc.VendorProperties{}, &BindgenProperties{}, &BaseCompilerProperties{}, &BinaryCompilerProperties{}, @@ -473,11 +459,6 @@ func (mod *Module) OutputFile() android.OptionalPath { return mod.outputFile } -func (mod *Module) InRecovery() bool { - // For now, Rust has no notion of the recovery image - return false -} - func (mod *Module) CoverageFiles() android.Paths { if mod.compiler != nil { if !mod.compiler.nativeCoverage() { @@ -497,6 +478,7 @@ var _ cc.LinkableInterface = (*Module)(nil) func (mod *Module) Init() android.Module { mod.AddProperties(&mod.Properties) + mod.AddProperties(&mod.VendorProperties) if mod.compiler != nil { mod.AddProperties(mod.compiler.compilerProps()...) @@ -616,6 +598,12 @@ func (mod *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { } toolchain := mod.toolchain(ctx) + mod.makeLinkType = cc.GetMakeLinkType(actx, mod) + + // Differentiate static libraries that are vendor available + if mod.UseVndk() { + mod.Properties.SubName += ".vendor" + } if !toolchain.Supported() { // This toolchain's unsupported, there's nothing to do for this mod. @@ -957,10 +945,6 @@ func (mod *Module) DepsMutator(actx android.BottomUpMutatorContext) { deps := mod.deps(ctx) var commonDepVariations []blueprint.Variation - if !mod.Host() { - commonDepVariations = append(commonDepVariations, - blueprint.Variation{Mutator: "image", Variation: android.CoreVariation}) - } stdLinkage := "dylib-std" if mod.compiler.stdLinkage(ctx) == RlibLinkage { @@ -1077,7 +1061,29 @@ func (mod *Module) HostToolPath() android.OptionalPath { var _ android.ApexModule = (*Module)(nil) +func (mod *Module) minSdkVersion() string { + return String(mod.Properties.Min_sdk_version) +} + func (mod *Module) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion android.ApiLevel) error { + minSdkVersion := mod.minSdkVersion() + if minSdkVersion == "apex_inherit" { + return nil + } + if minSdkVersion == "" { + return fmt.Errorf("min_sdk_version is not specificed") + } + + // Not using nativeApiLevelFromUser because the context here is not + // necessarily a native context. + ver, err := android.ApiLevelFromUser(ctx, minSdkVersion) + if err != nil { + return err + } + + if ver.GreaterThan(sdkVersion) { + return fmt.Errorf("newer SDK(%v)", ver) + } return nil } |