Working directories are now set seperately from the commands so they
can later be swapped out when running linters over projects is
supported, and also better support filename mapping for running linters
on other machines in future.
ALE now converts paths from compile_commands.json files into absolute
paths and prefers matching against absolute file and directory names for
determining which flags to use for files. As a result, parsing
compile_commands.json to determine flags should work for a lot more C
and C++ projects.
* Parse CFLAGS that can be passed using a whitelist
I went through GCC's man page and selected flags that can safely be
passed to GCC and that can be useful to syntax checking. These include:
- -I/-i* include flags
- preprocessor flags such as -D
- -W* warning flags
- -O* optimization flags
- most -f options
- -m arch dependent options
* Fix CFLAGS tests: -Idir is now parsed to -I dir
* Added two tests for flags we want or don't want to pass.
* Also check for / in addition to s:sep
When using a compilation database (compile_commands.json) in very large
projects, significant delays would occur when changing files --
particularly those that happened to be far down the db. Rather than
iterating over the whole list every time, we now build up a lookup table
based on the tail of the filename (and tail of the directory for
widening searches) and iterate over the much smaller list of compile
commands for files with the given name.
Test metrics (from compile_database_perf/test.sh) show a 90% performance
improvement -- from 25 seconds to 2.5 seconds per run.
There is currently a check that tries to prevent c-flags that contain
'-' in them from being unintentionally split and included in the list of
commands. For example, we wouldn't want "-fno-exceptions " to appear as
"-fno" and "-exceptions ". The way this check was done was by making sure
the last character of the split string was a space.
This meant that the very last option to appear in the compile command
was ignored (as it doesn't end with a space). This fix explicitly skips
the ends-with-space check on the last option in the command-line.
This isn't the best fix. Really we should be using the same
argument-processing rules as a shell would rather than just splitting on
'-'. That's a much larger and more complicated change though.