File: generate_app.escript

package info (click to toggle)
elixir-lang 1.18.3.dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 14,436 kB
  • sloc: erlang: 11,996; sh: 324; makefile: 277
file content (15 lines) | stat: -rwxr-xr-x 648 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/env escript
%% -*- erlang -*-

main([Version]) ->
  Source = "lib/elixir/src/elixir.app.src",
  Target = "lib/elixir/ebin/elixir.app",
  {ok, [{application, Name, Props0}]} = file:consult(Source),
  Ebin = filename:dirname(Target),
  Files = filelib:wildcard(filename:join(Ebin, "*.beam")),
  Mods = [list_to_atom(filename:basename(F, ".beam")) || F <- Files],
  Props1 = lists:keyreplace(modules, 1, Props0, {modules, Mods}),
  Props = lists:keyreplace(vsn, 1, Props1, {vsn, Version}),
  AppDef = io_lib:format("~tp.~n", [{application, Name, Props}]),
  ok = file:write_file(Target, AppDef),
  io:format("Generated ~ts app~n", [Name]).