Update Erlang.mk to experimental version

Performance was improved by avoiding calling 'find'
and instead using Make's wildcard function. Changes:

  make -C deps/rabbit nope  0,02s user 0,01s system 99% cpu 0,033 total
  make -C deps/rabbit nope  0,02s user 0,00s system 97% cpu 0,020 total
This commit is contained in:
Loïc Hoguin 2024-05-28 15:45:52 +02:00
parent 1535e730de
commit 706ebde6f7
No known key found for this signature in database
GPG Key ID: C69E26E3A9DF618F
1 changed files with 15 additions and 10 deletions

25
erlang.mk vendored
View File

@ -17,7 +17,7 @@
ERLANG_MK_FILENAME := $(realpath $(lastword $(MAKEFILE_LIST)))
export ERLANG_MK_FILENAME
ERLANG_MK_VERSION = 04c473a
ERLANG_MK_VERSION = 2022.05.31-69-gb54e4b5-dirty
ERLANG_MK_WITHOUT =
# Make 3.81 and 3.82 are deprecated.
@ -184,8 +184,9 @@ core_http_get = curl -Lf$(if $(filter-out 0,$(V)),,s)o $(call core_native_path,$
core_eq = $(and $(findstring $(1),$(2)),$(findstring $(2),$(1)))
# We skip files that contain spaces or '#' because they end up causing issues.
core_find = $(if $(wildcard $1),$(shell find $(1:%/=%) \( -type l -o -type f \) -name $(subst *,\*,$2) -not -name "*[ \#]*"))
# We skip files that contain spaces because they end up causing issues.
# Files that begin with a dot are already ignored by the wildcard function.
core_find = $(foreach f,$(wildcard $(1:%/=%)/$2),$(if $(wildcard $f/.),$(call core_find,$f,$2),$(if $(wildcard $f),$f)))
core_lc = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$(1)))))))))))))))))))))))))))
@ -3564,8 +3565,10 @@ export DEPS_DIR
REBAR_DEPS_DIR = $(DEPS_DIR)
export REBAR_DEPS_DIR
# When testing Erlang.mk and updating these, make sure
# to delete test/test_rebar_git before running tests again.
REBAR3_GIT ?= https://github.com/erlang/rebar3
REBAR3_COMMIT ?= 3f563feaf1091a1980241adefa83a32dd2eebf7c # 3.20.0
REBAR3_COMMIT ?= bde4b54248d16280b2c70a244aca3bb7566e2033 # 3.23.0
CACHE_DEPS ?= 0
@ -4018,7 +4021,7 @@ define dep_autopatch_rebar.erl
false -> ok;
{_, Files0} ->
Files = [begin
hd(filelib:wildcard("$(call core_native_path,$(DEPS_DIR)/$1/src/**/" ++ filename:rootname(F) ++ ".*rl")))
hd(filelib:wildcard("$(call core_native_path,$(DEPS_DIR)/$1/src/)**/" ++ filename:rootname(F) ++ ".*rl"))
end || "src/" ++ F <- Files0],
Names = [[" ", case lists:reverse(F) of
"lre." ++ Elif -> lists:reverse(Elif);
@ -4147,8 +4150,8 @@ define dep_autopatch_rebar.erl
"\t$$\(CC) -o $$\@ $$\? $$\(LDFLAGS) $$\(ERL_LDFLAGS) $$\(DRV_LDFLAGS) $$\(LDLIBS) $$\(EXE_LDFLAGS)",
case {filename:extension(Output), $(PLATFORM)} of
{[], _} -> "\n";
{".so", darwin} -> "-shared\n";
{".dylib", darwin} -> "-shared\n";
{".so", darwin} -> " -shared\n";
{".dylib", darwin} -> " -shared\n";
{_, darwin} -> "\n";
_ -> " -shared\n"
end])
@ -4665,7 +4668,6 @@ define makedep.erl
end,
MakeDepend = fun
(F, Fd, Mod, StartLocation) ->
{ok, Filename} = file:pid2name(Fd),
case io:parse_erl_form(Fd, undefined, StartLocation) of
{ok, AbsData, EndLocation} ->
case AbsData of
@ -5838,7 +5840,7 @@ else
ci:: $(addprefix ci-,$(CI_OTP))
ci-prepare: $(addprefix $(KERL_INSTALL_DIR)/,$(CI_OTP))
ci-prepare: $(addprefix ci-prepare-,$(CI_OTP))
ci-setup::
$(verbose) :
@ -5850,7 +5852,10 @@ ci_verbose_0 = @echo " CI " $(1);
ci_verbose = $(ci_verbose_$(V))
define ci_target
ci-$1: $(KERL_INSTALL_DIR)/$2
ci-prepare-$1: $(KERL_INSTALL_DIR)/$2
$(verbose) :
ci-$1: ci-prepare-$1
$(verbose) $(MAKE) --no-print-directory clean
$(ci_verbose) \
PATH="$(KERL_INSTALL_DIR)/$2/bin:$(PATH)" \