diff options
author | Dave Smith <dizzyd@dizzyd.com> | 2011-10-25 13:33:40 -0600 |
---|---|---|
committer | Dave Smith <dizzyd@dizzyd.com> | 2011-10-25 13:33:40 -0600 |
commit | 45fc18f990ab93bbcce8934f0ba397f3cd87e519 (patch) | |
tree | 856e656347b4f55fcd389d9187ac8e0a596a900e /src | |
parent | 28b9cebf0a5ceef0849b214f324f18c7ead178b7 (diff) |
Add support for -p flag to profile rebar run
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar.erl | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/rebar.erl b/src/rebar.erl index a103d29..95f43df 100644 --- a/src/rebar.erl +++ b/src/rebar.erl @@ -67,7 +67,17 @@ run(RawArgs) -> ok = application:load(rebar), %% Parse out command line arguments -- what's left is a list of commands to %% run -- and start running commands - run_aux(parse_args(RawArgs)). + Args = parse_args(RawArgs), + + case rebar_config:get_global(enable_profiling, false) of + true -> + io:format("Profiling!\n"), + fprof:apply(fun(A) -> run_aux(A) end, [Args]), + fprof:profile(), + fprof:analyse(); + _ -> + run_aux(Args) + end. run_aux(["help"]) -> help(), @@ -138,6 +148,10 @@ parse_args(Args) -> GlobalDefines = proplists:get_all_values(defines, Options), rebar_config:set_global(defines, GlobalDefines), + %% Setup profiling flag + rebar_config:set_global(enable_profiling, + proplists:get_bool(profile, Options)), + %% Set global variables based on getopt options set_global_flag(Options, verbose), set_global_flag(Options, force), @@ -268,7 +282,8 @@ option_spec_list() -> {force, $f, "force", undefined, "Force"}, {defines, $D, undefined, string, "Define compiler macro"}, {jobs, $j, "jobs", integer, JobsHelp}, - {config, $C, "config", string, "Rebar config file to use"} + {config, $C, "config", string, "Rebar config file to use"}, + {profile, $p, "profile", undefined, "Profile this run of rebar"} ]. %% |