-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,15 +47,21 @@ defmodule Bundlex.Project do | |
- `precompiled` - Downloads the dependency from a given url and sets appropriate compilation | ||
and linking flags. Can be either `{:precompiled, url, libs}` or `{:precompiled, url}`, in which | ||
case the dependency name will be used as the lib name. | ||
Precompiled dependencies for given applications (Mix projects) can be disabled via configuration, for example: | ||
Precompiled dependencies can be disabled via configuration globally: | ||
|
||
```elixir | ||
config :bundlex, :disable_precompiled_os_deps, | ||
apps: [:my_application, :another_application] | ||
``` | ||
```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. | ||
Comment on lines
+52
to
+64
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Without it the indent breaks in the generated docs for some reason |
||
|
||
Check `t:os_dep/0` for details. | ||
* `pkg_configs` - (deprecated, use `os_deps` instead) Names of libraries for which the appropriate flags will be | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -38,7 +38,7 @@ defmodule Bundlex.Toolchain.Common.Unix.OSDeps do | |||||
end | ||||||
|
||||||
if is_old_api do | ||||||
IO.warn(""" | ||||||
Output.warn(""" | ||||||
Native #{inspect(native_name)} uses deprecated syntax for `os_deps`. \ | ||||||
See `Bundlex.Project.os_dep` for the new syntax. | ||||||
""") | ||||||
|
@@ -110,12 +110,13 @@ defmodule Bundlex.Toolchain.Common.Unix.OSDeps do | |||||
end | ||||||
|
||||||
defp resolve_os_dep_provider(name, {:precompiled, url, lib_names}, native) do | ||||||
disabled_apps = | ||||||
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 commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||||||
case Application.get_env(:bundlex, :disable_precompiled_os_deps, false) do | ||||||
bool when is_boolean(bool) -> bool | ||||||
[apps: apps] when is_list(apps) -> native.app in apps | ||||||
end | ||||||
|
||||||
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 commentThe reason will be displayed to describe this comment to others. Learn more. BTW this error message looks strange. What There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's concatenated to a prefix in line 90 :P |
||||||
|
@@ -136,7 +137,7 @@ defmodule Bundlex.Toolchain.Common.Unix.OSDeps do | |||||
create_relative_symlink(lib_path, output_path, dep_dir_name) | ||||||
|
||||||
# TODO: pass the platform via arguments | ||||||
# $ORIGIN must be escaped soo that it's not treated as an ENV variable | ||||||
# $ORIGIN must be escaped so that it's not treated as an ENV variable | ||||||
rpath_root = if Bundlex.platform() == :macosx, do: "@loader_path", else: "\\$ORIGIN" | ||||||
|
||||||
[ | ||||||
|
@@ -183,11 +184,13 @@ defmodule Bundlex.Toolchain.Common.Unix.OSDeps do | |||||
|> then(&{:ok, &1}) | ||||||
rescue | ||||||
e -> | ||||||
{:error, | ||||||
""" | ||||||
couldn't load #{inspect(pkg_configs)} libraries with pkg-config due to: | ||||||
#{format_exception(e)} | ||||||
"""} | ||||||
error = """ | ||||||
couldn't load #{inspect(pkg_configs)} libraries with pkg-config due to: | ||||||
#{format_exception(e)} | ||||||
""" | ||||||
|
||||||
Output.warn(error) | ||||||
{:error, error} | ||||||
end | ||||||
end | ||||||
|
||||||
|
@@ -222,11 +225,13 @@ defmodule Bundlex.Toolchain.Common.Unix.OSDeps do | |||||
e -> | ||||||
File.rm_rf!(package_path) | ||||||
|
||||||
{:error, | ||||||
""" | ||||||
couldn't download and extract the precompiled dependency #{inspect(name)} due to: | ||||||
#{format_exception(e)} | ||||||
"""} | ||||||
error = """ | ||||||
couldn't download and extract the precompiled dependency #{inspect(name)} due to: | ||||||
#{format_exception(e)} | ||||||
""" | ||||||
|
||||||
Output.warn(error) | ||||||
{:error, error} | ||||||
end | ||||||
end | ||||||
end | ||||||
|
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.
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 thinkBundlex.Output.warn
would work too, but I'm not sure about otherBundlex.Output
functions, so I'd not use it in runtimeThere 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
inextra_applications
inmix.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
inBundlex.Output.warn/1
orMix.shell().info/1
inBundlex.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 ¯\_(ツ)_/¯