mirror of
https://github.com/correl/rebar.git
synced 2024-12-18 11:06:20 +00:00
Add -D option
This commit is contained in:
parent
74ca540939
commit
a0dcc624d9
2 changed files with 18 additions and 8 deletions
|
@ -135,6 +135,9 @@ parse_args(Args) ->
|
||||||
%% Check options and maybe halt execution
|
%% Check options and maybe halt execution
|
||||||
ok = show_info_maybe_halt(Options, NonOptArgs),
|
ok = show_info_maybe_halt(Options, NonOptArgs),
|
||||||
|
|
||||||
|
GlobalDefines = proplists:get_all_values(defines, Options),
|
||||||
|
rebar_config:set_global(defines, GlobalDefines),
|
||||||
|
|
||||||
%% 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),
|
||||||
|
@ -263,6 +266,7 @@ option_spec_list() ->
|
||||||
{verbose, $v, "verbose", undefined, "Be verbose about what gets done"},
|
{verbose, $v, "verbose", undefined, "Be verbose about what gets done"},
|
||||||
{version, $V, "version", undefined, "Show version information"},
|
{version, $V, "version", undefined, "Show version information"},
|
||||||
{force, $f, "force", undefined, "Force"},
|
{force, $f, "force", undefined, "Force"},
|
||||||
|
{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"}
|
||||||
].
|
].
|
||||||
|
|
|
@ -122,14 +122,8 @@ doterl_compile(Config, OutDir) ->
|
||||||
|
|
||||||
doterl_compile(Config, OutDir, MoreSources) ->
|
doterl_compile(Config, OutDir, MoreSources) ->
|
||||||
FirstErls = rebar_config:get_list(Config, erl_first_files, []),
|
FirstErls = rebar_config:get_list(Config, erl_first_files, []),
|
||||||
RawErlOpts = filter_defines(rebar_config:get(Config, erl_opts, []), []),
|
ErlOpts = erl_opts(Config),
|
||||||
ErlOpts = case proplists:is_defined(no_debug_info, RawErlOpts) of
|
?DEBUG("erl_opts ~p~n", [ErlOpts]),
|
||||||
true ->
|
|
||||||
[O || O <- RawErlOpts, O =/= no_debug_info];
|
|
||||||
_ ->
|
|
||||||
[debug_info|RawErlOpts]
|
|
||||||
end,
|
|
||||||
?DEBUG("erl_opts ~p~n",[ErlOpts]),
|
|
||||||
%% Support the src_dirs option allowing multiple directories to
|
%% Support the src_dirs option allowing multiple directories to
|
||||||
%% contain erlang source. This might be used, for example, should
|
%% contain erlang source. This might be used, for example, should
|
||||||
%% eunit tests be separated from the core application source.
|
%% eunit tests be separated from the core application source.
|
||||||
|
@ -170,6 +164,18 @@ doterl_compile(Config, OutDir, MoreSources) ->
|
||||||
%% Internal functions
|
%% Internal functions
|
||||||
%% ===================================================================
|
%% ===================================================================
|
||||||
|
|
||||||
|
erl_opts(Config) ->
|
||||||
|
RawErlOpts = filter_defines(rebar_config:get(Config, erl_opts, []), []),
|
||||||
|
GlobalDefines = lists:map(fun(D) -> list_to_atom(D) end,
|
||||||
|
rebar_config:get_global(defines, [])),
|
||||||
|
Opts = GlobalDefines ++ RawErlOpts,
|
||||||
|
case proplists:is_defined(no_debug_info, Opts) of
|
||||||
|
true ->
|
||||||
|
[O || O <- Opts, O =/= no_debug_info];
|
||||||
|
_ ->
|
||||||
|
[debug_info|Opts]
|
||||||
|
end.
|
||||||
|
|
||||||
-spec include_path(Source::file:filename(),
|
-spec include_path(Source::file:filename(),
|
||||||
Config::rebar_config:config()) -> [file:filename(), ...].
|
Config::rebar_config:config()) -> [file:filename(), ...].
|
||||||
include_path(Source, Config) ->
|
include_path(Source, Config) ->
|
||||||
|
|
Loading…
Reference in a new issue