mirror of
https://github.com/correl/rebar.git
synced 2024-12-18 03:00:17 +00:00
Add support for -p flag to profile rebar run
This commit is contained in:
parent
28b9cebf0a
commit
45fc18f990
1 changed files with 17 additions and 2 deletions
|
@ -67,7 +67,17 @@ run(RawArgs) ->
|
||||||
ok = application:load(rebar),
|
ok = application:load(rebar),
|
||||||
%% Parse out command line arguments -- what's left is a list of commands to
|
%% Parse out command line arguments -- what's left is a list of commands to
|
||||||
%% run -- and start running commands
|
%% 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"]) ->
|
run_aux(["help"]) ->
|
||||||
help(),
|
help(),
|
||||||
|
@ -138,6 +148,10 @@ parse_args(Args) ->
|
||||||
GlobalDefines = proplists:get_all_values(defines, Options),
|
GlobalDefines = proplists:get_all_values(defines, Options),
|
||||||
rebar_config:set_global(defines, GlobalDefines),
|
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 variables based on getopt options
|
||||||
set_global_flag(Options, verbose),
|
set_global_flag(Options, verbose),
|
||||||
set_global_flag(Options, force),
|
set_global_flag(Options, force),
|
||||||
|
@ -268,7 +282,8 @@ option_spec_list() ->
|
||||||
{force, $f, "force", undefined, "Force"},
|
{force, $f, "force", undefined, "Force"},
|
||||||
{defines, $D, undefined, string, "Define compiler macro"},
|
{defines, $D, undefined, string, "Define compiler macro"},
|
||||||
{jobs, $j, "jobs", integer, JobsHelp},
|
{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"}
|
||||||
].
|
].
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
Loading…
Reference in a new issue