diff options
| author | ruki <[email protected]> | 2022-04-06 19:22:31 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-04-06 19:22:31 +0800 |
| commit | 79e14625b3977bf7953c2150e584332a0ea8dd16 (patch) | |
| tree | 219def4a33c8a56ca15d0843c740929eaab6fda1 | |
| parent | 313fc50dbd586e43c7516dc12202db02e6b94945 (diff) | |
| parent | 1a38d758f48624c09d2e16d1df360909a8046e61 (diff) | |
Merge pull request #2244 from SirLynix/patch-10
vstudio generator: fix batchcmd dir
| -rw-r--r-- | xmake/plugins/project/vstudio/impl/vs201x.lua | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/xmake/plugins/project/vstudio/impl/vs201x.lua b/xmake/plugins/project/vstudio/impl/vs201x.lua index aa5a715e2..e4b5596b5 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x.lua @@ -79,13 +79,20 @@ function _clear_cache() end -- get command string -function _get_command_string(cmd) +function _get_command_string(cmd, vcxprojdir) local kind = cmd.kind local opt = cmd.opt if cmd.program then - local command = os.args(table.join(cmd.program, cmd.argv)) + local argv = {} + for _, v in ipairs(table.join(cmd.program, cmd.argv)) do + if path.is_absolute(v) then + v = _make_dirs(v, vcxprojdir) + end + table.insert(argv, v) + end + local command = os.args(argv) if opt and opt.curdir then - command = string.format("pushd \"%s\"\n%s\npopd", opt.curdir, command) + command = string.format("pushd \"%s\"\n%s\npopd", _make_dirs(opt.curdir, vcxprojdir), command) end return command elseif kind == "cp" then @@ -104,7 +111,7 @@ function _get_command_string(cmd) end -- add target custom commands for target -function _make_custom_commands_for_target(commands, target, suffix) +function _make_custom_commands_for_target(commands, target, vcxprojdir, suffix) for _, ruleinst in ipairs(target:orderules()) do local scriptname = "buildcmd" .. (suffix and ("_" .. suffix) or "") local script = ruleinst:script(scriptname) @@ -113,7 +120,7 @@ function _make_custom_commands_for_target(commands, target, suffix) script(target, batchcmds_, {}) if not batchcmds_:empty() then for _, cmd in ipairs(batchcmds_:cmds()) do - local command = _get_command_string(cmd) + local command = _get_command_string(cmd, vcxprojdir) if command then local key = suffix and suffix or "before" commands[key] = commands[key] or {} @@ -130,7 +137,7 @@ function _make_custom_commands_for_target(commands, target, suffix) script(target, batchcmds_, {}) if not batchcmds_:empty() then for _, cmd in ipairs(batchcmds_:cmds()) do - local command = _get_command_string(cmd) + local command = _get_command_string(cmd, vcxprojdir) if command then local key = (suffix and suffix or "before") .. "_link" commands[key] = commands[key] or {} @@ -143,7 +150,7 @@ function _make_custom_commands_for_target(commands, target, suffix) end -- add target custom commands for object rules -function _make_custom_commands_for_objectrules(commands, target, sourcebatch, suffix) +function _make_custom_commands_for_objectrules(commands, target, sourcebatch, vcxprojdir, suffix) -- get rule local rulename = assert(sourcebatch.rulename, "unknown rule for sourcebatch!") @@ -157,7 +164,7 @@ function _make_custom_commands_for_objectrules(commands, target, sourcebatch, su script(target, batchcmds_, sourcebatch, {}) if not batchcmds_:empty() then for _, cmd in ipairs(batchcmds_:cmds()) do - local command = _get_command_string(cmd) + local command = _get_command_string(cmd, vcxprojdir) if command then local key = suffix and suffix or "before" commands[key] = commands[key] or {} @@ -178,7 +185,7 @@ function _make_custom_commands_for_objectrules(commands, target, sourcebatch, su script(target, batchcmds_, sourcefile, {}) if not batchcmds_:empty() then for _, cmd in ipairs(batchcmds_:cmds()) do - local command = _get_command_string(cmd) + local command = _get_command_string(cmd, vcxprojdir) if command then local key = suffix and suffix or "before" commands[key] = commands[key] or {} @@ -192,19 +199,19 @@ function _make_custom_commands_for_objectrules(commands, target, sourcebatch, su end -- make custom commands -function _make_custom_commands(target) +function _make_custom_commands(target, vcxprojdir) local commands = {} - _make_custom_commands_for_target(commands, target, "before") - _make_custom_commands_for_target(commands, target) + _make_custom_commands_for_target(commands, target, vcxprojdir, "before") + _make_custom_commands_for_target(commands, target, vcxprojdir) for _, sourcebatch in pairs(target:sourcebatches()) do local sourcekind = sourcebatch.sourcekind if sourcekind ~= "cc" and sourcekind ~= "cxx" and sourcekind ~= "as" then - _make_custom_commands_for_objectrules(commands, target, sourcebatch, "before") - _make_custom_commands_for_objectrules(commands, target, sourcebatch) - _make_custom_commands_for_objectrules(commands, target, sourcebatch, "after") + _make_custom_commands_for_objectrules(commands, target, sourcebatch, vcxprojdir, "before") + _make_custom_commands_for_objectrules(commands, target, sourcebatch, vcxprojdir, nil) + _make_custom_commands_for_objectrules(commands, target, sourcebatch, vcxprojdir, "after") end end - _make_custom_commands_for_target(commands, target, "after") + _make_custom_commands_for_target(commands, target, vcxprojdir, "after") return commands end @@ -356,7 +363,7 @@ function _make_targetinfo(mode, arch, target, vcxprojdir) end -- save custom commands - targetinfo.commands = _make_custom_commands(target) + targetinfo.commands = _make_custom_commands(target, vcxprojdir) return targetinfo end |
