mad_bundle.erl 767 B

123456789101112131415161718192021
  1. -module(mad_bundle).
  2. -copyright('Maxim Sokhatsky').
  3. -compile(export_all).
  4. main(App) ->
  5. EmuArgs = "-noshell -noinput",
  6. Files = static() ++ beams(),
  7. escript:create(App,[shebang,{comment,""},{emu_args,EmuArgs},{archive,Files,[memory]}]),
  8. file:change_mode(App, 8#764).
  9. read_file(File) -> {ok, Bin} = file:read_file(filename:absname(File)), Bin.
  10. static() -> Name = "static.gz",
  11. {ok,{_,Bin}} = zip:create(Name,
  12. [F || F <- mad_repl:wildcards(["{apps,deps}/*/priv/**","priv/**"]), not filelib:is_dir(F) ],
  13. [{compress,all},memory]), [ { Name, Bin } ].
  14. beams() ->
  15. [ { filename:basename(F), read_file(F) } || F <-
  16. lists:concat([filelib:wildcard(X)||X <-
  17. [ "ebin/*","{apps,deps}/*/ebin/*","sys.config",".applist"]])].