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.

59 rivejä
2.2 KiB

10 vuotta sitten
10 vuotta sitten
10 vuotta sitten
10 vuotta sitten
10 vuotta sitten
10 vuotta sitten
  1. %% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
  2. %% ex: ts=4 sw=4 et
  3. -module(rebar_prv_release).
  4. -behaviour(provider).
  5. -export([init/1,
  6. do/1,
  7. format_error/1]).
  8. -include("rebar.hrl").
  9. -define(PROVIDER, release).
  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, "rebar release"},
  21. {short_desc, "Build release 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. Options = rebar_state:command_args(State),
  28. DepsDir = rebar_dir:deps_dir(State),
  29. LibDirs = rebar_utils:filtermap(fun ec_file:exists/1,
  30. [DepsDir | lists:delete(".", ?DEFAULT_PROJECT_APP_DIRS)]),
  31. OutputDir = filename:join(rebar_dir:base_dir(State), ?DEFAULT_RELEASE_DIR),
  32. AllOptions = string:join(["release" | Options], " "),
  33. try
  34. case rebar_state:get(State, relx, []) of
  35. [] ->
  36. relx:main([{lib_dirs, LibDirs}
  37. ,{output_dir, OutputDir}], AllOptions);
  38. Config ->
  39. relx:main([{lib_dirs, LibDirs}
  40. ,{config, Config}
  41. ,{output_dir, OutputDir}], AllOptions)
  42. end,
  43. {ok, State}
  44. catch
  45. throw:T ->
  46. {error, {rlx_prv_release, T}}
  47. end.
  48. -spec format_error(any()) -> iolist().
  49. format_error(Reason) ->
  50. io_lib:format("~p", [Reason]).