diff options
| author | ruki <[email protected]> | 2015-06-02 10:50:54 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-06-02 10:50:54 +0800 |
| commit | 4b85064e874d050de835f4a4a0b2158f1405a6aa (patch) | |
| tree | c3f0ccec578302d4ad215198014d7f6331975546 /xmake/scripts/compiler | |
| parent | bf6315e4e63270175eb27d9ab73dc98f3408cea8 (diff) | |
reimpl unique for flags
Diffstat (limited to 'xmake/scripts/compiler')
| -rw-r--r-- | xmake/scripts/compiler/_clang.lua | 14 | ||||
| -rw-r--r-- | xmake/scripts/compiler/compiler.lua | 26 |
2 files changed, 32 insertions, 8 deletions
diff --git a/xmake/scripts/compiler/_clang.lua b/xmake/scripts/compiler/_clang.lua index b275f23b8..00b49c47f 100644 --- a/xmake/scripts/compiler/_clang.lua +++ b/xmake/scripts/compiler/_clang.lua @@ -66,6 +66,20 @@ function _clang._make(configs, srcfile, objfile, flags) return string.format("%s -c %s -o%s %s", configs.name, flags, objfile, srcfile) end +-- make the define flag +function _clang._make_define(configs, define) + + -- make it + return "-D" .. define +end + +-- make the includedir flag +function _clang._make_includedir(configs, includedir) + + -- make it + return "-I" .. includedir +end + -- map gcc flag to the current compiler flag function _clang._mapflag(configs, flag) diff --git a/xmake/scripts/compiler/compiler.lua b/xmake/scripts/compiler/compiler.lua index a4c5c59b7..ac25f176a 100644 --- a/xmake/scripts/compiler/compiler.lua +++ b/xmake/scripts/compiler/compiler.lua @@ -91,24 +91,34 @@ function compiler._make(self, target, filetype, srcfile, objfile) for _, flag_name in ipairs(flag_names) do -- get flags - local flags = target[flag_name] - if flags then - flags = table.concat(compiler._mapflags(self, utils.wrap(flags)), " ") - end + local flags = table.concat(compiler._mapflags(self, utils.wrap(target[flag_name])), " ") -- append flags flags_target = string.format("%s %s", flags_target, flags or "") end + -- get the includedirs flags from the current project + if self._make_includedir then + local includedirs = utils.wrap(target.includedirs) + for _, includedir in ipairs(includedirs) do + flags_target = string.format("%s %s", flags_target, self._make_includedir(configs, includedir)) + end + end + + -- get the defines flags from the current project + if self._make_define then + local defines = utils.wrap(target.defines) + for _, define in ipairs(defines) do + flags_target = string.format("%s %s", flags_target, self._make_define(configs, define)) + end + end + -- get the config flags local flags_config = "" for _, flag_name in ipairs(flag_names) do -- get flags - local flags = config.get(flag_name) - if flags then - flags = table.concat(compiler._mapflags(self, utils.wrap(flags)), " ") - end + local flags = table.concat(compiler._mapflags(self, utils.wrap(config.get(flag_name))), " ") -- append flags flags_config = string.format("%s %s", flags_config, flags or "") |
