diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2017-02-24 08:08:46 -0500 |
---|---|---|
committer | Fred Hebert <mononcqc@ferd.ca> | 2017-02-24 08:08:46 -0500 |
commit | ab1f93d6fa712c3b85bce30cab09edb5ddf7f3d9 (patch) | |
tree | 4ca77dcd8bb2529ce4ea9a12651b3c0db7c5fa8b /src | |
parent | 1810ae30abdddc95dc93d96f5c9d0f27182f0e62 (diff) |
Fix default .app.src file for rebar_app_info
The finding of the file was done based on an assumed 'src' path which
may not be correct. This patch instead replaces the value with a lookup
in configured paths and returns the first that matches to an existing
file.
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_app_info.erl | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/rebar_app_info.erl b/src/rebar_app_info.erl index fdaadb8..62ec6dd 100644 --- a/src/rebar_app_info.erl +++ b/src/rebar_app_info.erl @@ -248,13 +248,12 @@ set(AppInfo=#app_info_t{opts=Opts}, Key, Value) -> %% @doc finds the .app.src file for an app, if any. -spec app_file_src(t()) -> file:filename_all() | undefined. -app_file_src(#app_info_t{app_file_src=undefined, dir=Dir, name=Name}) -> - AppFileSrc = filename:join([ec_cnv:to_list(Dir), "src", ec_cnv:to_list(Name)++".app.src"]), - case filelib:is_file(AppFileSrc) of - true -> - AppFileSrc; - false -> - undefined +app_file_src(#app_info_t{app_file_src=undefined, dir=Dir, name=Name, opts=Opts}) -> + CandidatePaths = [filename:join([ec_cnv:to_list(Dir), Src, ec_cnv:to_list(Name)++".app.src"]) + || Src <- rebar_opts:get(Opts, src_dirs, ["src"])], + case lists:dropwhile(fun(Path) -> not filelib:is_file(Path) end, CandidatePaths) of + [] -> undefined; + [AppFileSrc|_] -> AppFileSrc end; app_file_src(#app_info_t{app_file_src=AppFileSrc}) -> ec_cnv:to_list(AppFileSrc). |