adding support for export_all in mix elixirc_options.

141 views
Skip to first unread message

Matthew O'Gorman

unread,
Apr 1, 2019, 2:27:22 AM4/1/19
to elixir-lang-core
I submitted this pr https://github.com/elixir-lang/elixir/pull/8925  and jose asked that I come to list, to talk about it.

My motivations for doing so is to expose export_all compiler option at mix level. My use case exposing private functions to unit tests for smaller more directed tests, as well as writing tests for some private functions.  I also want to allow my dev environment to access private function for easier debugging and experimentation.

I realized that others have solved this issue other  ways, putting @compile flags everywhere wrapped in an if Mix.env == :test block, or other macros and libraries doing the same thing.

I personally think it makes sense to expose the builtin erlang method for doing this instead of those other techniques, especially as when I googled around it seems people think what I am doing is already possible even though it is not.

There also seems to be a bug currently that when you pass ERL_COMPILER_OPTIONS="export_all" from the command line it tags it as an option in the compiled beam, but it did not actually export_all modules.

Mog

José Valim

unread,
Apr 1, 2019, 3:46:15 AM4/1/19
to elixir-l...@googlegroups.com
My biggest concern about this feature is that we discourage testing of private functions and adding this feature only to encourage it would be directly against the practices we want to promote.

Given there are other ways to achieve this feature, for example, having a "use ExportAll", I would prefer for developers to achieve this in one of the many ways than directly make it part of the language.

> There also seems to be a bug currently that when you pass ERL_COMPILER_OPTIONS="export_all" from the command line it tags it as an option in the compiled beam, but it did not actually export_all modules.

This is a bug though. It will be fixed in master, thank you.


José Valim
Skype: jv.ptec
Founder and Director of R&D


--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/aa4e74c3-d1d6-416a-9169-77037d056db4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Matthew O'Gorman

unread,
Apr 1, 2019, 4:10:44 AM4/1/19
to elixir-l...@googlegroups.com
Thank you for fixing the bug with ERL_COMPILER_OPTIONS I verified it
on my box. There is still no way to set ERL_COMPILER_OPTIONS from
within mix.exs then?
> To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4%2BgyS%3DX3-mpQiB2Kb6qyZ0bmzgTA-Hj6k5Lpe99EzL8yA%40mail.gmail.com.

Matthew O'Gorman

unread,
Apr 1, 2019, 4:27:03 AM4/1/19
to elixir-l...@googlegroups.com
Actually I see I can just call System.put_env("ERL_COMPILER_OPTIONS",
Opts) from mix.exs. but that does feel pretty hacky, and doesnt cause
recompiles if it the value of the variable changes.

floati...@gmail.com

unread,
Apr 1, 2019, 9:02:38 AM4/1/19
to elixir-lang-core
Hi Matthew + everyone.
(Sorry for jumping in here)
As ERL_COMPILER_OPTIONS is not directly being used by the "elixirc" or "elixirc.bat" (as far as I can see)
and must then be used by passing it in as a command line environment variable BEFORE you issue the command, is 
it possible that you might have this environment variable already set in your shell environment before you issue the command?
Just a thought.

Also, for something to cause recompiles, you are then thinking of make and Makefile environment setups?
In order for that to happen, you would have to write something (compiler variable settings?) into the file system 
that the make tool could use to compare against to trigger recompiles. 

I am new to this ecosystem, and although there is a makefile, it seems only to be used for elixir language development, 
and not on the "consumer" side of elixir (i.e. projects that are using elixir).

R.
Fridrik.


> >> To unsubscribe from this group and stop receiving emails from it, send an email to elixir-l...@googlegroups.com.
> >> To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/aa4e74c3-d1d6-416a-9169-77037d056db4%40googlegroups.com.
> >> For more options, visit https://groups.google.com/d/optout.
> >
> > --
> > You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to elixir-l...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages