summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2016-11-02 13:05:19 +0800
committerruki <[email protected]>2016-11-02 13:05:19 +0800
commite747b0d8abc2ddb6aa2595e6a522eb29d3e7d2fd (patch)
treec23a305ac2fc2c46ef036795ed1cadea4f703f7a
parent1fcfcb5ea078834548392177599a0a0340d20204 (diff)
add c++ stl search directories for android
-rw-r--r--xmake/platforms/android/checker.lua21
-rwxr-xr-xxmake/platforms/android/xmake.lua34
2 files changed, 53 insertions, 2 deletions
diff --git a/xmake/platforms/android/checker.lua b/xmake/platforms/android/checker.lua
index fa5987cf4..f34da2f2d 100644
--- a/xmake/platforms/android/checker.lua
+++ b/xmake/platforms/android/checker.lua
@@ -63,11 +63,11 @@ function _check_ndk_sdkver(config)
config.set("ndk_sdkver", ndk_sdkver)
-- trace
- print("checking for the SDK version of NDK ... android-%d", ndk_sdkver)
+ cprint("checking for the SDK version of NDK ... ${green}android-%d", ndk_sdkver)
else
-- trace
- print("checking for the SDK version of NDK ... no")
+ cprint("checking for the SDK version of NDK ... ${red}no")
end
end
end
@@ -101,6 +101,23 @@ function _check_toolchains(config)
end
end
+ -- get toolchains version
+ local toolchains = config.get("toolchains")
+ if toolchains then
+ local pos, _, toolchains_ver = toolchains:find("%-(%d*%.%d*)/")
+ if pos and toolchains_ver then
+
+ -- save the toolchains version
+ config.set("toolchains_ver", toolchains_ver)
+
+ -- trace
+ cprint("checking for the version of toolchains ... ${green}%s", toolchains_ver)
+ else
+ -- trace
+ cprint("checking for the version of toolchains ... ${red}no")
+ end
+ end
+
-- get cross
local cross = "arm-linux-androideabi-"
if arch and arch:startswith("arm64") then
diff --git a/xmake/platforms/android/xmake.lua b/xmake/platforms/android/xmake.lua
index e07cb788a..7595d78c7 100755
--- a/xmake/platforms/android/xmake.lua
+++ b/xmake/platforms/android/xmake.lua
@@ -58,18 +58,24 @@ platform("android")
_g.asflags = {}
_g.ldflags = {"-llog"}
_g.shflags = {"-llog"}
+ _g.cxxflags = {}
else
_g.cxflags = { "-march=" .. arch, "-mthumb"}
_g.asflags = { "-march=" .. arch, "-mthumb"}
_g.ldflags = { "-march=" .. arch, "-llog", "-mthumb"}
_g.shflags = { "-march=" .. arch, "-llog", "-mthumb"}
+ _g.cxxflags = {}
end
-- add flags for the sdk directory of ndk
local ndk = config.get("ndk")
local ndk_sdkver = config.get("ndk_sdkver")
if ndk and ndk_sdkver then
+
+ -- get ndk sdk directory
local ndk_sdkdir = path.translate(format("%s/platforms/android-%d", ndk, ndk_sdkver))
+
+ -- add sysroot
if arch:startswith("arm64") then
insert(_g.cxflags, format("--sysroot=%s/arch-arm64", ndk_sdkdir))
insert(_g.asflags, format("--sysroot=%s/arch-arm64", ndk_sdkdir))
@@ -81,6 +87,34 @@ platform("android")
insert(_g.ldflags, format("--sysroot=%s/arch-arm", ndk_sdkdir))
insert(_g.shflags, format("--sysroot=%s/arch-arm", ndk_sdkdir))
end
+
+ -- only for c++ stl
+ local toolchains_ver = config.get("toolchains_ver")
+ if toolchains_ver then
+
+ -- get c++ stl sdk directory
+ local cxxstl_sdkdir = path.translate(format("%s/sources/cxx-stl/gnu-libstdc++/%s", ndk, toolchains_ver))
+
+ -- the toolchains archs
+ local toolchains_archs =
+ {
+ ["armv5te"] = "armeabi"
+ , ["armv6"] = "armeabi"
+ , ["armv7-a"] = "armeabi-v7a"
+ , ["armv8-a"] = "armeabi-v8a"
+ , ["arm64-v8a"] = "arm64-v8a"
+ }
+
+ -- add search directories for c++ stl
+ insert(_g.cxxflags, format("-I%s/include", cxxstl_sdkdir))
+ if toolchains_archs[arch] then
+ insert(_g.cxxflags, format("-I%s/libs/%s/include", cxxstl_sdkdir, toolchains_archs[arch]))
+ insert(_g.ldflags, format("-L%s/libs/%s", cxxstl_sdkdir, toolchains_archs[arch]))
+ insert(_g.shflags, format("-L%s/libs/%s", cxxstl_sdkdir, toolchains_archs[arch]))
+ insert(_g.ldflags, format("-lgnustl_static"))
+ insert(_g.shflags, format("-lgnustl_static"))
+ end
+ end
end
end)