Skip to content

Commit

Permalink
Merge pull request #5211 from SirLynix/patch-17
Browse files Browse the repository at this point in the history
Improve Android
  • Loading branch information
waruqi authored Jun 12, 2024
2 parents 33f3078 + 6bf7abf commit ebc4520
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
1 change: 1 addition & 0 deletions xmake/modules/detect/sdks/find_ndk.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ function _find_ndk_sdkver(sdkdir, bindir, sysroot, arch)

-- get triple
local triple = _get_triple(arch)
assert(triple, "no triple found for arch %s (wrong arch?)", arch)

-- try to select the best compatible version
local sdkver = "16"
Expand Down
29 changes: 16 additions & 13 deletions xmake/toolchains/ndk/load.lua
Original file line number Diff line number Diff line change
Expand Up @@ -171,21 +171,24 @@ function main(toolchain)
toolchain:add("cxflags", "-D__ANDROID_API__=" .. ndk_sdkver)
toolchain:add("asflags", "-D__ANDROID_API__=" .. ndk_sdkver)
end
toolchain:add("cflags", "--sysroot=" .. ndk_sysroot)
toolchain:add("cxxflags","--sysroot=" .. ndk_sysroot)
toolchain:add("asflags", "--sysroot=" .. ndk_sysroot)
toolchain:add("cflags", "-isystem " .. path.join(ndk_sysroot, "usr", "include", triple))
toolchain:add("cxxflags","-isystem " .. path.join(ndk_sysroot, "usr", "include", triple))
toolchain:add("asflags", "-isystem " .. path.join(ndk_sysroot, "usr", "include", triple))
local flag_sysroot = "--sysroot=" .. os.args(ndk_sysroot)
local flag_isystem = "-isystem " .. os.args(path.join(ndk_sysroot, "usr", "include", triple))
toolchain:add("cflags", flag_sysroot)
toolchain:add("cxxflags", flag_sysroot)
toolchain:add("asflags", flag_sysroot)
toolchain:add("cflags", flag_isystem)
toolchain:add("cxxflags", flag_isystem)
toolchain:add("asflags", flag_isystem)
else
local ndk_sdkdir = path.translate(format("%s/platforms/android-%d", ndk, ndk_sdkver))
if os.isdir(ndk_sdkdir) then
if sysroot_arch then
toolchain:add("cflags", format("--sysroot=%s/%s", ndk_sdkdir, sysroot_arch))
toolchain:add("cxxflags", format("--sysroot=%s/%s", ndk_sdkdir, sysroot_arch))
toolchain:add("asflags", format("--sysroot=%s/%s", ndk_sdkdir, sysroot_arch))
toolchain:add("ldflags", format("--sysroot=%s/%s", ndk_sdkdir, sysroot_arch))
toolchain:add("shflags", format("--sysroot=%s/%s", ndk_sdkdir, sysroot_arch))
local flag_sysroot = "--sysroot=" .. os.args(path.join(ndk_sdkdir, sysroot_arch))
toolchain:add("cflags", flag_sysroot)
toolchain:add("cxxflags", flag_sysroot)
toolchain:add("asflags", flag_sysroot)
toolchain:add("ldflags", flag_sysroot)
toolchain:add("shflags", flag_sysroot)
end
end
end
Expand Down Expand Up @@ -318,8 +321,8 @@ function main(toolchain)
-- The NDK's libc++ now comes directly from our LLVM toolchain above 26b
-- https://github.com/xmake-io/xmake/issues/4614
if ndk_cxxstl == "c++_static" then
toolchain:add("ldflags", "-static-libstdc++", "-lc++abi")
toolchain:add("shflags", "-static-libstdc++", "-lc++abi")
toolchain:add("ldflags", "-static-libstdc++")
toolchain:add("shflags", "-static-libstdc++")
if arm32 then
toolchain:add("syslinks", "unwind", "atomic")
end
Expand Down

0 comments on commit ebc4520

Please sign in to comment.