Skip to content

Conversation

Attempt3035
Copy link
Contributor

Adjusting the symlink prefix is useful both for organisation (putting in a subdirectory) as well as performance in some IDEs. This is an experimental feature that uses a thorough regex search and replace on each compiler parameter to update paths matching the symlink prefix.

This applies to the commands before they go through the compiler stages, hence everything else in the script including caching etc works seamlessly. There are minor changes to the automated symlink creation and detection function.

Regex Assumptions:

  1. bazel-out and external are the only simlinks used in compile_commands.json
  2. These paths only appear at the begining of a string (ie "bazel-out/.. "-Ibazel-out/... etc) or after an argument's = in a string (ie -frandom-seed=bazel-out/...)
  3. In the case of a direct prefix to the path (ie -I), it will always begin with at least one - or / (MSVC) and be followed by only alphanumeric characters, - and _ up until the bazel-out/ or external/ section
  4. Optionally, an = will be matched before the path

Full Regex for testing: ^(?P(?:[-/][a-zA-Z0-9-_]+)?=?)(?Pbazel-out|external)/

Known considerations:
Doesn't attempt to deal with flags which contain multiple comma deliniated values after =, ie "--extract-api-ignores=foo,external/bar,baz"
In order to deal with flags like this, we'd need to be able to tell whether the comma is part of the path or separating paths. So far I haven't come across any flags like this, and presumably they'd be split up into multiple flags by default unless it was a user custom added one. Cross that bridge when we get to it.

TODO:
Windows should work but needs testing

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

Successfully merging this pull request may close these issues.

1 participant