diff options
| author | ruki <[email protected]> | 2017-04-01 19:42:41 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-04-01 19:42:41 +0800 |
| commit | 01231296e809f900a7af34d00564aece602d1a7b (patch) | |
| tree | d3a057b4dd0c817a2f28d752a4924f59f83fde7e | |
| parent | 192de2d5897e8bee0eefecabac637443125ce2a5 (diff) | |
check rpath for gcc and dmd
| -rwxr-xr-x | tests/shared_library_c++/xmake.lua | 1 | ||||
| -rw-r--r-- | xmake/tools/dmd.lua | 26 | ||||
| -rw-r--r-- | xmake/tools/gcc.lua | 26 |
3 files changed, 41 insertions, 12 deletions
diff --git a/tests/shared_library_c++/xmake.lua b/tests/shared_library_c++/xmake.lua index d9bc4878f..36966c338 100755 --- a/tests/shared_library_c++/xmake.lua +++ b/tests/shared_library_c++/xmake.lua @@ -47,4 +47,5 @@ target("test") -- add link directory add_linkdirs("$(buildir)") + add_rpathdirs("$(buildir)") diff --git a/xmake/tools/dmd.lua b/xmake/tools/dmd.lua index 6fb8e8b3b..12da2ded4 100644 --- a/xmake/tools/dmd.lua +++ b/xmake/tools/dmd.lua @@ -162,8 +162,22 @@ end -- make the rpathdir flag function nf_rpathdir(dir) - -- make it - return "-L-rpath=" .. dir + -- check this flag + local flag = "-L-rpath=" .. dir + if _g._RPATH == nil then + _g._RPATH = try + { + function () + check(flag) + return true + end + } + end + + -- ok? + if _g._RPATH then + return flags + end end -- make the link command @@ -204,16 +218,16 @@ end function check(flags) -- make an stub source file - local objectfile = os.tmpfile() .. ".o" + local binaryfile = os.tmpfile() .. ".b" local sourcefile = os.tmpfile() .. ".d" -- make stub code io.writefile(sourcefile, "void main() {\n}") - -- check it - os.run("%s -c %s -of%s %s", _g.shellname, ifelse(flags, flags, ""), objectfile, sourcefile) + -- check it, need check compflags and linkflags + os.run("%s %s -of%s %s", _g.shellname, ifelse(flags, flags, ""), binaryfile, sourcefile) -- remove files - os.rm(objectfile) + os.rm(binaryfile) os.rm(sourcefile) end diff --git a/xmake/tools/gcc.lua b/xmake/tools/gcc.lua index a7b447df9..52f5ae599 100644 --- a/xmake/tools/gcc.lua +++ b/xmake/tools/gcc.lua @@ -244,8 +244,22 @@ end -- make the rpathdir flag function nf_rpathdir(dir) - -- make it - return "-Wl,-rpath=" .. dir + -- check this flag + local flag = "-Wl,-rpath=" .. dir + if _g._RPATH == nil then + _g._RPATH = try + { + function () + check(flag) + return true + end + } + end + + -- ok? + if _g._RPATH then + return flags + end end -- make the framework flag @@ -388,17 +402,17 @@ end function check(flags) -- make an stub source file - local objectfile = os.tmpfile() .. ".o" + local binaryfile = os.tmpfile() .. ".b" 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 - os.run("%s -c %s -o %s %s", _g.shellname, ifelse(flags, flags, ""), objectfile, sourcefile) + -- check it, need check compflags and linkflags + os.run("%s %s -o %s %s", _g.shellname, ifelse(flags, flags, ""), binaryfile, sourcefile) -- remove files - os.rm(objectfile) + os.rm(binaryfile) os.rm(sourcefile) end |
