Pārlūkot izejas kodu

Merge pull request #532 from tsloughter/pkgs_for_deps

Updates some deps, moves to packages for deps and adds dialyzer profile
pull/537/head
Fred Hebert pirms 10 gadiem
vecāks
revīzija
11d7a07064
6 mainītis faili ar 72 papildinājumiem un 90 dzēšanām
  1. +32
    -19
      bootstrap
  2. +23
    -25
      rebar.config
  3. +5
    -20
      rebar.lock
  4. +1
    -0
      src/rebar.app.src
  5. +10
    -25
      src/rebar_prv_install_deps.erl
  6. +1
    -1
      src/rebar_templater.erl

+ 32
- 19
bootstrap Parādīt failu

@ -4,6 +4,12 @@
main(_Args) -> main(_Args) ->
application:start(crypto),
application:start(asn1),
application:start(public_key),
application:start(ssl),
inets:start(),
%% Fetch and build deps required to build rebar3 %% Fetch and build deps required to build rebar3
BaseDeps = [{providers, []} BaseDeps = [{providers, []}
,{getopt, []} ,{getopt, []}
@ -24,6 +30,7 @@ main(_Args) ->
setup_env(), setup_env(),
os:putenv("REBAR_PROFILE", "bootstrap"), os:putenv("REBAR_PROFILE", "bootstrap"),
rebar3:run(["update"]),
{ok, State} = rebar3:run(["compile"]), {ok, State} = rebar3:run(["compile"]),
reset_env(), reset_env(),
os:putenv("REBAR_PROFILE", ""), os:putenv("REBAR_PROFILE", ""),
@ -56,28 +63,33 @@ fetch_and_compile({Name, ErlFirstFiles}, Deps) ->
ok = fetch(Repo, Name), ok = fetch(Repo, Name),
compile(Name, ErlFirstFiles). compile(Name, ErlFirstFiles).
fetch({git, Url, Source}, App) ->
fetch({pkg, Name, Vsn}, App) ->
Dir = filename:join([filename:absname("_build/default/lib/"), App]), Dir = filename:join([filename:absname("_build/default/lib/"), App]),
case filelib:is_dir(Dir) of
true ->
true = code:add_path(filename:join(Dir, "ebin")),
ok;
false ->
fetch_source(Dir, Url, Source),
ok
CDN = "https://s3.amazonaws.com/s3.hex.pm/tarballs",
Package = binary_to_list(<<Name/binary, "-", Vsn/binary, ".tar">>),
Url = string:join([CDN, Package], "/"),
case request(Url) of
{ok, Binary} ->
{ok, Contents} = extract(Binary),
ok = erl_tar:extract({binary, Contents}, [{cwd, Dir}, compressed]);
_ ->
io:format("Error: Unable to fetch package ~p ~p~n", [Name, Vsn])
end. end.
fetch_source(Dir, Url, {ref, Ref}) ->
ok = filelib:ensure_dir(Dir),
os:cmd(io_lib:format("git clone ~s ~s", [Url, Dir])),
{ok, Cwd} = file:get_cwd(),
file:set_cwd(Dir),
os:cmd(io_lib:format("git checkout -q ~s", [Ref])),
file:set_cwd(Cwd);
fetch_source(Dir, Url, {_, Branch}) ->
ok = filelib:ensure_dir(Dir),
os:cmd(io_lib:format("git clone ~s ~s -b ~s --single-branch",
[Url, Dir, Branch])).
extract(Binary) ->
{ok, Files} = erl_tar:extract({binary, Binary}, [memory]),
{"contents.tar.gz", Contents} = lists:keyfind("contents.tar.gz", 1, Files),
{ok, Contents}.
request(Url) ->
case httpc:request(get, {Url, []},
[{relaxed, true}],
[{body_format, binary}]) of
{ok, {{_Version, 200, _Reason}, _Headers, Body}} ->
{ok, Body};
Error ->
Error
end.
compile(App, FirstFiles) -> compile(App, FirstFiles) ->
Dir = filename:join(filename:absname("_build/default/lib/"), App), Dir = filename:join(filename:absname("_build/default/lib/"), App),
@ -86,6 +98,7 @@ compile(App, FirstFiles) ->
FirstFilesPaths = [filename:join([Dir, "src", Module]) || Module <- FirstFiles], FirstFilesPaths = [filename:join([Dir, "src", Module]) || Module <- FirstFiles],
Sources = FirstFilesPaths ++ filelib:wildcard(filename:join([Dir, "src", "*.erl"])), Sources = FirstFilesPaths ++ filelib:wildcard(filename:join([Dir, "src", "*.erl"])),
[compile_file(X, [{i, filename:join(Dir, "include")} [compile_file(X, [{i, filename:join(Dir, "include")}
,debug_info
,{outdir, filename:join(Dir, "ebin")} ,{outdir, filename:join(Dir, "ebin")}
,return | additional_defines()]) || X <- Sources]. ,return | additional_defines()]) || X <- Sources].

+ 23
- 25
rebar.config Parādīt failu

@ -2,21 +2,11 @@
%% ex: ts=4 sw=4 ft=erlang et %% ex: ts=4 sw=4 ft=erlang et
{deps, [ {deps, [
{erlware_commons, "",
{git, "https://github.com/erlware/erlware_commons.git",
{branch, "master"}}},
{providers, "",
{git, "https://github.com/tsloughter/providers.git",
{tag, "v1.4.0"}}},
{relx, "",
{git, "https://github.com/erlware/relx.git",
{branch, "master"}}},
{mustache, ".*",
{git, "https://github.com/soranoba/mustache.git",
{tag, "v0.3.0"}}},
{getopt, "",
{git, "https://github.com/jcomellas/getopt.git",
{branch, "master"}}}]}.
{erlware_commons, "0.12.0"},
{providers, "1.4.1"},
{getopt, "0.8.2"},
{bbmustache, "1.0.1"},
{relx, "2.1.0"}]}.
{escript_name, rebar3}. {escript_name, rebar3}.
{escript_emu_args, "%%! +sbtu +A0\n"}. {escript_emu_args, "%%! +sbtu +A0\n"}.
@ -41,8 +31,9 @@
{erl_opts, [debug_info]} {erl_opts, [debug_info]}
]}, ]},
%% We don't want erlydtl to attempt to run on the first compile pass to bootstrap
{bootstrap, []}
{bootstrap, []},
{dialyze, [{erl_opts, [debug_info]}]}
]}. ]}.
%% Overrides %% Overrides
@ -51,16 +42,23 @@
{platform_define, "^R1[4|5]", deprecated_crypto}, {platform_define, "^R1[4|5]", deprecated_crypto},
no_debug_info, no_debug_info,
warnings_as_errors]}, warnings_as_errors]},
{deps, []}, {plugins, []}
{deps, []}, {plugins, []},
{profiles, [{dialyze, [{erl_opts, [debug_info]}]}]}
]}, ]},
{override, mustache, [
{erl_opts, [{platform_define, "^[0-9]+", namespaced_types},
no_debug_info]},
{deps, []}, {plugins, []}]},
{override, getopt, [{erl_opts, [no_debug_info]}]},
{override, providers, [{erl_opts, [no_debug_info]}]},
{override, bbmustache, [
{erl_opts, [no_debug_info,
{platform_define, "^[0-9]+", namespaced_types}]},
{deps, []}, {plugins, []},
{profiles, [{dialyze, [{erl_opts, [debug_info]}]}]}
]},
{override, getopt, [{erl_opts, [no_debug_info]},
{profiles, [{dialyze, [{erl_opts, [debug_info]}]}]}]},
{override, providers, [{erl_opts, [no_debug_info]},
{profiles, [{dialyze, [{erl_opts, [debug_info]}]}]}]},
{override, relx, [{erl_opts, [{platform_define, "^[0-9]+", namespaced_types}, {override, relx, [{erl_opts, [{platform_define, "^[0-9]+", namespaced_types},
{platform_define, "^R1[4|5]", deprecated_crypto}, {platform_define, "^R1[4|5]", deprecated_crypto},
no_debug_info, no_debug_info,
warnings_as_errors]}]}
warnings_as_errors]},
{profiles, [{dialyze, [{erl_opts, [debug_info]}]}]}
]}
]}. ]}.

+ 5
- 20
rebar.lock Parādīt failu

@ -1,20 +1,5 @@
[{<<"relx">>,
{git,"https://github.com/erlware/relx.git",
{ref,"74fec3455ba6dbb7d9e369137c1b15ab10804993"}},
0},
{<<"providers">>,
{git,"https://github.com/tsloughter/providers.git",
{ref,"adc0af0a3f5de2049419a753777686b94f4e2c90"}},
0},
{<<"mustache">>,
{git,"https://github.com/soranoba/mustache.git",
{ref,"e5401042c66039eef20ee81abc1537ced1f22bc7"}},
0},
{<<"getopt">>,
{git,"https://github.com/jcomellas/getopt.git",
{ref,"626698975e63866156159661d100785d65eab6f9"}},
0},
{<<"erlware_commons">>,
{git,"https://github.com/erlware/erlware_commons.git",
{ref,"ef0d252b11c863f9c228af2fe93a4e42fba2f7f3"}},
0}].
[{<<"bbmustache">>,{pkg,<<"bbmustache">>,<<"1.0.1">>},0},
{<<"providers">>,{pkg,<<"providers">>,<<"1.4.1">>},0},
{<<"erlware_commons">>,{pkg,<<"erlware_commons">>,<<"0.12.0">>},0},
{<<"relx">>,{pkg,<<"relx">>,<<"2.1.0">>},0},
{<<"getopt">>,{pkg,<<"getopt">>,<<"0.8.2">>},0}].

+ 1
- 0
src/rebar.app.src Parādīt failu

@ -17,6 +17,7 @@
common_test, common_test,
erlware_commons, erlware_commons,
providers, providers,
bbmustache,
relx, relx,
inets]}, inets]},
{env, [ {env, [

+ 10
- 25
src/rebar_prv_install_deps.erl Parādīt failu

@ -224,28 +224,13 @@ update_pkg_deps(Profile, Pkgs, Packages, Upgrade, Seen, State, Locks) ->
handle_pkg_dep(Profile, Pkg, Packages, Upgrade, DepsDir, Fetched, Seen, Locks, State) -> handle_pkg_dep(Profile, Pkg, Packages, Upgrade, DepsDir, Fetched, Seen, Locks, State) ->
IsLock = pkg_locked(Pkg, Locks), IsLock = pkg_locked(Pkg, Locks),
AppInfo = package_to_app(DepsDir, Packages, Pkg, IsLock, State), AppInfo = package_to_app(DepsDir, Packages, Pkg, IsLock, State),
Deps = rebar_app_info:deps(AppInfo),
Level = rebar_app_info:dep_level(AppInfo), Level = rebar_app_info:dep_level(AppInfo),
{NewSeen, NewState} = maybe_lock(Profile, AppInfo, Seen, State, Level), {NewSeen, NewState} = maybe_lock(Profile, AppInfo, Seen, State, Level),
{_, AppInfo1} = maybe_fetch(AppInfo, Profile, Upgrade, Seen, NewState), {_, AppInfo1} = maybe_fetch(AppInfo, Profile, Upgrade, Seen, NewState),
Profiles = rebar_state:current_profiles(State),
Name = rebar_app_info:name(AppInfo1),
C = rebar_config:consult(rebar_app_info:dir(AppInfo1)),
BaseDir = rebar_state:get(State, base_dir, []),
S1 = rebar_state:new(rebar_state:set(rebar_state:new(), base_dir, BaseDir),
C, rebar_app_info:dir(AppInfo1)),
S2 = rebar_state:apply_overrides(S1, Name),
Plugins = rebar_state:get(S2, plugins, []),
S3 = rebar_state:set(S2, {plugins, Profile}, Plugins),
S4 = rebar_state:apply_profiles(S3, Profiles),
AppInfo2 = rebar_app_info:state(AppInfo1, S4),
%% Dep may have plugins to install. Find and install here.
S5 = rebar_plugins:install(S4),
AppInfo3 = rebar_app_info:state(AppInfo2, S5),
{AppInfo2, _, _, _, _} =
handle_dep(NewState, Profile, DepsDir, AppInfo1, Locks, Level),
AppInfo3 = rebar_app_info:deps(AppInfo2, Deps),
{[AppInfo3 | Fetched], NewSeen, NewState}. {[AppInfo3 | Fetched], NewSeen, NewState}.
maybe_lock(Profile, AppInfo, Seen, State, Level) -> maybe_lock(Profile, AppInfo, Seen, State, Level) ->
@ -284,12 +269,12 @@ package_to_app(DepsDir, Packages, {Name, Vsn, Level}, IsLock, State) ->
throw(?PRV_ERROR({missing_package, Name, Vsn})) throw(?PRV_ERROR({missing_package, Name, Vsn}))
end; end;
{ok, PkgDeps} -> {ok, PkgDeps} ->
{ok, AppInfo} = rebar_app_info:new(Name, Vsn),
AppInfo1 = rebar_app_info:deps(AppInfo, PkgDeps),
AppInfo2 = rebar_app_info:dir(AppInfo1, filename:join([DepsDir, Name])),
AppInfo3 = rebar_app_info:dep_level(AppInfo2, Level),
AppInfo4 = rebar_app_info:is_lock(AppInfo3, IsLock),
rebar_app_info:source(AppInfo4, {pkg, Name, Vsn})
Source = {pkg, Name, Vsn},
AppInfo = new_dep(DepsDir, Name, Vsn, Source, IsLock, State),
AppInfo1 = rebar_app_info:dep_level(rebar_app_info:deps(AppInfo, PkgDeps), Level),
BaseDir = rebar_state:get(State, base_dir, []),
AppState1 = rebar_state:set(rebar_app_info:state(AppInfo1), base_dir, BaseDir),
rebar_app_info:state(AppInfo1, AppState1)
end. end.
-spec update_src_deps(atom(), non_neg_integer(), list(), list(), list(), rebar_state:t(), boolean(), sets:set(binary()), list()) -> {rebar_state:t(), list(), list(), sets:set(binary())}. -spec update_src_deps(atom(), non_neg_integer(), list(), list(), list(), rebar_state:t(), boolean(), sets:set(binary()), list()) -> {rebar_state:t(), list(), list(), sets:set(binary())}.

+ 1
- 1
src/rebar_templater.erl Parādīt failu

@ -380,4 +380,4 @@ write_file(Output, Data, Force) ->
%% Render a binary to a string, using mustache and the specified context %% Render a binary to a string, using mustache and the specified context
%% %%
render(Bin, Context) -> render(Bin, Context) ->
mustache:render(ec_cnv:to_binary(Bin), Context, [{key_type, atom}]).
bbmustache:render(ec_cnv:to_binary(Bin), Context, [{key_type, atom}]).

Notiek ielāde…
Atcelt
Saglabāt