mad_erl.erl 616 B

123456789101112131415161718
  1. -module(mad_erl).
  2. -copyright('Sina Samavati').
  3. -compile(export_all).
  4. -define(COMPILE_OPTS(Inc, Ebin, Opts), [report, {i, Inc}, {outdir, Ebin}] ++ Opts).
  5. erl_to_beam(Bin, F) -> filename:join(Bin, filename:basename(F, ".erl") ++ ".beam").
  6. compile(File,Inc,Bin,Opt) ->
  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),
  11. % io:format("Compiling ~s Opts ~p~n\r", [File,Opts1]),
  12. io:format("Compiling ~s~n\r", [File]),
  13. compile:file(File, Opts1),
  14. ok;
  15. true -> ok end.