diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2015-07-27 09:39:20 +0100 |
---|---|---|
committer | Fred Hebert <mononcqc@ferd.ca> | 2015-07-27 09:39:20 +0100 |
commit | 7c46eea294ecce8338bee7e76a13a0390b7c5901 (patch) | |
tree | e34c6793fc2324d7011b91ace63c4138e63a9eca /src/rebar_app_discover.erl | |
parent | 8e5662147f59e52f9384b4daa7dd7c0345d126ef (diff) | |
parent | 806f7f9219b43b20f4ed23761019282235b32681 (diff) |
Merge pull request #654 from tsloughter/discover_script
include app.src.script in app discover
Diffstat (limited to 'src/rebar_app_discover.erl')
-rw-r--r-- | src/rebar_app_discover.erl | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/rebar_app_discover.erl b/src/rebar_app_discover.erl index 95b3273..a350235 100644 --- a/src/rebar_app_discover.erl +++ b/src/rebar_app_discover.erl @@ -102,13 +102,17 @@ app_dirs(LibDir) -> "*.app.src"]), Path2 = filename:join([LibDir, + "src", + "*.app.src.script"]), + + Path3 = filename:join([LibDir, "ebin", "*.app"]), lists:usort(lists:foldl(fun(Path, Acc) -> Files = filelib:wildcard(ec_cnv:to_list(Path)), [app_dir(File) || File <- Files] ++ Acc - end, [], [Path1, Path2])). + end, [], [Path1, Path2, Path3])). find_unbuilt_apps(LibDirs) -> find_apps(LibDirs, invalid). @@ -127,7 +131,8 @@ find_apps(LibDirs, Validate) -> find_app(AppDir, Validate) -> AppFile = filelib:wildcard(filename:join([AppDir, "ebin", "*.app"])), AppSrcFile = filelib:wildcard(filename:join([AppDir, "src", "*.app.src"])), - AppInfo = try_handle_app_file(AppFile, AppDir, AppSrcFile, Validate), + AppSrcScriptFile = filelib:wildcard(filename:join([AppDir, "src", "*.app.src.script"])), + AppInfo = try_handle_app_file(AppFile, AppDir, AppSrcFile, AppSrcScriptFile, Validate), AppInfo. app_dir(AppFile) -> @@ -158,9 +163,11 @@ dedup([H|T]) -> [H|dedup(T)]. %% Read in and parse the .app file if it is availabe. Do the same for %% the .app.src file if it exists. -try_handle_app_file([], AppDir, AppSrcFile, Validate) -> +try_handle_app_file([], AppDir, [], AppSrcScriptFile, Validate) -> + try_handle_app_src_file([], AppDir, AppSrcScriptFile, Validate); +try_handle_app_file([], AppDir, AppSrcFile, _, Validate) -> try_handle_app_src_file([], AppDir, AppSrcFile, Validate); -try_handle_app_file([File], AppDir, AppSrcFile, Validate) -> +try_handle_app_file([File], AppDir, AppSrcFile, _, Validate) -> try create_app_info(AppDir, File) of AppInfo -> AppInfo1 = rebar_app_info:app_file(AppInfo, File), @@ -195,7 +202,7 @@ try_handle_app_file([File], AppDir, AppSrcFile, Validate) -> ?DEBUG("Falling back to app.src file because .app failed: ~s", [Module:format_error(Reason)]), try_handle_app_src_file(File, AppDir, AppSrcFile, Validate) end; -try_handle_app_file(Other, _AppDir, _AppSrcFile, _Validate) -> +try_handle_app_file(Other, _AppDir, _AppSrcFile, _, _Validate) -> throw({error, {multiple_app_files, Other}}). %% Read in the .app.src file if we aren't looking for a valid (already built) app @@ -210,7 +217,12 @@ try_handle_app_src_file(_, AppDir, [File], Validate) when Validate =:= invalid {error, Reason} -> throw({error, {invalid_app_file, File, Reason}}); _ -> - {true, rebar_app_info:app_file_src(AppInfo, File)} + case filename:extension(File) of + ".script" -> + {true, rebar_app_info:app_file_src_script(AppInfo, File)}; + _ -> + {true, rebar_app_info:app_file_src(AppInfo, File)} + end end; try_handle_app_src_file(_, _AppDir, Other, _Validate) -> throw({error, {multiple_app_files, Other}}). |