addrummond

addrummond OP

Very helpful – thank you!

0
Post #11
josevalim

josevalim

Creator of Elixir

Please do not do this:

This is relying on internal compiler behaviour. Use the suggestions from @kip instead, which uses public APIs. :slight_smile:

8
Post #12
mxgrn

mxgrn

Just out of curiosity: would it be correct to say that in this case BEAM never creates a corresponding .beam file?

0
Post #13
mudasobwa

mudasobwa

Creator of Cure

BEAM does not create files on its own, Elixir and Erlang compiler do if run under some special conditions (e. g. from the command line.)

If you are compiling files manually, you are responsible for persisting them, if you wish. Here I do it, because Common Test needs tests to be available as beams.

Basically, it’s

{module, code} = Code.compile_file(file)
beam = Path.join(Path.dirname(file), to_string(module) <> ".beam")
:ok = File.write!(Path.join(Path.dirname(file), to_string(module) <> ".beam"), code)
4
Post #14
dimitarvp

dimitarvp

I have to admit I don’t remember if the files are created.

But yes, the usual order of executing code, including during compile-time, still applies, regardless if the .beam file is persisted or not.

0
Post #15
— All posts loaded —