-
Notifications
You must be signed in to change notification settings - Fork 14
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
Improve precompiled DX #121
Conversation
fa67897
to
e206574
Compare
56c8e1d
to
18eda03
Compare
require Logger | ||
|
||
Logger.error(""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
require Logger | |
Logger.error(""" | |
Bundlex.Output.warn(""" |
Are you sure Logger will work here? Loading a NIF may happen in the compile time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm quite sure. I changed it from raise
because previously we'd get both error and warning, both via Logger. I think Bundlex.Output.warn
would work too, but I'm not sure about other Bundlex.Output
functions, so I'd not use it in runtime
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so I checked and in the compilation the bundlex compilation is called first and there we do Application.ensure_all_started
https://github.com/membraneframework/bundlex/blob/master/lib/mix/tasks/compile.bundlex.ex#L22 and because we have :logger
in extra_applications
in mix.exs
, the logger should be started at that point. So, it seems that the logger is started before any C code is even compiled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If so, is there any reason to call IO.warn/1
in Bundlex.Output.warn/1
or Mix.shell().info/1
in Bundlex.Output.info/1
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why we do this, probably we could use Logger as well ¯\_(ツ)_/¯
Application.get_env(:bundlex, :disable_precompiled_os_deps, []) | ||
|> Keyword.get(:apps, []) | ||
|> Bunch.listify() | ||
is_precompiled_disabled = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is_precompiled_disabled = | |
precompiled_disabled? = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The convention is to use the quotation mark in function names only AFAIK
|
||
if native.app in disabled_apps do | ||
if is_precompiled_disabled do | ||
{:error, | ||
""" | ||
is disabled in the application configuration, check the config.exs file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW this error message looks strange. What is disabled in the application configuration
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's concatenated to a prefix in line 90 :P
```elixir | ||
config :bundlex, :disable_precompiled_os_deps, true | ||
``` | ||
|
||
Note that this will affect the natives and libs defined in the `bundlex.exs` files of specified | ||
applications only, not in their dependencies. | ||
or for given applications (Mix projects), for example: | ||
|
||
```elixir | ||
config :bundlex, :disable_precompiled_os_deps, | ||
apps: [:my_application, :another_application] | ||
``` | ||
|
||
Note that this will affect the natives and libs defined in the `bundlex.exs` files of specified | ||
applications only, not in their dependencies. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary additional tab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without it the indent breaks in the generated docs for some reason
is_precompiled_disabled = | ||
case Application.get_env(:bundlex, :disable_precompiled_os_deps, false) do | ||
bool when is_boolean(bool) -> bool | ||
[apps: apps] -> native.app in Bunch.listify(apps) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not mentioned in the Bundlex.Project
moduledoc, that apps
might be also just name of the app, eg. [apps: :my_app]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meh, I don't like the fact, that in one place we use Logger
and in the another place we use IO
, but I understand that there is no option to have an error-like log without nor raising an error neither using Logger
dc01cc2
to
7af0f89
Compare
No description provided.