From a2f1b62d74e2133321bf7255d4ae5017d58b8b20 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Tue, 8 Jun 2010 13:31:43 -0600 Subject: [PATCH] Slightly different fix for bug#5 that avoids running preprocess twice --- src/rebar_core.erl | 18 +++--------------- src/rebar_otp_app.erl | 4 ++++ 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/rebar_core.erl b/src/rebar_core.erl index 8b7c74f..6cf7bff 100644 --- a/src/rebar_core.erl +++ b/src/rebar_core.erl @@ -316,18 +316,6 @@ process_subdirs(Dir, Modules, Config, ModuleSetFile, Command, ProcessedDirs) -> end, NewProcessedDirs = lists:foldl(F, sets:add_element(parent, ProcessedDirs), Dirs), - %% http://bitbucket.org/basho/rebar/issue/5 - %% If the compiler ran, run the preprocess again because a new ebin dir - %% may have been produced. - %% {UpdatedConfig1, _} = case (Dirs =/= [] andalso compile == Command) of - %% true -> - %% acc_modules(Modules, preprocess, UpdatedConfig, - %% ModuleSetFile); - %% false -> - %% {UpdatedConfig, Dirs} - %% end, - UpdatedConfig1 = UpdatedConfig, - %% Make sure the CWD is reset properly; processing subdirs may have caused it %% to change ok = file:set_cwd(Dir), @@ -339,11 +327,11 @@ process_subdirs(Dir, Modules, Config, ModuleSetFile, Command, ProcessedDirs) -> false -> %% Get the list of plug-in modules from rebar.config. These modules are %% processed LAST and do not participate in preprocess. - {ok, PluginModules} = plugin_modules(UpdatedConfig1), + {ok, PluginModules} = plugin_modules(UpdatedConfig), %% Finally, process the current working directory ?DEBUG("Command: ~p Modules: ~p Plugins: ~p\n", [Command, Modules, PluginModules]), - apply_command(Command, Modules ++ PluginModules, UpdatedConfig1, ModuleSetFile) + apply_command(Command, Modules ++ PluginModules, UpdatedConfig, ModuleSetFile) end, %% Repeat the process if there are new SeenDirs @@ -351,7 +339,7 @@ process_subdirs(Dir, Modules, Config, ModuleSetFile, Command, ProcessedDirs) -> true -> ok; false -> - process_subdirs(Dir, Modules, UpdatedConfig1, ModuleSetFile, Command, + process_subdirs(Dir, Modules, UpdatedConfig, ModuleSetFile, Command, NewProcessedDirs) end. diff --git a/src/rebar_otp_app.erl b/src/rebar_otp_app.erl index bcc13fd..7a62081 100644 --- a/src/rebar_otp_app.erl +++ b/src/rebar_otp_app.erl @@ -152,6 +152,10 @@ preprocess(AppSrcFile) -> %% Setup file .app filename and write new contents AppFile = rebar_app_utils:app_src_to_app(AppSrcFile), ok = file:write_file(AppFile, Spec), + + %% Make certain that the ebin/ directory is available on the code path + code:add_path(filename:absname(filename:dirname(AppFile))), + AppFile; {error, Reason} ->