diff --git a/cc/cc.go b/cc/cc.go index c1a432743..dc574267b 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -3077,6 +3077,12 @@ func squashRecoverySrcs(m *Module) { } } +func squashVendorRamdiskSrcs(m *Module) { + if lib, ok := m.compiler.(*libraryDecorator); ok { + lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs, lib.baseCompiler.Properties.Target.Vendor_ramdisk.Exclude_srcs...) + } +} + func (c *Module) IsSdkVariant() bool { return c.Properties.IsSdkVariant || c.AlwaysSdk() } diff --git a/cc/compiler.go b/cc/compiler.go index 21da2fc60..e2a33d7ae 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -177,6 +177,15 @@ type BaseCompilerProperties struct { // build the recovery variant of the C/C++ module. Exclude_generated_sources []string } + Vendor_ramdisk struct { + // list of source files that should not be used to + // build the vendor ramdisk variant of the C/C++ module. + Exclude_srcs []string `android:"path"` + + // List of additional cflags that should be used to build the vendor ramdisk + // variant of the C/C++ module. + Cflags []string + } } Proto struct { @@ -290,6 +299,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps CheckBadCompilerFlags(ctx, "asflags", compiler.Properties.Asflags) CheckBadCompilerFlags(ctx, "vendor.cflags", compiler.Properties.Target.Vendor.Cflags) CheckBadCompilerFlags(ctx, "recovery.cflags", compiler.Properties.Target.Recovery.Cflags) + CheckBadCompilerFlags(ctx, "vendor_ramdisk.cflags", compiler.Properties.Target.Vendor_ramdisk.Cflags) esc := proptools.NinjaAndShellEscapeList @@ -471,6 +481,10 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps flags.Local.CFlags = append(flags.Local.CFlags, esc(compiler.Properties.Target.Recovery.Cflags)...) } + if ctx.inVendorRamdisk() { + flags.Local.CFlags = append(flags.Local.CFlags, esc(compiler.Properties.Target.Vendor_ramdisk.Cflags)...) + } + // We can enforce some rules more strictly in the code we own. strict // indicates if this is code that we can be stricter with. If we have // rules that we want to apply to *our* code (but maybe can't for diff --git a/cc/image.go b/cc/image.go index ba091e13c..7b9425f4e 100644 --- a/cc/image.go +++ b/cc/image.go @@ -353,8 +353,11 @@ func (c *Module) ExtraImageVariations(ctx android.BaseModuleContext) []string { func (c *Module) SetImageVariation(ctx android.BaseModuleContext, variant string, module android.Module) { m := module.(*Module) - if variant == android.RamdiskVariation || variant == android.VendorRamdiskVariation { + if variant == android.RamdiskVariation { m.MakeAsPlatform() + } else if variant == android.VendorRamdiskVariation { + m.MakeAsPlatform() + squashVendorRamdiskSrcs(m) } else if variant == android.RecoveryVariation { m.MakeAsPlatform() squashRecoverySrcs(m) diff --git a/cc/library.go b/cc/library.go index 0e0f14340..910fc3108 100644 --- a/cc/library.go +++ b/cc/library.go @@ -833,6 +833,13 @@ func (library *libraryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps { deps.ReexportSharedLibHeaders = removeListFromList(deps.ReexportSharedLibHeaders, library.baseLinker.Properties.Target.Ramdisk.Exclude_shared_libs) deps.ReexportStaticLibHeaders = removeListFromList(deps.ReexportStaticLibHeaders, library.baseLinker.Properties.Target.Ramdisk.Exclude_static_libs) } + if ctx.inVendorRamdisk() { + deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, library.baseLinker.Properties.Target.Vendor_ramdisk.Exclude_static_libs) + deps.SharedLibs = removeListFromList(deps.SharedLibs, library.baseLinker.Properties.Target.Vendor_ramdisk.Exclude_shared_libs) + deps.StaticLibs = removeListFromList(deps.StaticLibs, library.baseLinker.Properties.Target.Vendor_ramdisk.Exclude_static_libs) + deps.ReexportSharedLibHeaders = removeListFromList(deps.ReexportSharedLibHeaders, library.baseLinker.Properties.Target.Vendor_ramdisk.Exclude_shared_libs) + deps.ReexportStaticLibHeaders = removeListFromList(deps.ReexportStaticLibHeaders, library.baseLinker.Properties.Target.Vendor_ramdisk.Exclude_static_libs) + } return deps } diff --git a/cc/linker.go b/cc/linker.go index 7cbb9d698..7f13e288d 100644 --- a/cc/linker.go +++ b/cc/linker.go @@ -158,6 +158,15 @@ type BaseLinkerProperties struct { // the ramdisk variant of the C/C++ module. Exclude_static_libs []string } + Vendor_ramdisk struct { + // list of shared libs that should not be used to build + // the recovery variant of the C/C++ module. + Exclude_shared_libs []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 + } Platform struct { // list of shared libs that should be use to build the platform variant // of a module that sets sdk_version. This should rarely be necessary, @@ -267,6 +276,14 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps { deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, linker.Properties.Target.Ramdisk.Exclude_static_libs) } + if ctx.inVendorRamdisk() { + deps.SharedLibs = removeListFromList(deps.SharedLibs, linker.Properties.Target.Vendor_ramdisk.Exclude_shared_libs) + deps.ReexportSharedLibHeaders = removeListFromList(deps.ReexportSharedLibHeaders, linker.Properties.Target.Vendor_ramdisk.Exclude_shared_libs) + deps.StaticLibs = removeListFromList(deps.StaticLibs, linker.Properties.Target.Vendor_ramdisk.Exclude_static_libs) + 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) + } + if !ctx.useSdk() { deps.SharedLibs = append(deps.SharedLibs, linker.Properties.Target.Platform.Shared_libs...) }