Skip to content

Commit

Permalink
Add support of prelink steps (similar to prebuild steps) for Codelite.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarod42 committed Mar 23, 2024
1 parent d1f2f0a commit c695d8a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
13 changes: 12 additions & 1 deletion modules/codelite/codelite_project.lua
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,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, '<PreBuild>')
p.escaper(codelite.escElementText)
if cfg.prebuildmessage then
Expand All @@ -336,6 +336,17 @@
for _, command in ipairs(commands) do
_x(4, '<Command Enabled="yes">%s</Command>', 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, '<Command Enabled="yes">%s</Command>', command)
end
local commands = os.translateCommandsAndPaths(cfg.prelinkcommands, cfg.project.basedir, cfg.project.location)
for _, command in ipairs(commands) do
_x(4, '<Command Enabled="yes">%s</Command>', command)
end
p.escaper(codelite.esc)
_p(3, '</PreBuild>')
else
Expand Down
25 changes: 25 additions & 0 deletions modules/codelite/tests/test_codelite_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,31 @@ cmd2</StartupCommands>
]]
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 [[
<PreBuild>
<Command Enabled="yes">@echo "msg_prebuild"</Command>
<Command Enabled="yes">cmd_prebuild1</Command>
<Command Enabled="yes">cmd_prebuild2</Command>
<Command Enabled="yes">@echo "msg_prelink"</Command>
<Command Enabled="yes">cmd_prelink1</Command>
<Command Enabled="yes">cmd_prelink2</Command>
</PreBuild>
]]
end

function suite.OnProjectCfg_PostBuild()
postbuildcommands { "cmd0", "cmd1" }
prepare()
Expand Down
6 changes: 4 additions & 2 deletions website/docs/prelinkcommands.md
Original file line number Diff line number Diff line change
@@ -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" }
Expand All @@ -19,11 +19,13 @@ Premake 4.4 or later.
### Examples ###

```lua
prelinkcommands { "{COPY} %[default.config] %[bin/project.config]" }
prelinkcommands { "{COPYFILE} %[default.config] %[bin/project.config]" }
```

### See Also ###

* [Tokens](Tokens.md)
* [prelinkmessage](prelinkmessage.md)
* [prebuildcommands](prebuildcommands.md)
* [postbuildcommands](postbuildcommands.md)
* [Tokens](Tokens.md)

0 comments on commit c695d8a

Please sign in to comment.