Browse Source

Autopatch: Move to Rebar3

Loïc Hoguin 2 years ago
parent
commit
2f5e90da51
4 changed files with 20 additions and 11 deletions
  1. 9 0
      CHANGELOG.asciidoc
  2. 1 1
      core/core.mk
  3. 7 7
      core/deps.mk
  4. 3 3
      test/Makefile

+ 9 - 0
CHANGELOG.asciidoc

@@ -35,3 +35,12 @@
             Xref language to perform custom queries. Erlang.mk
             Xref language to perform custom queries. Erlang.mk
             can also run analyses and queries against all
             can also run analyses and queries against all
             dependencies as well as Erlang/OTP applications.
             dependencies as well as Erlang/OTP applications.
+
+2023/05/05: Rebar3 is now used for autopatch instead of
+            Rebar2. `make distclean` or `rm -rf .erlang.mk`
+            might be required after updating Erlang.mk.
+            Moving to Rebar3 increases compatibility now
+            that few maintained projects are using Rebar2.
+            For compatibility reasons the variables to
+            point to a different rebar are now REBAR3_GIT
+            and REBAR3_COMMIT.

+ 1 - 1
core/core.mk

@@ -171,7 +171,7 @@ endef
 
 
 # Adding erlang.mk to make Erlang scripts who call init:get_plain_arguments() happy.
 # Adding erlang.mk to make Erlang scripts who call init:get_plain_arguments() happy.
 define erlang
 define erlang
-$(ERL) $2 -pz $(ERLANG_MK_TMP)/rebar/ebin -eval "$(subst $(newline),,$(call escape_dquotes,$1))" -- erlang.mk
+$(ERL) $2 -pz $(ERLANG_MK_TMP)/rebar3/_build/prod/lib/*/ebin/ -eval "$(subst $(newline),,$(call escape_dquotes,$1))" -- erlang.mk
 endef
 endef
 
 
 ifeq ($(PLATFORM),msys2)
 ifeq ($(PLATFORM),msys2)

+ 7 - 7
core/deps.mk

@@ -21,8 +21,8 @@ export DEPS_DIR
 REBAR_DEPS_DIR = $(DEPS_DIR)
 REBAR_DEPS_DIR = $(DEPS_DIR)
 export REBAR_DEPS_DIR
 export REBAR_DEPS_DIR
 
 
-REBAR_GIT ?= https://github.com/rebar/rebar
+REBAR3_GIT ?= https://github.com/erlang/rebar3
-REBAR_COMMIT ?= 576e12171ab8d69b048b827b92aa65d067deea01
+REBAR3_COMMIT ?= 3f563feaf1091a1980241adefa83a32dd2eebf7c # 3.20.0
 
 
 # External "early" plugins (see core/plugins.mk for regular plugins).
 # External "early" plugins (see core/plugins.mk for regular plugins).
 # They both use the core_dep_plugin macro.
 # They both use the core_dep_plugin macro.
@@ -301,10 +301,10 @@ define dep_autopatch_fetch_rebar
 endef
 endef
 
 
 define dep_autopatch_fetch_rebar2
 define dep_autopatch_fetch_rebar2
-	if [ ! -d $(ERLANG_MK_TMP)/rebar ]; then \
+	if [ ! -d $(ERLANG_MK_TMP)/rebar3 ]; then \
-		git clone -q -n -- $(REBAR_GIT) $(ERLANG_MK_TMP)/rebar; \
+		git clone -q -n -- $(REBAR3_GIT) $(ERLANG_MK_TMP)/rebar3; \
-		cd $(ERLANG_MK_TMP)/rebar; \
+		cd $(ERLANG_MK_TMP)/rebar3; \
-		git checkout -q $(REBAR_COMMIT); \
+		git checkout -q $(REBAR3_COMMIT); \
 		./bootstrap; \
 		./bootstrap; \
 		cd -; \
 		cd -; \
 	fi
 	fi
@@ -321,7 +321,7 @@ endef
 define dep_autopatch_rebar.erl
 define dep_autopatch_rebar.erl
 	application:load(rebar),
 	application:load(rebar),
 	application:set_env(rebar, log_level, debug),
 	application:set_env(rebar, log_level, debug),
-	rmemo:start(),
+	{module, rebar3} = c:l(rebar3),
 	Conf1 = case file:consult("$(call core_native_path,$(DEPS_DIR)/$1/rebar.config)") of
 	Conf1 = case file:consult("$(call core_native_path,$(DEPS_DIR)/$1/rebar.config)") of
 		{ok, Conf0} -> Conf0;
 		{ok, Conf0} -> Conf0;
 		_ -> []
 		_ -> []

+ 3 - 3
test/Makefile

@@ -131,14 +131,14 @@ clean::
 init: clean
 init: clean
 	$i "Prefetch Rebar if necessary"
 	$i "Prefetch Rebar if necessary"
 	$t if [ ! -d test_rebar_git ]; then \
 	$t if [ ! -d test_rebar_git ]; then \
-		git clone -q -n -- https://github.com/rebar/rebar test_rebar_git; \
+		git clone -q -n -- https://github.com/erlang/rebar3 test_rebar_git; \
 	fi
 	fi
 
 
 	$i "Generate a bleeding edge Erlang.mk"
 	$i "Generate a bleeding edge Erlang.mk"
 	$t cd .. && $(MAKE) $v
 	$t cd .. && $(MAKE) $v
 
 
-REBAR_GIT = file://$(CURDIR)/test_rebar_git
+REBAR3_GIT = file://$(CURDIR)/test_rebar_git
-export REBAR_GIT
+export REBAR3_GIT
 
 
 # Core.
 # Core.