summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2016-03-21 21:32:11 +0800
committerruki <[email protected]>2016-03-21 21:32:11 +0800
commit308b4d3661fad938dae830ee357778f85918f963 (patch)
treecee803e184a4f375f7b741772117a5c4a5e67343
parentb898400a3a5f18d332ce7ef159769d8f17fd28e5 (diff)
fix make config.h bug
-rwxr-xr-xxmake/actions/config/config_h.lua17
-rw-r--r--xmake/core/platform/compiler.lua104
-rw-r--r--xmake/core/project/option.lua2
-rw-r--r--xmake/core/project/target.lua2
4 files changed, 59 insertions, 66 deletions
diff --git a/xmake/actions/config/config_h.lua b/xmake/actions/config/config_h.lua
index 886ee8486..acd94eeb2 100755
--- a/xmake/actions/config/config_h.lua
+++ b/xmake/actions/config/config_h.lua
@@ -67,20 +67,13 @@ function _make_for_target(files, target)
local undefines = table.copy(target:get("undefines_h"))
-- make the options
- for _, name in ipairs(target:get("options")) do
+ for name, 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
+ -- get the option defines
+ table.join2(defines, opt:get("defines_h_if_ok"))
- -- get the option defines
- table.join2(defines, opt.defines_h_if_ok)
-
- -- get the option undefines
- table.join2(undefines, opt.undefines_h_if_ok)
-
- end
+ -- get the option undefines
+ table.join2(undefines, opt:get("undefines_h_if_ok"))
end
-- make the defines
diff --git a/xmake/core/platform/compiler.lua b/xmake/core/platform/compiler.lua
index 0b6d6fdb4..000805055 100644
--- a/xmake/core/platform/compiler.lua
+++ b/xmake/core/platform/compiler.lua
@@ -269,10 +269,10 @@ function compiler._addflags_from_target(self, flags, flagnames, target)
if target.options then
-- add the flags for the target options
- for name, opt in ipairs(target:options()) do
+ for name, opt in pairs(target:options()) do
-- add the flags from the option
- compiler._addflags_from_target(self, flags, flagnames, opt)
+ self:_addflags_from_target(flags, flagnames, opt)
-- append the defines flags
if self.flag_define then
@@ -298,9 +298,41 @@ function compiler._addflags_from_option(self, flags, flagnames, opt)
assert(self and flags and flagnames and opt)
-- add the flags from the option
- compiler._addflags_from_target(self, flags, flagnames, opt)
+ self:_addflags_from_target(flags, flagnames, opt)
end
+
+-- make the compile command for option
+function compiler._make_for_option(self, opt, srcfile, objfile, logfile)
+
+ -- check
+ assert(self and self._TOOL and opt)
+
+ -- the flag names
+ local flagnames = compiler._flagnames(self._KIND)
+ assert(flagnames)
+
+ -- init flags
+ local flags = {}
+
+ -- add flags from the configure
+ compiler._addflags_from_config(self, flags, flagnames)
+
+ -- add flags from the option
+ compiler._addflags_from_option(self, flags, flagnames, opt)
+
+ -- add flags from the platform
+ compiler._addflags_from_platform(self, flags, flagnames)
+
+ -- add flags from the compiler
+ compiler._addflags_from_compiler(self, flags, flagnames)
+
+ -- remove repeat
+ flags = table.unique(flags)
+
+ -- execute the compile command
+ return self._TOOL:command_compile(srcfile, objfile, table.concat(flags, " "):trim(), logfile)
+end
-- get the flag names from the given compiler name
function compiler._flagnames(name)
@@ -353,38 +385,6 @@ function compiler._kind(srcfile)
-- ok
return kind
end
-
--- make the compile command for option
-function compiler._make_for_option(self, opt, srcfile, objfile, logfile)
-
- -- check
- assert(self and self._TOOL and opt)
-
- -- the flag names
- local flagnames = compiler._flagnames(self._KIND)
- assert(flagnames)
-
- -- init flags
- local flags = {}
-
- -- add flags from the configure
- compiler._addflags_from_config(self, flags, flagnames)
-
- -- add flags from the option
- compiler._addflags_from_option(self, flags, flagnames, opt)
-
- -- add flags from the platform
- compiler._addflags_from_platform(self, flags, flagnames)
-
- -- add flags from the compiler
- compiler._addflags_from_compiler(self, flags, flagnames)
-
- -- remove repeat
- flags = table.unique(flags)
-
- -- execute the compile command
- return self._TOOL:command_compile(srcfile, objfile, table.concat(flags, " "):trim(), logfile)
-end
-- init the compiler from the given source file
function compiler.init(srcfile)
@@ -422,23 +422,6 @@ function compiler.init(srcfile)
return instance
end
--- make the compile command
-function compiler.makecmd(self, target, srcfile, objfile, logfile)
-
- -- check
- assert(self and self._TOOL and target)
-
- -- the flag names
- local flagnames = compiler._flagnames(self._KIND)
- assert(flagnames)
-
- -- get flags
- local flags = self:flags(flagnames, target)
-
- -- make the compile command
- return self._TOOL:command_compile(srcfile, objfile, table.concat(flags, " "):trim(), logfile)
-end
-
-- get flags from the given flag names
function compiler.flags(self, flagnames, target)
@@ -464,6 +447,23 @@ function compiler.flags(self, flagnames, target)
return flags
end
+-- make the compile command
+function compiler.makecmd(self, target, srcfile, objfile, logfile)
+
+ -- check
+ assert(self and self._TOOL and target)
+
+ -- the flag names
+ local flagnames = compiler._flagnames(self._KIND)
+ assert(flagnames)
+
+ -- get flags
+ local flags = self:flags(flagnames, target)
+
+ -- make the compile command
+ return self._TOOL:command_compile(srcfile, objfile, table.concat(flags, " "):trim(), logfile)
+end
+
-- check include for the project option
function compiler.check_include(opt, include, srcpath, objpath)
diff --git a/xmake/core/project/option.lua b/xmake/core/project/option.lua
index 2c4fd1876..c8e2da9eb 100644
--- a/xmake/core/project/option.lua
+++ b/xmake/core/project/option.lua
@@ -282,7 +282,7 @@ function option.load(name)
end
-- init option instance
- local instance = {}
+ local instance = table.inherit(option)
instance._INFO = info
instance._NAME = name
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index a7fd954d3..68dfefe3a 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -85,7 +85,7 @@ function target.options(self)
-- get option if be enabled
local opt = nil
- if config.get(name) then opt = poption.load(name) end
+ if config.get(name) then opt = option.load(name) end
if nil ~= opt then
options[name] = opt
end