--- a/Makefile Fri Mar 03 19:26:38 2023 +0100
+++ b/Makefile Thu Sep 28 22:29:30 2023 +0200
@@ -11,9 +11,7 @@
DIST ?= win32
src := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
-HGREMOTE ?= REMOTE_HG_DISABLED
-HGROOT ?= $(abspath $(src)/..)
-GITROOT := $(HGROOT)
+WORKSPACE ?= $(abspath $(src)/..)
CPUS := `cat /proc/cpuinfo | grep -e 'processor\W*:\W*[[:digit:]]*' | nl -n ln | tail -n1 | cut -f1`
distfiles = $(src)/distfiles
@@ -21,9 +19,8 @@
tmp := $(shell rm -rf $${TMPDIR:-/tmp}/beremiz_dist_build_tmp.* ; mktemp -d -t beremiz_dist_build_tmp.XXXXXXXXXX)
define hg_get_archive
- test -d $(HGROOT)/`basename $(1)` || hg --cwd $(HGROOT) clone $(HGREMOTE)`basename $(1)`;\
- hg -R $(HGROOT)/`basename $(1)` archive $(2) $(1);\
- hg -R $(HGROOT)/`basename $(1)` id -i | sed 's/\+//' > $(1)/revision;
+ hg -R $(WORKSPACE)/`basename $(1)` archive $(2) $(1);\
+ hg -R $(WORKSPACE)/`basename $(1)` id -i | sed 's/\+//' > $(1)/revision;
endef
define get_src_hg
@@ -32,37 +29,32 @@
endef
define get_src_git
- rm -rf $(1)
- test -d $(GITROOT)/`basename $(1)` || git clone $(3) $(GITROOT)/`basename $(1)`
- mkdir $(1)
- (cd $(GITROOT)/`basename $(1)`; git archive --format=tar $(2)) | tar -C $(1) -x
endef
define get_src_http
dld=$(distfiles)/`echo $(2) | tr ' ()' '___'`;( ( [ -f $$dld ] || wget $(1)/$(2) -O $$dld ) && ( [ ! -f $$dld.md5 ] && (cd $(distfiles);md5sum `basename $$dld`) > $$dld.md5 || (cd $(distfiles);md5sum -c `basename $$dld.md5`) ) ) &&
endef
-get_src_pypi=$(call get_src_http,https://pypi.python.org/packages/$(1),$(2))
-
-get_src_sf=$(call get_src_http,https://$(sfmirror).sourceforge.net/project/$(1),$(2))
-
ifneq ("$(DIST)","")
include $(src)/$(DIST).mk
endif
-OWN_PROJECTS=beremiz matiec canfestival Modbus
+FROM_SOURCE_PROJECTS=beremiz matiec $(DIST_FROM_SOURCE_PROJECTS)
define get_revision
$(1)_revision?=$(lastword $(shell grep $(1) $(src)/revisions.txt))
endef
-$(foreach project,$(OWN_PROJECTS),$(eval $(call get_revision,$(project))))
+$(foreach project,$(FROM_SOURCE_PROJECTS),$(eval $(call get_revision,$(project))))
+
+tar_opts=--absolute-names --exclude=.hg --exclude=.git --exclude=.*.pyc --exclude=.*.swp --exclude=__pycache__
define get_revisionid
-ifeq ($(origin $(1)_revisionid), undefined)
-$(1)_revisionid?=$(shell hg -R $(HGROOT)/$(1) id -i -r $($(1)_revision))
-endif
+$(1)_revisionid ?=\
+ $(if $(filter local, $($(1)_revision)),\
+ $(shell tar $(tar_opts) -P -c $(WORKSPACE)/$(1) | sha1sum | cut -d ' ' -f 1),\
+ $(1)_revisionid?=$$(shell hg -R $(WORKSPACE)/$(1) id -i -r $($(1)_revision)))
endef
-$(foreach project,$(OWN_PROJECTS),$(eval $(call get_revisionid,$(project))))
+$(foreach project,$(FROM_SOURCE_PROJECTS),$(eval $(call get_revisionid,$(project))))
sources:
mkdir -p sources
@@ -72,14 +64,19 @@
touch $$@
sources/$(1)_$($(1)_revisionid): | sources
+ rm -rf sources/$(1)*
+ifeq ($($(1)_revision),local)
+ echo "Copy local source code for $(1)_$($(1)_revisionid)"
+ tar -C $(WORKSPACE) $(tar_opts) -P -c $(1) | tar -C sources -x
+else
echo "Checkout HG source $(1)_$($(1)_revisionid)"
- rm -rf sources/$(1)*
$(call get_src_hg,sources/$(1),-r $($(1)_revisionid))
+endif
touch $$@
endef
-$(foreach project,$(OWN_PROJECTS),$(eval $(call make_src_rule,$(project))))
+$(foreach project,$(FROM_SOURCE_PROJECTS),$(eval $(call make_src_rule,$(project))))
-own_sources: $(foreach project,$(OWN_PROJECTS), sources/$(project)_src)
+own_sources: $(foreach project,$(FROM_SOURCE_PROJECTS), sources/$(project)_src)
touch $@
all_sources: own_sources sources/open62541_src
@@ -93,15 +90,18 @@
define show_revision_details
-echo -n $(1) "revision is: "; hg -R $(HGROOT)/$(1) id -r $($(1)_revisionid);
+ $(if $(filter local, $($(1)_revision)),\
+ echo -n $(1) "state is: "; test -d .hg \
+ && (hg -R $(WORKSPACE)/$(1) id; echo; hg -R $(WORKSPACE)/$(1) st) \
+ || (git -C $(WORKSPACE)/$(1) show --pretty=format:'%P' -s; echo; git -C $(WORKSPACE)/$(1) status --porcelain);,\
+ echo -n $(1) "revision is: "; hg -R $(WORKSPACE)/$(1) id -r $($(1)_revisionid); )
endef
revisions.txt: $(src)/revisions.txt own_sources
echo "Generate revisions.txt"
echo "\n******* PACKAGE REVISIONS ********\n" > revisions.txt
- (echo -n "beremiz_public_dist revision is: "; hg -R $(src) id;) >> revisions.txt
- ($(foreach project,$(OWN_PROJECTS),$(call show_revision_details,$(project)))) >> revisions.txt
- bash -c 'hg -R $(src) st | ( if read ; then echo -e "\n******* beremiz_public_dist IS MODIFIED ********\n" ; hg -R $(src) st ; fi ) >> revisions.txt'
+ (echo -n "beremiz_public_dist revision is: "; test -d .hg && (hg -R $(src) id ; echo; hg -R $(src) st) || (git -C $(src) show --pretty=format:'%P' -s; echo; git -C $(src) status --porcelain)) >> revisions.txt
+ ($(foreach project,$(FROM_SOURCE_PROJECTS),$(call show_revision_details,$(project)))) >> revisions.txt