michaelforney/samurai

When accessing $rspfile and $depfile for internal use, use unescaped $in and $out

Closed this issue · 0 comments

Normally, when variables containing $in or $out are expanded, the paths are escaped for the shell. However, in a couple cases ($rspfile and $depfile), we access the resulting path directly (removal in tool.c:clean and build.c:edgedone, parsing in deps.c:depsload, or initial creation in build.c:jobstart) and need the unescaped version.

Some ideas:

  • Keep track of both escaped and unescaped expansions in environments. When expanding a variable, if any variable references have different escaped and unescaped versions, produce an expansion for both versions, otherwise just set both versions to the same value to avoid any extra work.
  • Distinguish between edge variables and cached expansions of rule variables (separate map?), and disable the cached expansions when looking up the unescaped version of variables.