Check NDK linking, expose SDK_VERSION to Make am: a96ff64527
am: e996f78112
Change-Id: I903231f0af81360e3674400da2fc09d741d86fe3
This commit is contained in:
commit
4811b8c822
|
@ -35,6 +35,13 @@ func (c *Module) AndroidMk() (ret android.AndroidMkData, err error) {
|
||||||
if len(c.Properties.AndroidMkSharedLibs) > 0 {
|
if len(c.Properties.AndroidMkSharedLibs) > 0 {
|
||||||
fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES := "+strings.Join(c.Properties.AndroidMkSharedLibs, " "))
|
fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES := "+strings.Join(c.Properties.AndroidMkSharedLibs, " "))
|
||||||
}
|
}
|
||||||
|
if c.Target().Os == android.Android && c.Properties.Sdk_version != "" {
|
||||||
|
fmt.Fprintln(w, "LOCAL_SDK_VERSION := "+c.Properties.Sdk_version)
|
||||||
|
fmt.Fprintln(w, "LOCAL_NDK_STL_VARIANT := none")
|
||||||
|
} else {
|
||||||
|
// These are already included in LOCAL_SHARED_LIBRARIES
|
||||||
|
fmt.Fprintln(w, "LOCAL_CXX_STL := none")
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -85,8 +92,6 @@ func (library *libraryLinker) AndroidMk(ret *android.AndroidMkData) {
|
||||||
|
|
||||||
fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+outputFile.Ext())
|
fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+outputFile.Ext())
|
||||||
|
|
||||||
// These are already included in LOCAL_SHARED_LIBRARIES
|
|
||||||
fmt.Fprintln(w, "LOCAL_CXX_STL := none")
|
|
||||||
fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
|
fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
58
cc/cc.go
58
cc/cc.go
|
@ -636,11 +636,17 @@ func (ctx *moduleContextImpl) noDefaultCompilerFlags() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctx *moduleContextImpl) sdk() bool {
|
func (ctx *moduleContextImpl) sdk() bool {
|
||||||
return ctx.mod.Properties.Sdk_version != ""
|
if ctx.ctx.Device() {
|
||||||
|
return ctx.mod.Properties.Sdk_version != ""
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctx *moduleContextImpl) sdkVersion() string {
|
func (ctx *moduleContextImpl) sdkVersion() string {
|
||||||
return ctx.mod.Properties.Sdk_version
|
if ctx.ctx.Device() {
|
||||||
|
return ctx.mod.Properties.Sdk_version
|
||||||
|
}
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctx *moduleContextImpl) selectedStl() string {
|
func (ctx *moduleContextImpl) selectedStl() string {
|
||||||
|
@ -901,6 +907,28 @@ func (c *Module) clang(ctx BaseModuleContext) bool {
|
||||||
func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
||||||
var depPaths PathDeps
|
var depPaths PathDeps
|
||||||
|
|
||||||
|
// Whether a module can link to another module, taking into
|
||||||
|
// account NDK linking.
|
||||||
|
linkTypeOk := func(from, to *Module) bool {
|
||||||
|
if from.Target().Os != android.Android {
|
||||||
|
// Host code is not restricted
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if from.Properties.Sdk_version == "" {
|
||||||
|
// Platform code can link to anything
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if _, ok := to.linker.(*toolchainLibraryLinker); ok {
|
||||||
|
// These are always allowed
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if _, ok := to.linker.(*ndkPrebuiltLibraryLinker); ok {
|
||||||
|
// These are allowed, but don't set sdk_version
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return from.Properties.Sdk_version != ""
|
||||||
|
}
|
||||||
|
|
||||||
ctx.VisitDirectDeps(func(m blueprint.Module) {
|
ctx.VisitDirectDeps(func(m blueprint.Module) {
|
||||||
name := ctx.OtherModuleName(m)
|
name := ctx.OtherModuleName(m)
|
||||||
tag := ctx.OtherModuleDependencyTag(m)
|
tag := ctx.OtherModuleDependencyTag(m)
|
||||||
|
@ -911,8 +939,8 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c, _ := m.(*Module)
|
cc, _ := m.(*Module)
|
||||||
if c == nil {
|
if cc == nil {
|
||||||
switch tag {
|
switch tag {
|
||||||
case android.DefaultsDepTag:
|
case android.DefaultsDepTag:
|
||||||
case genSourceDepTag:
|
case genSourceDepTag:
|
||||||
|
@ -952,19 +980,19 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !c.outputFile.Valid() {
|
if !cc.outputFile.Valid() {
|
||||||
ctx.ModuleErrorf("module %q missing output file", name)
|
ctx.ModuleErrorf("module %q missing output file", name)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if tag == reuseObjTag {
|
if tag == reuseObjTag {
|
||||||
depPaths.ObjFiles = append(depPaths.ObjFiles,
|
depPaths.ObjFiles = append(depPaths.ObjFiles,
|
||||||
c.compiler.(*libraryCompiler).reuseObjFiles...)
|
cc.compiler.(*libraryCompiler).reuseObjFiles...)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if t, ok := tag.(dependencyTag); ok && t.library {
|
if t, ok := tag.(dependencyTag); ok && t.library {
|
||||||
if i, ok := c.linker.(exportedFlagsProducer); ok {
|
if i, ok := cc.linker.(exportedFlagsProducer); ok {
|
||||||
cflags := i.exportedFlags()
|
cflags := i.exportedFlags()
|
||||||
depPaths.Cflags = append(depPaths.Cflags, cflags...)
|
depPaths.Cflags = append(depPaths.Cflags, cflags...)
|
||||||
|
|
||||||
|
@ -972,6 +1000,10 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
||||||
depPaths.ReexportedCflags = append(depPaths.ReexportedCflags, cflags...)
|
depPaths.ReexportedCflags = append(depPaths.ReexportedCflags, cflags...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !linkTypeOk(c, cc) {
|
||||||
|
ctx.ModuleErrorf("depends on non-NDK-built library %q", name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var depPtr *android.Paths
|
var depPtr *android.Paths
|
||||||
|
@ -987,9 +1019,9 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
||||||
depPtr = &depPaths.LateStaticLibs
|
depPtr = &depPaths.LateStaticLibs
|
||||||
case wholeStaticDepTag:
|
case wholeStaticDepTag:
|
||||||
depPtr = &depPaths.WholeStaticLibs
|
depPtr = &depPaths.WholeStaticLibs
|
||||||
staticLib, _ := c.linker.(*libraryLinker)
|
staticLib, _ := cc.linker.(*libraryLinker)
|
||||||
if staticLib == nil || !staticLib.static() {
|
if staticLib == nil || !staticLib.static() {
|
||||||
ctx.ModuleErrorf("module %q not a static library", ctx.OtherModuleName(m))
|
ctx.ModuleErrorf("module %q not a static library", name)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1005,15 +1037,15 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
||||||
case objDepTag:
|
case objDepTag:
|
||||||
depPtr = &depPaths.ObjFiles
|
depPtr = &depPaths.ObjFiles
|
||||||
case crtBeginDepTag:
|
case crtBeginDepTag:
|
||||||
depPaths.CrtBegin = c.outputFile
|
depPaths.CrtBegin = cc.outputFile
|
||||||
case crtEndDepTag:
|
case crtEndDepTag:
|
||||||
depPaths.CrtEnd = c.outputFile
|
depPaths.CrtEnd = cc.outputFile
|
||||||
default:
|
default:
|
||||||
panic(fmt.Errorf("unknown dependency tag: %s", tag))
|
panic(fmt.Errorf("unknown dependency tag: %s", tag))
|
||||||
}
|
}
|
||||||
|
|
||||||
if depPtr != nil {
|
if depPtr != nil {
|
||||||
*depPtr = append(*depPtr, c.outputFile.Path())
|
*depPtr = append(*depPtr, cc.outputFile.Path())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1266,7 +1298,7 @@ func (linker *baseLinker) deps(ctx BaseModuleContext, deps Deps) Deps {
|
||||||
deps.ReexportStaticLibHeaders = append(deps.ReexportStaticLibHeaders, linker.Properties.Export_static_lib_headers...)
|
deps.ReexportStaticLibHeaders = append(deps.ReexportStaticLibHeaders, linker.Properties.Export_static_lib_headers...)
|
||||||
deps.ReexportSharedLibHeaders = append(deps.ReexportSharedLibHeaders, linker.Properties.Export_shared_lib_headers...)
|
deps.ReexportSharedLibHeaders = append(deps.ReexportSharedLibHeaders, linker.Properties.Export_shared_lib_headers...)
|
||||||
|
|
||||||
if ctx.ModuleName() != "libcompiler_rt-extras" {
|
if !ctx.sdk() && ctx.ModuleName() != "libcompiler_rt-extras" {
|
||||||
deps.StaticLibs = append(deps.StaticLibs, "libcompiler_rt-extras")
|
deps.StaticLibs = append(deps.StaticLibs, "libcompiler_rt-extras")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue