[Scons-users] Testing ninja build generator

Julien Pommier pommier at pianoteq.com
Fri Jun 6 09:53:30 EDT 2025


On 6 Jun 2025, at 14:11, Mats Wichmann <mats at wichmann.us> wrote:
> 
> That's a List Action. A bug in the ninja tool's handling of list actions was just fixed, I wonder if it would help your case. If you feel adventurous, could you try the current version of the Utils module?
> 
> https://github.com/SCons/scons/blob/master/SCons/Tool/ninja_tool/Utils.py
> 

Unfortunately it fails in the same way

> 
> If the data is encoded as a URL, that would be correct - can't use a space.  Sounds like those ought to be escaped somewhere.  Of course spaces in filenames are evil anyway :-)
> 
> Do you have a slightly more complete testcase you can share?

I can’t completely avoid spaces unfortunately, I have to build a few files with spaces in their names.

So I tried to escape the url in ninja_deamon_build.py with

  from urllib.parse import quote
  conn.request("GET", "/?build=" + quote(sys.argv[3]))

instead of

  conn.request("GET", "/?build=" + sys.argv[3])

at ninja_deamon_build.py:80. 

But there is another failure later where scons complains that the target ‘run’ (instead of ‘run me.sh’) does not exist.

I don’t really have a larger testcase to share, but here is a self-contained SConstruct that reproduces the 3 ninja issues I have currently encountered (the only one for which I don’t have a workaround being the spaces issue):


if int(ARGUMENTS.get('ninja', 1)) != 0:
    SetOption('experimental', 'ninja')

env = Environment(tools=['default', 'ninja'])


run_sh_txt = env.Textfile('run.sh.txt', 'echo "hi there"')

# issue 1 : Action list fails with ninja builder
runner1 = env.Command("run1.sh", run_sh_txt, [ Copy("$TARGET", "$SOURCE"), Chmod("$TARGET", 0o755) ]);

# issue 2 : Whitespace in target failed with ninja builder
runner2 = env.Textfile("run me.sh", "COUCOUCOU");

# issue 3 : with regular scons I have to quote the '<stdio.h>’ when putting it in CPPDEFINES , while with ninja builder I have to unquote it
test_c = env.Textfile('test.c', '#include FOO\nint main() { return 0; }\n')
env.Append(CPPDEFINES={'FOO':"'<stdio.h>'"})
env.Program('test', test_c)



More information about the Scons-users mailing list