1717ERLANG_MK_FILENAME := $(realpath $(lastword $(MAKEFILE_LIST ) ) )
1818export ERLANG_MK_FILENAME
1919
20- ERLANG_MK_VERSION = 2022.05.31-151-gef04797-dirty
20+ ERLANG_MK_VERSION = 2022.05.31-167-g10b849e
2121ERLANG_MK_WITHOUT =
2222
2323# Make 3.81 and 3.82 are deprecated.
@@ -1754,7 +1754,9 @@ ebin/$(PROJECT).app:: $(ERL_FILES) $(CORE_FILES) $(wildcard src/$(PROJECT).app.s
17541754 $(eval FILES_TO_COMPILE := $(filter-out $(EX_FILES ) src/$(PROJECT ) .app.src,$? ) )
17551755 $(if $(strip $(FILES_TO_COMPILE ) ) ,$(call compile_erl,$(FILES_TO_COMPILE ) ) )
17561756 $(if $(filter $? ,$(EX_FILES ) ) ,$(elixirc_verbose ) $(eval MODULES := $(shell $(call erlang,$(call compile_ex.erl,$(EX_FILES ) ) ) ) ) )
1757+ $(eval ELIXIR_COMP_FAILED := $(if $(filter _ERROR_,$(firstword $(MODULES ) ) ) ,true,false) )
17571758# Older git versions do not have the --first-parent flag. Do without in that case.
1759+ $(verbose) if $(ELIXIR_COMP_FAILED); then exit 1; fi
17581760 $(eval GITDESCRIBE := $(shell git describe --dirty --abbrev=7 --tags --always --first-parent 2>/dev/null \
17591761 || git describe --dirty --abbrev=7 --tags --always 2>/dev/null || true))
17601762 $(eval MODULES := $(MODULES) $(patsubst %,'%',$(sort $(notdir $(basename \
@@ -1791,7 +1793,7 @@ clean-app:
17911793
17921794endif
17931795
1794- # Copyright (c) 2024, Tyler Hughes <[email protected] >1796+ # Copyright (c) 2024, Tyler Hughes <[email protected] >17951797# Copyright (c) 2024, Loïc Hoguin <[email protected] >17961798# This file is part of erlang.mk and subject to the terms of the ISC License.
17971799
@@ -1809,7 +1811,7 @@ else
18091811ERL_LIBS := $(ERL_LIBS ) :$(DEPS_DIR ) /elixir/lib/
18101812endif
18111813
1812- elixirc_verbose_0 = @echo " EXC $(words $(EX_FILES ) ) files"
1814+ elixirc_verbose_0 = @echo " EXC $(words $(EX_FILES ) ) files";
18131815elixirc_verbose_2 = set -x;
18141816elixirc_verbose = $(elixirc_verbose_$(V ) )
18151817
@@ -1818,13 +1820,17 @@ define dep_autopatch_mix.erl
18181820 {ok, _} = application:ensure_all_started(elixir),
18191821 {ok, _} = application:ensure_all_started(mix),
18201822 MixFile = <<"$(call core_native_path,$(DEPS_DIR ) /$1/mix.exs) ">>,
1821- [{Mod, Bin}] = elixir_compiler:file(MixFile, fun(_File, _LexerPid) -> ok end),
1823+ {Mod, Bin} =
1824+ case elixir_compiler:file(MixFile, fun(_File, _LexerPid) -> ok end) of
1825+ [{T = {_, _}, _CheckerPid}] -> T;
1826+ [T = {_, _}] -> T
1827+ end,
18221828 {module, Mod} = code:load_binary(Mod, binary_to_list(MixFile), Bin),
18231829 Project = Mod:project(),
18241830 Application = try Mod:application() catch error:undef -> [] end,
18251831 StartMod = case lists:keyfind(mod, 1, Application) of
18261832 {mod, {StartMod0, _StartArgs}} ->
1827- StartMod0;
1833+ atom_to_list( StartMod0) ;
18281834 _ ->
18291835 ""
18301836 end,
@@ -1926,15 +1932,27 @@ define dep_autopatch_mix
19261932 $(call erlang,$(call dep_autopatch_mix.erl,$1) )
19271933endef
19281934
1935+ # We change the group leader so the Elixir io:format output
1936+ # isn't captured as we need to either print the modules on
1937+ # success, or print _ERROR_ on failure.
19291938define compile_ex.erl
19301939 {ok, _} = application:ensure_all_started(elixir),
19311940 {ok, _} = application:ensure_all_started(mix),
19321941 ModCode = list_to_atom("Elixir.Code"),
19331942 ModCode:put_compiler_option(ignore_module_conflict, true),
19341943 ModComp = list_to_atom("Elixir.Kernel.ParallelCompiler"),
1935- {ok, Modules, _} = ModComp:compile_to_path([$(call comma_list,$(patsubst % ,<<"% ">>,$(EX_FILES ) ) ) ], <<"ebin/">>),
1936- lists:foreach(fun(E) -> io:format("~p ", [E]) end, Modules),
1937- halt()
1944+ ModMixProject = list_to_atom("Elixir.Mix.Project"),
1945+ erlang:group_leader(whereis(standard_error), self()),
1946+ ModMixProject:in_project($(PROJECT ) , ".", [], fun(_MixFile) ->
1947+ case ModComp:compile_to_path([$(call comma_list,$(patsubst % ,<<"% ">>,$1) ) ], <<"ebin/">>) of
1948+ {ok, Modules, _} ->
1949+ lists:foreach(fun(E) -> io:format(user, "~p ", [E]) end, Modules),
1950+ halt(0);
1951+ {error, _ErroredModules, _WarnedModules} ->
1952+ io:format(user, "_ERROR_", []),
1953+ halt(1)
1954+ end
1955+ end)
19381956endef
19391957
19401958# Copyright (c) 2016, Loïc Hoguin <[email protected] >@@ -3616,7 +3634,7 @@ define hex_tarball_create.erl
36163634 <<"$(if $(subst hex,,$(call query_fetch_method,$d) ) ,$d,$(if $(word 3,$(dep_$d ) ) ,$(word 3,$(dep_$d ) ) ,$d) ) ">> => #{
36173635 <<"app">> => <<"$d">>,
36183636 <<"optional">> => false,
3619- <<"requirement">> => <<"$(call query_version,$d) ">>
3637+ <<"requirement">> => <<"$(if $( hex_req_$d ) , $( strip $( hex_req_$d ) ) , $( call query_version,$d) ) ">>
36203638 },)
36213639 $(if $(DEPS ) ,dummy => dummy)
36223640 },
0 commit comments