Closed Spirrwell closed 5 years ago
Are you using alpha12 or latest master? I'm fairly certain that there was a fix for this, but it was after alpha12 was released.
I was using alpha12, however, I just went ahead and built premake from master and I got the same result.
This particular function is used to escape the build commands, but the &
escaping is going to break all the others. I wonder if modifying this would resolve the problem, in your premake5.lua
can you add the following and let me know if that resolves the issue?
require "codelite"
premake.override(premake.modules.codelite, "esc", function(oldfn, value)
local result = value:gsub('&', '&')
result = result:gsub('"', '\\"')
result = result:gsub('<', '<')
result = result:gsub('>', '>')
return result
end)
If that doesn't resolve the issue, it could be that the build commands aren't supposed to be escaped?
Almost I'm still left with the \"
Ok, so looks like the build commands shouldn't have the escaped characters at all. These two functions just need to have the p.esc(command)
replaced with command
. To get it working for you locally, you can replace the previous overload with:
require "codelite"
premake.override(premake.modules.codelite.project, "postBuild", function(oldfn, cfg)
if #cfg.postbuildcommands > 0 then
_p(3, '<PostBuild>')
local commands = os.translateCommandsAndPaths(cfg.postbuildcommands, cfg.project.basedir, cfg.project.location)
for _, command in ipairs(commands) do
_x(4, '<Command Enabled="yes">%s</Command>', command)
end
_p(3, '</PostBuild>')
end
end)
Still has \"
Strange, just to confirm you grabbed my edited version? I originally forgot to remove the p.esc
call and edited the post. I can't see why it would do the escaping otherwise, but I'm not overly familiar with the CodeLite module so I might just be overlooking something.
Yeah, before you edited, it simply failed to generate the projects, but I got what you meant when you said to replace p.esc(command) with just command
But yeah, it doesn't appear to be working.
This is what it looks like in the .project file with the override in place:
And here is what it looks like if I manually edit the postbuild command in codelite myself:
require "codelite"
premake.override(premake.modules.codelite, "esc", function(oldfn, value)
return value
end)
So, this does work. I don't know why. Based on what I'm seeing, this should be the same functionality as passing in "command" raw like you were doing in the postbuild override.
All I'm doing is returning the value passed in through p.esc()
Oh it's part of the _x
function. Changing from _x
to _p
might do the trick. I believe we're replacing the _x
and _p
functions with p.x
and p.w
, so it looks like there's quite a bit of work to be done within the CodeLite module.
Ah yes,
require "codelite"
premake.override(premake.modules.codelite.project, "postBuild", function(oldfn, cfg)
if #cfg.postbuildcommands > 0 then
_p(3, '<PostBuild>')
local commands = os.translateCommandsAndPaths(cfg.postbuildcommands, cfg.project.basedir, cfg.project.location)
for _, command in ipairs(commands) do
_p(4, '<Command Enabled="yes">%s</Command>', command)
end
_p(3, '</PostBuild>')
end
end)
This does work.
Hey @Spirrwell,
(Side note, I know there's probably a better way to copy the file in a more platform independent way, so if somebody wants to chime in on that, please do)
Here is how you can do this with tokens:
postbuildcommands { "cp \"%{cfg.targetdir}/%{cfg.targetprefix}%{cfg.targetname}%{cfg.targetextension}\" \"../lib/shared/%{cfg.platform:lower()}/%{cfg.buildcfg:lower()}\"" }
EDIT: Just some extra information
CodeLite Version 12.0.8 Linux Distro: Linux Mint 19 MATE x64 Tested with premake alpha 12 AND tested with premake built from master
Hello there!
So, when using gmake with premake, my post build commands to copy files and whatnot work totally fine. However, with CodeLite, it seems the formatting of the command gets a little garbled.
Fair warning, I have not built the latest premake myself, I got the latest release binary for premake5 a few days ago.
But yeah, I have post build commands that are setup like this:
filter { "platforms:Linux64", "configurations:Release" } postbuildcommands { "cp \"%{cfg.targetdir}/%{cfg.targetprefix}%{cfg.targetname}%{cfg.targetextension}\" \"../lib/shared/linux64/release\"" }
(Side note, I know there's probably a better way to copy the file in a more platform independent way, so if somebody wants to chime in on that, please do)
In CodeLite, the command ends up looking like it does in the screenshot posted.
Is there any way to fix this?