-
Notifications
You must be signed in to change notification settings - Fork 26
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
Path expansion in builds doesn't take take build variables in context #39
Comments
For what it's worth, this was one of the two issues I faced in our build when trying to switch over to n2 from ninja. Our build generator would define things like $builddir at the top of build.ninja, and then in individual build steps, it would use variables that made use of them, eg out_dir = $builddir/some/path. |
Dang, that's a pretty strong argument that we ought to fix this. Unfortunately it will likely end up fairly costly. :( n2 is very aggressive about trying to do work incrementally to avoid needing to buffer stuff while parsing... |
Might be worth waiting around to see if anyone else hits this - it was fairly easy to work around in our case, and we may be an outlier. Doing a couple of string replacements in the build generator does seem to make more sense that pushing the work to build time. |
Rereading this, I think this ought to be something that currently does work with n2. The specific issue here is instead about how in some (rare) cases Ninja variable expansion refers to a variable that it defined textually below where it's referenced, while n2 expands things roughly top-down. So I think that doesn't describe what you encountered. |
I might be missing something. Here's an example:
This fails with:
|
Thanks, opened #83 about this one. |
(And now fixed, maybe.) |
Can confirm that's fixed it - thank you! |
This fixes an incompatibility with ninja. I've also refactored Env to make it clearer and remove the TODO(evmar#83), but I actually think we could do signifigant further cleanup. Only rules should require EvalStrings, global variables and build bindings can be evaluated as soon as they're read, although maybe that would change with subninjas. Also, rules currently parse their variables as EvalString<String>, but I think that could be changed to EvalString<&'text str> if we hold onto the byte buffers of all the included files until the parsing is done. Fixes evmar#91, and evmar#39.
This fixes an incompatibility with ninja. I've also refactored Env to make it clearer and remove the TODO(evmar#83), but I actually think we could do signifigant further cleanup. Only rules should require EvalStrings, global variables and build bindings can be evaluated as soon as they're read, although maybe that would change with subninjas. Also, rules currently parse their variables as EvalString<String>, but I think that could be changed to EvalString<&'text str> if we hold onto the byte buffers of all the included files until the parsing is done. Fixes evmar#91 and evmar#39.
This fixes an incompatibility with ninja. I've also refactored Env to make it clearer and remove the TODO(evmar#83), but I actually think we could do signifigant further cleanup. Only rules should require EvalStrings, global variables and build bindings can be evaluated as soon as they're read, although maybe that would change with subninjas. Also, rules currently parse their variables as EvalString<String>, but I think that could be changed to EvalString<&'text str> if we hold onto the byte buffers of all the included files until the parsing is done. Fixes evmar#91 and evmar#39.
This fixes an incompatibility with ninja. I've also refactored Env to make it clearer and remove the TODO(evmar#83), but I actually think we could do signifigant further cleanup. Only rules should require EvalStrings, global variables and build bindings can be evaluated as soon as they're read, although maybe that would change with subninjas. Also, rules currently parse their variables as EvalString<String>, but I think that could be changed to EvalString<&'text str> if we hold onto the byte buffers of all the included files until the parsing is done. Fixes evmar#91 and evmar#39.
This fixes an incompatibility with ninja. I've also refactored Env to make it clearer and remove the TODO(evmar#83), but I actually think we could do signifigant further cleanup. Only rules should require EvalStrings, global variables and build bindings can be evaluated as soon as they're read, although maybe that would change with subninjas. Also, rules currently parse their variables as EvalString<String>, but I think that could be changed to EvalString<&'text str> if we hold onto the byte buffers of all the included files until the parsing is done. Fixes evmar#91 and evmar#39.
This fixes an incompatibility with ninja. I've also refactored Env to make it clearer and remove the TODO(evmar#83), but I actually think we could do signifigant further cleanup. Only rules should require EvalStrings, global variables and build bindings can be evaluated as soon as they're read, although maybe that would change with subninjas. Also, rules currently parse their variables as EvalString<String>, but I think that could be changed to EvalString<&'text str> if we hold onto the byte buffers of all the included files until the parsing is done. Fixes evmar#91 and evmar#39.
This fixes an incompatibility with ninja. I've also refactored Env to make it clearer and remove the TODO(evmar#83), but I actually think we could do signifigant further cleanup. Only rules should require EvalStrings, global variables and build bindings can be evaluated as soon as they're read, although maybe that would change with subninjas. Also, rules currently parse their variables as EvalString<String>, but I think that could be changed to EvalString<&'text str> if we hold onto the byte buffers of all the included files until the parsing is done. Fixes evmar#91 and evmar#39.
This fixes an incompatibility with ninja. I've also moved a bunch of variable evaluations out of the parser and into the loader, in preparation for parsing the build file in multiple threads, and then only doing the evaluations after all the chunks of the file have been parsed. Fixes evmar#91 and evmar#39.
This fixes an incompatibility with ninja. I've also moved a bunch of variable evaluations out of the parser and into the loader, in preparation for parsing the build file in multiple threads, and then only doing the evaluations after all the chunks of the file have been parsed. Fixes evmar#91 and evmar#39.
This fixes an incompatibility with ninja. I've also moved a bunch of variable evaluations out of the parser and into the loader, in preparation for parsing the build file in multiple threads, and then only doing the evaluations after all the chunks of the file have been parsed. Fixes evmar#91 and evmar#39.
This fixes an incompatibility with ninja. I've also moved a bunch of variable evaluations out of the parser and into the loader, in preparation for parsing the build file in multiple threads, and then only doing the evaluations after all the chunks of the file have been parsed. Fixes evmar#91 and evmar#39.
This fixes an incompatibility with ninja. I've also moved a bunch of variable evaluations out of the parser and into the loader, in preparation for parsing the build file in multiple threads, and then only doing the evaluations after all the chunks of the file have been parsed. Fixes evmar#91 and evmar#39.
This should be completed as of #94 |
In Ninja, the below refers to the file
foo.3
.In n2 this doesn't. n2 aggressively expands variables while parsing, which is to say that in the above it never even generates intermediate data like the parse of
foo.$bar
, but rather expands$bar
right as it sees it and then interns the path, and even reuses that buffer to parse/canonicalize the next path.This is fixable but I'm kinda hesitant. To implement the Ninja behavior we'd instead need to build up an array of all the paths and then expand them once we've parsed through the variables. (Edit: another possibly costlier idea, we could skip forward to the variables, parse them, then go back and parse the paths again.)
The fact that builds seem to currently work suggests that maybe existing projects don't depend on this?
The text was updated successfully, but these errors were encountered: