diff options
| author | ruki <[email protected]> | 2017-04-12 14:30:18 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-04-12 14:30:18 +0800 |
| commit | d3604af304e6acd9ea32167750373eb94bfa6df0 (patch) | |
| tree | cd05b0d187a684ff33b462b584560c61df05c308 | |
| parent | 1c4b2c9caea676c34d7f0c05b2ea66b8deca9b20 (diff) | |
fix check android compiler error
| -rw-r--r-- | CHANGELOG.md | 2 | ||||
| -rw-r--r-- | xmake/platforms/android/load.lua | 8 | ||||
| -rw-r--r-- | xmake/tools/dmd.lua | 16 | ||||
| -rw-r--r-- | xmake/tools/gcc.lua | 16 |
4 files changed, 30 insertions, 12 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 197bbdbef..523fed0ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ ### Bugs fixed * [#67](https://github.com/tboox/xmake/issues/67): Fix `sudo make install` permission problem +* [#70](https://github.com/tboox/xmake/issues/70): Fix check android compiler error ## v2.1.3 @@ -261,6 +262,7 @@ ### Bugs fixed * [#67](https://github.com/tboox/xmake/issues/67): 修复 `sudo make install` 命令权限问题 +* [#70](https://github.com/tboox/xmake/issues/70): 修复检测android编译器错误 ## v2.1.3 diff --git a/xmake/platforms/android/load.lua b/xmake/platforms/android/load.lua index e80ff5c89..a9b00b554 100644 --- a/xmake/platforms/android/load.lua +++ b/xmake/platforms/android/load.lua @@ -51,8 +51,8 @@ function main() _g.cxxflags = {} end - -- init cxflags and ldflags for the target kind: binary - _g.binary = { cxflags = {"-fPIE", "-pie"}, ldflags = {"-fPIE", "-pie"} } + -- init cxflags for the target kind: binary + _g.binary = { cxflags = {"-fPIE", "-pie"} } -- add flags for the sdk directory of ndk local ndk = config.get("ndk") @@ -75,6 +75,10 @@ function main() insert(_g.shflags, format("--sysroot=%s/arch-arm", ndk_sdkdir)) end + -- add "-fPIE -pie" to ldflags + insert(_g.ldflags, "-fPIE") + insert(_g.ldflags, "-pie") + -- only for c++ stl local toolchains_ver = config.get("toolchains_ver") if toolchains_ver then diff --git a/xmake/tools/dmd.lua b/xmake/tools/dmd.lua index 928d98fb3..bd6b67379 100644 --- a/xmake/tools/dmd.lua +++ b/xmake/tools/dmd.lua @@ -168,7 +168,7 @@ function nf_rpathdir(dir) _g._RPATH = try { function () - check(flag) + check(flag, true) return true end } @@ -215,19 +215,25 @@ function compile(sourcefiles, objectfile, incdepfile, flags) end -- check the given flags -function check(flags) +function check(flags, trylink) -- make an stub source file local binaryfile = os.tmpfile() .. ".b" + local objectfile = os.tmpfile() .. ".o" local sourcefile = os.tmpfile() .. ".d" -- make stub code io.writefile(sourcefile, "void main() {\n}") -- check it, need check compflags and linkflags - os.run("%s %s -of%s %s", _g.shellname, ifelse(flags, flags, ""), binaryfile, sourcefile) + if trylink then + os.run("%s %s -of%s %s", _g.shellname, ifelse(flags, flags, ""), binaryfile, sourcefile) + else + os.run("%s -c %s -of%s %s", _g.shellname, ifelse(flags, flags, ""), binaryfile, sourcefile) + end -- remove files - os.rm(binaryfile) - os.rm(sourcefile) + os.tryrm(binaryfile) + os.tryrm(objectfile) + os.tryrm(sourcefile) end diff --git a/xmake/tools/gcc.lua b/xmake/tools/gcc.lua index 06156ffff..b29904b56 100644 --- a/xmake/tools/gcc.lua +++ b/xmake/tools/gcc.lua @@ -250,7 +250,7 @@ function nf_rpathdir(dir) _g._RPATH = try { function () - check(flag) + check(flag, true) return true end } @@ -399,20 +399,26 @@ function compile(sourcefiles, objectfile, incdepfile, flags) end -- check the given flags -function check(flags) +function check(flags, trylink) -- make an stub source file local binaryfile = os.tmpfile() .. ".b" + local objectfile = os.tmpfile() .. ".o" local sourcefile = os.tmpfile() .. ".c" .. ifelse(_g.kind == "cxx", "pp", "") -- make stub code io.writefile(sourcefile, "int main(int argc, char** argv)\n{return 0;}") -- check it, need check compflags and linkflags - os.run("%s %s -o %s %s", _g.shellname, ifelse(flags, flags, ""), binaryfile, sourcefile) + if trylink then + os.run("%s %s -o %s %s", _g.shellname, ifelse(flags, flags, ""), binaryfile, sourcefile) + else + os.run("%s -c %s -o %s %s", _g.shellname, ifelse(flags, flags, ""), binaryfile, sourcefile) + end -- remove files - os.rm(binaryfile) - os.rm(sourcefile) + os.tryrm(binaryfile) + os.tryrm(objectfile) + os.tryrm(sourcefile) end |
