ソースを参照

apply profiles and overrides for an app's opts to the base opts

pull/233/head
Tristan Sloughter 10年前
コミット
7f508c30a1
3個のファイルの変更11行の追加8行の削除
  1. +2
    -2
      src/rebar_app_discover.erl
  2. +5
    -4
      src/rebar_core.erl
  3. +4
    -2
      src/rebar_state.erl

+ 2
- 2
src/rebar_app_discover.erl ファイルの表示

@ -34,13 +34,14 @@ format_error({missing_module, Module}) ->
io_lib:format("Module defined in app file missing: ~p~n", [Module]). io_lib:format("Module defined in app file missing: ~p~n", [Module]).
merge_deps(AppInfo, State) -> merge_deps(AppInfo, State) ->
Default = rebar_state:default(State),
Profiles = rebar_state:current_profiles(State), Profiles = rebar_state:current_profiles(State),
Name = rebar_app_info:name(AppInfo), Name = rebar_app_info:name(AppInfo),
C = rebar_config:consult(rebar_app_info:dir(AppInfo)), C = rebar_config:consult(rebar_app_info:dir(AppInfo)),
AppState = rebar_state:apply_overrides( AppState = rebar_state:apply_overrides(
rebar_state:apply_profiles( rebar_state:apply_profiles(
rebar_state:new(State, C, rebar_app_info:dir(AppInfo)), Profiles), Name),
rebar_state:new(rebar_state:opts(State, Default), C, rebar_app_info:dir(AppInfo)), Profiles), Name),
AppInfo1 = rebar_app_info:state(AppInfo, AppState), AppInfo1 = rebar_app_info:state(AppInfo, AppState),
State1 = lists:foldl(fun(Profile, StateAcc) -> State1 = lists:foldl(fun(Profile, StateAcc) ->
@ -50,7 +51,6 @@ merge_deps(AppInfo, State) ->
rebar_state:set(StateAcc, {deps, Profile}, ProfDeps2) rebar_state:set(StateAcc, {deps, Profile}, ProfDeps2)
end, State, lists:reverse(Profiles)), end, State, lists:reverse(Profiles)),
{AppInfo1, State1}. {AppInfo1, State1}.
-spec all_app_dirs(list(file:name())) -> list(file:name()). -spec all_app_dirs(list(file:name())) -> list(file:name()).

+ 5
- 4
src/rebar_core.erl ファイルの表示

@ -78,12 +78,13 @@ process_command(State, Command) ->
Command when Command =:= do; Command =:= as -> Command when Command =:= do; Command =:= as ->
do(TargetProviders, State); do(TargetProviders, State);
_ -> _ ->
Profiles = providers:profiles(CommandProvider),
State1 = rebar_state:apply_profiles(State, Profiles),
Opts = providers:opts(CommandProvider)++rebar3:global_option_spec_list(), Opts = providers:opts(CommandProvider)++rebar3:global_option_spec_list(),
case getopt:parse(Opts, rebar_state:command_args(State)) of
case getopt:parse(Opts, rebar_state:command_args(State1)) of
{ok, Args} -> {ok, Args} ->
State1 = rebar_state:command_parsed_args(State, Args),
do(TargetProviders, State1);
State2 = rebar_state:command_parsed_args(State1, Args),
do(TargetProviders, State2);
{error, {invalid_option, Option}} -> {error, {invalid_option, Option}} ->
{error, io_lib:format("Invalid option ~s on task ~p", [Option, Command])} {error, io_lib:format("Invalid option ~s on task ~p", [Option, Command])}
end end

+ 4
- 2
src/rebar_state.erl ファイルの表示

@ -3,7 +3,7 @@
-export([new/0, new/1, new/2, new/3, -export([new/0, new/1, new/2, new/3,
get/2, get/3, set/3, get/2, get/3, set/3,
opts/1,
opts/1, opts/2,
default/1, default/2, default/1, default/2,
escript_path/1, escript_path/2, escript_path/1, escript_path/2,
@ -37,7 +37,6 @@
-record(state_t, {dir :: file:name(), -record(state_t, {dir :: file:name(),
opts = dict:new() :: rebar_dict(), opts = dict:new() :: rebar_dict(),
default = dict:new() :: rebar_dict(), default = dict:new() :: rebar_dict(),
escript_path :: undefined | file:filename_all(), escript_path :: undefined | file:filename_all(),
lock = [], lock = [],
@ -129,6 +128,9 @@ default(State, Opts) ->
opts(#state_t{opts=Opts}) -> opts(#state_t{opts=Opts}) ->
Opts. Opts.
opts(State, Opts) ->
State#state_t{opts=Opts}.
current_profiles(#state_t{current_profiles=Profiles}) -> current_profiles(#state_t{current_profiles=Profiles}) ->
Profiles. Profiles.

読み込み中…
キャンセル
保存