Skip to content

Commit 65c6b7f

Browse files
committed
Update Erlang.mk to get the Windows optimization
1 parent 3d057d7 commit 65c6b7f

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

erlang.mk

Lines changed: 21 additions & 16 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 = f157f11
20+
ERLANG_MK_VERSION = 2022.05.31-137-g1d40371
2121
ERLANG_MK_WITHOUT =
2222

2323
# Make 3.81 and 3.82 are deprecated.
@@ -59,11 +59,6 @@ gen_verbose_esc_0 = @echo " GEN " $$@;
5959
gen_verbose_esc_2 = set -x;
6060
gen_verbose_esc = $(gen_verbose_esc_$(V))
6161

62-
# Temporary files directory.
63-
64-
ERLANG_MK_TMP ?= $(CURDIR)/.erlang.mk
65-
export ERLANG_MK_TMP
66-
6762
# "erl" command.
6863

6964
ERL = erl -noinput -boot no_dot_erlang -kernel start_distribution false +P 1024 +Q 1024
@@ -98,6 +93,19 @@ endif
9893
export PLATFORM
9994
endif
10095

96+
ifeq ($(PLATFORM),msys2)
97+
core_native_path = $(shell cygpath -m $1)
98+
else
99+
core_native_path = $1
100+
endif
101+
102+
# Temporary files directory.
103+
104+
ERLANG_MK_TMP ?= $(CURDIR)/.erlang.mk
105+
export ERLANG_MK_TMP
106+
107+
NATIVE_ERLANG_MK_TMP = $(eval NATIVE_ERLANG_MK_TMP := $$(call core_native_path,$(ERLANG_MK_TMP)))$(NATIVE_ERLANG_MK_TMP)
108+
101109
# Core targets.
102110

103111
all:: deps app rel
@@ -174,12 +182,6 @@ define erlang
174182
$(ERL) $2 -pz $(ERLANG_MK_TMP)/rebar3/_build/prod/lib/*/ebin/ -eval "$(subst $(newline),,$(call escape_dquotes,$1))" -- erlang.mk
175183
endef
176184

177-
ifeq ($(PLATFORM),msys2)
178-
core_native_path = $(shell cygpath -m $1)
179-
else
180-
core_native_path = $1
181-
endif
182-
183185
core_http_get = curl -Lf$(if $(filter-out 0,$V),,s)o $(call core_native_path,$1) $2
184186

185187
core_eq = $(and $(findstring $1,$2),$(findstring $2,$1))
@@ -448,6 +450,8 @@ CACHE_DEPS ?= 0
448450
CACHE_DIR ?= $(if $(XDG_CACHE_HOME),$(XDG_CACHE_HOME),$(HOME)/.cache)/erlang.mk
449451
export CACHE_DIR
450452

453+
NATIVE_CACHE_DIR = $(eval NATIVE_CACHE_DIR := $$(call core_native_path,$(CACHE_DIR)))$(NATIVE_CACHE_DIR)
454+
451455
HEX_CONFIG ?=
452456

453457
define hex_config.erl
@@ -1247,7 +1251,7 @@ define hex_get_tarball.erl
12471251
Config = $(hex_config.erl),
12481252
case hex_repo:get_tarball(Config, <<"$1">>, <<"$(strip $2)">>) of
12491253
{ok, {200, _, Tarball}} ->
1250-
ok = file:write_file("$(call core_native_path,$3)", Tarball),
1254+
ok = file:write_file("$3", Tarball),
12511255
halt(0);
12521256
{ok, {Status, _, Errors}} ->
12531257
io:format("Error ~b: ~0p~n", [Status, Errors]),
@@ -1263,7 +1267,7 @@ define dep_fetch_hex
12631267
$(eval hex_pkg_name := $(if $(word 3,$(dep_$1)),$(word 3,$(dep_$1)),$1)) \
12641268
$(eval hex_tar_name := $(hex_pkg_name)-$(strip $(word 2,$(dep_$1))).tar) \
12651269
$(if $(wildcard $(CACHE_DIR)/hex/$(hex_tar_name)),,\
1266-
$(call erlang,$(call hex_get_tarball.erl,$(hex_pkg_name),$(word 2,$(dep_$1)),$(CACHE_DIR)/hex/$(hex_tar_name)));) \
1270+
$(call erlang,$(call hex_get_tarball.erl,$(hex_pkg_name),$(word 2,$(dep_$1)),$(NATIVE_CACHE_DIR)/hex/$(hex_tar_name)));) \
12671271
tar -xOf $(CACHE_DIR)/hex/$(hex_tar_name) contents.tar.gz | tar -C $(DEPS_DIR)/$1 -xzf -;
12681272
endef
12691273

@@ -1272,7 +1276,7 @@ else
12721276
# Hex only has a package version. No need to look in the Erlang.mk packages.
12731277
define dep_fetch_hex
12741278
mkdir -p $(ERLANG_MK_TMP)/hex $(DEPS_DIR)/$1; \
1275-
$(call erlang,$(call hex_get_tarball.erl,$(if $(word 3,$(dep_$1)),$(word 3,$(dep_$1)),$1),$(word 2,$(dep_$1)),$(ERLANG_MK_TMP)/hex/$1.tar)); \
1279+
$(call erlang,$(call hex_get_tarball.erl,$(if $(word 3,$(dep_$1)),$(word 3,$(dep_$1)),$1),$(word 2,$(dep_$1)),$(NATIVE_ERLANG_MK_TMP)/hex/$1.tar)); \
12761280
tar -xOf $(ERLANG_MK_TMP)/hex/$1.tar contents.tar.gz | tar -C $(DEPS_DIR)/$1 -xzf -;
12771281
endef
12781282

@@ -1954,7 +1958,8 @@ define dep_autopatch_mix.erl
19541958
endef
19551959

19561960
define dep_autopatch_mix
1957-
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; \
1961+
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; \
1962+
mv $(DEPS_DIR)/$(1)/mix.exs.new $(DEPS_DIR)/$(1)/mix.exs; \
19581963
$(MAKE) $(DEPS_DIR)/hex_core/ebin/dep_built; \
19591964
MIX_ENV="$(if $(MIX_ENV),$(strip $(MIX_ENV)),prod)" \
19601965
$(call erlang,$(call dep_autopatch_mix.erl,$1))

0 commit comments

Comments
 (0)