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.

60 line
1.7 KiB

14 年之前
  1. -module(tdeps1_rt).
  2. -compile(export_all).
  3. %% Exercise transitive dependencies
  4. %% A -> B -> C, where A includes a .hrl from B which includes .hrl from C
  5. files() ->
  6. [
  7. %% A application
  8. {create, "ebin/a.app", app(a, [a])},
  9. {copy, "a.rebar.config", "rebar.config"},
  10. {copy, "a.erl", "src/a.erl"},
  11. {copy, "../../rebar", "rebar"},
  12. %% B application
  13. {create, "repo/b/ebin/b.app", app(b, [])},
  14. {copy, "b.rebar.config", "repo/b/rebar.config"},
  15. {copy, "b.hrl", "repo/b/include/b.hrl"},
  16. %% C application
  17. {create, "repo/c/ebin/c.app", app(c, [])},
  18. {copy, "c.hrl", "repo/c/include/c.hrl"}
  19. ].
  20. apply_cmds([], _Params) ->
  21. ok;
  22. apply_cmds([Cmd | Rest], Params) ->
  23. io:format("Running: ~s (~p)\n", [Cmd, Params]),
  24. {ok, _} = retest_sh:run(Cmd, Params),
  25. apply_cmds(Rest, Params).
  26. run(_Dir) ->
  27. %% Initialize the b/c apps as git repos so that dependencies pull
  28. %% properly
  29. GitCmds = ["git init",
  30. "git add -A",
  31. "git config user.email 'tdeps@example.com'",
  32. "git config user.name 'tdeps'",
  33. "git commit -a -m 'Initial Commit'"],
  34. apply_cmds(GitCmds, [{dir, "repo/b"}]),
  35. apply_cmds(GitCmds, [{dir, "repo/c"}]),
  36. {ok, _} = retest_sh:run("./rebar get-deps", []),
  37. {ok, _} = retest_sh:run("./rebar compile", []),
  38. true = filelib:is_regular("ebin/a.beam"),
  39. ok.
  40. %%
  41. %% Generate the contents of a simple .app file
  42. %%
  43. app(Name, Modules) ->
  44. App = {application, Name,
  45. [{description, atom_to_list(Name)},
  46. {vsn, "1"},
  47. {modules, Modules},
  48. {registered, []},
  49. {applications, [kernel, stdlib]}]},
  50. io_lib:format("~p.\n", [App]).