From 8312af7f8c0f25b09f80bf013e8a2799ce2ed682 Mon Sep 17 00:00:00 2001 From: Jarod42 Date: Thu, 27 Apr 2023 00:18:05 +0200 Subject: [PATCH] Add support of prelink steps (similar to prebuild steps) for Codelite. --- modules/codelite/codelite_project.lua | 13 +++++++++- .../codelite/tests/test_codelite_config.lua | 25 +++++++++++++++++++ website/docs/prelinkcommands.md | 10 +++----- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/modules/codelite/codelite_project.lua b/modules/codelite/codelite_project.lua index 4c6e71afe1..a6c8640d9c 100755 --- a/modules/codelite/codelite_project.lua +++ b/modules/codelite/codelite_project.lua @@ -322,7 +322,7 @@ end function m.preBuild(cfg) - if #cfg.prebuildcommands > 0 or cfg.prebuildmessage then + if #cfg.prebuildcommands > 0 or cfg.prebuildmessage or #cfg.prelinkcommands > 0 or cfg.prelinkmessage then _p(3, '') p.escaper(codelite.escElementText) if cfg.prebuildmessage then @@ -333,6 +333,17 @@ for _, command in ipairs(commands) do _x(4, '%s', command) end + if #cfg.prelinkcommands then + p.warnOnce("codelite_prelink", "prelinkcommands is treated as prebuildcommands by Codelite") + end + if cfg.prelinkmessage then + local command = os.translateCommandsAndPaths("@{ECHO} " .. p.quote(cfg.prelinkmessage), cfg.project.basedir, cfg.project.location) + _x(4, '%s', command) + end + local commands = os.translateCommandsAndPaths(cfg.prelinkcommands, cfg.project.basedir, cfg.project.location) + for _, command in ipairs(commands) do + _x(4, '%s', command) + end p.escaper(codelite.esc) _p(3, '') else diff --git a/modules/codelite/tests/test_codelite_config.lua b/modules/codelite/tests/test_codelite_config.lua index 2129c80d6e..cc7ec8247c 100644 --- a/modules/codelite/tests/test_codelite_config.lua +++ b/modules/codelite/tests/test_codelite_config.lua @@ -340,6 +340,31 @@ cmd2 ]] end + function suite.OnProjectCfg_PreLinkAfterPreBuild() + prebuildmessage "msg_prebuild" + prebuildcommands { + "cmd_prebuild1", + "cmd_prebuild2" + } + prelinkmessage "msg_prelink" + prelinkcommands { + "cmd_prelink1", + "cmd_prelink2" + } + prepare() + codelite.project.preBuild(prj) + test.capture [[ + + @echo "msg_prebuild" + cmd_prebuild1 + cmd_prebuild2 + @echo "msg_prelink" + cmd_prelink1 + cmd_prelink2 + + ]] + end + function suite.OnProjectCfg_PostBuild() postbuildcommands { "cmd0", "cmd1" } prepare() diff --git a/website/docs/prelinkcommands.md b/website/docs/prelinkcommands.md index c3d70db922..cef577d10c 100644 --- a/website/docs/prelinkcommands.md +++ b/website/docs/prelinkcommands.md @@ -1,4 +1,4 @@ -Specifies shell commands to run after the source files have been compiled, but before the link step. +Specifies shell commands to run after the source files have been compiled, but before the link step (if unsupported by the action, it will be treated the same as [prebuildcommands](prebuildcommands.md)). ```lua prelinkcommands { "commands" } @@ -19,14 +19,12 @@ Premake 4.4 or later. ### Examples ### ```lua -filter { "system:windows" } - prelinkcommands { "copy default.config bin\\project.config" } - -filter { "not system:windows" } - prelinkcommands { "cp default.config bin/project.config" } +prelinkcommands { "{COPYFILE} default.config bin/project.config" } ``` ### See Also ### + * [prelinkmessage](prelinkmessage.md) * [prebuildcommands](prebuildcommands.md) * [postbuildcommands](postbuildcommands.md) + * [Tokens](Tokens.md)