No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

89 líneas
2.9 KiB

  1. -module(tdeps3_rt).
  2. -compile(export_all).
  3. %% Exercise transitive dependencies where there are multiple files
  4. %% depending on the same set of deps as well as lib_dir directives
  5. %% A -> B -> C -> D -> E
  6. %% |--> G(via lib_dir)
  7. %% |--> F -> D -> E
  8. files() ->
  9. [
  10. %% A1 application
  11. {create, "ebin/a.app", app(a, [a])},
  12. {template, "a.erl", "src/a.erl", dict:from_list([{module, a}, {dep, b}])},
  13. {copy, "a.rebar.config", "rebar.config"},
  14. {copy, "../../rebar", "rebar"},
  15. %% B application
  16. {create, "repo/b/ebin/b.app", app(b, [b])},
  17. {template, "a.erl", "repo/b/src/b.erl", dict:from_list([{module, b}, {dep, b}])},
  18. {copy, "b.rebar.config", "repo/b/rebar.config"},
  19. {copy, "b.hrl", "repo/b/include/b.hrl"},
  20. %% C application
  21. {create, "repo/c/ebin/c.app", app(c, [c])},
  22. {template, "a.erl", "repo/c/src/c.erl", dict:from_list([{module, c}, {dep, d}])},
  23. {copy, "c.rebar.config", "repo/c/rebar.config"},
  24. {copy, "c.hrl", "repo/c/include/c.hrl"},
  25. %% D application
  26. {create, "repo/d/ebin/d.app", app(d, [d])},
  27. {template, "a.erl", "repo/d/src/d.erl", dict:from_list([{module, d}, {dep, e}])},
  28. {copy, "d.rebar.config", "repo/d/rebar.config"},
  29. {copy, "d.hrl", "repo/d/include/d.hrl"},
  30. %% E application
  31. {create, "repo/e/ebin/e.app", app(e, [])},
  32. {copy, "e.hrl", "repo/e/include/e.hrl"},
  33. %% F application
  34. {create, "repo/f/ebin/f.app", app(f, [f])},
  35. {template, "a.erl", "repo/f/src/f.erl", dict:from_list([{module, f}, {dep, d}])},
  36. {copy, "c.rebar.config", "repo/f/rebar.config"},
  37. {copy, "f.hrl", "repo/f/include/f.hrl"},
  38. %% G application, which is part of the B repo, in a lib_dir
  39. {create, "repo/b/apps/g/ebin/g.app", app(g, [])},
  40. {copy, "e.hrl", "repo/b/apps/g/include/g.hrl"}
  41. ].
  42. apply_cmds([], _Params) ->
  43. ok;
  44. apply_cmds([Cmd | Rest], Params) ->
  45. io:format("Running: ~s (~p)\n", [Cmd, Params]),
  46. {ok, _} = retest_sh:run(Cmd, Params),
  47. apply_cmds(Rest, Params).
  48. run(_Dir) ->
  49. %% Initialize the b/c apps as git repos so that dependencies pull
  50. %% properly
  51. GitCmds = ["git init",
  52. "git add -A",
  53. "git config user.email 'tdeps@example.com'",
  54. "git config user.name 'tdeps'",
  55. "git commit -a -m 'Initial Commit'"],
  56. ok = apply_cmds(GitCmds, [{dir, "repo/b"}]),
  57. ok = apply_cmds(GitCmds, [{dir, "repo/c"}]),
  58. ok = apply_cmds(GitCmds, [{dir, "repo/d"}]),
  59. ok = apply_cmds(GitCmds, [{dir, "repo/e"}]),
  60. ok = apply_cmds(GitCmds, [{dir, "repo/f"}]),
  61. {ok, _} = retest_sh:run("./rebar -v get-deps compile", []),
  62. ok.
  63. %%
  64. %% Generate the contents of a simple .app file
  65. %%
  66. app(Name, Modules) ->
  67. App = {application, Name,
  68. [{description, atom_to_list(Name)},
  69. {vsn, "1"},
  70. {modules, Modules},
  71. {registered, []},
  72. {applications, [kernel, stdlib]}]},
  73. io_lib:format("~p.\n", [App]).