Skip to content

Commit e98716e

Browse files
committed
Allow disabling Eunit, and update Erlang.mk
Elixir will not be checked for if there are no EX_FILES.
1 parent 32d6d03 commit e98716e

File tree

2 files changed

+56
-38
lines changed

2 files changed

+56
-38
lines changed

deps/rabbitmq_cli/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ ifeq ($(VERBOSE_TEST),true)
4242
MIX_TEST := $(MIX_TEST) --trace
4343
endif
4444

45+
EUNIT = disable
46+
4547
export MAKE
4648

4749
ESCRIPT_NAME = Elixir.RabbitMQCtl

erlang.mk

Lines changed: 54 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
ERLANG_MK_FILENAME := $(realpath $(lastword $(MAKEFILE_LIST)))
1818
export ERLANG_MK_FILENAME
1919

20-
ERLANG_MK_VERSION = 2022.05.31-167-g10b849e
20+
ERLANG_MK_VERSION = 2022.05.31-171-g33d7b80
2121
ERLANG_MK_WITHOUT =
2222

2323
# Make 3.81 and 3.82 are deprecated.
@@ -361,7 +361,7 @@ pkg_proper_name = proper
361361
pkg_proper_description = PropEr: a QuickCheck-inspired property-based testing tool for Erlang.
362362
pkg_proper_homepage = http://proper.softlab.ntua.gr
363363
pkg_proper_fetch = git
364-
pkg_proper_repo = https://github.com/proper-testing/proper
364+
pkg_proper_repo = https://github.com/manopapad/proper
365365
pkg_proper_commit = master
366366

367367
PACKAGES += ranch
@@ -1239,37 +1239,6 @@ define hex_get_tarball.erl
12391239
end
12401240
endef
12411241

1242-
# Unfortunately this currently requires Elixir.
1243-
define hex_version_resolver.erl
1244-
HexVersionResolve = fun(Name, Req) ->
1245-
application:ensure_all_started(ssl),
1246-
application:ensure_all_started(inets),
1247-
Config = $(hex_config.erl),
1248-
case hex_repo:get_package(Config, atom_to_binary(Name)) of
1249-
{ok, {200, _RespHeaders, Package}} ->
1250-
#{releases := List} = Package,
1251-
{value, #{version := Version}} = lists:search(fun(#{version := Vsn}) ->
1252-
M = list_to_atom("Elixir.Version"),
1253-
F = list_to_atom("match?"),
1254-
M:F(Vsn, Req)
1255-
end, List),
1256-
{ok, Version};
1257-
{ok, {Status, _, Errors}} ->
1258-
{error, Status, Errors}
1259-
end
1260-
end,
1261-
HexVersionResolveAndPrint = fun(Name, Req) ->
1262-
case HexVersionResolve(Name, Req) of
1263-
{ok, Version} ->
1264-
io:format("~s", [Version]),
1265-
halt(0);
1266-
{error, Status, Errors} ->
1267-
io:format("Error ~b: ~0p~n", [Status, Errors]),
1268-
halt(77)
1269-
end
1270-
end
1271-
endef
1272-
12731242
ifeq ($(CACHE_DEPS),1)
12741243

12751244
# Hex only has a package version. No need to look in the Erlang.mk packages.
@@ -1325,7 +1294,7 @@ endif
13251294

13261295
ifeq ($1,elixir)
13271296
autopatch-elixir::
1328-
ln -s lib/elixir/ebin $(DEPS_DIR)/elixir/
1297+
$$(verbose) ln -s lib/elixir/ebin $(DEPS_DIR)/elixir/
13291298
else
13301299
autopatch-$(call query_name,$1)::
13311300
$$(autopatch_verbose) $$(call dep_autopatch_for_$(AUTOPATCH_METHOD),$(call query_name,$1))
@@ -1530,7 +1499,6 @@ ALL_SRC_FILES := $(sort $(call core_find,src/,*))
15301499
ERL_FILES := $(filter %.erl,$(ALL_SRC_FILES))
15311500
CORE_FILES := $(filter %.core,$(ALL_SRC_FILES))
15321501

1533-
# @todo Must be defined first.
15341502
ALL_LIB_FILES := $(sort $(call core_find,lib/,*))
15351503
EX_FILES := $(filter-out lib/mix/%,$(filter %.ex,$(ALL_SRC_FILES) $(ALL_LIB_FILES)))
15361504

@@ -1753,7 +1721,7 @@ endef
17531721
ebin/$(PROJECT).app:: $(ERL_FILES) $(CORE_FILES) $(wildcard src/$(PROJECT).app.src) $(EX_FILES)
17541722
$(eval FILES_TO_COMPILE := $(filter-out $(EX_FILES) src/$(PROJECT).app.src,$?))
17551723
$(if $(strip $(FILES_TO_COMPILE)),$(call compile_erl,$(FILES_TO_COMPILE)))
1756-
$(if $(filter $?,$(EX_FILES)),$(elixirc_verbose) $(eval MODULES := $(shell $(call erlang,$(call compile_ex.erl,$(EX_FILES))))))
1724+
$(if $(filter $(ELIXIR),disable),,$(if $(filter $?,$(EX_FILES)),$(elixirc_verbose) $(eval MODULES := $(shell $(call erlang,$(call compile_ex.erl,$(EX_FILES)))))))
17571725
$(eval ELIXIR_COMP_FAILED := $(if $(filter _ERROR_,$(firstword $(MODULES))),true,false))
17581726
# Older git versions do not have the --first-parent flag. Do without in that case.
17591727
$(verbose) if $(ELIXIR_COMP_FAILED); then exit 1; fi
@@ -1797,24 +1765,64 @@ endif
17971765
# Copyright (c) 2024, Loïc Hoguin <[email protected]>
17981766
# This file is part of erlang.mk and subject to the terms of the ISC License.
17991767

1800-
ELIXIR ?= $(if $(filter elixir,$(BUILD_DEPS) $(DEPS)),dep,system)
1768+
# Elixir is automatically enabled in all cases except when
1769+
# an Erlang project uses an Elixir dependency. In that case
1770+
# $(ELIXIR) must be set explicitly.
1771+
ELIXIR ?= $(if $(filter elixir,$(BUILD_DEPS) $(DEPS)),dep,$(if $(EX_FILES),system,disable))
18011772
export ELIXIR
18021773

18031774
ifeq ($(ELIXIR),system)
18041775
# We expect 'elixir' to be on the path.
1805-
# @todo Only if there are EX_FILES
18061776
ELIXIR_LIBS ?= $(dir $(shell readlink -f `which elixir`))/../lib
18071777
ELIXIR_LIBS := $(ELIXIR_LIBS)
18081778
export ELIXIR_LIBS
18091779
ERL_LIBS := $(ERL_LIBS):$(ELIXIR_LIBS)
18101780
else
1781+
ifeq ($(ELIXIR),dep)
18111782
ERL_LIBS := $(ERL_LIBS):$(DEPS_DIR)/elixir/lib/
18121783
endif
1784+
endif
18131785

18141786
elixirc_verbose_0 = @echo " EXC $(words $(EX_FILES)) files";
18151787
elixirc_verbose_2 = set -x;
18161788
elixirc_verbose = $(elixirc_verbose_$(V))
18171789

1790+
# Unfortunately this currently requires Elixir.
1791+
# https://github.com/jelly-beam/verl is a good choice
1792+
# for an Erlang implementation, but we already have to
1793+
# pull hex_core and Rebar3 so adding yet another pull
1794+
# is annoying, especially one that would be necessary
1795+
# every time we autopatch Rebar projects. Wait and see.
1796+
define hex_version_resolver.erl
1797+
HexVersionResolve = fun(Name, Req) ->
1798+
application:ensure_all_started(ssl),
1799+
application:ensure_all_started(inets),
1800+
Config = $(hex_config.erl),
1801+
case hex_repo:get_package(Config, atom_to_binary(Name)) of
1802+
{ok, {200, _RespHeaders, Package}} ->
1803+
#{releases := List} = Package,
1804+
{value, #{version := Version}} = lists:search(fun(#{version := Vsn}) ->
1805+
M = list_to_atom("Elixir.Version"),
1806+
F = list_to_atom("match?"),
1807+
M:F(Vsn, Req)
1808+
end, List),
1809+
{ok, Version};
1810+
{ok, {Status, _, Errors}} ->
1811+
{error, Status, Errors}
1812+
end
1813+
end,
1814+
HexVersionResolveAndPrint = fun(Name, Req) ->
1815+
case HexVersionResolve(Name, Req) of
1816+
{ok, Version} ->
1817+
io:format("~s", [Version]),
1818+
halt(0);
1819+
{error, Status, Errors} ->
1820+
io:format("Error ~b: ~0p~n", [Status, Errors]),
1821+
halt(77)
1822+
end
1823+
end
1824+
endef
1825+
18181826
define dep_autopatch_mix.erl
18191827
$(call hex_version_resolver.erl),
18201828
{ok, _} = application:ensure_all_started(elixir),
@@ -1926,6 +1934,7 @@ define dep_autopatch_mix.erl
19261934
endef
19271935

19281936
define dep_autopatch_mix
1937+
if [ "$(ELIXIR)" = "disable" ]; then echo "Elixir is currently disabled. Please set 'ELIXIR = system' in the Makefile to enable"; exit 99; fi
19291938
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; \
19301939
$(MAKE) $(DEPS_DIR)/hex_core/ebin/dep_built; \
19311940
MIX_ENV="$(if $(MIX_ENV),$(strip $(MIX_ENV)),prod)" \
@@ -3483,6 +3492,11 @@ distclean-escript:
34833492

34843493
.PHONY: eunit apps-eunit
34853494

3495+
# Eunit can be disabled by setting this to any other value.
3496+
EUNIT ?= system
3497+
3498+
ifeq ($(EUNIT),system)
3499+
34863500
# Configuration
34873501

34883502
EUNIT_OPTS ?=
@@ -3541,6 +3555,8 @@ apps-eunit: test-build
35413555
endif
35423556
endif
35433557

3558+
endif
3559+
35443560
# Copyright (c) 2020, Loïc Hoguin <[email protected]>
35453561
# This file is part of erlang.mk and subject to the terms of the ISC License.
35463562

0 commit comments

Comments
 (0)