aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2015-06-28 23:08:01 +0200
committerLoïc Hoguin <[email protected]>2015-06-28 23:12:10 +0200
commit857f595ed5293a9dae42ef64062461ee35547663 (patch)
tree27b3fd1690f1141ef51c89ec0507762e2976ae3e /core
parent9a2dd5dfb20b2b5dbb08d9441a184815b5337cbe (diff)
downloaderlang.mk-857f595ed5293a9dae42ef64062461ee35547663.tar.gz
erlang.mk-857f595ed5293a9dae42ef64062461ee35547663.tar.bz2
erlang.mk-857f595ed5293a9dae42ef64062461ee35547663.zip
Bundle the package index directly inside erlang.mk
If you were using the index file as a "lock file", bear with me for a moment, equivalent functionality will soon be added. :-)
Diffstat (limited to 'core')
-rw-r--r--core/core.mk25
-rw-r--r--core/deps.mk92
-rw-r--r--core/index.mk26
3 files changed, 63 insertions, 80 deletions
diff --git a/core/core.mk b/core/core.mk
index 4fe4e5c..c9c8256 100644
--- a/core/core.mk
+++ b/core/core.mk
@@ -12,7 +12,7 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-.PHONY: all deps app rel docs install-docs tests check clean distclean help erlang-mk
+.PHONY: all app deps search rel docs install-docs check tests clean distclean help erlang-mk
ERLANG_MK_FILENAME := $(realpath $(lastword $(MAKEFILE_LIST)))
@@ -96,28 +96,24 @@ distclean:: clean
help::
@printf "%s\n" \
"erlang.mk (version $(ERLANG_MK_VERSION)) is distributed under the terms of the ISC License." \
- "Copyright (c) 2013-2014 Loïc Hoguin <[email protected]>" \
+ "Copyright (c) 2013-2015 Loïc Hoguin <[email protected]>" \
"" \
- "Usage: [V=1] $(MAKE) [-jNUM] [target]" \
+ "Usage: [V=1] $(MAKE) [-jNUM] [target]..." \
"" \
"Core targets:" \
" all Run deps, app and rel targets in that order" \
- " deps Fetch dependencies (if needed) and compile them" \
" app Compile the project" \
+ " deps Fetch dependencies (if needed) and compile them" \
+ " search q=... Search for a package in the built-in index" \
" rel Build a release for this project, if applicable" \
" docs Build the documentation for this project" \
" install-docs Install the man pages for this project" \
- " tests Run the tests for this project" \
" check Compile and run all tests and analysis for this project" \
+ " tests Run the tests for this project" \
" clean Delete temporary and output files from most targets" \
" distclean Delete all temporary and output files" \
" help Display this help and exit" \
- "" \
- "The target clean only removes files that are commonly removed." \
- "Dependencies and releases are left untouched." \
- "" \
- "Setting V=1 when calling $(MAKE) enables verbose mode." \
- "Parallel execution is supported through the -j $(MAKE) flag."
+ " erlang-mk Update erlang.mk to the latest version"
# Core functions.
@@ -164,6 +160,10 @@ define core_http_get
endef
endif
+core_eq = $(and $(findstring $(1),$(2)),$(findstring $(2),$(1)))
+
+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)))))))))))))))))))))))))))
+
# Automated update.
ERLANG_MK_BUILD_CONFIG ?= build.config
@@ -175,3 +175,6 @@ erlang-mk:
cd $(ERLANG_MK_BUILD_DIR) && $(MAKE)
cp $(ERLANG_MK_BUILD_DIR)/erlang.mk ./erlang.mk
rm -rf $(ERLANG_MK_BUILD_DIR)
+
+# The erlang.mk package index is bundled in the default erlang.mk build.
+# Search for the string "copyright" to skip to the rest of the code.
diff --git a/core/deps.mk b/core/deps.mk
index 9f36be6..a95c98c 100644
--- a/core/deps.mk
+++ b/core/deps.mk
@@ -1,7 +1,7 @@
# Copyright (c) 2013-2015, Loïc Hoguin <[email protected]>
# This file is part of erlang.mk and subject to the terms of the ISC License.
-.PHONY: distclean-deps distclean-pkg pkg-list pkg-search
+.PHONY: distclean-deps distclean-pkg
# Configuration.
@@ -24,11 +24,6 @@ endif
endif
export ERL_LIBS
-PKG_FILE2 ?= $(CURDIR)/.erlang.mk.packages.v2
-export PKG_FILE2
-
-PKG_FILE_URL ?= https://raw.githubusercontent.com/ninenines/erlang.mk/master/packages.v2.tsv
-
# Verbosity.
dep_verbose_0 = @echo " DEP " $(1);
@@ -475,16 +470,16 @@ define dep_autopatch_appsrc.erl
endef
define dep_fetch
- if [ "$$$$VS" = "git" ]; then \
- git clone -q -n -- $$$$REPO $(DEPS_DIR)/$(1); \
- cd $(DEPS_DIR)/$(1) && git checkout -q $$$$COMMIT; \
- elif [ "$$$$VS" = "hg" ]; then \
- hg clone -q -U $$$$REPO $(DEPS_DIR)/$(1); \
- cd $(DEPS_DIR)/$(1) && hg update -q $$$$COMMIT; \
- elif [ "$$$$VS" = "svn" ]; then \
- svn checkout -q $$$$REPO $(DEPS_DIR)/$(1); \
- elif [ "$$$$VS" = "cp" ]; then \
- cp -R $$$$REPO $(DEPS_DIR)/$(1); \
+ if [ "$(2)" = "git" ]; then \
+ git clone -q -n -- $(3) $(DEPS_DIR)/$(1); \
+ cd $(DEPS_DIR)/$(1) && git checkout -q $(4); \
+ elif [ "$(2)" = "hg" ]; then \
+ hg clone -q -U $(3) $(DEPS_DIR)/$(1); \
+ cd $(DEPS_DIR)/$(1) && hg update -q $(4); \
+ elif [ "$(2)" = "svn" ]; then \
+ svn checkout -q $(3) $(DEPS_DIR)/$(1); \
+ elif [ "$(2)" = "cp" ]; then \
+ cp -R $(3) $(DEPS_DIR)/$(1); \
else \
echo "Unknown or invalid dependency: $(1). Please consult the erlang.mk README for instructions." >&2; \
exit 78; \
@@ -495,29 +490,23 @@ define dep_target
$(DEPS_DIR)/$(1):
@mkdir -p $(DEPS_DIR)
ifeq (,$(dep_$(1)))
- @if [ ! -f $(PKG_FILE2) ]; then $(call core_http_get,$(PKG_FILE2),$(PKG_FILE_URL)); fi
- $(dep_verbose) DEPPKG=$$$$(awk 'BEGIN { FS = "\t" }; $$$$1 == "$(1)" { print $$$$2 " " $$$$3 " " $$$$4 }' $(PKG_FILE2);); \
- VS=$$$$(echo $$$$DEPPKG | cut -d " " -f1); \
- REPO=$$$$(echo $$$$DEPPKG | cut -d " " -f2); \
- COMMIT=$$$$(echo $$$$DEPPKG | cut -d " " -f3); \
- $(call dep_fetch,$(1))
+ $(dep_verbose) $(call dep_fetch,$(pkg_$(1)_name),$(pkg_$(1)_fetch), \
+ $(patsubst git://github.com/%,https://github.com/%,$(pkg_$(1)_repo)), \
+ $(pkg_$(1)_commit))
else
ifeq (1,$(words $(dep_$(1))))
- $(dep_verbose) VS=git; \
- REPO=$(patsubst git://github.com/%,https://github.com/%,$(dep_$(1))); \
- COMMIT=master; \
- $(call dep_fetch,$(1))
+ $(dep_verbose) $(call dep_fetch,$(1),git, \
+ $(patsubst git://github.com/%,https://github.com/%,$(dep_$(1))), \
+ master)
else
ifeq (2,$(words $(dep_$(1))))
- $(dep_verbose) VS=git; \
- REPO=$(patsubst git://github.com/%,https://github.com/%,$(word 1,$(dep_$(1)))); \
- COMMIT=$(word 2,$(dep_$(1))); \
- $(call dep_fetch,$(1))
+ $(dep_verbose) $(call dep_fetch,$(1),git, \
+ $(patsubst git://github.com/%,https://github.com/%,$(word 1,$(dep_$(1)))), \
+ $(word 2,$(dep_$(1))))
else
- $(dep_verbose) VS=$(word 1,$(dep_$(1))); \
- REPO=$(patsubst git://github.com/%,https://github.com/%,$(word 2,$(dep_$(1)))); \
- COMMIT=$(word 3,$(dep_$(1))); \
- $(call dep_fetch,$(1))
+ $(dep_verbose) $(call dep_fetch,$(1),$(word 1,$(dep_$(1))), \
+ $(patsubst git://github.com/%,https://github.com/%,$(word 2,$(dep_$(1)))), \
+ $(word 3,$(dep_$(1))))
endif
endif
endif
@@ -555,38 +544,3 @@ $(foreach dep,$(DEPS),$(eval $(call dep_target,$(dep))))
distclean-deps:
$(gen_verbose) rm -rf $(DEPS_DIR)
-
-# Packages related targets.
-
-$(PKG_FILE2):
- @$(call core_http_get,$(PKG_FILE2),$(PKG_FILE_URL))
-
-pkg-list: $(PKG_FILE2)
- @cat $(PKG_FILE2) | awk 'BEGIN { FS = "\t" }; { print \
- "Name:\t\t" $$1 "\n" \
- "Repository:\t" $$3 "\n" \
- "Website:\t" $$5 "\n" \
- "Description:\t" $$6 "\n" }'
-
-ifdef q
-pkg-search: $(PKG_FILE2)
- @cat $(PKG_FILE2) | grep -i ${q} | awk 'BEGIN { FS = "\t" }; { print \
- "Name:\t\t" $$1 "\n" \
- "Repository:\t" $$3 "\n" \
- "Website:\t" $$5 "\n" \
- "Description:\t" $$6 "\n" }'
-else
-pkg-search:
- $(error Usage: $(MAKE) pkg-search q=STRING)
-endif
-
-ifeq ($(PKG_FILE2),$(CURDIR)/.erlang.mk.packages.v2)
-distclean-pkg:
- $(gen_verbose) rm -f $(PKG_FILE2)
-endif
-
-help::
- @printf "%s\n" "" \
- "Package-related targets:" \
- " pkg-list List all known packages" \
- " pkg-search q=STRING Search for STRING in the package index"
diff --git a/core/index.mk b/core/index.mk
new file mode 100644
index 0000000..a16eceb
--- /dev/null
+++ b/core/index.mk
@@ -0,0 +1,26 @@
+# Copyright (c) 2015, Loïc Hoguin <[email protected]>
+# This file is part of erlang.mk and subject to the terms of the ISC License.
+
+.PHONY: search
+
+define pkg_print
+ @printf "%s\n" \
+ $(if $(call core_eq,$(1),$(pkg_$(1)_name)),,"Pkg name: $(1)") \
+ "App name: $(pkg_$(1)_name)" \
+ "Description: $(pkg_$(1)_description)" \
+ "Home page: $(pkg_$(1)_homepage)" \
+ "Fetch with: $(pkg_$(1)_fetch)" \
+ "Repository: $(pkg_$(1)_repo)" \
+ "Commit: $(pkg_$(1)_commit)" \
+ ""
+
+endef
+
+search:
+ifdef q
+ $(foreach p,$(PACKAGES), \
+ $(if $(findstring $(call core_lc,$(q)),$(call core_lc,$(pkg_$(p)_name) $(pkg_$(p)_description))), \
+ $(call pkg_print,$(p))))
+else
+ $(foreach p,$(PACKAGES),$(call pkg_print,$(p)))
+endif