From ae9c83fb4bafd3f2faf849c931ba440053f5cb97 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Thu, 26 Feb 2015 09:11:59 -0600 Subject: copy project apps to deps output dir for compilation --- src/rebar_otp_app.erl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/rebar_otp_app.erl') diff --git a/src/rebar_otp_app.erl b/src/rebar_otp_app.erl index 49579ae..f55ac6e 100644 --- a/src/rebar_otp_app.erl +++ b/src/rebar_otp_app.erl @@ -40,12 +40,11 @@ compile(State, App) -> %% If we get an .app.src file, it needs to be pre-processed and %% written out as a ebin/*.app file. That resulting file will then %% be validated as usual. - Dir = ec_cnv:to_list(rebar_app_info:dir(App)), App1 = case rebar_app_info:app_file_src(App) of undefined -> App; AppFileSrc -> - File = preprocess(State, Dir, AppFileSrc), + File = preprocess(State, App, AppFileSrc), rebar_app_info:app_file(App, File) end, @@ -92,13 +91,14 @@ validate_app_modules(State, App, AppData) -> {ok, rebar_app_info:original_vsn(App, AppVsn)} end. -preprocess(State, Dir, AppSrcFile) -> +preprocess(State, AppInfo, AppSrcFile) -> case consult_app_file(AppSrcFile) of {ok, [{application, AppName, AppData}]} -> %% Look for a configuration file with vars we want to %% substitute. Note that we include the list of modules available in %% ebin/ and update the app data accordingly. - AppVars = load_app_vars(State) ++ [{modules, ebin_modules(Dir)}], + OutDir = rebar_app_info:out_dir(AppInfo), + AppVars = load_app_vars(State) ++ [{modules, ebin_modules(OutDir)}], A1 = apply_app_vars(AppVars, AppData), %% AppSrcFile may contain instructions for generating a vsn number @@ -113,7 +113,9 @@ preprocess(State, Dir, AppSrcFile) -> Spec = io_lib:format("~p.\n", [{application, AppName, A3}]), %% Setup file .app filename and write new contents - AppFile = rebar_app_utils:app_src_to_app(AppSrcFile), + EbinDir = rebar_app_info:ebin_dir(AppInfo), + filelib:ensure_dir(filename:join(EbinDir, "dummy.beam")), + AppFile = rebar_app_utils:app_src_to_app(OutDir, AppSrcFile), ok = rebar_file_utils:write_file_if_contents_differ(AppFile, Spec), %% Make certain that the ebin/ directory is available -- cgit v1.1 From a238bc24c678320c323dc57ca675ad19ad602d0e Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Fri, 27 Feb 2015 20:25:19 -0600 Subject: output proper error message for missing app file --- src/rebar_otp_app.erl | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/rebar_otp_app.erl') diff --git a/src/rebar_otp_app.erl b/src/rebar_otp_app.erl index f55ac6e..278d7e5 100644 --- a/src/rebar_otp_app.erl +++ b/src/rebar_otp_app.erl @@ -51,6 +51,8 @@ compile(State, App) -> %% Load the app file and validate it. validate_app(State, App1). +format_error(invalid_app_file) -> + "Failed to read app file"; format_error({file_read, File, Reason}) -> io_lib:format("Failed to read ~s for processing: ~p", [File, Reason]); format_error({invalid_name, File, AppName}) -> @@ -174,11 +176,16 @@ ensure_registered(AppData) -> %% config. However, in the case of *.app, rebar should not manipulate %% that file. This enforces that dichotomy between app and app.src. consult_app_file(Filename) -> - case lists:suffix(".app.src", Filename) of + case filelib:is_file(Filename) of false -> - file:consult(Filename); + throw(?PRV_ERROR(invalid_app_file)); true -> - {ok, rebar_config:consult_file(Filename)} + case lists:suffix(".app.src", Filename) of + false -> + file:consult(Filename); + true -> + {ok, rebar_config:consult_file(Filename)} + end end. app_vsn(AppFile) -> -- cgit v1.1