소스 검색

Merge pull request #46 from tsloughter/master

Fixes for profiles breaking templates and installing of non-default deps
pull/48/head
Fred Hebert 10 년 전
부모
커밋
40ef004f39
8개의 변경된 파일66개의 추가작업 그리고 35개의 파일을 삭제
  1. +0
    -1
      priv/templates/release.template
  2. +2
    -2
      priv/templates/relx_rebar.config.dtl
  3. +1
    -1
      src/rebar3.erl
  4. +18
    -9
      src/rebar_prv_install_deps.erl
  5. +5
    -3
      src/rebar_prv_release.erl
  6. +7
    -5
      src/rebar_prv_tar.erl
  7. +32
    -13
      src/rebar_state.erl
  8. +1
    -1
      src/rebar_templater.erl

+ 0
- 1
priv/templates/release.template 파일 보기

@ -7,7 +7,6 @@
{template, "sup.erl.dtl", "{{name}}/{{apps_dir}}/{{name}}/src/{{name}}_sup.erl"}.
{template, "otp_app.app.src.dtl", "{{name}}/{{apps_dir}}/{{name}}/src/{{name}}.app.src"}.
{template, "relx_rebar.config.dtl", "{{name}}/rebar.config"}.
{template, "relx.config.dtl", "{{name}}/relx.config"}.
{template, "sys.config.dtl", "{{name}}/config/sys.config"}.
{template, "vm.args.dtl", "{{name}}/config/vm.args"}.
{template, "gitignore.dtl", "{{name}}/.gitignore"}.

+ 2
- 2
priv/templates/relx_rebar.config.dtl 파일 보기

@ -14,7 +14,7 @@
{extended_start_script, true}]
}.
{profiles, [{prod, [{relx, [{dev_mode, true},
{include_erts, false},]}]
{profiles, [{prod, [{relx, [{dev_mode, false},
{include_erts, true}]}]
}]
}.

+ 1
- 1
src/rebar3.erl 파일 보기

@ -167,7 +167,7 @@ init_config() ->
%% resources out of the escript
State1 = try
ScriptName = filename:absname(escript:script_name()),
rebar_state:set(State, escript, ScriptName)
rebar_state:escript_path(State, ScriptName)
catch
_:_ ->
State

+ 18
- 9
src/rebar_prv_install_deps.erl 파일 보기

@ -66,13 +66,17 @@ init(State) ->
-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
do(State) ->
Profile = rebar_state:current_profile(State),
?INFO("Verifying ~p dependencies...", [Profile]),
ProjectApps = rebar_state:project_apps(State),
try
{ok, SrcApps, State1} = case rebar_state:get(State, locks, []) of
[] ->
{ok, SrcApps, State1} = case {Profile, rebar_state:get(State, locks, [])} of
{default, []} ->
handle_deps(State, rebar_state:get(State, {deps, Profile}, []));
Locks ->
handle_deps(State, Locks)
{default, Locks} ->
handle_deps(State, Locks);
_ ->
%% If not the default profile, ignore locks file
handle_deps(State, rebar_state:get(State, {deps, Profile}, []))
end,
Source = ProjectApps ++ SrcApps,
@ -170,11 +174,16 @@ update_pkg_deps(Pkgs, Packages, Update, Seen, State) ->
maybe_lock(AppInfo, Seen, State) ->
Name = rebar_app_info:name(AppInfo),
case sets:is_element(Name, Seen) of
false ->
{sets:add_element(Name, Seen),
rebar_state:lock(State, AppInfo)};
true ->
case rebar_state:current_profile(State) of
default ->
case sets:is_element(Name, Seen) of
false ->
{sets:add_element(Name, Seen),
rebar_state:lock(State, AppInfo)};
true ->
{Seen, State}
end;
_ ->
{Seen, State}
end.

+ 5
- 3
src/rebar_prv_release.erl 파일 보기

@ -33,16 +33,18 @@ init(State) ->
-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
do(State) ->
Options = rebar_state:command_args(State),
DepsDir = [rebar_dir:default_deps_dir(State)], % rebar_dir:deps_dir(State)],
DepsDir = rebar_dir:default_deps_dir(State),
ProfileDepsDir = rebar_dir:deps_dir(State),
LibDirs = lists:usort(rebar_utils:filtermap(fun ec_file:exists/1, [DepsDir, ProfileDepsDir])),
OutputDir = filename:join(rebar_dir:profile_dir(State), ?DEFAULT_RELEASE_DIR),
AllOptions = string:join(["release" | Options], " "),
try
case rebar_state:get(State, relx, []) of
[] ->
relx:main([{lib_dirs, DepsDir}
relx:main([{lib_dirs, LibDirs}
,{output_dir, OutputDir}], AllOptions);
Config ->
relx:main([{lib_dirs, DepsDir}
relx:main([{lib_dirs, LibDirs}
,{config, Config}
,{output_dir, OutputDir}], AllOptions)
end,

+ 7
- 5
src/rebar_prv_tar.erl 파일 보기

@ -12,7 +12,7 @@
-include("rebar.hrl").
-define(PROVIDER, tar).
-define(DEPS, [compile]).
-define(DEPS, [{compile, default}, compile]).
%% ===================================================================
%% Public API
@ -32,16 +32,18 @@ init(State) ->
-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
do(State) ->
OutputDir = filename:join(rebar_dir:profile_dir(State), ?DEFAULT_RELEASE_DIR),
Options = rebar_state:command_args(State),
DepsDir = rebar_dir:deps_dir(State),
DepsDir = rebar_dir:default_deps_dir(State),
ProfileDepsDir = rebar_dir:deps_dir(State),
LibDirs = lists:usort(rebar_utils:filtermap(fun ec_file:exists/1, [DepsDir, ProfileDepsDir])),
OutputDir = filename:join(rebar_dir:profile_dir(State), ?DEFAULT_RELEASE_DIR),
AllOptions = string:join(["release", "tar" | Options], " "),
case rebar_state:get(State, relx, []) of
[] ->
relx:main([{lib_dirs, [DepsDir]
relx:main([{lib_dirs, LibDirs
,{output_dir, OutputDir}}], AllOptions);
Config ->
relx:main([{lib_dirs, [DepsDir]}
relx:main([{lib_dirs, LibDirs}
,{config, Config}
,{output_dir, OutputDir}], AllOptions)
end,

+ 32
- 13
src/rebar_state.erl 파일 보기

@ -6,6 +6,8 @@
opts/1,
default/1, default/2,
escript_path/1, escript_path/2,
lock/1, lock/2,
current_profile/1,
@ -34,6 +36,8 @@
opts = dict:new() :: rebar_dict(),
default = dict:new() :: rebar_dict(),
escript_path :: undefined | file:filename_all(),
lock = [],
current_profile = default :: atom(),
@ -129,6 +133,12 @@ lock(#state_t{lock=Lock}) ->
lock(State=#state_t{lock=Lock}, App) ->
State#state_t{lock=[App | Lock]}.
escript_path(#state_t{escript_path=EscriptPath}) ->
EscriptPath.
escript_path(State, EscriptPath) ->
State#state_t{escript_path=EscriptPath}.
command_args(#state_t{command_args=CmdArgs}) ->
CmdArgs.
@ -142,6 +152,10 @@ command_parsed_args(State, CmdArgs) ->
State#state_t{command_parsed_args=CmdArgs}.
%% Only apply profiles to the default profile
apply_profile(State=#state_t{default=Opts}, default) ->
Deps = rebar_state:get(State, deps, []),
Opts1 = dict:store({deps, default}, Deps, Opts),
State#state_t{opts=Opts1};
apply_profile(State=#state_t{default=Opts}, Profile) ->
ConfigProfiles = rebar_state:get(State, profiles, []),
Deps = rebar_state:get(State, deps, []),
@ -149,22 +163,27 @@ apply_profile(State=#state_t{default=Opts}, Profile) ->
ProfileOpts = dict:from_list(proplists:get_value(Profile, ConfigProfiles, [])),
State#state_t{opts=merge_opts(Profile, ProfileOpts, Opts1)}.
merge_opts(Profile, Opts1, Opts2) ->
dict:fold(fun(deps, Value, OptsAcc) ->
dict:store({deps, Profile}, Value, OptsAcc);
(Key, Value, OptsAcc) ->
case dict:fetch(Key, Opts2) of
OldValue when is_list(OldValue) ->
case io_lib:printable_list(Value) of
merge_opts(Profile, NewOpts, OldOpts) ->
Dict = dict:merge(fun(_Key, NewValue, OldValue) when is_list(NewValue) ->
case io_lib:printable_list(NewValue) of
true ->
dict:store(Key, Value, OptsAcc);
NewValue;
false ->
dict:store(Key, lists:keymerge(1, lists:keysort(1, OldValue), lists:keysort(1, Value)), OptsAcc)
lists:keymerge(1
,lists:keysort(1, OldValue)
,lists:keysort(1, NewValue))
end;
_ ->
dict:store(Key, Value, OptsAcc)
end
end, Opts2, Opts1).
(_Key, NewValue, _OldValue) ->
NewValue
end, NewOpts, OldOpts),
case dict:find(deps, NewOpts) of
error ->
dict:store({deps, Profile}, [], Dict);
{ok, Deps} ->
dict:store({deps, Profile}, Deps, Dict)
end.
dir(#state_t{dir=Dir}) ->
Dir.

+ 1
- 1
src/rebar_templater.erl 파일 보기

@ -258,7 +258,7 @@ cache_escript_files(State) ->
fun(Name, _, GetBin, Acc) ->
[{Name, GetBin()} | Acc]
end,
[], rebar_state:get(State, escript)),
[], rebar_state:escript_path(State)),
Files.
%% Find all the template indexes hiding in the rebar3 escript.

불러오는 중...
취소
저장