summaryrefslogtreecommitdiff
path: root/xmake/tools
diff options
context:
space:
mode:
authorruki <[email protected]>2016-04-19 10:15:50 +0800
committerruki <[email protected]>2016-04-19 10:15:50 +0800
commit223c87f37fb9e8f3ffe808fae5041a1c4aee95d0 (patch)
tree2aad82da78da4444094a83ad5705f5cdeef28cd4 /xmake/tools
parent9495e08a20c2aeda6b54a4b06b17057056c79ec9 (diff)
reimpl check tool
Diffstat (limited to 'xmake/tools')
-rw-r--r--xmake/tools/ar.lua (renamed from xmake/tools/linker/ar.lua)11
-rwxr-xr-xxmake/tools/clang++.lua (renamed from xmake/tools/compiler/clang++.lua)0
-rwxr-xr-xxmake/tools/clang.lua (renamed from xmake/tools/linker/clang.lua)5
-rwxr-xr-xxmake/tools/compiler/clang.lua38
-rwxr-xr-xxmake/tools/g++.lua (renamed from xmake/tools/compiler/g++.lua)0
-rwxr-xr-xxmake/tools/gcc.lua (renamed from xmake/tools/compiler/gcc.lua)66
-rwxr-xr-xxmake/tools/linker/clang++.lua33
-rwxr-xr-xxmake/tools/linker/g++.lua33
-rwxr-xr-xxmake/tools/linker/gcc.lua101
-rw-r--r--xmake/tools/make.lua21
-rw-r--r--xmake/tools/swiftc.lua (renamed from xmake/tools/compiler/swiftc.lua)9
11 files changed, 85 insertions, 232 deletions
diff --git a/xmake/tools/linker/ar.lua b/xmake/tools/ar.lua
index 484ba3199..0999672f1 100644
--- a/xmake/tools/linker/ar.lua
+++ b/xmake/tools/ar.lua
@@ -46,8 +46,8 @@ end
function linkdir(dir)
end
--- make the command
-function command(objfiles, targetfile, flags, logfile)
+-- make the link command
+function linkcmd(objfiles, targetfile, flags, logfile)
-- redirect
local redirect = ""
@@ -63,3 +63,10 @@ function run(...)
-- run it
os.run(...)
end
+
+-- check the given flags
+function check(flags)
+
+ -- check it
+ os.run("%s %s", _g.shellname, ifelse(flags, flags, ""))
+end
diff --git a/xmake/tools/compiler/clang++.lua b/xmake/tools/clang++.lua
index 6b2feaa2f..6b2feaa2f 100755
--- a/xmake/tools/compiler/clang++.lua
+++ b/xmake/tools/clang++.lua
diff --git a/xmake/tools/linker/clang.lua b/xmake/tools/clang.lua
index 712b578e3..27bce4e3a 100755
--- a/xmake/tools/linker/clang.lua
+++ b/xmake/tools/clang.lua
@@ -32,6 +32,11 @@ function init(shellname)
-- init shflags
_super._g.shflags = { "-dynamiclib", "-fPIC" }
+ -- suppress warning
+ _super._g.cxflags = {"-Qunused-arguments"}
+ _super._g.mxflags = {"-Qunused-arguments"}
+ _super._g.asflags = {"-Qunused-arguments"}
+
-- init flags map
_super._g.mapflags["-s"] = "-Wl,-S"
_super._g.mapflags["-S"] = "-Wl,-S"
diff --git a/xmake/tools/compiler/clang.lua b/xmake/tools/compiler/clang.lua
deleted file mode 100755
index 253e14270..000000000
--- a/xmake/tools/compiler/clang.lua
+++ /dev/null
@@ -1,38 +0,0 @@
---!The Automatic Cross-platform Build Tool
---
--- XMake is free software; you can redistribute it and/or modify
--- it under the terms of the GNU Lesser General Public License as published by
--- the Free Software Foundation; either version 2.1 of the License, or
--- (at your option) any later version.
---
--- XMake is distributed in the hope that it will be useful,
--- but WITHOUT ANY WARRANTY; without even the implied warranty of
--- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--- GNU Lesser General Public License for more details.
---
--- You should have received a copy of the GNU Lesser General Public License
--- along with XMake;
--- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a>
---
--- Copyright (C) 2015 - 2016, ruki All rights reserved.
---
--- @author ruki
--- @file clang.lua
---
-
--- inherit gcc
-inherit("gcc")
-
--- init it
-function init(shellname)
-
- -- init super
- _super.init(shellname or "clang")
-
- -- suppress warning
- _super._g.cxflags = {"-Qunused-arguments"}
- _super._g.mxflags = {"-Qunused-arguments"}
- _super._g.asflags = {"-Qunused-arguments"}
-
-end
-
diff --git a/xmake/tools/compiler/g++.lua b/xmake/tools/g++.lua
index 7b2837b8e..7b2837b8e 100755
--- a/xmake/tools/compiler/g++.lua
+++ b/xmake/tools/g++.lua
diff --git a/xmake/tools/compiler/gcc.lua b/xmake/tools/gcc.lua
index ebe5c492f..9e0f55671 100755
--- a/xmake/tools/compiler/gcc.lua
+++ b/xmake/tools/gcc.lua
@@ -34,6 +34,9 @@ function init(shellname)
, "\"-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))\""
, "\"-DIBAction=void)__attribute__((ibaction)\""}
+ -- init shflags
+ _g.shflags = { "-shared", "-fPIC" }
+
-- init cxflags for the kind: shared
_g.shared = {}
_g.shared.cxflags = {"-fPIC"}
@@ -42,10 +45,14 @@ function init(shellname)
_g.mapflags =
{
-- warnings
- ["-W1"] = "-Wall"
- , ["-W2"] = "-Wall"
- , ["-W3"] = "-Wall"
-
+ ["-W1"] = "-Wall"
+ , ["-W2"] = "-Wall"
+ , ["-W3"] = "-Wall"
+
+ -- strip
+ , ["-s"] = "-s"
+ , ["-S"] = "-S"
+
}
end
@@ -77,8 +84,22 @@ function includedir(dir)
return "-I" .. dir
end
--- make the command
-function command(srcfile, objfile, flags, logfile)
+-- make the link flag
+function link(lib)
+
+ -- make it
+ return "-l" .. lib
+end
+
+-- make the linkdir flag
+function linkdir(dir)
+
+ -- make it
+ return "-L" .. dir
+end
+
+-- make the complie command
+function compcmd(srcfile, objfile, flags, logfile)
-- redirect
local redirect = ""
@@ -88,26 +109,15 @@ function command(srcfile, objfile, flags, logfile)
return format("%s -c %s -o %s %s%s", _g.shellname, flags, objfile, srcfile, redirect)
end
--- check the given flags
-function check(flags)
+-- make the link command
+function linkcmd(objfiles, targetfile, flags, logfile)
- -- done
- local ok = false
- try
- {
- function ()
-
- -- check it
- os.run("%s %s -S -o %s -xc %s > %s 2>&1", _g.shellname, flags, os.nuldev(), os.nuldev(), os.nuldev())
-
- -- ok
- ok = true
-
- end
- }
+ -- redirect
+ local redirect = ""
+ if logfile then redirect = format(" > %s 2>&1", logfile) end
- -- ok?
- return ok
+ -- make it
+ return format("%s -o %s %s %s%s", _g.shellname, targetfile, objfiles, flags, redirect)
end
-- run command
@@ -116,3 +126,11 @@ function run(...)
-- run it
os.run(...)
end
+
+-- check the given flags
+function check(flags)
+
+ -- check it
+ os.run("%s %s -S -o %s -xc %s", _g.shellname, ifelse(flags, flags, ""), os.nuldev(), os.nuldev())
+end
+
diff --git a/xmake/tools/linker/clang++.lua b/xmake/tools/linker/clang++.lua
deleted file mode 100755
index 6b2feaa2f..000000000
--- a/xmake/tools/linker/clang++.lua
+++ /dev/null
@@ -1,33 +0,0 @@
---!The Automatic Cross-platform Build Tool
---
--- XMake is free software; you can redistribute it and/or modify
--- it under the terms of the GNU Lesser General Public License as published by
--- the Free Software Foundation; either version 2.1 of the License, or
--- (at your option) any later version.
---
--- XMake is distributed in the hope that it will be useful,
--- but WITHOUT ANY WARRANTY; without even the implied warranty of
--- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--- GNU Lesser General Public License for more details.
---
--- You should have received a copy of the GNU Lesser General Public License
--- along with XMake;
--- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a>
---
--- Copyright (C) 2015 - 2016, ruki All rights reserved.
---
--- @author ruki
--- @file clang++.lua
---
-
--- inherit clang
-inherit("clang")
-
--- init it
-function init(shellname)
-
- -- init super
- _super.init(shellname or "clang++")
-
-end
-
diff --git a/xmake/tools/linker/g++.lua b/xmake/tools/linker/g++.lua
deleted file mode 100755
index 7b2837b8e..000000000
--- a/xmake/tools/linker/g++.lua
+++ /dev/null
@@ -1,33 +0,0 @@
---!The Automatic Cross-platform Build Tool
---
--- XMake is free software; you can redistribute it and/or modify
--- it under the terms of the GNU Lesser General Public License as published by
--- the Free Software Foundation; either version 2.1 of the License, or
--- (at your option) any later version.
---
--- XMake is distributed in the hope that it will be useful,
--- but WITHOUT ANY WARRANTY; without even the implied warranty of
--- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--- GNU Lesser General Public License for more details.
---
--- You should have received a copy of the GNU Lesser General Public License
--- along with XMake;
--- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a>
---
--- Copyright (C) 2015 - 2016, ruki All rights reserved.
---
--- @author ruki
--- @file g++.lua
---
-
--- inherit gcc
-inherit("gcc")
-
--- init it
-function init(shellname)
-
- -- init super
- _super.init(shellname or "g++")
-
-end
-
diff --git a/xmake/tools/linker/gcc.lua b/xmake/tools/linker/gcc.lua
deleted file mode 100755
index 35c263e34..000000000
--- a/xmake/tools/linker/gcc.lua
+++ /dev/null
@@ -1,101 +0,0 @@
---!The Automatic Cross-platform Build Tool
---
--- XMake is free software; you can redistribute it and/or modify
--- it under the terms of the GNU Lesser General Public License as published by
--- the Free Software Foundation; either version 2.1 of the License, or
--- (at your option) any later version.
---
--- XMake is distributed in the hope that it will be useful,
--- but WITHOUT ANY WARRANTY; without even the implied warranty of
--- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--- GNU Lesser General Public License for more details.
---
--- You should have received a copy of the GNU Lesser General Public License
--- along with XMake;
--- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a>
---
--- Copyright (C) 2015 - 2016, ruki All rights reserved.
---
--- @author ruki
--- @file gcc.lua
---
-
--- init it
-function init(shellname)
-
- -- save the shell name
- _g.shellname = shellname or "gcc"
-
- -- init shflags
- _g.shflags = { "-shared", "-fPIC" }
-
- -- init flags map
- _g.mapflags =
- {
- -- strip
- ["-s"] = "-s"
- , ["-S"] = "-S"
-
- }
-end
-
--- get the property
-function get(name)
-
- -- get it
- return _g[name]
-end
-
--- make the link flag
-function link(lib)
-
- -- make it
- return "-l" .. lib
-end
-
--- make the linkdir flag
-function linkdir(dir)
-
- -- make it
- return "-L" .. dir
-end
-
--- make the command
-function command(objfiles, targetfile, flags, logfile)
-
- -- redirect
- local redirect = ""
- if logfile then redirect = format(" > %s 2>&1", logfile) end
-
- -- make it
- return format("%s -o %s %s %s%s", _g.shellname, targetfile, objfiles, flags, redirect)
-end
-
--- check the given flags
-function check(flags)
-
- -- done
- local ok = false
- try
- {
- function ()
-
- -- check it
- os.run("%s %s -S -o %s -xc %s > %s 2>&1", _g.shellname, flags, os.nuldev(), os.nuldev(), os.nuldev())
-
- -- ok
- ok = true
-
- end
- }
-
- -- ok?
- return ok
-end
-
--- run command
-function run(...)
-
- -- run it
- os.run(...)
-end
diff --git a/xmake/tools/make.lua b/xmake/tools/make.lua
index 8cab41067..2785eaf73 100644
--- a/xmake/tools/make.lua
+++ b/xmake/tools/make.lua
@@ -31,6 +31,13 @@ function init(shellname)
end
+-- get the property
+function get(name)
+
+ -- get it
+ return _g[name]
+end
+
-- run it
function run(makefile, target, jobs)
@@ -74,3 +81,17 @@ function run(makefile, target, jobs)
end
end
+
+-- check the given flags
+function check(flags)
+
+ -- make an empty makefile
+ local tmpfile = os.tmpfile()
+ io.write(tmpfile, "all:\n")
+
+ -- check it
+ os.run("%s %s -f %s", _g.shellname, ifelse(flags, flags, ""), tmpfile)
+
+ -- remove this makefile
+ os.rm(tmpfile)
+end
diff --git a/xmake/tools/compiler/swiftc.lua b/xmake/tools/swiftc.lua
index 517df88a8..65e6f8245 100644
--- a/xmake/tools/compiler/swiftc.lua
+++ b/xmake/tools/swiftc.lua
@@ -72,7 +72,7 @@ function get(name)
end
-- make the compile command
-function command(srcfile, objfile, flags, logfile)
+function compcmd(srcfile, objfile, flags, logfile)
-- redirect
local redirect = ""
@@ -103,3 +103,10 @@ function undefine(macro)
return "-Xcc -U" .. macro
end
+-- run command
+function run(...)
+
+ -- run it
+ os.run(...)
+end
+