-
Notifications
You must be signed in to change notification settings - Fork 521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: include priv in escript #1936
Comments
The big issue is extracting it from the escript though, you either have to access the escript directly or have to use a custom erlang build since it hardcodes the priv location. The normal Elixir style is to read the priv files into a module at compile-time then it can be accessed via a global non-gc binary from anywhere at any time (or if the file can be parsed out then parse it at compile-time to bake it into a better structure at runtime for even better speed). Doing the same in straight erlang is...not quite as easy but still doable (pregenerator to generate an appropriate erl file), and might be the best way to handle those files? But yeah, in the official erlang distributions the |
What is wrong with including priv the same as rebar3 does with the escript_incl_extra option? https://github.com/erlang/rebar3/blob/master/rebar.config#L30-L31 |
%% escript_incl_extra is for internal rebar-private use only.
%% Do not use outside rebar. Config interface is not stable. ^.^ What it looks like that does is what I described though, it reads in the files as a Oh, and even the code all about that option in rebar is still full of scary warnings like |
For now I would be happy with any hack that makes it work both in the shell and as an escript. |
@OvermindDL1 not sure what you mean about having to do anything different if it is baked in. The usual way of accessing it after using I agree we need to get rid of the warning, its been the same api for it for so long it should just be marked stable. |
Bleh, nevermind, scratch my last response. If that actually works in Elixir then let me know how and we could duplicate it. I have no idea how they achieve that. |
@Zalastax yea, the only hack I know is what rebar3 does to extract the files:
|
Uh, it shouldn't? You have a modified OTP distribution if so? o.O
Remember that Elixir is basically erlang with a ruby'ish (ugh) syntax but a fantastic compile-time code execution macro system, so literally the expression Way way way back when I programmed mainly on erlang (rebar1 was but a new thing just being thought of) there was a useful parse transform that could grab a file contents and bake it into a module similar to what the above elixir code does, wouldn't be hard to recreate it, or just make a preprocessor script that reads in a file, converts it to a binary string and writes out a All of the above patterns are quite a bit more efficient than what rebar is doing at the cost of slightly more ram being used (you obviously don't want to store a 100+ meg file in the module cache but a few megs here and there is perfectly fine). The elixir macro/unquote method works for escript's, libraries, any method at all with no code changes. Baking it into the module cache is of course not existing as a file on the filesystem, but accepting file binaries is a better method for gradualizer to run anyway instead of accessing the filesystem directly, however if needed you can always write out a temp file and read it in... |
Ah, ok, it does it at compile time. Then yea, going to have to stick to finding it by extracting from the escript with |
I believe this is the relevant upstream issue to keep an eye on: |
#2602 will cover the basic priv dir stuff, I would however consider NIF resources to be distinct. |
Picking up this thread, I've worked on this a bit, and have added a file access API to my Initially, I ran into the problem when trying to support OTP applications as 'plugins' packaged as In Ironically, almost all the core logic in The functions I've implemented so far are: |
I have an OTP application (Gradualizer) which I want to package as an escript.
The application has some application specific files and following the OTP directory structure guidelines we have placed these in the
priv
directory.Unfortunately, the
priv
directory is not included in the escript.I didn't find an official way to include additional directories in the escript and after reading
rebar_prv_escriptize
I know that it's not a bug thatpriv
is not included.Since
priv
is an official part of OTP I would very much wantpriv
to be included in the escript. I suggest we add it toescript_incl_extra
.The text was updated successfully, but these errors were encountered: