diff options
author | Colin Cross <ccross@android.com> | 2017-03-17 13:28:06 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2017-03-17 14:06:28 -0700 |
commit | de89fb870706a59df36586eba1c58ccc7c1a1bae (patch) | |
tree | b7e3d88a3cee596b46a8f1dd71c4381386de8d1e /cc | |
parent | dfee1bcf437f40046e591b197eb3c1222b1420ba (diff) | |
download | build_soong-de89fb870706a59df36586eba1c58ccc7c1a1bae.tar.gz build_soong-de89fb870706a59df36586eba1c58ccc7c1a1bae.tar.bz2 build_soong-de89fb870706a59df36586eba1c58ccc7c1a1bae.zip |
Add support for binary and static library and prebuilts
Add cc_prebuilt_library_static and cc_prebuilt_binary module types.
Bug: 35576244
Test: Add cc_prebuilt_library_static and cc_prebuilt_binary modules
and verify they are used
Change-Id: I708ec7b1ed1a0eddae083159575ae04d5ea25a37
Diffstat (limited to 'cc')
-rw-r--r-- | cc/prebuilt.go | 66 |
1 files changed, 60 insertions, 6 deletions
diff --git a/cc/prebuilt.go b/cc/prebuilt.go index 7deb0ed4..08ba1457 100644 --- a/cc/prebuilt.go +++ b/cc/prebuilt.go @@ -22,6 +22,8 @@ import ( func init() { android.RegisterModuleType("cc_prebuilt_library_shared", prebuiltSharedLibraryFactory) + android.RegisterModuleType("cc_prebuilt_library_static", prebuiltStaticLibraryFactory) + android.RegisterModuleType("cc_prebuilt_binary", prebuiltBinaryFactory) } type prebuiltLinkerInterface interface { @@ -29,17 +31,21 @@ type prebuiltLinkerInterface interface { prebuilt() *android.Prebuilt } -type prebuiltLibraryLinker struct { - *libraryDecorator +type prebuiltLinker struct { android.Prebuilt } -var _ prebuiltLinkerInterface = (*prebuiltLibraryLinker)(nil) - -func (p *prebuiltLibraryLinker) prebuilt() *android.Prebuilt { +func (p *prebuiltLinker) prebuilt() *android.Prebuilt { return &p.Prebuilt } +type prebuiltLibraryLinker struct { + *libraryDecorator + prebuiltLinker +} + +var _ prebuiltLinkerInterface = (*prebuiltLibraryLinker)(nil) + func (p *prebuiltLibraryLinker) linkerProps() []interface{} { props := p.libraryDecorator.linkerProps() return append(props, &p.Prebuilt.Properties) @@ -61,13 +67,61 @@ func (p *prebuiltLibraryLinker) link(ctx ModuleContext, func prebuiltSharedLibraryFactory() (blueprint.Module, []interface{}) { module, library := NewLibrary(android.HostAndDeviceSupported) + library.BuildOnlyShared() module.compiler = nil prebuilt := &prebuiltLibraryLinker{ libraryDecorator: library, } module.linker = prebuilt - module.installer = prebuilt + + return module.Init() +} + +func prebuiltStaticLibraryFactory() (blueprint.Module, []interface{}) { + module, library := NewLibrary(android.HostAndDeviceSupported) + library.BuildOnlyStatic() + module.compiler = nil + + prebuilt := &prebuiltLibraryLinker{ + libraryDecorator: library, + } + module.linker = prebuilt + + return module.Init() +} + +type prebuiltBinaryLinker struct { + *binaryDecorator + prebuiltLinker +} + +var _ prebuiltLinkerInterface = (*prebuiltBinaryLinker)(nil) + +func (p *prebuiltBinaryLinker) linkerProps() []interface{} { + props := p.binaryDecorator.linkerProps() + return append(props, &p.Prebuilt.Properties) +} + +func (p *prebuiltBinaryLinker) link(ctx ModuleContext, + flags Flags, deps PathDeps, objs Objects) android.Path { + // TODO(ccross): verify shared library dependencies + if len(p.Prebuilt.Properties.Srcs) > 0 { + // TODO(ccross): .toc optimization, stripping, packing + return p.Prebuilt.Path(ctx) + } + + return nil +} + +func prebuiltBinaryFactory() (blueprint.Module, []interface{}) { + module, binary := NewBinary(android.HostAndDeviceSupported) + module.compiler = nil + + prebuilt := &prebuiltBinaryLinker{ + binaryDecorator: binary, + } + module.linker = prebuilt return module.Init() } |