Remove boolean arguments from NewLibrary()
NewLibrary is going to be used for header only libraries. Instead of adding more boolean arguments, replace the existing ones with BuildOnlyStatic and BuildOnlyShared calls on the libraryDecorator returned by NewLibrary. Test: m -j, compare build.ninja Change-Id: Id390b66cbf2a5f0932b32f40a5e18eb9e3852ee7
This commit is contained in:
@@ -95,31 +95,35 @@ func init() {
|
||||
// Module factory for combined static + shared libraries, device by default but with possible host
|
||||
// support
|
||||
func libraryFactory() (blueprint.Module, []interface{}) {
|
||||
module, _ := NewLibrary(android.HostAndDeviceSupported, true, true)
|
||||
module, _ := NewLibrary(android.HostAndDeviceSupported)
|
||||
return module.Init()
|
||||
}
|
||||
|
||||
// Module factory for static libraries
|
||||
func libraryStaticFactory() (blueprint.Module, []interface{}) {
|
||||
module, _ := NewLibrary(android.HostAndDeviceSupported, false, true)
|
||||
module, library := NewLibrary(android.HostAndDeviceSupported)
|
||||
library.BuildOnlyStatic()
|
||||
return module.Init()
|
||||
}
|
||||
|
||||
// Module factory for shared libraries
|
||||
func librarySharedFactory() (blueprint.Module, []interface{}) {
|
||||
module, _ := NewLibrary(android.HostAndDeviceSupported, true, false)
|
||||
module, library := NewLibrary(android.HostAndDeviceSupported)
|
||||
library.BuildOnlyShared()
|
||||
return module.Init()
|
||||
}
|
||||
|
||||
// Module factory for host static libraries
|
||||
func libraryHostStaticFactory() (blueprint.Module, []interface{}) {
|
||||
module, _ := NewLibrary(android.HostSupported, false, true)
|
||||
module, library := NewLibrary(android.HostSupported)
|
||||
library.BuildOnlyStatic()
|
||||
return module.Init()
|
||||
}
|
||||
|
||||
// Module factory for host shared libraries
|
||||
func libraryHostSharedFactory() (blueprint.Module, []interface{}) {
|
||||
module, _ := NewLibrary(android.HostSupported, true, false)
|
||||
module, library := NewLibrary(android.HostSupported)
|
||||
library.BuildOnlyShared()
|
||||
return module.Init()
|
||||
}
|
||||
|
||||
@@ -562,13 +566,21 @@ func (library *libraryDecorator) setStatic(static bool) {
|
||||
library.Properties.VariantIsStatic = static
|
||||
}
|
||||
|
||||
func NewLibrary(hod android.HostOrDeviceSupported, shared, static bool) (*Module, *libraryDecorator) {
|
||||
func (library *libraryDecorator) BuildOnlyStatic() {
|
||||
library.Properties.BuildShared = false
|
||||
}
|
||||
|
||||
func (library *libraryDecorator) BuildOnlyShared() {
|
||||
library.Properties.BuildStatic = false
|
||||
}
|
||||
|
||||
func NewLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) {
|
||||
module := newModule(hod, android.MultilibBoth)
|
||||
|
||||
library := &libraryDecorator{
|
||||
Properties: LibraryProperties{
|
||||
BuildShared: shared,
|
||||
BuildStatic: static,
|
||||
BuildShared: true,
|
||||
BuildStatic: true,
|
||||
},
|
||||
baseCompiler: NewBaseCompiler(),
|
||||
baseLinker: NewBaseLinker(),
|
||||
|
@@ -277,7 +277,8 @@ func (stub *stubDecorator) install(ctx ModuleContext, path android.Path) {
|
||||
}
|
||||
|
||||
func newStubLibrary() (*Module, []interface{}) {
|
||||
module, library := NewLibrary(android.DeviceSupported, true, false)
|
||||
module, library := NewLibrary(android.DeviceSupported)
|
||||
library.BuildOnlyShared()
|
||||
module.stl = nil
|
||||
module.sanitize = nil
|
||||
library.StripProperties.Strip.None = true
|
||||
|
@@ -102,7 +102,8 @@ func (*ndkPrebuiltLibraryLinker) linkerDeps(ctx BaseModuleContext, deps Deps) De
|
||||
}
|
||||
|
||||
func ndkPrebuiltLibraryFactory() (blueprint.Module, []interface{}) {
|
||||
module, library := NewLibrary(android.DeviceSupported, true, false)
|
||||
module, library := NewLibrary(android.DeviceSupported)
|
||||
library.BuildOnlyShared()
|
||||
linker := &ndkPrebuiltLibraryLinker{
|
||||
libraryDecorator: library,
|
||||
}
|
||||
@@ -132,7 +133,8 @@ type ndkPrebuiltStlLinker struct {
|
||||
}
|
||||
|
||||
func ndkPrebuiltSharedStlFactory() (blueprint.Module, []interface{}) {
|
||||
module, library := NewLibrary(android.DeviceSupported, true, false)
|
||||
module, library := NewLibrary(android.DeviceSupported)
|
||||
library.BuildOnlyShared()
|
||||
linker := &ndkPrebuiltStlLinker{
|
||||
ndkPrebuiltLibraryLinker: ndkPrebuiltLibraryLinker{
|
||||
libraryDecorator: library,
|
||||
@@ -146,7 +148,8 @@ func ndkPrebuiltSharedStlFactory() (blueprint.Module, []interface{}) {
|
||||
}
|
||||
|
||||
func ndkPrebuiltStaticStlFactory() (blueprint.Module, []interface{}) {
|
||||
module, library := NewLibrary(android.DeviceSupported, false, true)
|
||||
module, library := NewLibrary(android.DeviceSupported)
|
||||
library.BuildOnlyStatic()
|
||||
linker := &ndkPrebuiltStlLinker{
|
||||
ndkPrebuiltLibraryLinker: ndkPrebuiltLibraryLinker{
|
||||
libraryDecorator: library,
|
||||
|
@@ -60,7 +60,7 @@ func (p *prebuiltLibraryLinker) link(ctx ModuleContext,
|
||||
}
|
||||
|
||||
func prebuiltSharedLibraryFactory() (blueprint.Module, []interface{}) {
|
||||
module, library := NewLibrary(android.HostAndDeviceSupported, true, true)
|
||||
module, library := NewLibrary(android.HostAndDeviceSupported)
|
||||
module.compiler = nil
|
||||
|
||||
prebuilt := &prebuiltLibraryLinker{
|
||||
|
@@ -263,7 +263,7 @@ func (test *testLibrary) linkerFlags(ctx ModuleContext, flags Flags) Flags {
|
||||
}
|
||||
|
||||
func NewTestLibrary(hod android.HostOrDeviceSupported) *Module {
|
||||
module, library := NewLibrary(android.HostAndDeviceSupported, true, true)
|
||||
module, library := NewLibrary(android.HostAndDeviceSupported)
|
||||
library.baseInstaller = NewTestInstaller()
|
||||
test := &testLibrary{
|
||||
testDecorator: testDecorator{
|
||||
|
@@ -39,7 +39,8 @@ func (*toolchainLibraryDecorator) linkerDeps(ctx BaseModuleContext, deps Deps) D
|
||||
}
|
||||
|
||||
func toolchainLibraryFactory() (blueprint.Module, []interface{}) {
|
||||
module, library := NewLibrary(android.HostAndDeviceSupported, false, true)
|
||||
module, library := NewLibrary(android.HostAndDeviceSupported)
|
||||
library.BuildOnlyStatic()
|
||||
toolchainLibrary := &toolchainLibraryDecorator{
|
||||
libraryDecorator: library,
|
||||
}
|
||||
|
Reference in New Issue
Block a user