mad_erl.erl 767 B

12345678910111213141516171819202122
  1. -module(mad_erl).
  2. -copyright('Sina Samavati').
  3. -compile(export_all).
  4. -define(COMPILE_OPTS(Inc, Ebin, Opts, Deps), [report, {i, [Inc]}, {outdir, Ebin}] ++ Opts++Deps).
  5. erl_to_beam(Bin, F) -> filename:join(Bin, filename:basename(F, ".erl") ++ ".beam").
  6. compile(File,Inc,Bin,Opt,Deps) ->
  7. BeamFile = erl_to_beam(Bin, File),
  8. Compiled = mad_compile:is_compiled(BeamFile, File),
  9. if Compiled =:= false ->
  10. Opts1 = ?COMPILE_OPTS(Inc, Bin, Opt, Deps),
  11. % io:format("Compiling ~s~n Opts ~p~n Deps~p~n", [File,Opts1,Deps]),
  12. io:format("Compiling ~s~n", [File]),
  13. ret(compile:file(File, Opts1));
  14. true -> false end.
  15. ret(error) -> true;
  16. ret({error,_,_}) -> true;
  17. ret({ok,_}) -> false;
  18. ret({ok,_,_}) -> false;
  19. ret({ok,_,_,_}) -> false.