Refactor out exported cflags am: 919281a
am: 5b135f5
* commit '5b135f5c45ddedf19d4e1371f5a4e57411992e87':
Refactor out exported cflags
Change-Id: I914e63027f2f4e4c629ab3a0f98828c9fc005861
This commit is contained in:
69
cc/cc.go
69
cc/cc.go
@@ -341,6 +341,12 @@ type LibraryCompilerProperties struct {
|
|||||||
} `android:"arch_variant"`
|
} `android:"arch_variant"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type FlagExporterProperties struct {
|
||||||
|
// list of directories relative to the Blueprints file that will
|
||||||
|
// be added to the include path using -I for any module that links against this module
|
||||||
|
Export_include_dirs []string `android:"arch_variant"`
|
||||||
|
}
|
||||||
|
|
||||||
type LibraryLinkerProperties struct {
|
type LibraryLinkerProperties struct {
|
||||||
Static struct {
|
Static struct {
|
||||||
Whole_static_libs []string `android:"arch_variant"`
|
Whole_static_libs []string `android:"arch_variant"`
|
||||||
@@ -362,10 +368,6 @@ type LibraryLinkerProperties struct {
|
|||||||
// local file name to pass to the linker as -force_symbols_weak_list
|
// local file name to pass to the linker as -force_symbols_weak_list
|
||||||
Force_symbols_weak_list *string `android:"arch_variant"`
|
Force_symbols_weak_list *string `android:"arch_variant"`
|
||||||
|
|
||||||
// list of directories relative to the Blueprints file that will
|
|
||||||
// be added to the include path using -I for any module that links against this module
|
|
||||||
Export_include_dirs []string `android:"arch_variant"`
|
|
||||||
|
|
||||||
// don't link in crt_begin and crt_end. This flag should only be necessary for
|
// don't link in crt_begin and crt_end. This flag should only be necessary for
|
||||||
// compiling crt or libc.
|
// compiling crt or libc.
|
||||||
Nocrt *bool `android:"arch_variant"`
|
Nocrt *bool `android:"arch_variant"`
|
||||||
@@ -1271,10 +1273,6 @@ type baseLinkerInterface interface {
|
|||||||
staticBinary() bool
|
staticBinary() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type exportedFlagsProducer interface {
|
|
||||||
exportedFlags() []string
|
|
||||||
}
|
|
||||||
|
|
||||||
type baseInstaller struct {
|
type baseInstaller struct {
|
||||||
Properties InstallerProperties
|
Properties InstallerProperties
|
||||||
|
|
||||||
@@ -1308,6 +1306,31 @@ func (installer *baseInstaller) inData() bool {
|
|||||||
// Combined static+shared libraries
|
// Combined static+shared libraries
|
||||||
//
|
//
|
||||||
|
|
||||||
|
type flagExporter struct {
|
||||||
|
Properties FlagExporterProperties
|
||||||
|
|
||||||
|
flags []string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *flagExporter) exportIncludes(ctx ModuleContext, inc string) {
|
||||||
|
includeDirs := common.PathsForModuleSrc(ctx, f.Properties.Export_include_dirs)
|
||||||
|
f.flags = append(f.flags, common.JoinWithPrefix(includeDirs.Strings(), inc))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *flagExporter) reexportFlags(flags []string) {
|
||||||
|
f.flags = append(f.flags, flags...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *flagExporter) exportedFlags() []string {
|
||||||
|
return f.flags
|
||||||
|
}
|
||||||
|
|
||||||
|
type exportedFlagsProducer interface {
|
||||||
|
exportedFlags() []string
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ exportedFlagsProducer = (*flagExporter)(nil)
|
||||||
|
|
||||||
type libraryCompiler struct {
|
type libraryCompiler struct {
|
||||||
baseCompiler
|
baseCompiler
|
||||||
|
|
||||||
@@ -1365,6 +1388,7 @@ func (library *libraryCompiler) compile(ctx ModuleContext, flags Flags, deps Pat
|
|||||||
|
|
||||||
type libraryLinker struct {
|
type libraryLinker struct {
|
||||||
baseLinker
|
baseLinker
|
||||||
|
flagExporter
|
||||||
|
|
||||||
Properties LibraryLinkerProperties
|
Properties LibraryLinkerProperties
|
||||||
|
|
||||||
@@ -1373,8 +1397,6 @@ type libraryLinker struct {
|
|||||||
BuildShared bool `blueprint:"mutated"`
|
BuildShared bool `blueprint:"mutated"`
|
||||||
}
|
}
|
||||||
|
|
||||||
exportFlags []string
|
|
||||||
|
|
||||||
// If we're used as a whole_static_lib, our missing dependencies need
|
// If we're used as a whole_static_lib, our missing dependencies need
|
||||||
// to be given
|
// to be given
|
||||||
wholeStaticMissingDeps []string
|
wholeStaticMissingDeps []string
|
||||||
@@ -1384,11 +1406,13 @@ type libraryLinker struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var _ linker = (*libraryLinker)(nil)
|
var _ linker = (*libraryLinker)(nil)
|
||||||
var _ exportedFlagsProducer = (*libraryLinker)(nil)
|
|
||||||
|
|
||||||
func (library *libraryLinker) props() []interface{} {
|
func (library *libraryLinker) props() []interface{} {
|
||||||
props := library.baseLinker.props()
|
props := library.baseLinker.props()
|
||||||
return append(props, &library.Properties, &library.dynamicProperties)
|
return append(props,
|
||||||
|
&library.Properties,
|
||||||
|
&library.dynamicProperties,
|
||||||
|
&library.flagExporter.Properties)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (library *libraryLinker) flags(ctx ModuleContext, flags Flags) Flags {
|
func (library *libraryLinker) flags(ctx ModuleContext, flags Flags) Flags {
|
||||||
@@ -1452,10 +1476,6 @@ func (library *libraryLinker) deps(ctx BaseModuleContext, deps Deps) Deps {
|
|||||||
return deps
|
return deps
|
||||||
}
|
}
|
||||||
|
|
||||||
func (library *libraryLinker) exportedFlags() []string {
|
|
||||||
return library.exportFlags
|
|
||||||
}
|
|
||||||
|
|
||||||
func (library *libraryLinker) linkStatic(ctx ModuleContext,
|
func (library *libraryLinker) linkStatic(ctx ModuleContext,
|
||||||
flags Flags, deps PathDeps, objFiles common.Paths) common.Path {
|
flags Flags, deps PathDeps, objFiles common.Paths) common.Path {
|
||||||
|
|
||||||
@@ -1542,9 +1562,8 @@ func (library *libraryLinker) link(ctx ModuleContext,
|
|||||||
out = library.linkShared(ctx, flags, deps, objFiles)
|
out = library.linkShared(ctx, flags, deps, objFiles)
|
||||||
}
|
}
|
||||||
|
|
||||||
includeDirs := common.PathsForModuleSrc(ctx, library.Properties.Export_include_dirs)
|
library.exportIncludes(ctx, "-I")
|
||||||
library.exportFlags = []string{includeDirsToFlags(includeDirs)}
|
library.reexportFlags(deps.ReexportedCflags)
|
||||||
library.exportFlags = append(library.exportFlags, deps.ReexportedCflags...)
|
|
||||||
|
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
@@ -2065,6 +2084,7 @@ func defaultsFactory() (blueprint.Module, []interface{}) {
|
|||||||
&BaseCompilerProperties{},
|
&BaseCompilerProperties{},
|
||||||
&BaseLinkerProperties{},
|
&BaseLinkerProperties{},
|
||||||
&LibraryCompilerProperties{},
|
&LibraryCompilerProperties{},
|
||||||
|
&FlagExporterProperties{},
|
||||||
&LibraryLinkerProperties{},
|
&LibraryLinkerProperties{},
|
||||||
&BinaryLinkerProperties{},
|
&BinaryLinkerProperties{},
|
||||||
&TestLinkerProperties{},
|
&TestLinkerProperties{},
|
||||||
@@ -2178,16 +2198,13 @@ func (c *ndkPrebuiltObjectLinker) link(ctx ModuleContext, flags Flags,
|
|||||||
|
|
||||||
type ndkPrebuiltLibraryLinker struct {
|
type ndkPrebuiltLibraryLinker struct {
|
||||||
libraryLinker
|
libraryLinker
|
||||||
Properties struct {
|
|
||||||
Export_include_dirs []string `android:"arch_variant"`
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ baseLinkerInterface = (*ndkPrebuiltLibraryLinker)(nil)
|
var _ baseLinkerInterface = (*ndkPrebuiltLibraryLinker)(nil)
|
||||||
var _ exportedFlagsProducer = (*libraryLinker)(nil)
|
var _ exportedFlagsProducer = (*libraryLinker)(nil)
|
||||||
|
|
||||||
func (ndk *ndkPrebuiltLibraryLinker) props() []interface{} {
|
func (ndk *ndkPrebuiltLibraryLinker) props() []interface{} {
|
||||||
return append(ndk.libraryLinker.props(), &ndk.Properties)
|
return append(ndk.libraryLinker.props(), &ndk.Properties, &ndk.flagExporter.Properties)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*ndkPrebuiltLibraryLinker) deps(ctx BaseModuleContext, deps Deps) Deps {
|
func (*ndkPrebuiltLibraryLinker) deps(ctx BaseModuleContext, deps Deps) Deps {
|
||||||
@@ -2210,8 +2227,7 @@ func (ndk *ndkPrebuiltLibraryLinker) link(ctx ModuleContext, flags Flags,
|
|||||||
ctx.ModuleErrorf("NDK prebuilts must have an ndk_lib prefixed name")
|
ctx.ModuleErrorf("NDK prebuilts must have an ndk_lib prefixed name")
|
||||||
}
|
}
|
||||||
|
|
||||||
includeDirs := common.PathsForModuleSrc(ctx, ndk.Properties.Export_include_dirs)
|
ndk.exportIncludes(ctx, "-isystem")
|
||||||
ndk.exportFlags = []string{common.JoinWithPrefix(includeDirs.Strings(), "-isystem ")}
|
|
||||||
|
|
||||||
return ndkPrebuiltModuleToPath(ctx, flags.Toolchain, flags.Toolchain.ShlibSuffix(),
|
return ndkPrebuiltModuleToPath(ctx, flags.Toolchain, flags.Toolchain.ShlibSuffix(),
|
||||||
ctx.sdkVersion())
|
ctx.sdkVersion())
|
||||||
@@ -2269,8 +2285,7 @@ func (ndk *ndkPrebuiltStlLinker) link(ctx ModuleContext, flags Flags,
|
|||||||
ctx.ModuleErrorf("NDK prebuilts must have an ndk_lib prefixed name")
|
ctx.ModuleErrorf("NDK prebuilts must have an ndk_lib prefixed name")
|
||||||
}
|
}
|
||||||
|
|
||||||
includeDirs := common.PathsForModuleSrc(ctx, ndk.Properties.Export_include_dirs)
|
ndk.exportIncludes(ctx, "-I")
|
||||||
ndk.exportFlags = []string{includeDirsToFlags(includeDirs)}
|
|
||||||
|
|
||||||
libName := strings.TrimPrefix(ctx.ModuleName(), "ndk_")
|
libName := strings.TrimPrefix(ctx.ModuleName(), "ndk_")
|
||||||
libExt := flags.Toolchain.ShlibSuffix()
|
libExt := flags.Toolchain.ShlibSuffix()
|
||||||
|
Reference in New Issue
Block a user