erlang.mk
erlang.mk copied to clipboard
Erlang.mk and Elixir apps
I have Many applications in one repository
, as in the guide, under the apps
directory.
I have a top level Makefile where I declare several Erlang dependencies (git).
If the apps are Erlang, everything works. How can I integrate an Elixir app ?
I tried adding simple elixir app, which in turn depends on an Erlang app. This Erlang app dependencies end up at the top level deps folder, and then mix compile fails to work.
Do you have a guide on how to integrate an elixir app with Erlang.mk, either via DEP or via LOCAL_DEP?
I don't have a guide. RabbitMQ has done it with https://github.com/rabbitmq/rabbitmq-cli but it is using Erlang.mk in the Elixir dependency itself as well. Otherwise there's some plugins but I do not know how well they work, might need some updating: https://erlang.mk/guide/plugins_list.html
Hi @picaoao and @essen, I've added the following in my Makefile to:
- to
autopatch
Elixir dependencies - to disable dependency resolution of
mix
for Elixir apps
# Elixir specific section
ELIXIR_MIX_ENV ?= prod
define render_tmpl
printf -- '$(subst $(newline),\n,$(subst %,%%,$(subst $(tab),$(WS),$(call $(1)))))\n' > $(2)
endef
define bs_mix_Makefile
include ../../erlang.mk
compile-ex: local-hex
\t@ MIX_ENV=$m mix compile --no-archives-check --no-protocol-consolidation --no-deps-check
\t@ ln -s _build/$m/lib/$d/ebin ebin
local-%:
\t@ mix local.$$* --force
endef
override define dep_autopatch_noop
if [ -f $(DEPS_DIR)/$(1)/mix.lock -o -f $(DEPS_DIR)/$(1)/mix.exs ]; then \
$(eval m := $(ELIXIR_MIX_ENV)) \
$(eval d := $(1)) \
$(call render_tmpl,bs_mix_Makefile,$(DEPS_DIR)/$(1)/Makefile); \
$(MAKE) -C $(DEPS_DIR)/$(1) compile-ex; \
else \
printf "noop:\n" > $(DEPS_DIR)/$(1)/Makefile; \
fi
endef
# End of 'Elixir specific section'
Probably not a guide, but it works for small projects :)
Sounds good. Maybe this can be extended with extracting deps from the mix.lock/exs files and then it'd work for everything.
I'm trying the same, run a small elixir application between other erlang apps, I'm getting this error
failed to calculate used apps for iexapp
error:{badmatch,{error,enoent}}
[{'calculate-dep-targets_escript__escript__1624__474815__975373__5',
consult_for_app_deps,2,
[{file,"/home/main/scripts/calculate-dep-targets.escript"},
{line,65}]},
{'calculate-dep-targets_escript__escript__1624__474815__975373__5',calc,2,
[{file,"/home/main/scripts/calculate-dep-targets.escript"},
{line,27}]},
{'calculate-dep-targets_escript__escript__1624__474815__975373__5',main,1,
[{file,"/home/main/scripts/calculate-dep-targets.escript"},
{line,14}]},
{escript,run,2,[{file,"escript.erl"},{line,758}]},
{escript,start,1,[{file,"escript.erl"},{line,277}]},
{init,start_em,1,[]},
{init,do_boot,3,[]}]
make: *** [.test.deps] Error 1
Your error is in "/home/main/scripts/calculate-dep-targets.escript", I don't know what that is.
yeah, this guy is the failing https://github.com/2600hz/kazoo/blob/master/scripts/calculate-dep-targets.escript
Well it tries to open a .app.src file. I don't think it's related to this ticket at all. If you think it's related to Erlang.mk please open a new ticket, but I don't think it is? It seems that a script in Kazoo just expects all deps to have .app;src files, nothing else.
thank you very much @essen, should I delete my comments? since it is not related
No need I've hidden all comments. Cheers.