您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

71 行
2.0 KiB

  1. %%% Packages rebar.hrl features and macros into a more generic API
  2. %%% that can be used by plugin builders.
  3. -module(rebar_api).
  4. -include("rebar.hrl").
  5. -include_lib("providers/include/providers.hrl").
  6. -export([abort/0, abort/2,
  7. console/2,
  8. debug/2, info/2, warn/2, error/2,
  9. expand_env_variable/3,
  10. get_arch/0,
  11. wordsize/0,
  12. add_deps_to_path/1,
  13. restore_code_path/1,
  14. processing_base_dir/1,
  15. ssl_opts/1]).
  16. -export_type([rebar_dict/0, rebar_digraph/0]).
  17. %%%%%%%%%%%%%%%%%%%%%%%
  18. %%% Error reporting %%%
  19. %%%%%%%%%%%%%%%%%%%%%%%
  20. %% @doc Interrupts program flow
  21. -spec abort() -> no_return().
  22. abort() -> ?FAIL.
  23. %% @doc like {@link error/2}, except it also raises an
  24. %% exception to interrupt program flow.
  25. -spec abort(string(), list()) -> no_return().
  26. abort(Str, Args) -> ?ABORT(Str, Args).
  27. %% @doc Prints to the console, including a newline
  28. console(Str, Args) -> ?CONSOLE(Str, Args).
  29. %% @doc logs with severity `debug'
  30. debug(Str, Args) -> ?DEBUG(Str, Args).
  31. %% @doc logs with severity `info'
  32. info(Str, Args) -> ?INFO(Str, Args).
  33. %% @doc logs with severity `warn'
  34. warn(Str, Args) -> ?WARN(Str, Args).
  35. %% @doc logs with severity `error'
  36. error(Str, Args) -> ?ERROR(Str, Args).
  37. %%
  38. %% Given env. variable FOO we want to expand all references to
  39. %% it in InStr. References can have two forms: $FOO and ${FOO}
  40. %% The end of form $FOO is delimited with whitespace or eol
  41. %%
  42. expand_env_variable(InStr, VarName, RawVarValue) ->
  43. rebar_utils:expand_env_variable(InStr, VarName, RawVarValue).
  44. get_arch() ->
  45. rebar_utils:get_arch().
  46. wordsize() ->
  47. rebar_utils:wordsize().
  48. %% Add deps to the code path
  49. add_deps_to_path(State) ->
  50. code:add_pathsa(rebar_state:code_paths(State, all_deps)).
  51. %% Revert to only having the beams necessary for running rebar3 and plugins in the path
  52. restore_code_path(State) ->
  53. rebar_utils:cleanup_code_path(rebar_state:code_paths(State, default)).
  54. processing_base_dir(State) ->
  55. rebar_dir:processing_base_dir(State).
  56. ssl_opts(Url) ->
  57. rebar_pkg_resource:ssl_opts(Url).