From de0771a4b3d882161f10c1d2d03c8027327f9323 Mon Sep 17 00:00:00 2001 From: Hans Bolinder Date: Thu, 4 Jan 2018 16:54:22 +0100 Subject: stdlib: Let filelib:find_source() search subdirs The Design Principles states that an application can have Erlang source files one level below the "src" directory, and now filelib:find_source() by default searches one level below "src". The same applies to "esrc". That directory is only mentioned in filename(3). --- lib/stdlib/doc/src/filelib.xml | 4 ++-- lib/stdlib/doc/src/filename.xml | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) (limited to 'lib/stdlib/doc/src') diff --git a/lib/stdlib/doc/src/filelib.xml b/lib/stdlib/doc/src/filelib.xml index 80c4acffdb..11762a3c5a 100644 --- a/lib/stdlib/doc/src/filelib.xml +++ b/lib/stdlib/doc/src/filelib.xml @@ -4,7 +4,7 @@
- 20032017 + 20032018 Ericsson AB. All Rights Reserved. @@ -267,7 +267,7 @@ filelib:wildcard("lib/**/*.{erl,hrl}") for a file with the extension .beam, the default rule is to look for a file with a corresponding extension .erl by replacing the suffix "ebin" of the object directory path with - "src". + "src" or "src/*". The file search is done through find_file/3. The directory of the object file is always tried before any other directory specified diff --git a/lib/stdlib/doc/src/filename.xml b/lib/stdlib/doc/src/filename.xml index 14fd5ef787..1135a6dd80 100644 --- a/lib/stdlib/doc/src/filename.xml +++ b/lib/stdlib/doc/src/filename.xml @@ -4,7 +4,7 @@
- 19972017 + 19972018 Ericsson AB. All Rights Reserved. @@ -372,15 +372,18 @@ true tuples {BinSuffix, SourceSuffix} and is interpreted as follows: if the end of the directory name where the object is located matches BinSuffix, then the - source code directory has the same name, but with - BinSuffix replaced by - SourceSuffix. Rules defaults + name created by replacing BinSuffix with + SourceSuffix is expanded by calling + + filelib:wildcard/1. + If a regular file is found among the matches, the function + returns that location together with Options. + Otherwise the next rule is tried, and so on.

+

Rules defaults to:

-[{"", ""}, {"ebin", "src"}, {"ebin", "esrc"}] -

If the source file is found in the resulting directory, the function - returns that location together with Options. - Otherwise the next rule is tried, and so on.

+[{"", ""}, {"ebin", "src"}, {"ebin", "esrc"}, + {"ebin", "src/*"}, {"ebin", "esrc/*"}]

The function returns {SourceFile, Options} if it succeeds. SourceFile is the absolute path to the source -- cgit v1.2.3