Improve variable handling when rebuilding build.ninja

Variables which are not referencing other variables are no longer provided with their literal value. Variables which do reference other variables have the reference escaped, so that ninja won’t expand the reference when rebuilding build.ninja.

There is still some redundancy in that APP_VERSION has the major + tag part stated both at the top and as a command line argument, haven’t yet figured out how to best deal with this.
This commit is contained in:
Allan Odgaard
2013-04-11 10:24:47 +07:00
parent be83c7d91d
commit 610624ca5a

View File

@@ -668,7 +668,7 @@ open("#{builddir}/build.ninja", "w") do |io|
io << user_variables.map { |arr| format("%-#{width}s = %s\n", *arr) }
io << "\n"
args = variables.map { |key, value| "-d'#{key}=#{key =~ /APP_\w+/ ? "$#$&" : value.gsub(/\$/, '$\&')}'" }.join(' ')
args = variables.map { |key, value| "-d'#{key}=#{value =~ /\$/ ? value.gsub(/\$/, '$$') : "$#{key}"}'" }.join(' ')
io << "rule configure\n"
io << " command = bin/gen_build -C \"$builddir\" #{args} -o $out $in\n"
io << " depfile = $builddir/$out.d\n"