Comments (4)
All that being said, i'm not sure i personally understand the usecase of having escript and bakeware in the same project. Could you explain your usecase a little bit so that maybe we can make accommodations in the library for it.
Please consider the following scenario:
Alice wrote many Elixir scripts for personal use. She compiled the scripts using escript (instead of Bakeware) to save some disk space, since she always has Erlang/Elixir installed on machine.
One day, Bob was impressed by one of Alice's script and wants to try it, but he does not have Erlang/Elixir installed.
In order to make Bob's life easier, Alice decided to build an all-in-one binary using Bakeware since they are using the same OS.
Another day, Alice wanted to add some new function and build a V2 script for herself.
Then boom! The escript did not work anymore, unless she commented out the mod
line in mix.exs
.
To me, this is an anti-pattern. The use-case for bakeware is in place of other scripting options, like escript.
IMHO, it is a valid scenario (I got the same issue as Alice).
I understand that the goal of Bakeware is to replace escript etc, but the ability to distribute software in multiple ways should also be taken into consideration, since Bakeware cannot generate a binary without the runtime.
(Of course my statement will no longer hold if Bakeware can do that, but from the docs I tend to believe it cannot.)
So my ideas are:
- Support function to produce a binary without the runtime, i.e. include the function of escript. Then a build warning might be added when escript usage is detected.
- Make it work with escript.
The current error is rather confusing (and hard to find) when Bakeware and escript are used together.
What do you think?
from bakeware.
Is it unexpected behavior?
I'm not sure that it isn't unexpected behavior as we didn't add any checks. I think we could work around it in the assembler.
Is there any workaround to bypass it?
the only thing i could think of is having two different modules, one for escript, and one for bakeware. Maybe something like:
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.BakewareMain, []} # <- bakeware entry point
]
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.EscriptMain] # <- escript entrypoint
end
end
And then have both of those modules (SimpleScript.BakewareMain
, SimpleScript.EscriptMain
) use some common shared code between them.
All that being said, i'm not sure i personally understand the usecase of having escript and bakeware in the same project. Could you explain your usecase a little bit so that maybe we can make accommodations in the library for it.
CC: @fhunleth
from bakeware.
To me, this is an anti-pattern. The use-case for bakeware is in place of other scripting options, like escript. Though I would still be interested to here in the expectations here as I could just clearly be missing something.
Maybe the desire is for interaction during development?
from bakeware.
And then have both of those modules (
SimpleScript.BakewareMain
,SimpleScript.EscriptMain
) use some common shared code between them.
In fact, even if you do it like this, it still does not work.
The mod
section under application
will still be read and take effect, which leads to exactly the same behavior.
from bakeware.
Related Issues (20)
- bakeware messes up ssl library? HOT 8
- adding rlwrap HOT 5
- Each build I make on Windows 10 prints "The system cannot find the path specified." when ran HOT 11
- How to call to running agent in production? HOT 5
- Only allow 1 app to run | Reuse the same .cache if appname is the same HOT 2
- Cache directory is not properly created automatically on first run.
- Error during `mix deps.compile` under Windows 10 HOT 4
- Windows executable is an empty file HOT 6
- Issue when home path contains spaces HOT 1
- Compilation error in CentOS 7.9
- Windows? HOT 2
- Include runtime NPM packages HOT 1
- Is it possible to setup a Windows Bakeware release in GitHub Actions? HOT 9
- Running on mobile devices? HOT 2
- Run the binary as PID 1 HOT 1
- [Knowledge share] Cross-compiling to Windows from Linux
- different behavior between with and without bakeware. HOT 3
- Ability to run detached HOT 3
- Missing `release` in `assembler` struct during bakeware.assemble HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bakeware.