Browse Source

chore(build): Update rebar3

This rebar3 puts a stamp to app build output dir
skips re-build if alreay built
Zaiming Shi 5 years atrás
parent
commit
dab57b0f0f
5 changed files with 39 additions and 7 deletions
  1. 1 0
      .gitignore
  2. 15 4
      Makefile
  3. 20 0
      ensure-rebar3.sh
  4. 3 3
      rebar.config
  5. BIN
      rebar3

+ 1 - 0
.gitignore

@@ -34,3 +34,4 @@ Mnesia.*/
 *.DS_Store
 _checkouts
 rebar.config.rendered
+/rebar3

+ 15 - 4
Makefile

@@ -1,4 +1,5 @@
-REBAR = $(CURDIR)/rebar3
+REBAR_VERSION = 3.13.2-emqx-1
+REBAR = ./rebar3
 
 PROFILE ?= emqx
 PROFILES := emqx emqx-edge
@@ -10,6 +11,12 @@ default: $(REBAR) $(PROFILE)
 .PHONY: all
 all: $(REBAR) $(PROFILES)
 
+.PHONY: ensure-rebar3
+ensure-rebar3:
+	@./ensure-rebar3.sh $(REBAR_VERSION)
+
+$(REBAR): ensure-rebar3
+
 .PHONY: distclean
 distclean:
 	@rm -rf _build
@@ -27,11 +34,15 @@ endif
 $(PROFILES:%=build-%): $(REBAR)
 	$(REBAR) as $(@:build-%=%) compile
 
+# rebar clean
 .PHONY: clean $(PROFILES:%=clean-%)
-clean: $(PROFILES:%=clean-%)
+clean: $(PROFILES:%=clean-%) clean-stamps
 $(PROFILES:%=clean-%): $(REBAR)
-	@rm -rf _build/$(@:clean-%=%)
-	@rm -rf _build/$(@:clean-%=%)+test
+	$(REBAR) as $(@:clean-%=%) clean
+
+.PHONY: clean-stamps
+clean-stamps:
+	find -L _build -name '.stamp' -type f | xargs rm -f
 
 .PHONY: deps-all
 deps-all: $(REBAR) $(PROFILES:%=deps-%) $(PKG_PROFILES:%=deps-%)

+ 20 - 0
ensure-rebar3.sh

@@ -0,0 +1,20 @@
+#!/bin/bash
+
+set -euo pipefail
+
+VERSION="$1"
+
+download() {
+    curl -L "https://s3-us-west-2.amazonaws.com/packages.emqx/rebar/rebar3-${VERSION}" -o ./rebar3
+}
+
+version() {
+    ./rebar3 -v | grep -v '===' | grep 'rebar.*Erlang' | awk '{print $2}'
+}
+
+if [ -f 'rebar3' ] && [ "$(version)" == "$VERSION" ]; then
+    exit 0
+fi
+
+download
+chmod +x ./rebar3

+ 3 - 3
rebar.config

@@ -162,11 +162,11 @@
     , {template, "data/loaded_plugins.tmpl", "data/loaded_plugins"}
     , {template, "data/loaded_modules.tmpl", "data/loaded_modules"}
     , {template,"data/emqx_vars","releases/emqx_vars"}
-    , {copy,"{{lib_dirs}}/cuttlefish/cuttlefish","bin/"}
+    , {copy,"_checkouts/cuttlefish/cuttlefish","bin/"}
     , {copy,"bin/*","bin/"}
     , {template,"etc/*.conf","etc/"}
     , {template,"etc/emqx.d/*.conf","etc/emqx.d/"}
-    , {copy,"{{lib_dirs}}/emqx/priv/emqx.schema","releases/{{rel_vsn}}/"}
+    , {copy,"_checkouts/emqx/priv/emqx.schema","releases/{{rel_vsn}}/"}
     , {copy, "etc/certs","etc/"}
     , "${RELUP_OVERLAYS}"
     ]
@@ -179,7 +179,7 @@
     , {copy,"bin/emqx_ctl","bin/emqx_ctl-{{rel_vsn}}"}
     , {copy,"bin/install_upgrade.escript", "bin/install_upgrade.escript-{{rel_vsn}}"}
     , {copy,"bin/nodetool","bin/nodetool-{{rel_vsn}}"}
-    , {copy,"{{lib_dirs}}/cuttlefish/cuttlefish","bin/cuttlefish-{{rel_vsn}}"}
+    , {copy,"_checkouts/cuttlefish/cuttlefish","bin/cuttlefish-{{rel_vsn}}"}
     ]
   },
 

BIN
rebar3