This repository was archived by the owner on Sep 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
This repository was archived by the owner on Sep 18, 2024. It is now read-only.
Conflict with escript #113
Copy link
Copy link
Open
Description
When bakeware and escript are used at the same time, the generated application will invoke main function twice.
How to reproduce
Taking the simple_script as an example.
Modify mix.exs by adding escript settings, as follows:
defmodule SimpleScript.MixProject do
use Mix.Project
@app :simple_script
def project do
[
app: @app,
version: "0.1.0",
elixir: "~> 1.10",
start_permanent: Mix.env() == :prod,
deps: deps(),
releases: [{@app, release()}],
escript: escript(), # <-- !! newly added
preferred_cli_env: [release: :prod]
]
end
# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [:logger],
mod: {SimpleScript, []}
]
end
# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:bakeware, path: "../..", runtime: false}
]
end
defp release do
[
overwrite: true,
cookie: "#{@app}_cookie",
quiet: true,
steps: [:assemble, &Bakeware.assemble/1],
strip_beams: Mix.env() == :prod
]
end
# !! newly added
defp escript do
[main_module: SimpleScript]
end
endAfter running mix escript.build, you can get the following result:
~/workspace/bakeware/examples/simple_script $ ./simple_script
Pass me some arguments and I will upcase them if you specify --upcase
Pass me some arguments and I will upcase them if you specify --upcase
Questions
My understanding is that when the program starts, module specified by mod is executed, then escript invokes the main function second time.
Now my questions are:
- Is it unexpected behavior?
- Is there any workaround to bypass it? (Maybe using another option instead of
mod?)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels