mad_bundle.erl 778 B

12345678910111213141516171819202122
  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. false.
  10. read_file(File) -> {ok, Bin} = file:read_file(filename:absname(File)), Bin.
  11. static() -> Name = "static.gz",
  12. {ok,{_,Bin}} = zip:create(Name,
  13. [ F || F <- mad_repl:wildcards(["{apps,deps}/*/priv/**","priv/**"]), not filelib:is_dir(F) ],
  14. [{compress,all},memory]), [ { Name, Bin } ].
  15. beams() ->
  16. [ { filename:basename(F), read_file(F) } || F <-
  17. lists:concat([filelib:wildcard(X)||X <-
  18. [ "ebin/*","{apps,deps}/*/ebin/*","sys.config",".applist"]])].