aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorTyler Hughes <[email protected]>2023-05-12 21:58:37 +0100
committerLoïc Hoguin <[email protected]>2025-03-17 15:23:40 +0100
commit39160fbf248ae6576e87847d9c33659190a476e6 (patch)
treed90d838214fe9d6013b540ede37687dc48260c47 /plugins
parent3f7955bad270767f87272f1066ecb0a7ae0c7914 (diff)
downloaderlang.mk-39160fbf248ae6576e87847d9c33659190a476e6.tar.gz
erlang.mk-39160fbf248ae6576e87847d9c33659190a476e6.tar.bz2
erlang.mk-39160fbf248ae6576e87847d9c33659190a476e6.zip
Native Elixir support
This commit also includes a way to completely disable Eunit as that is generally desirable for Elixir-only projects.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/escript.mk36
-rw-r--r--plugins/eunit.mk7
-rw-r--r--plugins/hex.mk24
3 files changed, 51 insertions, 16 deletions
diff --git a/plugins/escript.mk b/plugins/escript.mk
index 1790dcb..4eac352 100644
--- a/plugins/escript.mk
+++ b/plugins/escript.mk
@@ -27,17 +27,45 @@ help::
# Plugin-specific targets.
-escript-zip:: FULL=1
-escript-zip:: deps app
+ALL_ESCRIPT_DEPS_DIRS = $(LOCAL_DEPS_DIRS) $(addprefix $(DEPS_DIR)/,$(foreach dep,$(filter-out $(IGNORE_DEPS),$(DEPS)),$(call query_name,$(dep))))
+
+ESCRIPT_RUNTIME_DEPS_FILE ?= $(ERLANG_MK_TMP)/escript-deps.log
+
+escript-list-runtime-deps:
+ifeq ($(IS_DEP),)
+ $(verbose) rm -f $(ESCRIPT_RUNTIME_DEPS_FILE)
+endif
+ $(verbose) touch $(ESCRIPT_RUNTIME_DEPS_FILE)
+ $(verbose) set -e; for dep in $(ALL_ESCRIPT_DEPS_DIRS) ; do \
+ if ! grep -qs ^$$dep$$ $(ESCRIPT_RUNTIME_DEPS_FILE); then \
+ echo $$dep >> $(ESCRIPT_RUNTIME_DEPS_FILE); \
+ if grep -qs -E "^[[:blank:]]*include[[:blank:]]+(erlang\.mk|.*/erlang\.mk|.*ERLANG_MK_FILENAME.*)$$" \
+ $$dep/GNUmakefile $$dep/makefile $$dep/Makefile; then \
+ $(MAKE) -C $$dep escript-list-runtime-deps \
+ IS_DEP=1 \
+ ESCRIPT_RUNTIME_DEPS_FILE=$(ESCRIPT_RUNTIME_DEPS_FILE); \
+ fi \
+ fi \
+ done
+ifeq ($(IS_DEP),)
+ $(verbose) sort < $(ESCRIPT_RUNTIME_DEPS_FILE) | uniq > $(ESCRIPT_RUNTIME_DEPS_FILE).sorted
+ $(verbose) mv $(ESCRIPT_RUNTIME_DEPS_FILE).sorted $(ESCRIPT_RUNTIME_DEPS_FILE)
+endif
+
+escript-prepare: deps app
+ $(MAKE) escript-list-runtime-deps
+
+escript-zip:: escript-prepare
$(verbose) mkdir -p $(dir $(abspath $(ESCRIPT_ZIP_FILE)))
$(verbose) rm -f $(abspath $(ESCRIPT_ZIP_FILE))
- $(gen_verbose) cd .. && $(ESCRIPT_ZIP) $(abspath $(ESCRIPT_ZIP_FILE)) $(PROJECT)/ebin/*
+ $(gen_verbose) cd .. && $(ESCRIPT_ZIP) $(abspath $(ESCRIPT_ZIP_FILE)) $(notdir $(CURDIR))/ebin/*
ifneq ($(DEPS),)
$(verbose) cd $(DEPS_DIR) && $(ESCRIPT_ZIP) $(abspath $(ESCRIPT_ZIP_FILE)) \
$(subst $(DEPS_DIR)/,,$(addsuffix /*,$(wildcard \
- $(addsuffix /ebin,$(shell cat $(ERLANG_MK_TMP)/deps.log)))))
+ $(addsuffix /ebin,$(shell cat $(ESCRIPT_RUNTIME_DEPS_FILE))))))
endif
+# @todo Only generate the zip file if there were changes.
escript:: escript-zip
$(gen_verbose) printf "%s\n" \
"#!$(ESCRIPT_SHEBANG)" \
diff --git a/plugins/eunit.mk b/plugins/eunit.mk
index 211a744..8a97688 100644
--- a/plugins/eunit.mk
+++ b/plugins/eunit.mk
@@ -4,6 +4,11 @@
.PHONY: eunit apps-eunit
+# Eunit can be disabled by setting this to any other value.
+EUNIT ?= system
+
+ifeq ($(EUNIT),system)
+
# Configuration
EUNIT_OPTS ?=
@@ -61,3 +66,5 @@ apps-eunit: test-build
exit $$eunit_retcode
endif
endif
+
+endif
diff --git a/plugins/hex.mk b/plugins/hex.mk
index 482a56a..72c0db6 100644
--- a/plugins/hex.mk
+++ b/plugins/hex.mk
@@ -19,7 +19,7 @@ define hex_user_create.erl
endef
# The $(info ) call inserts a new line after the password prompt.
-hex-user-create: hex-core
+hex-user-create: $(DEPS_DIR)/hex_core/ebin/dep_built
$(if $(HEX_USERNAME),,$(eval HEX_USERNAME := $(shell read -p "Username: " username; echo $$username)))
$(if $(HEX_PASSWORD),,$(eval HEX_PASSWORD := $(shell stty -echo; read -p "Password: " password; stty echo; echo $$password) $(info )))
$(if $(HEX_EMAIL),,$(eval HEX_EMAIL := $(shell read -p "Email: " email; echo $$email)))
@@ -49,7 +49,7 @@ define hex_key_add.erl
end
endef
-hex-key-add: hex-core
+hex-key-add: $(DEPS_DIR)/hex_core/ebin/dep_built
$(if $(HEX_USERNAME),,$(eval HEX_USERNAME := $(shell read -p "Username: " username; echo $$username)))
$(if $(HEX_PASSWORD),,$(eval HEX_PASSWORD := $(shell stty -echo; read -p "Password: " password; stty echo; echo $$password) $(info )))
$(gen_verbose) $(call erlang,$(call hex_key_add.erl,$(HEX_USERNAME),$(HEX_PASSWORD),\
@@ -127,7 +127,7 @@ hex_tar_verbose_0 = @echo " TAR $(notdir $(ERLANG_MK_TMP))/$(@F)";
hex_tar_verbose_2 = set -x;
hex_tar_verbose = $(hex_tar_verbose_$(V))
-$(HEX_TARBALL_OUTPUT_FILE): hex-core app
+$(HEX_TARBALL_OUTPUT_FILE): $(DEPS_DIR)/hex_core/ebin/dep_built app
$(hex_tar_verbose) $(call erlang,$(call hex_tarball_create.erl))
hex-tarball-create: $(HEX_TARBALL_OUTPUT_FILE)
@@ -178,14 +178,14 @@ define hex_release_publish.erl
end
endef
-hex-release-tarball: hex-core $(HEX_TARBALL_OUTPUT_FILE)
+hex-release-tarball: $(DEPS_DIR)/hex_core/ebin/dep_built $(HEX_TARBALL_OUTPUT_FILE)
$(verbose) $(call erlang,$(call hex_release_publish_summary.erl))
-hex-release-publish: hex-core hex-release-tarball
+hex-release-publish: $(DEPS_DIR)/hex_core/ebin/dep_built hex-release-tarball
$(if $(HEX_SECRET),,$(eval HEX_SECRET := $(shell stty -echo; read -p "Secret: " secret; stty echo; echo $$secret) $(info )))
$(gen_verbose) $(call erlang,$(call hex_release_publish.erl,$(HEX_SECRET),false))
-hex-release-replace: hex-core hex-release-tarball
+hex-release-replace: $(DEPS_DIR)/hex_core/ebin/dep_built hex-release-tarball
$(if $(HEX_SECRET),,$(eval HEX_SECRET := $(shell stty -echo; read -p "Secret: " secret; stty echo; echo $$secret) $(info )))
$(gen_verbose) $(call erlang,$(call hex_release_publish.erl,$(HEX_SECRET),true))
@@ -204,7 +204,7 @@ define hex_release_delete.erl
end
endef
-hex-release-delete: hex-core
+hex-release-delete: $(DEPS_DIR)/hex_core/ebin/dep_built
$(if $(HEX_SECRET),,$(eval HEX_SECRET := $(shell stty -echo; read -p "Secret: " secret; stty echo; echo $$secret) $(info )))
$(gen_verbose) $(call erlang,$(call hex_release_delete.erl,$(HEX_SECRET)))
@@ -224,7 +224,7 @@ define hex_release_retire.erl
end
endef
-hex-release-retire: hex-core
+hex-release-retire: $(DEPS_DIR)/hex_core/ebin/dep_built
$(if $(HEX_SECRET),,$(eval HEX_SECRET := $(shell stty -echo; read -p "Secret: " secret; stty echo; echo $$secret) $(info )))
$(gen_verbose) $(call erlang,$(call hex_release_retire.erl,$(HEX_SECRET),\
$(if $(HEX_VERSION),$(HEX_VERSION),$(PROJECT_VERSION)),\
@@ -246,7 +246,7 @@ define hex_release_unretire.erl
end
endef
-hex-release-unretire: hex-core
+hex-release-unretire: $(DEPS_DIR)/hex_core/ebin/dep_built
$(if $(HEX_SECRET),,$(eval HEX_SECRET := $(shell stty -echo; read -p "Secret: " secret; stty echo; echo $$secret) $(info )))
$(gen_verbose) $(call erlang,$(call hex_release_unretire.erl,$(HEX_SECRET),\
$(if $(HEX_VERSION),$(HEX_VERSION),$(PROJECT_VERSION))))
@@ -255,7 +255,7 @@ HEX_DOCS_DOC_DIR ?= doc/
HEX_DOCS_TARBALL_FILES ?= $(sort $(call core_find,$(HEX_DOCS_DOC_DIR),*))
HEX_DOCS_TARBALL_OUTPUT_FILE ?= $(ERLANG_MK_TMP)/$(PROJECT)-docs.tar.gz
-$(HEX_DOCS_TARBALL_OUTPUT_FILE): hex-core app docs
+$(HEX_DOCS_TARBALL_OUTPUT_FILE): $(DEPS_DIR)/hex_core/ebin/dep_built app docs
$(hex_tar_verbose) tar czf $(HEX_DOCS_TARBALL_OUTPUT_FILE) -C $(HEX_DOCS_DOC_DIR) \
$(HEX_DOCS_TARBALL_FILES:$(HEX_DOCS_DOC_DIR)%=%)
@@ -279,7 +279,7 @@ define hex_docs_publish.erl
end
endef
-hex-docs-publish: hex-core hex-docs-tarball-create
+hex-docs-publish: $(DEPS_DIR)/hex_core/ebin/dep_built hex-docs-tarball-create
$(if $(HEX_SECRET),,$(eval HEX_SECRET := $(shell stty -echo; read -p "Secret: " secret; stty echo; echo $$secret) $(info )))
$(gen_verbose) $(call erlang,$(call hex_docs_publish.erl,$(HEX_SECRET)))
@@ -299,7 +299,7 @@ define hex_docs_delete.erl
end
endef
-hex-docs-delete: hex-core
+hex-docs-delete: $(DEPS_DIR)/hex_core/ebin/dep_built
$(if $(HEX_SECRET),,$(eval HEX_SECRET := $(shell stty -echo; read -p "Secret: " secret; stty echo; echo $$secret) $(info )))
$(gen_verbose) $(call erlang,$(call hex_docs_delete.erl,$(HEX_SECRET),\
$(if $(HEX_VERSION),$(HEX_VERSION),$(PROJECT_VERSION))))