summaryrefslogtreecommitdiff
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
parent76fd1ccaf43262df8fae3d9d3bfba1c2f0e04ca5 (diff)
add self for tools
-rw-r--r--xmake/scripts/action/_lua.lua4
-rw-r--r--xmake/scripts/base/compiler.lua84
-rw-r--r--xmake/scripts/base/linker.lua26
-rw-r--r--xmake/scripts/base/makefile.lua2
-rw-r--r--xmake/scripts/platform/windows/tools/cl.lua23
-rw-r--r--xmake/scripts/platform/windows/tools/link.lua23
-rw-r--r--xmake/scripts/platform/windows/tools/nmake.lua12
-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
18 files changed, 149 insertions, 131 deletions
diff --git a/xmake/scripts/action/_lua.lua b/xmake/scripts/action/_lua.lua
index 8801307d2..11385a052 100644
--- a/xmake/scripts/action/_lua.lua
+++ b/xmake/scripts/action/_lua.lua
@@ -86,11 +86,11 @@ function _lua.done()
-- init module
if module.init then
- module.init(options.script)
+ module:init(options.script)
end
-- done module
- return module.main(arguments)
+ return module:main(arguments)
end
end
end
diff --git a/xmake/scripts/base/compiler.lua b/xmake/scripts/base/compiler.lua
index 23796d403..50bf38c5c 100644
--- a/xmake/scripts/base/compiler.lua
+++ b/xmake/scripts/base/compiler.lua
@@ -47,7 +47,13 @@ function compiler._mapflag(module, flag)
-- find and replace it using pattern
for k, v in pairs(module.mapflags) do
- local flag_mapped, count = flag:gsub(k, v)
+ local flag_mapped, count = flag:gsub(k, function (w)
+ if type(v) == "function" then
+ return v(module, w)
+ else
+ return v
+ end
+ end)
if flag_mapped and count ~= 0 then
return utils.ifelse(#flag_mapped ~= 0, flag_mapped, nil)
end
@@ -126,8 +132,8 @@ function compiler._flagnames(name)
return flagnames
end
--- get the compiler name from the source file type
-function compiler._name(srcfile)
+-- get the compiler kind from the source file type
+function compiler._kind(srcfile)
-- get the source file type
local filetype = path.extension(srcfile)
@@ -138,30 +144,30 @@ function compiler._name(srcfile)
-- get the lower file type
filetype = filetype:lower()
- -- get the compiler name
- local name = nil
- if filetype == ".c" then name = "cc"
- elseif filetype == ".cpp" or filetype == ".cc" then name = "cxx"
- elseif filetype == ".m" then name = "mm"
- elseif filetype == ".mm" then name = "mxx"
- elseif filetype == ".s" or filetype == ".asm" then name = "as"
+ -- get the compiler kind
+ local kind = nil
+ if filetype == ".c" then kind = "cc"
+ elseif filetype == ".cpp" or filetype == ".cc" then kind = "cxx"
+ elseif filetype == ".m" then kind = "mm"
+ elseif filetype == ".mm" then kind = "mxx"
+ elseif filetype == ".s" or filetype == ".asm" then kind = "as"
end
-- ok
- return name
+ return kind
end
-- get the compiler from the given source file
function compiler.get(srcfile)
- -- get the compiler name
- local name = compiler._name(srcfile)
- if not name then
+ -- get the compiler kind
+ local kind = compiler._kind(srcfile)
+ if not kind then
return
end
-- get compiler from the source file type
- local module = tools.get(name)
+ local module = tools.get(kind)
if module then
-- invalid compiler
@@ -169,8 +175,8 @@ function compiler.get(srcfile)
return
end
- -- save name
- module._NAME = name
+ -- save kind
+ module._KIND = kind
end
-- ok?
@@ -184,7 +190,7 @@ function compiler.make(module, target, srcfile, objfile)
assert(module and target)
-- the flag names
- local flagnames = compiler._flagnames(module._NAME)
+ local flagnames = compiler._flagnames(module._KIND)
assert(flagnames)
-- append the common flags from the current compiler
@@ -247,21 +253,21 @@ function compiler.make(module, target, srcfile, objfile)
-- append the includedirs flags from the current project
if module.flag_includedir then
for _, includedir in ipairs(utils.wrap(target.includedirs)) do
- table.join2(flags, module.flag_includedir(includedir))
+ table.join2(flags, module:flag_includedir(includedir))
end
end
-- append the defines flags from the current project
if module.flag_define then
for _, define in ipairs(utils.wrap(target.defines)) do
- table.join2(flags, module.flag_define(define))
+ table.join2(flags, module:flag_define(define))
end
end
-- append the undefines flags from the current project
if module.flag_undefine then
for _, undefine in ipairs(utils.wrap(target.undefines)) do
- table.join2(flags, module.flag_undefine(undefine))
+ table.join2(flags, module:flag_undefine(undefine))
end
end
@@ -282,7 +288,7 @@ function compiler.make(module, target, srcfile, objfile)
-- append the includedirs flags from the option
if module.flag_includedir then
for _, includedir in ipairs(utils.wrap(opt.includedirs)) do
- table.join2(flags, module.flag_includedir(includedir))
+ table.join2(flags, module:flag_includedir(includedir))
end
end
@@ -294,7 +300,7 @@ function compiler.make(module, target, srcfile, objfile)
if opt.defines_if_ok then table.join2(defines, opt.defines_if_ok) end
for _, define in ipairs(defines) do
- table.join2(flags, module.flag_define(define))
+ table.join2(flags, module:flag_define(define))
end
end
@@ -306,7 +312,7 @@ function compiler.make(module, target, srcfile, objfile)
if opt.undefines_if_ok then table.join2(undefines, opt.undefines_if_ok) end
for _, undefine in ipairs(undefines) do
- table.join2(flags, module.flag_undefine(undefine))
+ table.join2(flags, module:flag_undefine(undefine))
end
end
end
@@ -319,7 +325,7 @@ function compiler.make(module, target, srcfile, objfile)
end
-- make the compile command
- return module.command_compile(srcfile, objfile, table.concat(flags, " "):trim())
+ return module:command_compile(srcfile, objfile, table.concat(flags, " "):trim())
end
-- check include for the project option
@@ -351,7 +357,7 @@ function compiler.check_include(opt, include, srcpath, objpath)
if not module then return end
-- the flag names
- local flagnames = compiler._flagnames(module._NAME)
+ local flagnames = compiler._flagnames(module._KIND)
assert(flagnames)
-- append the common flags
@@ -369,7 +375,7 @@ function compiler.check_include(opt, include, srcpath, objpath)
if opt.defines and module.flag_define then
local defines = utils.wrap(opt.defines)
for _, define in ipairs(defines) do
- table.join2(flags, module.flag_define(define))
+ table.join2(flags, module:flag_define(define))
end
end
@@ -377,23 +383,23 @@ function compiler.check_include(opt, include, srcpath, objpath)
if opt.undefines and module.flag_undefine then
local undefines = utils.wrap(opt.undefines)
for _, undefine in ipairs(undefines) do
- table.join2(flags, module.flag_undefine(undefine))
+ table.join2(flags, module:flag_undefine(undefine))
end
end
-- append the includedirs flags
if opt.includedirs and module.flag_includedir then
for _, includedir in ipairs(utils.wrap(opt.includedirs)) do
- table.join2(flags, module.flag_includedir(includedir))
+ table.join2(flags, module:flag_includedir(includedir))
end
end
-- make the compile command
- local cmd = string.format("%s > %s 2>&1", module.command_compile(srcpath, objpath, table.concat(flags, " "):trim()), xmake._NULDEV)
+ local cmd = string.format("%s > %s 2>&1", module:command_compile(srcpath, objpath, table.concat(flags, " "):trim()), xmake._NULDEV)
if not cmd then return end
-- execute the compile command
- return module.main(cmd)
+ return module:main(cmd)
end
-- check function for the project option
@@ -412,8 +418,8 @@ function compiler.check_function(opt, interface, srcpath, objpath)
-- make includes
local includes = nil
- if module._NAME == "cc" then includes = opt.cincludes
- elseif module._NAME == "cxx" then includes = opt.cxxincludes
+ if module._KIND == "cc" then includes = opt.cincludes
+ elseif module._KIND == "cxx" then includes = opt.cxxincludes
end
if includes then
for _, include in ipairs(utils.wrap(includes)) do
@@ -437,7 +443,7 @@ function compiler.check_function(opt, interface, srcpath, objpath)
srcfile:close()
-- the flag names
- local flagnames = compiler._flagnames(module._NAME)
+ local flagnames = compiler._flagnames(module._KIND)
assert(flagnames)
-- append the common flags
@@ -455,7 +461,7 @@ function compiler.check_function(opt, interface, srcpath, objpath)
if opt.defines and module.flag_define then
local defines = utils.wrap(opt.defines)
for _, define in ipairs(defines) do
- table.join2(flags, module.flag_define(define))
+ table.join2(flags, module:flag_define(define))
end
end
@@ -463,23 +469,23 @@ function compiler.check_function(opt, interface, srcpath, objpath)
if opt.undefines and module.flag_undefine then
local undefines = utils.wrap(opt.undefines)
for _, undefine in ipairs(undefines) do
- table.join2(flags, module.flag_undefine(undefine))
+ table.join2(flags, module:flag_undefine(undefine))
end
end
-- append the includedirs flags
if opt.includedirs and module.flag_includedir then
for _, includedir in ipairs(utils.wrap(opt.includedirs)) do
- table.join2(flags, module.flag_includedir(includedir))
+ table.join2(flags, module:flag_includedir(includedir))
end
end
-- make the compile command
- local cmd = string.format("%s > %s 2>&1", module.command_compile(srcpath, objpath, table.concat(flags, " "):trim()), xmake._NULDEV)
+ local cmd = string.format("%s > %s 2>&1", module:command_compile(srcpath, objpath, table.concat(flags, " "):trim()), xmake._NULDEV)
if not cmd then return end
-- execute the compile command
- return module.main(cmd)
+ return module:main(cmd)
end
-- return module: compiler
diff --git a/xmake/scripts/base/linker.lua b/xmake/scripts/base/linker.lua
index befab7b7c..0019ca6b9 100644
--- a/xmake/scripts/base/linker.lua
+++ b/xmake/scripts/base/linker.lua
@@ -44,7 +44,13 @@ function linker._mapflag(module, flag)
-- find and replace it using pattern
for k, v in pairs(module.mapflags) do
- local flag_mapped, count = flag:gsub(k, v)
+ local flag_mapped, count = flag:gsub(k, function (w)
+ if type(v) == "function" then
+ return v(module, w)
+ else
+ return v
+ end
+ end)
if flag_mapped and count ~= 0 then
return utils.ifelse(#flag_mapped ~= 0, flag_mapped, nil)
end
@@ -156,14 +162,14 @@ function linker.make(module, target, objfiles, targetfile)
-- append the linkdirs flags from the current project
if module.flag_linkdir then
for _, linkdir in ipairs(utils.wrap(target.linkdirs)) do
- table.join2(flags, module.flag_linkdir(linkdir))
+ table.join2(flags, module:flag_linkdir(linkdir))
end
end
-- append the links flags from the current project
if module.flag_link then
for _, link in ipairs(utils.wrap(target.links)) do
- table.join2(flags, module.flag_link(link))
+ table.join2(flags, module:flag_link(link))
end
end
@@ -182,14 +188,14 @@ function linker.make(module, target, objfiles, targetfile)
-- append the linkdirs flags from the option
if module.flag_linkdir then
for _, linkdir in ipairs(utils.wrap(opt.linkdirs)) do
- table.join2(flags, module.flag_linkdir(linkdir))
+ table.join2(flags, module:flag_linkdir(linkdir))
end
end
-- append the links flags from the option
if module.flag_link then
for _, link in ipairs(utils.wrap(opt.links)) do
- table.join2(flags, module.flag_link(link))
+ table.join2(flags, module:flag_link(link))
end
end
end
@@ -204,7 +210,7 @@ function linker.make(module, target, objfiles, targetfile)
}))
-- make the link command
- return module.command_link(table.concat(objfiles, " "), targetfile, table.concat(flags, " "):trim())
+ return module:command_link(table.concat(objfiles, " "), targetfile, table.concat(flags, " "):trim())
end
-- check link for the project option
@@ -227,21 +233,21 @@ function linker.check_links(opt, links, objectfile, targetfile)
-- append the linkdirs flags
if opt.linkdirs and module.flag_linkdir then
for _, linkdir in ipairs(utils.wrap(opt.linkdirs)) do
- table.join2(flags, module.flag_linkdir(linkdir))
+ table.join2(flags, module:flag_linkdir(linkdir))
end
end
-- append the links flags
for _, link in ipairs(utils.wrap(links)) do
- table.join2(flags, module.flag_link(link))
+ table.join2(flags, module:flag_link(link))
end
-- make the compile command
- local cmd = string.format("%s > %s 2>&1", module.command_link(objectfile, targetfile, table.concat(flags, " "):trim()), xmake._NULDEV)
+ local cmd = string.format("%s > %s 2>&1", module:command_link(objectfile, targetfile, table.concat(flags, " "):trim()), xmake._NULDEV)
if not cmd then return end
-- execute the link command
- return module.main(cmd)
+ return module:main(cmd)
end
-- return module: linker
diff --git a/xmake/scripts/base/makefile.lua b/xmake/scripts/base/makefile.lua
index 6ad63490b..ba939790a 100644
--- a/xmake/scripts/base/makefile.lua
+++ b/xmake/scripts/base/makefile.lua
@@ -273,7 +273,7 @@ function makefile.build(target)
end
-- done make
- return make.main(buildir .. "/makefile", target)
+ return make:main(buildir .. "/makefile", target)
end
-- return module: makefile
diff --git a/xmake/scripts/platform/windows/tools/cl.lua b/xmake/scripts/platform/windows/tools/cl.lua
index c8d96b81c..879264e68 100644
--- a/xmake/scripts/platform/windows/tools/cl.lua
+++ b/xmake/scripts/platform/windows/tools/cl.lua
@@ -66,16 +66,19 @@ function cl._leave(name, old)
end
-- init the compiler
-function cl.init(name)
+function cl.init(self, name)
+
+ -- save name
+ self._NAME = name or "cl.exe"
-- init cflags
- cl.cflags = { "-nologo" }
+ self.cflags = { "-nologo" }
-- init cxxflags
- cl.cxxflags = { "-nologo" }
+ self.cxxflags = { "-nologo" }
-- init flags map
- cl.mapflags =
+ self.mapflags =
{
-- optimize
["-O0"] = "-Od"
@@ -113,35 +116,35 @@ function cl.init(name)
end
-- make the compiler command
-function cl.command_compile(srcfile, objfile, flags)
+function cl.command_compile(self, srcfile, objfile, flags)
-- make it
- return string.format("cl.exe -c %s -Fo%s %s", flags, objfile, srcfile)
+ return string.format("%s -c %s -Fo%s %s", self._NAME, flags, objfile, srcfile)
end
-- make the define flag
-function cl.flag_define(define)
+function cl.flag_define(self, define)
-- make it
return "-D" .. define
end
-- make the undefine flag
-function cl.flag_undefine(undefine)
+function cl.flag_undefine(self, undefine)
-- make it
return "-U" .. undefine
end
-- make the includedir flag
-function cl.flag_includedir(includedir)
+function cl.flag_includedir(self, includedir)
-- make it
return "-I" .. includedir
end
-- the main function
-function cl.main(cmd)
+function cl.main(self, cmd)
-- enter the vs environment
local pathes = cl._enter("path")
diff --git a/xmake/scripts/platform/windows/tools/link.lua b/xmake/scripts/platform/windows/tools/link.lua
index 5d37a43e6..ad1086ba5 100644
--- a/xmake/scripts/platform/windows/tools/link.lua
+++ b/xmake/scripts/platform/windows/tools/link.lua
@@ -66,7 +66,10 @@ function link._leave(name, old)
end
-- init the compiler
-function link.init(name)
+function link.init(self, name)
+
+ -- save name
+ self._NAME = name or "link.exe"
-- the architecture
local arch = config.get("arch")
@@ -79,7 +82,7 @@ function link.init(name)
end
-- init ldflags
- link.ldflags = { "-nologo"
+ self.ldflags = { "-nologo"
, "-dynamicbase"
, "-nxcompat"
, "-manifest"
@@ -87,13 +90,13 @@ function link.init(name)
, flags_arch}
-- init arflags
- link.arflags = {"-lib", "-nologo", flags_arch}
+ self.arflags = {"-lib", "-nologo", flags_arch}
-- init shflags
- link.shflags = {"-dll", "-nologo", flags_arch}
+ self.shflags = {"-dll", "-nologo", flags_arch}
-- init flags map
- link.mapflags =
+ self.mapflags =
{
-- strip
["-s"] = ""
@@ -108,28 +111,28 @@ function link.init(name)
end
-- make the linker command
-function link.command_link(objfiles, targetfile, flags)
+function link.command_link(self, objfiles, targetfile, flags)
-- make it
- return string.format("link.exe %s -out:%s %s", flags, targetfile, objfiles)
+ return string.format("%s %s -out:%s %s", self._NAME, flags, targetfile, objfiles)
end
-- make the link flag
-function link.flag_link(link)
+function link.flag_link(self, link)
-- make it
return link .. ".lib"
end
-- make the linkdir flag
-function link.flag_linkdir(linkdir)
+function link.flag_linkdir(self, linkdir)
-- make it
return "-libpath:" .. linkdir
end
-- the main function
-function link.main(cmd)
+function link.main(self, cmd)
-- enter the vs environment
local pathes = link._enter("path")
diff --git a/xmake/scripts/platform/windows/tools/nmake.lua b/xmake/scripts/platform/windows/tools/nmake.lua
index b7fc033c3..7d42dc706 100644
--- a/xmake/scripts/platform/windows/tools/nmake.lua
+++ b/xmake/scripts/platform/windows/tools/nmake.lua
@@ -68,18 +68,18 @@ function nmake._leave(name, old)
end
-- the init function
-function nmake.init(name)
+function nmake.init(self, name)
-- save name
- nmake._NAME = name or "nmake.exe"
+ self._NAME = name or "nmake.exe"
-- is verbose?
- nmake._VERBOSE = utils.ifelse(xmake._OPTIONS.verbose, "-v", "")
+ self._VERBOSE = utils.ifelse(xmake._OPTIONS.verbose, "-v", "")
end
-- the main function
-function nmake.main(mkfile, target)
+function nmake.main(self, mkfile, target)
-- enter the vs environment
local pathes = nmake._enter("path")
@@ -90,9 +90,9 @@ function nmake.main(mkfile, target)
-- make command
local cmd = nil
if mkfile and os.isfile(mkfile) then
- cmd = string.format("%s /f %s %s VERBOSE=%s 2> %s", nmake._NAME, mkfile, target or "", nmake._VERBOSE, xmake._NULDEV)
+ cmd = string.format("%s /f %s %s VERBOSE=%s 2> %s", self._NAME, mkfile, target or "", self._VERBOSE, xmake._NULDEV)
else
- cmd = string.format("%s %s VERBOSE=%s 2> %s", nmake._NAME, target or "", nmake._VERBOSE, xmake._NULDEV)
+ cmd = string.format("%s %s VERBOSE=%s 2> %s", self._NAME, target or "", self._VERBOSE, xmake._NULDEV)
end
-- done
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