From e00191a6e8c4b4fed2a4978c52f464d952842bb4 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Fri, 2 Nov 2018 11:40:00 +0000 Subject: [PATCH] projects-dir.mk: Code beautification Bigger diff, mostly because targets are reorganized into functional groups Signed-off-by: Jan Lindemann --- make/projects-dir.mk | 161 +++++++++++++++++++++++-------------------- 1 file changed, 85 insertions(+), 76 deletions(-) diff --git a/make/projects-dir.mk b/make/projects-dir.mk index 6f4c87d2..f6c30edf 100644 --- a/make/projects-dir.mk +++ b/make/projects-dir.mk @@ -57,7 +57,7 @@ EXCLUDES_FILES = exclude-$(shell $(GET_OS_SH) name).txt exclude-$(shell $ TEXT_FILES_CACHE ?= text-files.txt ifneq ($(wildcard $(EXCLUDES_FILES)),) - EXCLUDE_FROM_BUILD += $(shell sed 's/\#.*//g' $(wildcard $(EXCLUDES_FILES))) + EXCLUDE_FROM_BUILD += $(shell sed 's/\#.*//g' $(wildcard $(EXCLUDES_FILES))) endif BUILD_PROJECTS = $(filter-out $(EXCLUDE_FROM_BUILD),$(PROJECTS)) @@ -108,7 +108,6 @@ PGIT = /bin/bash $(MOD_SCRIPT_DIR)/pgit.sh PROJECTS_PY = python2 $(MOD_SCRIPT_DIR)/projects.py --prefix $(shell pwd) $(PROJECTS_PY_EXTRA_OPTS) PROJECTS_PY_BUILD = $(PROJECTS_PY) build $(PROJECTS_PY_EXTRA_BUILD_OPTS) PURGE_SH = /bin/bash $(firstword $(wildcard $(MOD_SCRIPT_DIR)/purge-stale-projects.sh /opt/jw-build/bin/purge-stale-projects.sh) purge-not-found) -RELEASE_SH = /bin/bash $(firstword $(wildcard $(MOD_SCRIPT_DIR)/build-release.sh /opt/jw-build/bin/build-release.sh) release-not-found) PKG_MANAGER_SH ?= /bin/bash $(firstword $(wildcard $(MOD_SCRIPT_DIR)/pkg-manager.sh /opt/jw-build/bin/pkg-manager.sh) pkg-manager-not-found) CREATE_PROJECT_SH ?= /bin/bash $(firstword $(wildcard $(MOD_SCRIPT_DIR)/jw-build-create-project.sh /opt/jw-build/bin/jw-build-create-project.sh) jw-build-create-project-not-found) LIST_VCS_FILES = /bin/bash $(firstword $(wildcard $(MOD_SCRIPT_DIR)/list-cvs-files.sh /opt/jw-build/bin/list-cvs-files.sh) list-cvs-files-not-found) @@ -120,6 +119,8 @@ CVS_ADMIN_SH = JW_BUILD_SSH_EXTRA_OPTS="$(JW_BUILD_SSH_EXTRA_OPTS)" $(G # ------------ targets +# --- mandatory targets + all: $(filter-out $(UNAVAILABLE_TARGETS),pull.done links.done) $(PROJECTS_PY_BUILD) $@ $(BUILD_PROJECTS) clean: clean-dirs done.clean @@ -131,17 +132,28 @@ install: @echo @exit 1 +# --- build targets + +rebuild: clean purge pull subdirs-all + +subdirs-%: + FORCE_REBUILD_SUBDIRS=true make $* + +# --- informative-only targets + +doc-project doc-module: + $(BROWSER) $(firstword $(shell sed '/https:/ !d; s%.*https%https%; s/ .*//' $(firstword $(MAKEFILE_LIST)))) + +status: $(SSH_WRAPPER_SH) + for p in $(CVS_PROJECTS); do test -f $$d/CVS || echo $$p; done + cvs status $(addsuffix VERSION,$(CVS_PROJECTS)) + $(PGIT) status + build-order-%: $(filter-out $(UNAVAILABLE_TARGETS),pull.done) $(PROJECTS_PY_BUILD) --build-order $* $(BUILD_PROJECTS) | sed 's/ */\n/g' build-order: build-order-all -clean-dirs: - if [ -n "$(wildcard */*.done)" ]; then ls */*.done 2>/dev/null | sed 's%/.*%%' | xargs -r $(PROJECTS_PY_BUILD) --exclude "" clean; fi - -clean-all-dirs: - $(PROJECTS_PY_BUILD) clean $(PROJECTS) - echo-prereq-build: @$(PROJECTS_PY) requires-pkg --skip-excluded --flavours "build" $(BUILD_PROJECTS) @@ -156,6 +168,45 @@ echo-os: echo-excludes: @echo $(EXCLUDE_FROM_BUILD) +edit-%: | $(TEXT_FILES_CACHE) + $(EDITOR) $(shell grep "/$*$$" $(TEXT_FILES_CACHE)) + +list-files: + @for p in $(PROJECTS); do \ + $(LIST_VCS_FILES) -znf $$p | sed -z "s/^/$$p\//" | \ + xargs -0 realpath ;\ + done + +clean: clean.text-files-cache +clean.text-files-cache: + rm -f $(TEXT_FILES_CACHE) +$(TEXT_FILES_CACHE): + @make text-files-update +text-files-update: + @make --no-print-directory list-files | xargs file -N | grep ":.*text" | cut -d: -f1 > $(TEXT_FILES_CACHE).tmp + mv $(TEXT_FILES_CACHE).tmp $(TEXT_FILES_CACHE) +text-files-update-all: + @PROJECTS_TXT= make text-files-update +text-files-list list-text-files: | $(TEXT_FILES_CACHE) + @cat $(TEXT_FILES_CACHE) + +loc-all: + @make --no-print-directory list-text-files | \ + grep -v "iow-standalone\|jux3\|ntv2/contrib\|\.dia$$\|\.dat\$$\|bootsrap\.css\|mpegplayer/contrib\|gitweb.cgi" | \ + xargs wc -l + +find-code-files: + find . -name '*.c' -o -name '*.cpp' -o -name '*.h' \ + -o -name Makefile -o -name '*.mk' \ + -o -name '*.sh' -o -name '*.pl' -o -name '*.py' \ + | grep -v "/dist/\|\.dep\.mk\|local.mk\|coordgen\|^\./[^/]\+/include/" \ + | grep -v "contrib/wt\|/bin/\|contrib/bootstrap\|contrib/chntpw/src\|contrib/jquery/src\|contrib/ntv2linux" \ + | grep -v "copilot-suse-tw-cf/initrd-tree" \ + | grep -v "iow-standalone\|jux3" \ + | grep -v "generated\|tmp\|old\|orig\|purged" + +# --- package-related targets + pkg-manager-refresh: $(PKG_MANAGER_SH) refresh -y @@ -193,19 +244,30 @@ pkg-init-%: pkg-%: $(filter-out $(UNAVAILABLE_TARGETS),pull.done) $(PROJECTS_PY_BUILD) $@ $(BUILD_PROJECTS) -doc-project doc-module: - $(BROWSER) $(firstword $(shell sed '/https:/ !d; s%.*https%https%; s/ .*//' $(firstword $(MAKEFILE_LIST)))) +# --- generic cleanup targets -status: $(SSH_WRAPPER_SH) - for p in $(CVS_PROJECTS); do test -f $$d/CVS || echo $$p; done - cvs status $(addsuffix VERSION,$(CVS_PROJECTS)) - $(PGIT) status +clean-dirs: + if [ -n "$(wildcard */*.done)" ]; then ls */*.done 2>/dev/null | sed 's%/.*%%' | xargs -r $(PROJECTS_PY_BUILD) --exclude "" clean; fi + +clean-all-dirs: + $(PROJECTS_PY_BUILD) clean $(PROJECTS) purge: $(SSH_WRAPPER_SH) ifneq ($(wildcard CVS),) $(PURGE_SH) endif +$(PROJECTS_TXT): + echo $(PROJECTS) | sed 's/ /\n/g; s%/%%g' > $@ + +done.clean: + rm -f *.done + +# --- collab targets + +list-maintainers: $(SSH_WRAPPER_SH) + $(GIT_SRV_ADMIN_SH) $@ + update pull: purge cvs-update git-clone touch pull.done @@ -223,21 +285,13 @@ pull-all: purge cvs-update git-clone git-pull-all diff-all diff: $(SSH_WRAPPER_SH) cvs diff -u; $(PGIT) diff -rebuild: clean purge pull subdirs-all - -release: $(SSH_WRAPPER_SH) - $(RELEASE_SH) - -subdirs-%: - FORCE_REBUILD_SUBDIRS=true make $* +cvs-diff: $(SSH_WRAPPER_SH) + cvs diff -u cvs-update: $(SSH_WRAPPER_SH) rm -f $@.done make $@.done -cvs-diff: $(SSH_WRAPPER_SH) - cvs diff -u - git-push push: $(SSH_WRAPPER_SH) $(PGIT) push @@ -274,11 +328,14 @@ git-show-non-master-branches: done # git-echo-link- returns a string functioning as hyperlink to -# matching files in git, if embedded into a janware wiki or ticket. +# matching files in git when embedded into a janware wiki or ticket. git-echo-links-%: | $(TEXT_FILES_CACHE) sed "/$*$$/!d; s%$(CWD)%%; s|^|\n \[\[jgit>/proj/$(JANWARE_USER)/|; s/$$/|$*\]\]\n/" $(TEXT_FILES_CACHE) -pull-%: $(SSH_WRAPPER_SH) +git-update-project-descriptions: $(SSH_WRAPPER_SH) + $(GIT_SRV_ADMIN_SH) -j update-descriptions all + +git-pull-%: $(SSH_WRAPPER_SH) PGIT_CLONE_FROM_USER=$* $(PGIT) clone git-commit: @@ -294,25 +351,12 @@ git-conv-%: $(SSH_WRAPPER_SH) fi \ } -check-conv: $(SSH_WRAPPER_SH) +git-check-conv: $(SSH_WRAPPER_SH) for p in `$(GIT_SRV_ADMIN_SH) -u jan -j list-personal-projects`; do \ make git-conv-$$p ;\ done -list-maintainers: $(SSH_WRAPPER_SH) - $(GIT_SRV_ADMIN_SH) $@ - -git-update-project-descriptions: $(SSH_WRAPPER_SH) - $(GIT_SRV_ADMIN_SH) -j update-descriptions all - -$(PROJECTS_TXT): - echo $(PROJECTS) | sed 's/ /\n/g; s%/%%g' > $@ - -edit-%: | $(TEXT_FILES_CACHE) - $(EDITOR) $(shell grep "/$*$$" $(TEXT_FILES_CACHE)) - -done.clean: - rm -f *.done +# --- rules links.done: if [ -d btools ]; then ln -sf btools dspider-btools; fi @@ -357,38 +401,3 @@ pull.done: $(filter-out $(UNAVAILABLE_TARGETS),cvs-update.done clone.done links. clone.done: $(filter-out $(UNAVAILABLE_TARGETS),$(SSH_WRAPPER_SH)) $(PGIT) clone touch $@ - -list-files: - @for p in $(PROJECTS); do \ - $(LIST_VCS_FILES) -znf $$p | sed -z "s/^/$$p\//" | \ - xargs -0 realpath ;\ - done - -clean: clean.text-files-cache -clean.text-files-cache: - rm -f $(TEXT_FILES_CACHE) -$(TEXT_FILES_CACHE): - @make text-files-update -text-files-update: - @make --no-print-directory list-files | xargs file -N | grep ":.*text" | cut -d: -f1 > $(TEXT_FILES_CACHE).tmp - mv $(TEXT_FILES_CACHE).tmp $(TEXT_FILES_CACHE) -text-files-update-all: - @PROJECTS_TXT= make text-files-update -text-files-list list-text-files: | $(TEXT_FILES_CACHE) - @cat $(TEXT_FILES_CACHE) - -loc-all: - @make --no-print-directory list-text-files | \ - grep -v "iow-standalone\|jux3\|ntv2/contrib\|\.dia$$\|\.dat\$$\|bootsrap\.css\|mpegplayer/contrib\|gitweb.cgi" | \ - xargs wc -l - -find-code-files: - find . -name '*.c' -o -name '*.cpp' -o -name '*.h' \ - -o -name Makefile -o -name '*.mk' \ - -o -name '*.sh' -o -name '*.pl' -o -name '*.py' \ - | grep -v "/dist/\|\.dep\.mk\|local.mk\|coordgen\|^\./[^/]\+/include/" \ - | grep -v "contrib/wt\|/bin/\|contrib/bootstrap\|contrib/chntpw/src\|contrib/jquery/src\|contrib/ntv2linux" \ - | grep -v "copilot-suse-tw-cf/initrd-tree" \ - | grep -v "iow-standalone\|jux3" \ - | grep -v "generated\|tmp\|old\|orig\|purged" -