PageRenderTime 594ms CodeModel.GetById 578ms RepoModel.GetById 1ms app.codeStats 0ms

/support/compile.erl

http://github.com/skarab/ewgi
Erlang | 44 lines | 25 code | 4 blank | 15 comment | 2 complexity | 0ed9dd92d9c597c9d5d26880147e1160 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception
  1. #!/usr/bin/env escript
  2. %% -*- erlang -*-
  3. %%! -noinput +B
  4. %% @author Davide MarquĂŞs <nesrait@gmail.com>
  5. %% @copyright 2009 Davide MarquĂŞs <nesrait@gmail.com>
  6. %%
  7. %% @doc Wrapper script for building a project using an Emakefile.
  8. %% If new modules are detected we do a touch("src/$(APP).app") to trigger (in the
  9. %% Makefile) the recreation of the ebin/$(APP).app file with the new modules.
  10. %% @end
  11. %%
  12. %% Licensed under the MIT license:
  13. %% http://www.opensource.org/licenses/mit-license.php
  14. main([EBinFolder, AppFileSrc | Others]) ->
  15. [code:add_patha(Other) || Other <- Others],
  16. code:add_patha(EBinFolder),
  17. M1 = filelib:wildcard(EBinFolder ++ "/*.beam"),
  18. case make:all() of
  19. up_to_date ->
  20. %% If there are new/missing files regenerate the .app file
  21. M2 = filelib:wildcard(EBinFolder ++ "/*.beam"),
  22. if (M1 =/= M2) ->
  23. touch(AppFileSrc);
  24. true -> ok
  25. end,
  26. halt(0);
  27. error ->
  28. halt(1)
  29. end;
  30. main(_) ->
  31. io:format("Invalid arguments to compile.erl!").
  32. -include_lib("kernel/include/file.hrl").
  33. %% Opening/closing file because just calling file:write_file_info/2
  34. %% wasn't getting the job done.
  35. touch(FileName) ->
  36. {ok, IoDevice} = file:open(FileName, [read, write]),
  37. {ok, FileInfo} = file:read_file_info(FileName),
  38. Now = calendar:now_to_local_time(erlang:now()),
  39. ok = file:write_file_info(FileName, FileInfo#file_info{mtime=Now}),
  40. file:close(IoDevice).