Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

66 строки
1.8 KiB

11 лет назад
11 лет назад
10 лет назад
14 лет назад
15 лет назад
14 лет назад
10 лет назад
14 лет назад
15 лет назад
11 лет назад
14 лет назад
14 лет назад
  1. #!/usr/bin/env escript
  2. %% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
  3. %% ex: ft=erlang ts=4 sw=4 et
  4. main(Args) ->
  5. case lists:member("--help", Args) of
  6. true ->
  7. usage(),
  8. halt(0);
  9. false ->
  10. ok
  11. end,
  12. %% Check for force=1 flag to force a rebuild
  13. case lists:member("force=1", Args) of
  14. true ->
  15. rm("ebin/*.beam");
  16. false ->
  17. rm("ebin/rebar.beam")
  18. end,
  19. %% Extract the system info of the version of OTP we use to compile rebar
  20. os:cmd("./bootstrap/rebar get-deps compile escriptize"),
  21. %% Finally, update executable perms for our script on *nix,
  22. %% or write out script files on win32.
  23. case os:type() of
  24. {unix,_} ->
  25. [] = os:cmd("chmod u+x rebar3"),
  26. ok;
  27. {win32,_} ->
  28. write_windows_scripts(),
  29. ok;
  30. _ ->
  31. ok
  32. end,
  33. %% Add a helpful message
  34. io:format("Congratulations! You now have a self-contained script called"
  35. " \"rebar3\" in\n"
  36. "your current working directory. "
  37. "Place this script anywhere in your path\n"
  38. "and you can use rebar to build OTP-compliant apps.\n").
  39. usage() ->
  40. io:format("Usage: bootstrap [OPTION]...~n"),
  41. io:format(" force=1 unconditional build~n"),
  42. io:format(" debug add debug information~n").
  43. rm(Path) ->
  44. NativePath = filename:nativename(Path),
  45. Cmd = case os:type() of
  46. {unix,_} -> "rm -f ";
  47. {win32,_} -> "del /q "
  48. end,
  49. [] = os:cmd(Cmd ++ NativePath),
  50. ok.
  51. write_windows_scripts() ->
  52. CmdScript=
  53. "@echo off\r\n"
  54. "setlocal\r\n"
  55. "set rebarscript=%~f0\r\n"
  56. "escript.exe \"%rebarscript:.cmd=%\" %*\r\n",
  57. ok = file:write_file("rebar.cmd", CmdScript).