summaryrefslogtreecommitdiff
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
parent2a549b0fb990bb06f6180fd7cbd3c212af5e2ebd (diff)
finish build
-rw-r--r--xmake/core/platform/compiler.lua70
-rw-r--r--xmake/core/platform/linker.lua68
2 files changed, 61 insertions, 77 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
diff --git a/xmake/core/platform/linker.lua b/xmake/core/platform/linker.lua
index 1b4573c92..7849ed638 100644
--- a/xmake/core/platform/linker.lua
+++ b/xmake/core/platform/linker.lua
@@ -37,16 +37,16 @@ local platform = require("platform/platform")
function linker._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)
@@ -73,7 +73,7 @@ function linker._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
@@ -118,9 +118,9 @@ function linker._addflags_from_links(self, flags, links)
assert(self and flags and links)
-- done
- if self.flag_link then
+ if self._TOOL.flag_link then
for _, link in ipairs(table.wrap(links)) do
- table.join2(flags, self:flag_link(link))
+ table.join2(flags, self._TOOL:flag_link(link))
end
end
end
@@ -132,7 +132,7 @@ function linker._addflags_from_linker(self, flags, flagname)
assert(self and flags and flagname)
-- done
- table.join2(flags, self[flagname])
+ table.join2(flags, self._TOOL[flagname])
end
-- add flags from the compiler
@@ -183,16 +183,16 @@ function linker._addflags_from_platform(self, flags, flagname)
table.join2(flags, linker._mapflags(self, platform.get(flagname)))
-- add the linkdirs flags
- if self.flag_linkdir then
+ if self._TOOL.flag_linkdir then
for _, linkdir in ipairs(table.wrap(platform.get("linkdirs"))) do
- table.join2(flags, self:flag_linkdir(linkdir))
+ table.join2(flags, self._TOOL:flag_linkdir(linkdir))
end
end
-- add the links flags
- if self.flag_link then
+ if self._TOOL.flag_link then
for _, link in ipairs(table.wrap(platform.get("links"))) do
- table.join2(flags, self:flag_link(link))
+ table.join2(flags, self._TOOL:flag_link(link))
end
end
end
@@ -207,42 +207,36 @@ function linker._addflags_from_target(self, flags, flagname, target)
table.join2(flags, linker._mapflags(self, target[flagname]))
-- add the linkdirs flags from the current project
- if self.flag_linkdir then
+ if self._TOOL.flag_linkdir then
for _, linkdir in ipairs(table.wrap(target:get("linkdirs"))) do
- table.join2(flags, self:flag_linkdir(linkdir))
+ table.join2(flags, self._TOOL:flag_linkdir(linkdir))
end
end
-- add the links flags from the current project
- if self.flag_link then
+ if self._TOOL.flag_link then
for _, link in ipairs(table.wrap(target:get("links"))) do
- table.join2(flags, self:flag_link(link))
+ table.join2(flags, self._TOOL:flag_link(link))
end
end
- -- the options
- for _, name in ipairs(table.wrap(target:get("options"))) do
+ -- add the flags for the target options
+ for _, opt in pairs(target:options()) do
- -- get option if be enabled
- local opt = nil
- if config.get(name) then opt = config.get("__" .. name) end
- if nil ~= opt then
-
- -- add the flags from the option
- table.join2(flags, linker._mapflags(self, opt[flagname]))
-
- -- add the linkdirs flags from the option
- if self.flag_linkdir then
- for _, linkdir in ipairs(table.wrap(opt.linkdirs)) do
- table.join2(flags, self:flag_linkdir(linkdir))
- end
+ -- add the flags from the option
+ table.join2(flags, linker._mapflags(self, opt:get(flagname)))
+
+ -- add the linkdirs flags from the option
+ if self._TOOL.flag_linkdir then
+ for _, linkdir in ipairs(table.wrap(opt:get("linkdirs"))) do
+ table.join2(flags, self._TOOL:flag_linkdir(linkdir))
end
+ end
- -- add the links flags from the option
- if self.flag_link then
- for _, link in ipairs(table.wrap(opt.links)) do
- table.join2(flags, self:flag_link(link))
- end
+ -- add the links flags from the option
+ if self._TOOL.flag_link then
+ for _, link in ipairs(table.wrap(opt:get("links"))) do
+ table.join2(flags, self._TOOL:flag_link(link))
end
end
end
@@ -266,9 +260,9 @@ function linker._addflags_from_option(self, flags, flagname, opt)
table.join2(flags, linker._mapflags(self, opt:get("flagname")))
-- append the linkdirs flags
- if opt.linkdirs and self.flag_linkdir then
+ if opt:get("linkdirs") and self._TOOL.flag_linkdir then
for _, linkdir in ipairs(table.wrap(opt:get("linkdirs"))) do
- table.join2(flags, self:flag_linkdir(linkdir))
+ table.join2(flags, self._TOOL:flag_linkdir(linkdir))
end
end
end