Search code examples
buildenvironment-variablesninja

Is there a way to use environment variables with Ninja?


I have the following ninja file because I could not find a way to pass environment variables to ninja steps:

rule init
 command = sh init.sh

rule plan
 command = sh plan.sh

rule apply
 command = sh apply.sh


build plan: plan
build init: init
build apply: apply

default plan

I would like to skip using shell scripts and capture all the steps in Ninja. I am not sure if this is supported at all.


Solution

  • It is a design decision of Ninja not to do that. If you need to pass in any parameter to Ninja the supported way to generate the build file with a build generator.