From b3c41150293ca0872fbdbb8779ba716cf3591793 Mon Sep 17 00:00:00 2001 From: maxbarsukov Date: Sun, 27 Oct 2024 17:52:19 +0300 Subject: [PATCH] feat: :sparkles: setup escript compilation --- .gitignore | 3 +++ lib/main.ex | 18 ++++++++++++++++++ mix.exs | 9 +++++++++ 3 files changed, 30 insertions(+) create mode 100644 lib/main.ex diff --git a/.gitignore b/.gitignore index 4ddc3c9..9e5d86c 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,9 @@ erl_crash.dump fp_lab3-*.tar # Temporary files, for example, from tests. /tmp/ +# Generated executables +/out/ +!/out/.keep ### IntelliJ IDEA ### .idea/ diff --git a/lib/main.ex b/lib/main.ex new file mode 100644 index 0000000..ed6325a --- /dev/null +++ b/lib/main.ex @@ -0,0 +1,18 @@ +defmodule InterpolationApp.Main do + @moduledoc """ + Application entry point + """ + + @spec main([String.t()]) :: any() + def main(args \\ []) do + args + |> parse_args() + |> IO.puts() + end + + defp parse_args(args) do + {opts, word, _} = args |> OptionParser.parse(switches: [upcase: :boolean]) + + {opts, List.to_string(word)} + end +end diff --git a/mix.exs b/mix.exs index 03d78c0..632f429 100644 --- a/mix.exs +++ b/mix.exs @@ -10,6 +10,7 @@ defmodule FpLab3.MixProject do def project do [ app: :fp_lab3, + escript: escript(), elixir: "~> 1.17", elixirc_paths: elixirc_paths(Mix.env()), preferred_cli_env: [ @@ -37,6 +38,14 @@ defmodule FpLab3.MixProject do ] end + defp escript do + [ + main_module: InterpolationApp.Main, + path: "./out/interpolation-app", + name: "interpolation-app" + ] + end + def application do [ extra_applications: [:logger]