diff options
author | Dave Smith <dizzyd@dizzyd.com> | 2010-04-09 09:26:04 -0600 |
---|---|---|
committer | Dave Smith <dizzyd@dizzyd.com> | 2010-04-09 09:26:04 -0600 |
commit | ab817cd020d141a2611ef0f2e3a663a93222d0d2 (patch) | |
tree | 94e3dd41fcf083f81d957098219a2098ede3e991 /src | |
parent | f36e044e5dbe8e348023e30a8ad74da14c120251 (diff) | |
parent | 4f470fcddd6326dd85c3183fd78dbd0414a45ef5 (diff) |
Merging w/ mainline
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_core.erl | 1 | ||||
-rw-r--r-- | src/rebar_erlc_compiler.erl | 47 |
2 files changed, 48 insertions, 0 deletions
diff --git a/src/rebar_core.erl b/src/rebar_core.erl index e721576..a6f2c68 100644 --- a/src/rebar_core.erl +++ b/src/rebar_core.erl @@ -173,6 +173,7 @@ commands() -> "create-app Create simple app skel~n" "create-node Create simple node skel~n" "~n" +"check-deps Display to be fetched dependencies~n" "get-deps Fetch dependencies~n" "delete-deps Delete fetched dependencies~n" "~n" diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl index 0320380..760111f 100644 --- a/src/rebar_erlc_compiler.erl +++ b/src/rebar_erlc_compiler.erl @@ -40,6 +40,14 @@ -spec compile(Config::#config{}, AppFile::string()) -> 'ok'. compile(Config, _AppFile) -> + rebar_base_compiler:run(Config, + rebar_config:get_list(Config, xrl_first_files, []), + "src", ".xrl", "src", ".erl", + fun compile_xrl/3), + rebar_base_compiler:run(Config, + rebar_config:get_list(Config, yrl_first_files, []), + "src", ".yrl", "src", ".erl", + fun compile_yrl/3), doterl_compile(Config, "ebin"), rebar_base_compiler:run(Config, rebar_config:get_list(Config, mib_first_files, []), "mibs", ".mib", "priv/mibs", ".bin", @@ -52,6 +60,11 @@ clean(_Config, _AppFile) -> %% much slower. ok = rebar_file_utils:rm_rf("ebin/*.beam priv/mibs/*.bin"), + YrlFiles = rebar_utils:find_files("src", "^.*\\.[x|y]rl\$"), + rebar_file_utils:delete_each( + [ binary_to_list(iolist_to_binary(re:replace(F, "\\.[x|y]rl$", ".erl"))) + || F <- YrlFiles ]), + %% Erlang compilation is recursive, so it's possible that we have a nested %% directory structure in ebin with .beam files within. As such, we want %% to scan whatever is left in the ebin/ directory for sub-dirs which @@ -198,6 +211,40 @@ compile_mib(Source, Target, Config) -> ?FAIL end. +-spec compile_xrl(Source::string(), Target::string(), Config::#config{}) -> 'ok'. +compile_xrl(Source, Target, Config) -> + Opts = [{scannerfile, Target}, {return, true} + |rebar_config:get(Config, xrl_opts, [])], + compile_xrl_yrl(Source, Target, Config, Opts, leex). + +-spec compile_yrl(Source::string(), Target::string(), Config::#config{}) -> 'ok'. +compile_yrl(Source, Target, Config) -> + Opts = [{parserfile, Target}, {return, true} + |rebar_config:get(Config, yrl_opts, [])], + compile_xrl_yrl(Source, Target, Config, Opts, yecc). + +-spec compile_xrl_yrl(Source::string(), Target::string(), Config::#config{}, + Opts::list(), Mod::atom()) -> 'ok'. +compile_xrl_yrl(Source, Target, Config, Opts, Mod) -> + case needs_compile(Source, Target, []) of + true -> + case Mod:file(Source, Opts) of + {ok, _, []} -> + ok; + {ok, _, _Warnings} -> + case lists:member(fail_on_warnings, Config) of + true -> + ?FAIL; + false -> + ok + end; + _X -> + ?FAIL + end; + false -> + skipped + end. + gather_src([], Srcs) -> Srcs; gather_src([Dir|Rest], Srcs) -> |