diff options
| author | 2017-12-15 13:56:59 -0800 | |
|---|---|---|
| committer | 2017-12-15 13:56:59 -0800 | |
| commit | 202fe493e3da480620504aa9a34b4e547ae3fbe1 (patch) | |
| tree | 6d0542ae2ba767c6b881e26bab727236eb6890b6 | |
| parent | e565435a7b7ce4205922db6eb56e38aed25b1f9d (diff) | |
Add basic NDK STL link type check.
Test: make native
Bug: None
Change-Id: If883fade38c837839857d82f294c459b0dae1ce0
| -rw-r--r-- | cc/cc.go | 21 | ||||
| -rw-r--r-- | cc/stl.go | 19 |
2 files changed, 40 insertions, 0 deletions
@@ -1036,6 +1036,27 @@ func checkLinkType(ctx android.ModuleContext, from *Module, to *Module) { ctx.ModuleErrorf("links %q built against newer API version %q", ctx.OtherModuleName(to), String(to.Properties.Sdk_version)) } + + // Also check that the two STL choices are compatible. + fromStl := from.stl.Properties.SelectedStl + toStl := to.stl.Properties.SelectedStl + if fromStl == "" || toStl == "" { + // Libraries that don't use the STL are unrestricted. + return + } + + if fromStl == "ndk_system" || toStl == "ndk_system" { + // We can be permissive with the system "STL" since it is only the C++ + // ABI layer, but in the future we should make sure that everyone is + // using either libc++ or nothing. + return + } + + if getNdkStlFamily(ctx, from) != getNdkStlFamily(ctx, to) { + ctx.ModuleErrorf("uses %q and depends on %q which uses incompatible %q", + from.stl.Properties.SelectedStl, ctx.OtherModuleName(to), + to.stl.Properties.SelectedStl) + } } // Convert dependencies to paths. Returns a PathDeps containing paths @@ -19,6 +19,25 @@ import ( "fmt" ) +func getNdkStlFamily(ctx android.ModuleContext, m *Module) string { + stl := m.stl.Properties.SelectedStl + switch stl { + case "ndk_libc++_shared", "ndk_libc++_static": + return "libc++" + case "ndk_libstlport_shared", "ndk_libstlport_static": + return "stlport" + case "ndk_libgnustl_static": + return "gnustl" + case "ndk_system": + return "system" + case "": + return "none" + default: + ctx.ModuleErrorf("stl: %q is not a valid STL", stl) + return "" + } +} + type StlProperties struct { // select the STL library to use. Possible values are "libc++", "libc++_static", // "stlport", "stlport_static", "ndk", "libstdc++", or "none". Leave blank to select the |