summaryrefslogtreecommitdiff
path: root/xmake/scripts/tools
diff options
context:
space:
mode:
authorruki <[email protected]>2015-06-11 16:58:01 +0800
committerruki <[email protected]>2015-06-11 16:58:01 +0800
commit882430fde4f0066e9adbbb664b98612fa4cf3bc1 (patch)
treef5eeeb2961d22bfd68a80d95404e07396791336e /xmake/scripts/tools
parent76fd1ccaf43262df8fae3d9d3bfba1c2f0e04ca5 (diff)
add self for tools
Diffstat (limited to 'xmake/scripts/tools')
-rw-r--r--xmake/scripts/tools/ar.lua12
-rw-r--r--xmake/scripts/tools/cp.lua2
-rw-r--r--xmake/scripts/tools/echo.lua2
-rw-r--r--xmake/scripts/tools/gcc.lua66
-rw-r--r--xmake/scripts/tools/make.lua12
-rw-r--r--xmake/scripts/tools/mkdir.lua2
-rw-r--r--xmake/scripts/tools/mv.lua2
-rw-r--r--xmake/scripts/tools/rm.lua2
-rw-r--r--xmake/scripts/tools/rmdir.lua2
-rw-r--r--xmake/scripts/tools/tools.lua2
-rw-r--r--xmake/scripts/tools/verbose.lua2
11 files changed, 53 insertions, 53 deletions
diff --git a/xmake/scripts/tools/ar.lua b/xmake/scripts/tools/ar.lua
index 4b1c20f21..b2e2618eb 100644
--- a/xmake/scripts/tools/ar.lua
+++ b/xmake/scripts/tools/ar.lua
@@ -29,25 +29,25 @@ local string = require("base/string")
local config = require("base/config")
-- init the linker
-function ar.init(name)
+function ar.init(self, name)
-- save name
- ar.name = name or "ar"
+ self._NAME = name or "ar"
-- init arflags
- ar.arflags = { "-crs" }
+ self.arflags = { "-crs" }
end
-- make the link command
-function ar.command_link(objfiles, targetfile, flags)
+function ar.command_link(self, objfiles, targetfile, flags)
-- make it
- return string.format("%s %s %s %s", ar.name, flags, targetfile, objfiles)
+ return string.format("%s %s %s %s", self._NAME, flags, targetfile, objfiles)
end
-- the main function
-function ar.main(cmd)
+function ar.main(self, cmd)
-- execute it
local ok = os.execute(cmd)
diff --git a/xmake/scripts/tools/cp.lua b/xmake/scripts/tools/cp.lua
index 4d400a19b..1b3ba9843 100644
--- a/xmake/scripts/tools/cp.lua
+++ b/xmake/scripts/tools/cp.lua
@@ -27,7 +27,7 @@ local cp = cp or {}
local os = require("base/os")
-- the main function
-function cp.main(...)
+function cp.main(self, ...)
-- cp it
local pathes = ...
diff --git a/xmake/scripts/tools/echo.lua b/xmake/scripts/tools/echo.lua
index 45abf8c24..a4911dd10 100644
--- a/xmake/scripts/tools/echo.lua
+++ b/xmake/scripts/tools/echo.lua
@@ -28,7 +28,7 @@ local io = require("base/io")
local string = require("base/string")
-- the main function
-function echo.main(...)
+function echo.main(self, ...)
-- echo all
for _, v in ipairs(...) do
diff --git a/xmake/scripts/tools/gcc.lua b/xmake/scripts/tools/gcc.lua
index 2cf61a0a2..b74081222 100644
--- a/xmake/scripts/tools/gcc.lua
+++ b/xmake/scripts/tools/gcc.lua
@@ -31,31 +31,31 @@ local platform = require("platform/platform")
local gcc = gcc or {}
-- check the given flag
-function gcc._check(flag)
+function gcc._check(self, flag)
-- this flag has been checked?
- gcc._CHECK = gcc._CHECK or {}
- if gcc._CHECK[flag] then
- return gcc._CHECK[flag]
+ self._CHECK = self._CHECK or {}
+ if self._CHECK[flag] then
+ return self._CHECK[flag]
end
-- check it
- if 0 ~= os.execute(string.format("%s %s -S -o %s -xc %s > %s 2>&1", gcc.name, flag, xmake._NULDEV, xmake._NULDEV, xmake._NULDEV)) then
+ if 0 ~= os.execute(string.format("%s %s -S -o %s -xc %s > %s 2>&1", self._NAME, flag, xmake._NULDEV, xmake._NULDEV, xmake._NULDEV)) then
flag = ""
end
-- save it
- gcc._CHECK[flag] = flag
+ self._CHECK[flag] = flag
-- ok?
return flag
end
-- the init function
-function gcc.init(name)
+function gcc.init(self, name)
-- save name
- gcc.name = name
+ self._NAME = name or "gcc"
-- the architecture
local arch = config.get("arch")
@@ -69,10 +69,10 @@ function gcc.init(name)
end
-- init cxflags
- gcc.cxflags = { flags_arch }
+ self.cxflags = { flags_arch }
-- init mxflags
- gcc.mxflags = { flags_arch
+ self.mxflags = { flags_arch
, "-fmessage-length=0"
, "-pipe"
, "-fpascal-strings"
@@ -81,16 +81,16 @@ function gcc.init(name)
, "\"-DIBAction=void)__attribute__((ibaction)\""}
-- init asflags
- gcc.asflags = { flags_arch }
+ self.asflags = { flags_arch }
-- init ldflags
- gcc.ldflags = { flags_arch }
+ self.ldflags = { flags_arch }
-- init shflags
if name:find("clang") then
- gcc.shflags = { flags_arch, "-dynamiclib" }
+ self.shflags = { flags_arch, "-dynamiclib" }
else
- gcc.shflags = { flags_arch, "-shared -Wl,-soname" }
+ self.shflags = { flags_arch, "-shared -Wl,-soname" }
end
-- append the xcode sdk directory if exists
@@ -98,80 +98,80 @@ function gcc.init(name)
if plat and (plat == "macosx" or plat == "iphoneos" or plat == "iphonesimulator") then
local xcode_sdkdir = platform.get("xcode_sdkdir")
if xcode_sdkdir then
- table.join2(gcc.cxflags, "-isysroot " .. xcode_sdkdir)
- table.join2(gcc.mxflags, "-isysroot " .. xcode_sdkdir)
- table.join2(gcc.ldflags, "-isysroot " .. xcode_sdkdir)
- table.join2(gcc.shflags, "-isysroot " .. xcode_sdkdir)
+ table.join2(self.cxflags, "-isysroot " .. xcode_sdkdir)
+ table.join2(self.mxflags, "-isysroot " .. xcode_sdkdir)
+ table.join2(self.ldflags, "-isysroot " .. xcode_sdkdir)
+ table.join2(self.shflags, "-isysroot " .. xcode_sdkdir)
end
end
-- suppress warning for the ccache bug
if name:find("clang") and config.get("ccache") then
- table.join2(gcc.cxflags, "-Qunused-arguments")
- table.join2(gcc.mxflags, "-Qunused-arguments")
+ table.join2(self.cxflags, "-Qunused-arguments")
+ table.join2(self.mxflags, "-Qunused-arguments")
end
-- init flags map
- gcc.mapflags =
+ self.mapflags =
{
-- others
- ["-ftrapv"] = gcc._check
- , ["-fsanitize=address"] = gcc._check
+ ["-ftrapv"] = self._check
+ , ["-fsanitize=address"] = self._check
}
end
-- make the compile command
-function gcc.command_compile(srcfile, objfile, flags)
+function gcc.command_compile(self, srcfile, objfile, flags)
-- make it
- return string.format("%s -c %s -o%s %s", gcc.name, flags, objfile, srcfile)
+ return string.format("%s -c %s -o%s %s", self._NAME, flags, objfile, srcfile)
end
-- make the link command
-function gcc.command_link(objfiles, targetfile, flags)
+function gcc.command_link(self, objfiles, targetfile, flags)
-- make it
- return string.format("%s %s -o%s %s", gcc.name, flags, targetfile, objfiles)
+ return string.format("%s %s -o%s %s", self._NAME, flags, targetfile, objfiles)
end
-- make the define flag
-function gcc.flag_define(define)
+function gcc.flag_define(self, define)
-- make it
return "-D" .. define
end
-- make the undefine flag
-function gcc.flag_undefine(undefine)
+function gcc.flag_undefine(self, undefine)
-- make it
return "-U" .. undefine
end
-- make the includedir flag
-function gcc.flag_includedir(includedir)
+function gcc.flag_includedir(self, includedir)
-- make it
return "-I" .. includedir
end
-- make the link flag
-function gcc.flag_link(link)
+function gcc.flag_link(self, link)
-- make it
return "-l" .. link
end
-- make the linkdir flag
-function gcc.flag_linkdir(linkdir)
+function gcc.flag_linkdir(self, linkdir)
-- make it
return "-L" .. linkdir
end
-- the main function
-function gcc.main(cmd)
+function gcc.main(self, cmd)
-- execute it
local ok = os.execute(cmd)
diff --git a/xmake/scripts/tools/make.lua b/xmake/scripts/tools/make.lua
index 25dd13515..3927aedb5 100644
--- a/xmake/scripts/tools/make.lua
+++ b/xmake/scripts/tools/make.lua
@@ -28,25 +28,25 @@ local utils = require("base/utils")
local make = make or {}
-- the init function
-function make.init(name)
+function make.init(self, name)
-- save name
- make.name = name or "make"
+ self.name = name or "make"
-- is verbose?
- make._VERBOSE = utils.ifelse(xmake._OPTIONS.verbose, "-v", "")
+ self._VERBOSE = utils.ifelse(xmake._OPTIONS.verbose, "-v", "")
end
-- the main function
-function make.main(mkfile, target)
+function make.main(self, mkfile, target)
-- make command
local cmd = nil
if mkfile and os.isfile(mkfile) then
- cmd = string.format("%s -j4 -f %s %s VERBOSE=%s 2> %s", make.name, mkfile, target or "", make._VERBOSE, xmake._NULDEV)
+ cmd = string.format("%s -j4 -f %s %s VERBOSE=%s 2> %s", self.name, mkfile, target or "", self._VERBOSE, xmake._NULDEV)
else
- cmd = string.format("%s -j4 %s VERBOSE=%s 2> %s", make.name, target or "", make._VERBOSE, xmake._NULDEV)
+ cmd = string.format("%s -j4 %s VERBOSE=%s 2> %s", self.name, target or "", self._VERBOSE, xmake._NULDEV)
end
-- done
diff --git a/xmake/scripts/tools/mkdir.lua b/xmake/scripts/tools/mkdir.lua
index 4b5ac1a7f..9fadb875d 100644
--- a/xmake/scripts/tools/mkdir.lua
+++ b/xmake/scripts/tools/mkdir.lua
@@ -27,7 +27,7 @@ local mkdir = mkdir or {}
local os = require("base/os")
-- the main function
-function mkdir.main(...)
+function mkdir.main(self, ...)
-- mkdir all
for _, dir in ipairs(...) do
diff --git a/xmake/scripts/tools/mv.lua b/xmake/scripts/tools/mv.lua
index 2fa2be735..7af2db9ed 100644
--- a/xmake/scripts/tools/mv.lua
+++ b/xmake/scripts/tools/mv.lua
@@ -27,7 +27,7 @@ local mv = mv or {}
local os = require("base/os")
-- the main function
-function mv.main(...)
+function mv.main(self, ...)
-- mv it
local pathes = ...
diff --git a/xmake/scripts/tools/rm.lua b/xmake/scripts/tools/rm.lua
index b05289b3b..47f57e68b 100644
--- a/xmake/scripts/tools/rm.lua
+++ b/xmake/scripts/tools/rm.lua
@@ -27,7 +27,7 @@ local rm = rm or {}
local os = require("base/os")
-- the main function
-function rm.main(...)
+function rm.main(self, ...)
-- rm all
for _, file_or_dir in ipairs(...) do
diff --git a/xmake/scripts/tools/rmdir.lua b/xmake/scripts/tools/rmdir.lua
index 23eb8ca61..cea1e28fa 100644
--- a/xmake/scripts/tools/rmdir.lua
+++ b/xmake/scripts/tools/rmdir.lua
@@ -27,7 +27,7 @@ local rmdir = rmdir or {}
local os = require("base/os")
-- the main function
-function rmdir.main(...)
+function rmdir.main(self, ...)
-- rmdir all
for _, dir in ipairs(...) do
diff --git a/xmake/scripts/tools/tools.lua b/xmake/scripts/tools/tools.lua
index abcee4018..9b5c457e2 100644
--- a/xmake/scripts/tools/tools.lua
+++ b/xmake/scripts/tools/tools.lua
@@ -142,7 +142,7 @@ function tools.load(name, root)
-- init tool
if tool and tool.init then
- tool.init(name)
+ tool:init(name)
end
-- save tool to the cache
diff --git a/xmake/scripts/tools/verbose.lua b/xmake/scripts/tools/verbose.lua
index fcf72c3f0..9de33fdcd 100644
--- a/xmake/scripts/tools/verbose.lua
+++ b/xmake/scripts/tools/verbose.lua
@@ -28,7 +28,7 @@ local verbose = verbose or {}
local io = require("base/io")
-- the main function
-function verbose.main(...)
+function verbose.main(self, ...)
-- verbose all
if xmake._OPTIONS.verbose then