diff options
| author | ruki <[email protected]> | 2021-11-16 09:48:53 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-11-16 09:48:53 +0800 |
| commit | 26ccb97f322fd3414001979d2d325522e7378868 (patch) | |
| tree | 06f6e72014871414646b9bebd25794412a9bdd33 | |
| parent | 8c67fe903098afed989fb9ba64881fb7267bca49 (diff) | |
add linkcmd for vs generator
| -rw-r--r-- | xmake/plugins/project/vstudio/impl/vs201x.lua | 33 | ||||
| -rw-r--r-- | xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua | 8 |
2 files changed, 33 insertions, 8 deletions
diff --git a/xmake/plugins/project/vstudio/impl/vs201x.lua b/xmake/plugins/project/vstudio/impl/vs201x.lua index d366649da..3c7d62737 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x.lua @@ -86,8 +86,26 @@ function _make_custom_commands_for_target(commands, target, suffix) for _, cmd in ipairs(batchcmds_:cmds()) do local command = _get_command_string(cmd) if command then - commands[suffix] = commands[suffix] or {} - table.insert(commands[suffix], command) + local key = suffix and suffix or "before" + commands[key] = commands[key] or {} + table.insert(commands[key], command) + end + end + end + end + + scriptname = "linkcmd" .. (suffix and ("_" .. suffix) or "") + script = ruleinst:script(scriptname) + if script then + local batchcmds_ = batchcmds.new({target = target}) + script(target, batchcmds_, {}) + if not batchcmds_:empty() then + for _, cmd in ipairs(batchcmds_:cmds()) do + local command = _get_command_string(cmd) + if command then + local key = (suffix and suffix or "before") .. "_link" + commands[key] = commands[key] or {} + table.insert(commands[key], command) end end end @@ -112,8 +130,9 @@ function _make_custom_commands_for_objectrules(commands, target, sourcebatch, su for _, cmd in ipairs(batchcmds_:cmds()) do local command = _get_command_string(cmd) if command then - commands[suffix] = commands[suffix] or {} - table.insert(commands[suffix], command) + local key = suffix and suffix or "before" + commands[key] = commands[key] or {} + table.insert(commands[key], command) end end end @@ -132,8 +151,9 @@ function _make_custom_commands_for_objectrules(commands, target, sourcebatch, su for _, cmd in ipairs(batchcmds_:cmds()) do local command = _get_command_string(cmd) if command then - commands[suffix] = commands[suffix] or {} - table.insert(commands[suffix], command) + local key = suffix and suffix or "before" + commands[key] = commands[key] or {} + table.insert(commands[key], command) end end end @@ -146,6 +166,7 @@ end function _make_custom_commands(target) local commands = {} _make_custom_commands_for_target(commands, target, "before") + _make_custom_commands_for_target(commands, target) for _, sourcebatch in pairs(target:sourcebatches()) do local sourcekind = sourcebatch.sourcekind if sourcekind ~= "cc" and sourcekind ~= "cxx" and sourcekind ~= "as" then diff --git a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua index 93e8633d9..6e77caf9b 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua @@ -374,10 +374,12 @@ end -- make custom commands item function _make_custom_commands_item(vcxprojfile, commands, suffix) - if suffix == "after" then + if suffix == "after" or suffix == "after_link" then vcxprojfile:print("<PostBuildEvent>") elseif suffix == "before" then vcxprojfile:print("<PreBuildEvent>") + elseif suffix == "before_link" then + vcxprojfile:print("<PreLinkEvent>") end vcxprojfile:print("<Message></Message>") vcxprojfile:print("<Command>setlocal") @@ -392,10 +394,12 @@ exit /b %1 :xmDone if %errorlevel% neq 0 goto :VCEnd</Command> ]]) - if suffix == "after" then + if suffix == "after" or suffix == "after_link" then vcxprojfile:print("</PostBuildEvent>") elseif suffix == "before" then vcxprojfile:print("</PreBuildEvent>") + elseif suffix == "before_link" then + vcxprojfile:print("</PreLinkEvent>") end end |
