diff options
| author | ruki <[email protected]> | 2018-04-12 00:28:09 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-04-11 20:48:54 +0800 |
| commit | 6a5bfcf9fd370a6f69ddeb49dacde279e8c2d45e (patch) | |
| tree | 39e2efad2db0bcc309d48bba1bce34cce9b7433b | |
| parent | b0196c2cc8d91c1db21442488ff44e64336bfa7c (diff) | |
build rule files
| -rw-r--r-- | tests/apis/rules/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/core/project/rule.lua | 18 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/project/rule.lua | 18 |
3 files changed, 28 insertions, 10 deletions
diff --git a/tests/apis/rules/xmake.lua b/tests/apis/rules/xmake.lua index b67c1ca2b..cf516686e 100644 --- a/tests/apis/rules/xmake.lua +++ b/tests/apis/rules/xmake.lua @@ -13,7 +13,7 @@ rule("man") for _, sourcefile in ipairs(sourcefiles) do print("generating man: %s", sourcefile) end - rule.build("markdown", target, sourcefiles) + rule.build_files("markdown", target, sourcefiles) end) -- define rule: c code diff --git a/xmake/core/project/rule.lua b/xmake/core/project/rule.lua index 7539b79a3..83d116cfc 100644 --- a/xmake/core/project/rule.lua +++ b/xmake/core/project/rule.lua @@ -236,19 +236,19 @@ function rule:orderdeps() end -- build source files -function rule:build(target, sourcefiles) +function rule:build_files(target, sourcefiles) - -- build all? - local build_all = self:script("build_files") - if build_all then - return sandbox.load(build_all, target, sourcefiles) + -- build files? + local build_files = self:script("build_files") + if build_files then + return sandbox.load(build_files, target, sourcefiles) else - local build = self:script("build_file") - if not build then - return false, string.format("rule(%s): build script not found!", self:name()) + local build_file = self:script("build_file") + if not build_file then + return false, string.format("rule(%s): on_build_file() script not found!", self:name()) end for _, sourcefile in ipairs(table.wrap(sourcefiles)) do - local ok, errors = sandbox.load(build, target, sourcefile) + local ok, errors = sandbox.load(build_file, target, sourcefile) if not ok then return false, errors end diff --git a/xmake/core/sandbox/modules/import/core/project/rule.lua b/xmake/core/sandbox/modules/import/core/project/rule.lua index 0f7766a87..78dbb1908 100644 --- a/xmake/core/sandbox/modules/import/core/project/rule.lua +++ b/xmake/core/sandbox/modules/import/core/project/rule.lua @@ -43,6 +43,23 @@ function sandbox_core_project_rule.rules() end -- build source files +function sandbox_core_project_rule.build_files(rulename, target, sourcefiles) + + -- get rule + local rule = project.rule(rulename) or rule.rule(rulename) + if not rule then + raise("unknown rule: %s", rulename) + end + + -- do build + local ok, errors = rule:build_files(target, sourcefiles) + if not ok then + raise(errors) + end +end + +--[[ +-- build source files function sandbox_core_project_rule.build(rulename, target, sourcefiles) -- get rule @@ -121,6 +138,7 @@ function sandbox_core_project_rule.package(rulename, target, sourcefiles) raise(errors) end end +]] -- return module return sandbox_core_project_rule |
