diff options
author | midipix <writeonce@midipix.org> | 2021-06-14 20:42:58 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2021-06-14 20:43:42 +0000 |
commit | ece54dd361c4f7ab0bbce9f0f29b707508b3fc3d (patch) | |
tree | 3b107cf54293e666e5377d5e4d8bc208325678ad | |
parent | 59e36e13a48dc358d67443373263722639484824 (diff) | |
download | sbpython2-ece54dd361c4f7ab0bbce9f0f29b707508b3fc3d.tar.bz2 sbpython2-ece54dd361c4f7ab0bbce9f0f29b707508b3fc3d.tar.xz |
project: pydist overhaul: integrated the new m4-based logic.
-rw-r--r-- | project/config/cfgdefs.sh | 12 | ||||
-rw-r--r-- | project/pydist.m4 | 155 | ||||
-rw-r--r-- | project/pydist.mk | 34 | ||||
-rwxr-xr-x | project/pydist.sh | 45 |
4 files changed, 245 insertions, 1 deletions
diff --git a/project/config/cfgdefs.sh b/project/config/cfgdefs.sh index 09b8f62..30ee66c 100644 --- a/project/config/cfgdefs.sh +++ b/project/config/cfgdefs.sh @@ -82,6 +82,18 @@ cfgdefs_detect_python_version() exit 2 fi + pydist_macros="$mb_project_dir/project/pydist.m4" + pydist_helper="$mb_project_dir/sofort/core/modern.m4" + pydist_srclst="$mb_project_dir/project/variants/$python_major.$python_minor.$python_micro/pydist.in" + + if ! [ -f "$pydist_srclst" ]; then + exit 2 + fi + + if ! m4 "$pydist_helper" "$pydist_macros" "$pydist_srclst" > pydist.mk ; then + exit 2 + fi + python_ver="$python_major.$python_minor" if [ "$mb_package" = '@' ]; then diff --git a/project/pydist.m4 b/project/pydist.m4 new file mode 100644 index 0000000..bef6dd0 --- /dev/null +++ b/project/pydist.m4 @@ -0,0 +1,155 @@ +m4_divert(-1) + +_ +_ <pysrcs> +_ +m4_divert(5) +m4_srclist(PYDIST_PY_SRCS) +m4_srcitem($(PYDIST_SYSCFG_SRCS)) +m4_divert(-1) + +m4_define([PYCDIR],[_ +m4_ifelse([$1],[],_ +[m4_divert(1)]_ +m4_srclist([PYDIST_SRCS]) +[m4_divert(-1)],_ +[$2],[1],_ +[m4_divert(1)]_ +m4_srclist([PYDIST_]m4_pathvar([$1][_SRCS])) +[m4_divert(-1)])_ +_ +m4_divert(2)_ +m4_ifelse([$1],[], +[m4_divert(-1)], +m4_tab[mkdir -p $(PYDIST_PYCDIR)/./][$1]) +_ +m4_divert(3)_ +m4_ifelse([$1],[], +m4_rightalign(64,[$(PYDIST_PYCDIR)/./][%.py:])[pydist.tag],_ +m4_rightalign(64,[$(PYDIST_PYCDIR)/./][$1]/[%.py:])[pydist.tag]) +_ +m4_divert(4) +m4_ifelse([$1],[], +[$(PYDIST_PYCDIR)/./][%.py: \] +m4_tabtabtab([$(SOURCE_DIR)/Lib/./][[$1]][%.py pydist.tag]), +[$(PYDIST_PYCDIR)/./][$1]/[%.py: \] +m4_tabtabtab([$(SOURCE_DIR)/Lib/./][[$1]]/[%.py pydist.tag])) +m4_tabtab[PYCOPY_PYTHON=$(PYCOPY_PYTHON) \] +m4_tabtab[PYCOPY_PREFIX=$(PYCOPY_PREFIX) \] +m4_tabtab[PYCOPY_DSTDIR=$(PYDIST_PYCDIR)/./][$1] \ +m4_tabtab[$(PYCOPY) $<] +_ +m4_ifelse([$1],[],_ +[m4_divert(5)]_ +m4_srcitem([$(PYDIST_SRCS)]) +[m4_divert(-1)], +[$2],[1],_ +[m4_divert(5)]_ +m4_srcitem([$(PYDIST_]m4_pathvar([$1][_SRCS)])) +[m4_divert(-1)]) +_ +m4_divert(6)_ +m4_tab[mkdir -p $(DESTDIR)/$(LIBDIR)/$(PACKAGE)/./][$1] +m4_divert(-1) +_ +m4_ifelse([$1],[],_ +[m4_divert(7)]_ +m4_tab[]_ +m4_rightalign(64,[cp -p $(PYDIST_SRCS)])_ +[$(DESTDIR)/$(LIBDIR)/$(PACKAGE)/./] +[m4_divert(-1)], +[$2],[1],_ +[m4_divert(7)]_ +m4_tab[]_ +m4_rightalign(64,[cp -p $(PYDIST_]m4_pathvar([$1][_SRCS)]))_ +[$(DESTDIR)/$(LIBDIR)/$(PACKAGE)/./][$1] +[m4_divert(-1)]) +_ +m4_ifelse([$1],[],_ +[m4_divert(8)]_ +m4_tab[]_ +m4_rightalign(68,[cp -p $(PYDIST_SRCS:%.py=%.pyc)])_ +[$(DESTDIR)/$(LIBDIR)/$(PACKAGE)/./] +[m4_divert(-1)], +[$2],[1],_ +[m4_divert(8)]_ +m4_tab[]_ +m4_rightalign(68,[cp -p $(PYDIST_]m4_pathvar([$1][_SRCS])[:%.py=%.pyc)])_ +[$(DESTDIR)/$(LIBDIR)/$(PACKAGE)/./][$1] +[m4_divert(-1)]) +]) + + +m4_define([PYCSRC],[_ +m4_divert(1)_ +m4_srcitem($(PYDIST_PYCDIR)/./[$1])]_ +m4_divert(-1)) +_ +_ </pysrcs> +_ + + +_ +_ <pydist.tag> +_ +m4_divert(2) +pydist.tag: +m4_divert(-1) +_ +m4_m4wrap([_ +m4_divert(2)_ +m4_tab[touch pydist.tag] +m4_divert(-1)_ +]) +_ +_ </pydist.tag> +_ + + +m4_divert(3) +m4_divert(4) + +_ +_ <pydist-install-tree> +_ +m4_divert(6) +pydist-install-tree: +m4_divert(-1) +_ +_ </pydist-install-tree> +_ + + +_ +_ <pydist-install-py> +_ +m4_divert(7) +pydist-install-py: $(PYDIST_PY_SRCS) +pydist-install-py: pydist-install-tree +pydist-install-py: +m4_tab[]_ +m4_rightalign([64],[cp -p $(PYDIST_SYSCFG_SRCS)])_ +[$(DESTDIR)/$(LIBDIR)/$(PACKAGE)] +m4_divert(-1) +_ +_ <pydist-install-py> +_ + + +_ +_ <pydist-install-pyc> +_ +m4_divert(8) +pydist-install-pyc: $(PYCGEN_OBJS) +pydist-install-pyc: pydist-install-tree +pydist-install-pyc: +m4_tab[]_ +m4_rightalign(68,[cp -p $(PYDIST_SYSCFG_SRCS:%.py=%.pyc)])_ +[$(DESTDIR)/$(LIBDIR)/$(PACKAGE)] +m4_divert(-1) +_ +_ <pydist-install-py> +_ + + +m4_divert(-1) diff --git a/project/pydist.mk b/project/pydist.mk index 2d0c914..18c0bda 100644 --- a/project/pydist.mk +++ b/project/pydist.mk @@ -1,3 +1,35 @@ +PYCOPY = $(PROJECT_DIR)/project/pycopy.sh +PYCOPY_PYTHON = $(NICKNAME) +PYCOPY_PREFIX = $(PREFIX) + +PYDIST_LIBDIR = lib +PYDIST_PYCDIR = lib/$(NICKNAME) + + +PYDIST_SYSCFG_SRCS = \ + $(PYDIST_PYCDIR)/./_sysconfigdata.py + + ifneq ($(PYTHON_MAJOR),) -include $(PROJECT_DIR)/project/variants/$(PYTHON_MAJOR).$(PYTHON_MINOR).$(PYTHON_MICRO)/pydist.mk +include pydist.mk endif + + +pydist-py-srcs: $(PYDIST_PY_SRCS) + +pydist-py-srcs-clean: + rm -f $(PYDIST_PY_SRCS) + rm -f pydist.tag + +clean: pydist-py-srcs-clean + +install-app: pydist-install-py +install-app: pydist-install-pyc + + +.PHONY: pydist-py-srcs +.PHONY: pydist-py-srcs-clean + +.PHONY: pydist-install-tree +.PHONY: pydist-install-py +.PHONY: pydist-install-pyc diff --git a/project/pydist.sh b/project/pydist.sh new file mode 100755 index 0000000..d5dd8f1 --- /dev/null +++ b/project/pydist.sh @@ -0,0 +1,45 @@ +#!/bin/sh + +# pydist.sh: a reference-only, development-time script +# objective: generate pydist.in based on the scripts found +# under $PYTHON_SRCDIR/Lib, excluding the 'test' +# and 'plat-*' sub-directories. + +set -eu + +export LC_ALL=C + +if [ -z "${PYTHON_SRCDIR:-}" ]; then + printf 'Variable PYTHON_SRCDIR is not set!\n' + exit 2 +fi + +cd -- "$PYTHON_SRCDIR/Lib" + +pydirs=$(find . -type d | grep -v -e '^\./test' -e '^./plat-' | sort) + +for pydir in $pydirs; do + if [ $pydir = '.' ]; then + pysrcs=*.py + printf 'PYCDIR(,1)_\n' + else + pydir=${pydir#./} + + if ls $pydir/*.py > /dev/null 2>&1; then + pysrcs=$pydir/*.py + printf 'PYCDIR(%s,1)\n' $pydir + else + pysrcs= + printf 'PYCDIR(%s,0)\n' $pydir + fi + + fi + + for pysrc in $(printf '%s' "$pysrcs" | sort); do + if [ "${pysrc##*/}" != 'py3_test_grammar.py' ]; then + printf 'PYCSRC(%s)\n' "$pysrc" + fi + done + + printf '\n' +done |