Rules with scripts on Windows

55 views
Skip to first unread message

Ildus K

unread,
Jan 24, 2025, 12:41:28 PMJan 24
to ninja-build
Hi all,
currently I am writing ninja generator for Jam build system (https://en.wikipedia.org/wiki/Perforce_Jam). I have some  projects using it and there is not much flexibility from my side.

The working version for Linux (Unix) - https://github.com/ildus/jamp

Currently I'm trying to adapt it to Windows too.
The problem is the jam configuration of these projects uses multiple raw multiline commands (like in .bat), and ninja uses CreateProcess for Windows.
For example:

Rule one
{
     MakeSomething $(<) ;
}
actions MakeSomething
{
     set VAR=1
     if exist $(<) touch $(<:D)/*$(<:S)
     some_cmd
     ....
     etc
}

These commands could be quite long.
The question is what's the best way for creating rules for something like this.
Only way that I can think right now is using rspfiles. `rspfile_content` will contain the script, rspfile=one.bat, and the command like  'cmd /c one.bat' will run it.
For linux I join the commands to one big one liner and that approach works well. But it's
not possible with Windows because of limitations.

From this a new question arises, is it possible to add an escape sequence like $\n but which will write real '\n' to the file, so I don't need to create one liners.

Evan Martin

unread,
Jan 24, 2025, 1:28:05 PMJan 24
to Ildus K, ninja-build
Could your build generator generate a .bat file itself?

--
You received this message because you are subscribed to the Google Groups "ninja-build" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ninja-build...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/ninja-build/35d95bc2-19aa-4060-b77b-29572cadef17n%40googlegroups.com.

Ildus K

unread,
Jan 24, 2025, 1:43:48 PMJan 24
to ninja-build

Yeah, that is possible.
But probably if I create one big bat file (with a parameter like some rule name), it will take too long to load.
And I would like to avoid creating too many bat files too.
Also with rspfile ninja creates and removes it. No need to manage these temporary files.
Reply all
Reply to author
Forward
0 new messages