1717ERLANG_MK_FILENAME := $(realpath $(lastword $(MAKEFILE_LIST ) ) )
1818export ERLANG_MK_FILENAME
1919
20- ERLANG_MK_VERSION = e13b4c7
20+ ERLANG_MK_VERSION = 7cef74a
2121ERLANG_MK_WITHOUT =
2222
2323# Make 3.81 and 3.82 are deprecated.
@@ -559,6 +559,14 @@ export ERL_LIBS
559559
560560export NO_AUTOPATCH
561561
562+ # Elixir.
563+
564+ # Elixir is automatically enabled in all cases except when
565+ # an Erlang project uses an Elixir dependency. In that case
566+ # $(ELIXIR) must be set explicitly.
567+ ELIXIR ?= $(if $(filter elixir,$(BUILD_DEPS ) $(DEPS ) ) ,dep,$(if $(EX_FILES ) ,system,disable) )
568+ export ELIXIR
569+
562570# Verbosity.
563571
564572dep_verbose_0 = @echo " DEP $1 ($(call query_version,$1) )";
@@ -940,10 +948,11 @@ define dep_autopatch_rebar.erl
940948 Write(io_lib:format("COMPILE_FIRST +=~s\n", [Names]))
941949 end
942950 end(),
943- Write("\n\nrebar_dep: preprocess pre-deps deps pre-app app\n"),
951+ Write("\n\nrebar_dep: preprocess pre-deps deps pre-app app post-app \n"),
944952 Write("\npreprocess::\n"),
945953 Write("\npre-deps::\n"),
946954 Write("\npre-app::\n"),
955+ Write("\npost-app::\n"),
947956 PatchHook = fun(Cmd) ->
948957 Cmd2 = re:replace(Cmd, "^([g]?make)(.*)( -C.*)", "\\\\1\\\\3\\\\2", [{return, list}]),
949958 case Cmd2 of
@@ -974,6 +983,24 @@ define dep_autopatch_rebar.erl
974983 end || H <- Hooks]
975984 end
976985 end(),
986+ fun() ->
987+ case lists:keyfind(post_hooks, 1, Conf) of
988+ false -> ok;
989+ {_, Hooks} ->
990+ [case H of
991+ {compile, Cmd} ->
992+ Write("\npost-app::\n\tCC=$$\(CC) " ++ PatchHook(Cmd) ++ "\n");
993+ {{pc, compile}, Cmd} ->
994+ Write("\npost-app::\n\tCC=$$\(CC) " ++ PatchHook(Cmd) ++ "\n");
995+ {Regex, compile, Cmd} ->
996+ case rebar_utils:is_arch(Regex) of
997+ true -> Write("\npost-app::\n\tCC=$$\(CC) " ++ PatchHook(Cmd) ++ "\n");
998+ false -> ok
999+ end;
1000+ _ -> ok
1001+ end || H <- Hooks]
1002+ end
1003+ end(),
9771004 ShellToMk = fun(V0) ->
9781005 V1 = re:replace(V0, "[$$][(]", "$$\(shell ", [global]),
9791006 V = re:replace(V1, "([$$])(?![(])(\\\\w*)", "\\\\1(\\\\2)", [global]),
@@ -1778,12 +1805,6 @@ endif
17781805# Copyright (c) 2024, Loïc Hoguin <[email protected] >17791806# This file is part of erlang.mk and subject to the terms of the ISC License.
17801807
1781- # Elixir is automatically enabled in all cases except when
1782- # an Erlang project uses an Elixir dependency. In that case
1783- # $(ELIXIR) must be set explicitly.
1784- ELIXIR ?= $(if $(filter elixir,$(BUILD_DEPS ) $(DEPS ) ) ,dep,$(if $(EX_FILES ) ,system,disable) )
1785- export ELIXIR
1786-
17871808ifeq ($(ELIXIR ) ,system)
17881809# We expect 'elixir' to be on the path.
17891810ELIXIR_BIN ?= $(shell readlink -f `which elixir`)
@@ -1952,7 +1973,8 @@ define dep_autopatch_mix.erl
19521973endef
19531974
19541975define dep_autopatch_mix
1955- sed 's|\(defmodule.*do\)|\1\n try do\n Code.compiler_options(on_undefined_variable: :warn)\n rescue _ -> :ok\n end\n|g' -i $(DEPS_DIR ) /$(1 ) /mix.exs; \
1976+ sed 's|\(defmodule.*do\)|\1\n try do\n Code.compiler_options(on_undefined_variable: :warn)\n rescue _ -> :ok\n end\n|g' $(DEPS_DIR ) /$(1 ) /mix.exs > $(DEPS_DIR ) /$(1 ) /mix.exs.new; \
1977+ mv $(DEPS_DIR ) /$(1 ) /mix.exs.new $(DEPS_DIR ) /$(1 ) /mix.exs; \
19561978 $(MAKE ) $(DEPS_DIR ) /hex_core/ebin/dep_built; \
19571979 MIX_ENV="$(if $(MIX_ENV ) ,$(strip $(MIX_ENV ) ) ,prod) " \
19581980 $(call erlang,$(call dep_autopatch_mix.erl,$1) )
@@ -1964,6 +1986,7 @@ endef
19641986define compile_ex.erl
19651987 {ok, _} = application:ensure_all_started(elixir),
19661988 {ok, _} = application:ensure_all_started(mix),
1989+ $(foreach dep,$(LOCAL_DEPS ) ,_ = application:load($(dep ) ) ,)
19671990 ModCode = list_to_atom("Elixir.Code"),
19681991 ModCode:put_compiler_option(ignore_module_conflict, true),
19691992 ModComp = list_to_atom("Elixir.Kernel.ParallelCompiler"),
0 commit comments