summaryrefslogtreecommitdiff
path: root/project/pydist.sh
blob: d5dd8f13cdd86ad148f20257a8b63547c4592149 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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