Skip to content

Commit

Permalink
allow globally disabling precompiled deps
Browse files Browse the repository at this point in the history
  • Loading branch information
mat-hek committed Jan 4, 2024
1 parent 90721da commit e206574
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
20 changes: 13 additions & 7 deletions lib/bundlex/project.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Check `t:os_dep/0` for details.
* `pkg_configs` - (deprecated, use `os_deps` instead) Names of libraries for which the appropriate flags will be
Expand Down
13 changes: 7 additions & 6 deletions lib/bundlex/toolchain/common/unix/os_deps.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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.
""")
Expand Down Expand Up @@ -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 =
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)
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.
Expand Down

0 comments on commit e206574

Please sign in to comment.