[cmake-developers] Custom commands with Ninja on Windows

Martin Ankerl martin.ankerl at gmail.com
Fri May 20 03:41:27 EDT 2016


>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've created a first attempt of this implementation, please see the
attached patch. It seems to do the trick for my test case, but I couldn't
test it well because unfortunately I've run into a different unrelated
problem: the slashes for the DEP_FILE are in the git version / instead of \
which makes the ninja build fail. This was not the case with version 3.5.2

Martin



On Thu, May 19, 2016 at 10:46 PM Brad King <brad.king at kitware.com> wrote:

> On 05/19/2016 04:31 PM, Martin Ankerl wrote:
> > I didn't think about just writing a .cmd (or .bat?) with cmake
>
> The ".cmd" extension is a modern version of ".bat".
>
> > that sounds like the simplest solution!
>
> Yes, assuming we never have a need for ninja placeholder substitution.
> Why are one-line response files generated by Ninja not a solution?
> Does cmd support them?
>
> > if %errorlevel% neq 0 exit /b %errorlevel%
>
> Yes.
>
> > I have no experience with cmake implementation though, how would you
> > find a name for the filename?
>
> First, it can be made conditional on when the command line is really long.
> Second, you could just put it in CMakeFiles/ and name it using a hash
> of its content (or of the list of outputs).  See Source/cmCryptoHash.h
> for example.
>
> Thanks,
> -Brad
>
> --
Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20160520/07b87a59/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: 3778 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20160520/07b87a59/attachment.obj>


More information about the cmake-developers mailing list