From c5fed632a287c2aedd335ba4e41f4347d2fe1956 Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 10 Jun 2019 22:32:56 +0800 Subject: add builtin rule for language --- xmake/core/project/project.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'xmake/core/project/project.lua') diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua index ed9b87bb3..6e670ec3b 100644 --- a/xmake/core/project/project.lua +++ b/xmake/core/project/project.lua @@ -498,7 +498,7 @@ function project._load_targets() t._ORDERDEPS = t._ORDERDEPS or {} project._load_deps(t, targets, t._DEPS, t._ORDERDEPS) - -- load rules + -- load rules from target and language -- -- .e.g -- @@ -509,7 +509,15 @@ function project._load_targets() -- t._RULES = t._RULES or {} t._ORDERULES = t._ORDERULES or {} - for _, rulename in ipairs(table.wrap(t:get("rules"))) do + local rulenames = {} + table.join2(rulenames, t:get("rules")) + for _, sourcefile in ipairs(table.wrap(t:get("files"))) do + local lang = language.load_ex(path.extension(sourcefile)) + if lang and lang:rules() then + table.join2(rulenames, lang:rules()) + end + end + for _, rulename in ipairs(rulenames) do local r = project.rule(rulename) or rule.rule(rulename) if r then t._RULES[rulename] = r @@ -523,7 +531,6 @@ function project._load_targets() table.insert(t._ORDERULES, r) end end - deprecated_project._patch_target_rules(t) -- laod packages t._PACKAGES = t._PACKAGES or {} -- cgit v1.3.1