diff options
| author | ruki <[email protected]> | 2020-06-13 12:47:31 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-06-13 12:47:31 +0800 |
| commit | 9a7b8dfdd5737c8f852958067081829e46d234a1 (patch) | |
| tree | 0a567c3e6375fd762e24e7bfd6cc20abdf007f13 | |
| parent | 6a26e78f28fa85b1ccd236cadac7784c960ca950 (diff) | |
support override rules
| -rw-r--r-- | xmake/core/project/target.lua | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index af9e194e9..7ec19ca4a 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -963,10 +963,12 @@ function _instance:filerules(sourcefile) -- add rules from file config local rules = {} + local override = false local fileconfig = self:fileconfig(sourcefile) if fileconfig then local filerules = fileconfig.rules or fileconfig.rule if filerules then + override = filerules.override for _, rulename in ipairs(table.wrap(filerules)) do local r = self._PROJECT.rule(rulename) or rule.rule(rulename) if r then @@ -975,6 +977,10 @@ function _instance:filerules(sourcefile) end end end + -- override? e.g. add_files("src/*.c", {rules = {"xxx", override = true}}) + if override then + return rules, true + end -- load all rules for this target with sourcekinds and extensions local key2rules = self._KEY2RULES @@ -1427,7 +1433,7 @@ function _instance:sourcebatches() for _, sourcefile in ipairs(sourcefiles) do -- get file rules - local filerules = self:filerules(sourcefile) + local filerules, override = self:filerules(sourcefile) if #filerules == 0 then os.raise("unknown source file: %s", sourcefile) end @@ -1450,7 +1456,7 @@ function _instance:sourcebatches() -- attempt to get source kind from the builtin languages local sourcekind = self:sourcekind_of(sourcefile) - if sourcekind then + if sourcekind and not override then -- save source kind sourcebatch.sourcekind = sourcekind |
