File: generate_app.escript

package info (click to toggle)
elixir-lang 1.19.5.dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 15,524 kB
  • sloc: erlang: 12,234; sh: 321; makefile: 288
file content (20 lines) | stat: -rwxr-xr-x 783 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env escript

%% SPDX-License-Identifier: Apache-2.0
%% SPDX-FileCopyrightText: 2021 The Elixir Team
%% SPDX-FileCopyrightText: 2012 Plataformatec

%% -*- 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]).