summaryrefslogtreecommitdiff
path: root/xmake/modules
diff options
context:
space:
mode:
authorruki <[email protected]>2022-12-19 14:00:49 +0800
committerGitHub <[email protected]>2022-12-19 14:00:49 +0800
commitba059f5723f290bea5682cfac0534739e66cf219 (patch)
tree88dcc1b15188e156101623c5c4aea71229a09b98 /xmake/modules
parentce7eccec1148a259ac8d73e098ceb1974deb1f5e (diff)
parentf84a1a0e45b85cbccd66e985f195bcfe031e2b67 (diff)
Merge pull request #3182 from xmake-io/modules
improve modules for project generator
Diffstat (limited to 'xmake/modules')
-rw-r--r--xmake/modules/private/utils/batchcmds.lua24
1 files changed, 21 insertions, 3 deletions
diff --git a/xmake/modules/private/utils/batchcmds.lua b/xmake/modules/private/utils/batchcmds.lua
index 797403b34..5948fe0cf 100644
--- a/xmake/modules/private/utils/batchcmds.lua
+++ b/xmake/modules/private/utils/batchcmds.lua
@@ -253,7 +253,26 @@ function batchcmds:compile(sourcefiles, objectfile, opt)
sourcekind = language.sourcekind_of(tostring(sourcefiles))
end
local compiler_inst = compiler.load(sourcekind, opt)
- local program, argv = compiler_inst:compargv(sourcefiles, path(objectfile), opt)
+ local _, argv = compiler_inst:compargv(sourcefiles, path(objectfile), opt)
+
+ -- add compilation command and bind run environments of compiler
+ self:mkdir(path.directory(objectfile))
+ self:compilev(argv, table.join({sourcekind = sourcekind, compiler = compiler_inst}, opt))
+end
+
+-- add command: compiler.compilev
+function batchcmds:compilev(argv, opt)
+
+ -- bind target if exists
+ opt = opt or {}
+ opt.target = self._TARGET
+
+ -- load compiler and get compilation command
+ local compiler_inst = opt.compiler
+ if not compiler_inst then
+ local sourcekind = opt.sourcekind
+ compiler_inst = compiler.load(sourcekind, opt)
+ end
-- we need translate path for the project generator
for idx, item in ipairs(argv) do
@@ -269,8 +288,7 @@ function batchcmds:compile(sourcefiles, objectfile, opt)
end
-- add compilation command and bind run environments of compiler
- self:mkdir(path.directory(objectfile))
- self:vrunv(program, argv, {envs = table.join(compiler_inst:runenvs(), opt.envs)})
+ self:vrunv(compiler_inst:program(), argv, {envs = table.join(compiler_inst:runenvs(), opt.envs)})
end
-- add command: linker.link