[cmake-developers] Ninja generator on Windows

Peter Kümmel syntheticpp at gmx.net
Wed Feb 1 15:54:34 EST 2012


On 01.02.2012 21:04, Peter Collingbourne wrote:
> On Tue, Jan 31, 2012 at 10:58:32PM +0000, Peter Collingbourne wrote:
>> On Tue, Jan 31, 2012 at 05:06:28PM -0500, Brad King wrote:
>>> On 1/31/2012 4:44 PM, Peter Kümmel wrote:
>>>> OK, thanks. I already noticed the usage of OutputFormat::SHELL.
>>>> Then I have to extend cmLocalGenerator by a Ninja case. It will be
>>>> similar to NMake but additionally replaces colons by '$:'.
>>>>
>>>> Should I add kwsysSystem_Shell_Flag_Ninja in System.h?
>>>
>>> Yes.  Unfortunately KWSys was not really the right place to have all
>>> the platform-specific shell escaping code, but it ended up that way
>>> historically.  Please keep any commits that touch KWSys mutually
>>> exclusive from commits that touch files outside KWSys.
>>
>> I disagree.  The escaping rules are already implemented correctly
>> and are only required in the specific case where a path name needs
>> to appear as a (lexicographical) identifier.  Also, it is impossible
>> to represent certain strings as identifiers without writing some
>> text beforehand.  For example, the generator will build things like
>> this for paths containing the '@' character:
>>
>> ident0 = a at b
>>
>> build foo: CUSTOM_COMMAND $ident0
>>    [...]
>>
>> Therefore, the best place to keep this code is in the part of the Ninja
>> generator that is responsible for writing rules/build statements to
>> a file.
>
> Having studied the situation a bit further, I think that
> kwsysSystem_Shell_Flag_Ninja should be used to request the Ninja
> encoding for variable values on top of the normal shell encoding
> scheme (the identifier encoding rules don't really fit into the
> existing scheme for shell encoding for the above reasons).  The only
> encoding required for Ninja variable values (on top of standard shell
> encoding) is to replace '$' by '$$' ('$' is the only special character
> in variable values).
>


Cleaned up the patch a bit.
https://github.com/syntheticpp/CMake/commit/c21b11ae8f6987b7f185e9f2c1a3714e3cc24091

It now builds a smaller project, but when I test it with CMake it breaks because
the command line passed to "cmd /c" is too long. Ninja first also used "cmd /s"
but then switched to the native CreateProcess call.

I don't know if it possible to pass multiple commands to a Win32 function.

Peter



More information about the cmake-developers mailing list