[cmake-developers] Custom commands with Ninja on Windows
Martin Ankerl
martin.ankerl at gmail.com
Mon May 23 06:48:47 EDT 2016
Thanks for the feedback!
Here is an updated patch that uses a hash as filename, .cmd as extension,
boolean argument, and some error checks.
Martin
On Fri, May 20, 2016 at 3:40 PM Brad King <brad.king at kitware.com> wrote:
> On 05/20/2016 03:41 AM, Martin Ankerl wrote:
> > From what I have understood it seems more safe to use .bat and not
> > .cmd, because the behavior of the errorlevel is different. From
> >
> http://waynes-world-it.blogspot.co.at/2008/08/difference-between-bat-and-cmd.html
> :
> >
> >> The differences between .CMD and .BAT as far as CMD.EXE is concerned
> are:
> >> With extensions enabled, PATH/APPEND/PROMPT/SET/ASSOC in .CMD files
> will set
> >> ERRORLEVEL regardless of error. .BAT sets ERRORLEVEL only on errors.
>
> I read that to mean the opposite: cmd is better than bat because it will
> always set ERRORLEVEL even if it is to zero, so one can reliably determine
> whether a command worked (Git's wrapper on windows is git.cmd and not
> git.bat).
>
> > I've created a first attempt of this implementation, please see the
> attached
> > patch.
>
> Good start.
>
> > + // TODO fail if command is too long and no file specified
>
> Several of the call sites of BuildCommandLine are constructing
> commands using ninja's $VAR reference/placeholder syntax. For
> these call sites it is never safe to use a separate cmdFile.
> Fortunately they tend to be for compiler/linker invocations
> that can use the normal RSP_FILE approach.
>
> Instead of adding a cmdFile argument to BuildCommandLine, add
> a boolean (or enum) to indicate whether the commands hold any
> placeholders. Only when no placeholders are used is it safe to
> activate the new behavior. When activated, I think it is
> cleaner to use a hash of the command line as the cmdFile name.
> That way when the command changes Ninja will be aware of the
> change and re-run it.
>
> Thanks,
> -Brad
>
> --
Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20160523/b8396534/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Support-for-many-custom-commands-in-Windows.patch
Type: application/octet-stream
Size: 5188 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20160523/b8396534/attachment.obj>
More information about the cmake-developers
mailing list