diff options
| author | ruki <[email protected]> | 2017-11-11 11:52:48 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-11-11 11:52:48 +0800 |
| commit | fc0ac813b07b28abdbd2b40c5ba78ee76dcc09d7 (patch) | |
| tree | 1288d79e7b51615d7f4f9235496dd46b379d5d0a /tests | |
| parent | 47e6e15e84968c6b0f1ebf6c939157fb027a1c4f (diff) | |
build rule
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/apis/rules/xmake.lua | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/tests/apis/rules/xmake.lua b/tests/apis/rules/xmake.lua index 1971e20fe..fd25ba94f 100644 --- a/tests/apis/rules/xmake.lua +++ b/tests/apis/rules/xmake.lua @@ -1,19 +1,21 @@ -- define rule: markdown rule("markdown") - on_build(function (target, sourcefile) - print("compiling %s", sourcefile) - os.cp(sourcefile, path.join(target:objectdir(), path.basename(sourcefile) .. ".html")) + on_build(function (target, sourcefiles) + for _, sourcefile in ipairs(sourcefiles) do + print("compiling %s", sourcefile) + os.cp(sourcefile, path.join(target:objectdir(), path.basename(sourcefile) .. ".html")) + end end) -- define rule: man rule("man") add_imports("core.project.rule") - on_build_all(function (target, sourcefiles) + on_build(function (target, sourcefiles) for _, sourcefile in ipairs(sourcefiles) do print("generating %s", sourcefile) end - rule.build_all("markdown", target, sourcefiles) + rule.build("markdown", target, sourcefiles) end) -- define rule: c code @@ -21,9 +23,11 @@ rule("c code") add_imports("core.tool.compiler") on_build(function (target, sourcefile) print("compiling %s", sourcefile) - local objectfile = os.tmpfile() .. ".o" - compiler.compile(sourcefile, objectfile, {sourcekind = "cc"}) - table.insert(target:objectfiles(), objectfile) + local objectfile_o = os.tmpfile() .. ".o" + local sourcefile_c = os.tmpfile() .. ".c" + os.cp(sourcefile, sourcefile_c) + compiler.compile(sourcefile_c, objectfile_o) + table.insert(target:objectfiles(), objectfile_o) end) -- define rule: stub |
