You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
2.2 KiB

пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
  1. %% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
  2. %% ex: ts=4 sw=4 et
  3. -module(rebar_prv_tar).
  4. -behaviour(provider).
  5. -export([init/1,
  6. do/1,
  7. format_error/1]).
  8. -include("rebar.hrl").
  9. -define(PROVIDER, tar).
  10. -define(DEPS, [compile]).
  11. %% ===================================================================
  12. %% Public API
  13. %% ===================================================================
  14. -spec init(rebar_state:t()) -> {ok, rebar_state:t()}.
  15. init(State) ->
  16. State1 = rebar_state:add_provider(State, providers:create([{name, ?PROVIDER},
  17. {module, ?MODULE},
  18. {bare, false},
  19. {deps, ?DEPS},
  20. {example, "rebar3 tar"},
  21. {short_desc, "Tar archive of release built of project."},
  22. {desc, ""},
  23. {opts, relx:opt_spec_list()}])),
  24. {ok, State1}.
  25. -spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
  26. do(State) ->
  27. Caller = rebar_state:get(State, caller, api),
  28. Options = rebar_state:command_args(State),
  29. DepsDir = rebar_dir:deps_dir(State),
  30. LibDirs = rebar_utils:filtermap(fun ec_file:exists/1,
  31. [DepsDir | lists:delete(".", ?DEFAULT_PROJECT_APP_DIRS)]),
  32. OutputDir = filename:join(rebar_dir:base_dir(State), ?DEFAULT_RELEASE_DIR),
  33. AllOptions = string:join(["release", "tar" | Options], " "),
  34. case rebar_state:get(State, relx, []) of
  35. [] ->
  36. relx:main([{lib_dirs, LibDirs}
  37. ,{output_dir, OutputDir}
  38. ,{caller, Caller}], AllOptions);
  39. Config ->
  40. relx:main([{lib_dirs, LibDirs}
  41. ,{config, Config}
  42. ,{output_dir, OutputDir}
  43. ,{caller, Caller}], AllOptions)
  44. end,
  45. {ok, State}.
  46. -spec format_error(any()) -> iolist().
  47. format_error(Reason) ->
  48. io_lib:format("~p", [Reason]).