[cmake-developers] Ninja generator on Windows

Peter Collingbourne peter at pcc.me.uk
Wed Feb 1 15:04:51 EST 2012


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).

Thanks,
-- 
Peter



More information about the cmake-developers mailing list