Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request: new environment variable NINJA_OPTIONS (or NINJA_FLAGS) #797

Closed
urkle opened this issue Jul 21, 2014 · 11 comments
Closed

request: new environment variable NINJA_OPTIONS (or NINJA_FLAGS) #797

urkle opened this issue Jul 21, 2014 · 11 comments

Comments

@urkle
Copy link

urkle commented Jul 21, 2014

This would allow global user-override parameters such as specifying -j#

e.g.

export NINJA_OPTIONS=-j6

would force all builds to be run with -j6 instead of the default. (unless overridden on the commandline of a particular execution of ninja).

@nico
Copy link
Collaborator

nico commented Jul 22, 2014

What's the use-case for this?

@urkle
Copy link
Author

urkle commented Jul 22, 2014

the default value for -j is too high on my system (# cores + 2) and makes the UI completely unresponsive if I'm doing active work while compiling code.. So I would prefer to have the ability to set a default value that is lower. So the ability to set it in an environment variable per-system would allow greater flexibility.

@nico
Copy link
Collaborator

nico commented Jul 22, 2014

What number do you use ? Just # cores? How many cores do you have?

Wouldn't it be better to just pick a better default for -j? Then it'd just work for everyone, without everyone having to set some option.

@urkle
Copy link
Author

urkle commented Jul 22, 2014

I have 8 cores in my system.. and -j10 (the default) just kills the system too much making it unusable. Doing simply # of cores would also probably be a better default. However, I would like to set things at -j4 by default as I usually run more than one compile at a time. (multiple archs usually, or just different variations on a build.. e.g. regular or steam enabled, debug or release)..

@evmar
Copy link
Collaborator

evmar commented Jul 22, 2014

What platform are you on? I wonder if there are OS-related causes. (In principle your UI shouldn't lag no matter how much is going on, but in practice scheduling is hard.)

@urkle
Copy link
Author

urkle commented Jul 22, 2014

It's a linux system.

@DemiMarie
Copy link
Contributor

Try nicing the Ninja command -- this will lower the priority of it and the processes it spawns.

@afbjorklund
Copy link

Why not just use $NINJAFLAGS ? Then it could fit both of -j and -l, just like with $MAKEFLAGS.

nicolasdespres added a commit to nicolasdespres/ninja that referenced this issue Dec 20, 2015
When ninja invokes ninja (for instance when building a sub-project) it
is useful to have a way to control the flags used by the sub-ninja
process. If I pass '-d explain' or '-v' when starting
ninja from the command line on the top project, I expect these flags
to be forwarded to the sub-ninja process.

Note that this patch has limited parsing capabilities of the
NINJA_FLAGS environment variables but that should be enough for our
use case.

Fixes ninja-build#797, ninja-build#922 and ninja-build#816.
@evmar
Copy link
Collaborator

evmar commented Jan 1, 2018

See #1370 about adding environment variables.

@martong
Copy link

martong commented Jan 21, 2019

Just ran into this and saw that the pull request for NINJA_FLAGS was not accepted. For those who still seek a solution ... this idea helped in my case (together with zsh): alias ninja="ninja -j48 "

@eli-schwartz
Copy link

The independent Ninja build language reimplementation https://github.com/michaelforney/samurai supports this via the environment variable SAMUFLAGS. Simply use samu anywhere you'd otherwise use ninja, or install samu as your system /usr/bin/ninja (some linux distros have options to install this competing implementation as the default, or only, ninja).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants