summaryrefslogtreecommitdiff
path: root/xmake/core/platform/compiler.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2016-03-23 21:46:13 +0800
committerruki <[email protected]>2016-03-23 21:46:13 +0800
commit9612b87afb5e86ca62457c4deacccaa3d0696373 (patch)
tree7bb165852f9492f67b74813ea01f80b075a487f8 /xmake/core/platform/compiler.lua
parent2a549b0fb990bb06f6180fd7cbd3c212af5e2ebd (diff)
finish build
Diffstat (limited to 'xmake/core/platform/compiler.lua')
-rw-r--r--xmake/core/platform/compiler.lua70
1 files changed, 30 insertions, 40 deletions
diff --git a/xmake/core/platform/compiler.lua b/xmake/core/platform/compiler.lua
index 5c380d569..d37ed06c1 100644
--- a/xmake/core/platform/compiler.lua
+++ b/xmake/core/platform/compiler.lua
@@ -38,16 +38,16 @@ local platform = require("platform/platform")
function compiler._mapflag(self, flag)
-- check
- assert(self.mapflags and flag)
+ assert(self._TOOL.mapflags and flag)
-- attempt to map it directly
- local flag_mapped = self.mapflags[flag]
+ local flag_mapped = self._TOOL.mapflags[flag]
if flag_mapped and type(flag_mapped) == "string" then
return flag_mapped
end
-- find and replace it using pattern
- for k, v in pairs(self.mapflags) do
+ for k, v in pairs(self._TOOL.mapflags) do
local flag_mapped, count = flag:gsub("^" .. k .. "$", function (w)
if type(v) == "function" then
return v(self, w)
@@ -74,7 +74,7 @@ function compiler._mapflags(self, flags)
flags = table.wrap(flags)
-- need not map flags? return it directly
- if not self.mapflags then
+ if not self._TOOL.mapflags then
return flags
end
@@ -121,11 +121,11 @@ function compiler._addflags_from_compiler(self, flags, flagnames, kind)
for _, flagname in ipairs(flagnames) do
-- add compiler.xxflags
- table.join2(flags, self, self[flagname])
+ table.join2(flags, self._TOOL[flagname])
-- add compiler.kind.xxflags
- if kind ~= nil and self[kind] ~= nil then
- table.join2(flags, self, self[kind][flagname])
+ if kind ~= nil and self._TOOL[kind] ~= nil then
+ table.join2(flags, self._TOOL[kind][flagname])
end
end
end
@@ -154,23 +154,23 @@ function compiler._addflags_from_platform(self, flags, flagnames)
end
-- add the includedirs flags
- if self.flag_includedir then
+ if self._TOOL.flag_includedir then
for _, includedir in ipairs(table.wrap(platform.get("includedirs"))) do
- table.join2(flags, self:flag_includedir(includedir))
+ table.join2(flags, self._TOOL:flag_includedir(includedir))
end
end
-- add the defines flags
- if self.flag_define then
+ if self._TOOL.flag_define then
for _, define in ipairs(table.wrap(platform.get("defines"))) do
- table.join2(flags, self:flag_define(define))
+ table.join2(flags, self._TOOL:flag_define(define))
end
end
-- append the undefines flags
- if self.flag_undefine then
+ if self._TOOL.flag_undefine then
for _, undefine in ipairs(table.wrap(platform.get("undefines"))) do
- table.join2(flags, self:flag_undefine(undefine))
+ table.join2(flags, self._TOOL:flag_undefine(undefine))
end
end
end
@@ -245,23 +245,23 @@ function compiler._addflags_from_target(self, flags, flagnames, target)
table.join2(flags, compiler._getflags(self, target:get("languages"), languages))
-- add the includedirs flags from the current project
- if self.flag_includedir then
+ if self._TOOL.flag_includedir then
for _, includedir in ipairs(table.wrap(target:get("includedirs"))) do
- table.join2(flags, self:flag_includedir(includedir))
+ table.join2(flags, self._TOOL:flag_includedir(includedir))
end
end
-- add the defines flags from the current project
- if self.flag_define then
+ if self._TOOL.flag_define then
for _, define in ipairs(table.wrap(target:get("defines"))) do
- table.join2(flags, self:flag_define(define))
+ table.join2(flags, self._TOOL:flag_define(define))
end
end
-- append the undefines flags from the current project
- if self.flag_undefine then
+ if self._TOOL.flag_undefine then
for _, undefine in ipairs(table.wrap(target:get("undefines"))) do
- table.join2(flags, self:flag_undefine(undefine))
+ table.join2(flags, self._TOOL:flag_undefine(undefine))
end
end
@@ -275,16 +275,16 @@ function compiler._addflags_from_target(self, flags, flagnames, target)
self:_addflags_from_target(flags, flagnames, opt)
-- append the defines flags
- if self.flag_define then
+ if self._TOOL.flag_define then
for _, define in ipairs(table.wrap(opt:get("defines_if_ok"))) do
- table.join2(flags, self:flag_define(define))
+ table.join2(flags, self._TOOL:flag_define(define))
end
end
-- append the undefines flags
- if self.flag_undefine then
+ if self._TOOL.flag_undefine then
for _, undefine in ipairs(table.wrap(opt:get("undefines_if_ok"))) do
- table.join2(flags, self:flag_undefine(undefine))
+ table.join2(flags, self._TOOL:flag_undefine(undefine))
end
end
end
@@ -306,7 +306,7 @@ end
function compiler._make_for_option(self, opt, srcfile, objfile, logfile)
-- check
- assert(self and self:_tool() and opt)
+ assert(self and self._TOOL and opt)
-- the flag names
local flagnames = compiler._flagnames(self._KIND)
@@ -331,7 +331,7 @@ function compiler._make_for_option(self, opt, srcfile, objfile, logfile)
flags = table.unique(flags)
-- execute the compile command
- return self:_tool():command_compile(srcfile, objfile, table.concat(flags, " "):trim(), logfile)
+ return self._TOOL:command_compile(srcfile, objfile, table.concat(flags, " "):trim(), logfile)
end
-- get the flag names from the given compiler name
@@ -358,16 +358,6 @@ function compiler._flagnames(name)
return flagnames
end
--- get the tool
-function compiler._tool(self)
-
- -- check
- assert(self and self:_tool())
-
- -- get it
- return self:_tool()
-end
-
-- get the compiler kind from the source file type
function compiler._kind(srcfile)
@@ -461,7 +451,7 @@ end
function compiler.makecmd(self, target, srcfile, objfile, logfile)
-- check
- assert(self and self:_tool() and target)
+ assert(self and self._TOOL and target)
-- the flag names
local flagnames = compiler._flagnames(self._KIND)
@@ -471,7 +461,7 @@ function compiler.makecmd(self, target, srcfile, objfile, logfile)
local flags = self:flags(flagnames, target)
-- make the compile command
- return self:_tool():command_compile(srcfile, objfile, table.concat(flags, " "):trim(), logfile)
+ return self._TOOL:command_compile(srcfile, objfile, table.concat(flags, " "):trim(), logfile)
end
-- check include for the project option
@@ -503,7 +493,7 @@ function compiler.check_include(opt, include, srcpath, objpath)
if not self then return end
-- execute the compile command
- return self:_tool():main(self:_make_for_option(opt, srcpath, objpath, utils.ifelse(option.get("verbose"), nil, xmake._NULDEV)))
+ return self._TOOL:main(self:_make_for_option(opt, srcpath, objpath, utils.ifelse(option.get("verbose"), nil, xmake._NULDEV)))
end
-- check function for the project option
@@ -547,7 +537,7 @@ function compiler.check_function(opt, interface, srcpath, objpath)
srcfile:close()
-- execute the compile command
- return self:_tool():main(self:_make_for_option(opt, srcpath, objpath, utils.ifelse(option.get("verbose"), nil, xmake._NULDEV)))
+ return self._TOOL:main(self:_make_for_option(opt, srcpath, objpath, utils.ifelse(option.get("verbose"), nil, xmake._NULDEV)))
end
-- check typedef for the project option
@@ -591,7 +581,7 @@ function compiler.check_typedef(opt, typedef, srcpath, objpath)
srcfile:close()
-- execute the compile command
- return self:_tool():main(self:_make_for_option(opt, srcpath, objpath, utils.ifelse(option.get("verbose"), nil, xmake._NULDEV)))
+ return self._TOOL:main(self:_make_for_option(opt, srcpath, objpath, utils.ifelse(option.get("verbose"), nil, xmake._NULDEV)))
end
-- return module