Since process_attr/3 searches source code for attributes, it can
happen that it finds an attribute which is eventually not needed
by the compilation, e.g. hidden by ifdef macro - see enclosed test.
Such attribute can reference a file which is not in the path or
which even doesn't exist at all, and current code doesn't expect
such a situation. We fix things by simply ignoring such files.
These times already contain max modified info of their
dependencies. Therefore we no longer have to check in
internal_erl_compile whether the file really needs
recompiling, which simplifies the flow somewhat, because
the work with dependency graph is now localized to much
smaller space then before.
The precise algorithm is now following:
- Decide which files need to be compiled first (ErlFirstFiles).
- Split AllErlFiles which are not in ErlFirstFiles into two groups,
one consisting of files some other file depends on (DepErls)
and the rest (OtherErls).
- Final FirstErls are obtained as ErlFirstFiles (in original order)
plus toposorted DepErls. OtherErls are left as is since they can
be compiled in any (random) order.
Also create the erlcinfo graph as acyclic, since otherwise the
toposort could not work and we don't want to have cycles among
dependencies anyway.
Optimizing for best compression could be very slow for large
projects, so optimize rather for the speed. erlcinfo file
isn't that huge anyway and moreover difference between levels
2 and 9 isn't that big in practice (although there's quite big
difference between level 2 and no compression at all).
When the source file changes it could happen that some of its
dependecies get removed. In that case we should remove these
former dependencies from the graph, so that they don't influence
recompilation of the source file anymore.
Current separation of part of the logic into include_path
obscures the purpose of Dirs (see expand_file_names).
Moreover for each particular Erl its source file was included
twice in Dirs, which is now corrected.
Also InclDirs (specified in erl_opts) as part of erlcinfo
since they can affect resulting graph, which needs to be
therefore regenerated when InclDirs change. See added
test as an example.
As erlcinfo is only an internal optimization mechanism, user
should be only minimally bothered by issues with it. Especially
it shouldn't ever cause a fatal error and if it cannot be restored
properly, only a warning (not error) message should be emitted (if
any). Also it probably doesn't make sense for this warning message
to be too detailed - just state that something went wrong and
silently delete the erlcinfo file.
- enable running eunit and retest tests separately
- add neccessary dependencies to each test target so that
one can just do 'make test' without recompiling changed files
manually
- enable overwriting retest's log level
- use retest's own Makefile instead of invoking rebar manually
Expand test cases to handle .appup.src with
empty upgrade from and downgrade to lists, lift
larger .appup.src file from OTP's
lib/dialyzer/test/r9c_SUITE_data/src/asn1/asn1.appup.src
If I pass an expression like: "$PWD/deps/local/lib" in the port env
string, it expands to "/deps/local/lib", (variable is expanded to the
empty string) but if I pass "${PWD}/deps/local/lib" it expands
properly. I found that confusing.
This was because we require environment vars to end with whitespace,
while I think requiring a non-word character would be sufficient, since
the variables can only contain word characters.
This changes the expansion system to recognize variables that are
terminated by non word characters.
This includes some fixes as per some comments by tuncer.
Fixesrebar/rebar#457
Similar to how .app.src are being handled, all files in directory
.src ending with .appup.src are processed, checked for
correctness and copied to ebin without the .src extension.
By way of using rebar_config:consult_file/1, .appup.src.script
files are automatically supported in exactly the same manner
as in .app.src.script.
Remove possible last dot from deps dir path by calling
dirname on base_dir, deps_dir and dummy path part.
With this fix delete-deps command deletes dependencies
properly in case of deps dir path ended with dot.
Examples of deps_dir config value that triggers error:
".", "some/path/.".
Code that triggers error: rebar_deps:'delete-deps'/2,
code line lists:prefix(DepsDir, D#dep.dir).
If deps_dir = ".", cwd = "/root", dependency name = "app"
then DepsDir = "/root/." and D#dep.dir = "/root/app" so
prefix fun returns false but should be true.
Dependency app will not be removed because of this.