Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

70 linhas
2.8 KiB

13 anos atrás
  1. %% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
  2. %% ex: ts=4 sw=4 et
  3. %% -------------------------------------------------------------------
  4. %%
  5. %% rebar: Erlang Build Tools
  6. %%
  7. %% Copyright (c) 2009 Dave Smith (dizzyd@dizzyd.com)
  8. %%
  9. %% Permission is hereby granted, free of charge, to any person obtaining a copy
  10. %% of this software and associated documentation files (the "Software"), to deal
  11. %% in the Software without restriction, including without limitation the rights
  12. %% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. %% copies of the Software, and to permit persons to whom the Software is
  14. %% furnished to do so, subject to the following conditions:
  15. %%
  16. %% The above copyright notice and this permission notice shall be included in
  17. %% all copies or substantial portions of the Software.
  18. %%
  19. %% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. %% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. %% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22. %% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. %% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24. %% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25. %% THE SOFTWARE.
  26. %%
  27. %% -------------------------------------------------------------------
  28. -module(rebar_require_vsn).
  29. -include("rebar.hrl").
  30. -export([compile/2,
  31. eunit/2]).
  32. %% ===================================================================
  33. %% Public API
  34. %% ===================================================================
  35. compile(Config, _) ->
  36. check_versions(Config).
  37. eunit(Config, _) ->
  38. check_versions(Config).
  39. %% ====================================================================
  40. %% Internal functions
  41. %% ====================================================================
  42. check_versions(Config) ->
  43. ErtsRegex = rebar_config:get(Config, require_erts_vsn, ".*"),
  44. ReOpts = [{capture, none}],
  45. case re:run(erlang:system_info(version), ErtsRegex, ReOpts) of
  46. match ->
  47. ?DEBUG("Matched required ERTS version: ~s -> ~s\n",
  48. [erlang:system_info(version), ErtsRegex]);
  49. nomatch ->
  50. ?ABORT("ERTS version ~s does not match required regex ~s\n",
  51. [erlang:system_info(version), ErtsRegex])
  52. end,
  53. OtpRegex = rebar_config:get(Config, require_otp_vsn, ".*"),
  54. case re:run(erlang:system_info(otp_release), OtpRegex, ReOpts) of
  55. match ->
  56. ?DEBUG("Matched required OTP release: ~s -> ~s\n",
  57. [erlang:system_info(otp_release), OtpRegex]);
  58. nomatch ->
  59. ?ABORT("OTP release ~s does not match required regex ~s\n",
  60. [erlang:system_info(otp_release), OtpRegex])
  61. end.