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.

50 lines
1.4 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. -export_type([rebar_dict/0, rebar_digraph/0]).
  13. %%%%%%%%%%%%%%%%%%%%%%%
  14. %%% Error reporting %%%
  15. %%%%%%%%%%%%%%%%%%%%%%%
  16. %% @doc Interrupts program flow
  17. abort() -> ?FAIL.
  18. %% @doc like {@link error/2}, except it also raises an
  19. %% exception to interrupt program flow.
  20. abort(Str, Args) -> ?ABORT(Str, Args).
  21. %% @doc Prints to the console, including a newline
  22. console(Str, Args) -> ?CONSOLE(Str, Args).
  23. %% @doc logs with severity `debug'
  24. debug(Str, Args) -> ?DEBUG(Str, Args).
  25. %% @doc logs with severity `info'
  26. info(Str, Args) -> ?INFO(Str, Args).
  27. %% @doc logs with severity `warn'
  28. warn(Str, Args) -> ?WARN(Str, Args).
  29. %% @doc logs with severity `error'
  30. error(Str, Args) -> ?ERROR(Str, Args).
  31. %%
  32. %% Given env. variable FOO we want to expand all references to
  33. %% it in InStr. References can have two forms: $FOO and ${FOO}
  34. %% The end of form $FOO is delimited with whitespace or eol
  35. %%
  36. expand_env_variable(InStr, VarName, RawVarValue) ->
  37. rebar_utils:expand_env_variable(InStr, VarName, RawVarValue).
  38. get_arch() ->
  39. rebar_utils:get_arch().
  40. wordsize() ->
  41. rebar_utils:wordsize().