summaryrefslogtreecommitdiffstats
path: root/makerelease.sh
blob: e46928fe75099881a5d60ee8783bd8f39c9488f4 (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
46
47
48
49
50
51
#!/bin/sh

srcdir="$(dirname "$0")"
[ "$(echo "$srcdir" | cut -c1)" = '/' ] || srcdir="$PWD/$srcdir"

die() { echo "$*"; exit 1; }

# Import the makerelease.lib
# http://bues.ch/gitweb?p=misc.git;a=blob_plain;f=makerelease.lib;hb=HEAD
for path in $(echo "$PATH" | tr ':' ' '); do
	[ -f "$MAKERELEASE_LIB" ] && break
	MAKERELEASE_LIB="$path/makerelease.lib"
done
[ -f "$MAKERELEASE_LIB" ] && . "$MAKERELEASE_LIB" || die "makerelease.lib not found."

hook_get_version()
{
	local file="$1/host/pymoistcontrol/util.py"
	local v="$(cat "$file" | grep -e VERSION | head -n1 | awk '{print $3;}' | cut -d'"' -f2)"
	version=v"$v"
}

hook_testbuild()
{
	for f in $(find . -name '*.c' -o -name '*.h'); do
		# Check CR/LF
		file "$f" | grep -qEe '(CRLF line terminators)|(assembler source text)' || {
			die "ERROR: '$(basename "$f")' is not in DOS format."
		}
	done
}

hook_pre_tarball()
{
	# Build the hex file before packing the tarball.
	default_hook_testbuild "$2"/firmware/
	cp "$2"/firmware/moistcontrol.hex "$2"/firmware-progmem.hex
	cp "$2"/firmware/moistcontrol.eep.hex "$2"/firmware-eeprom.hex

	# Move the documentation
	mv "$2"/schematics/moistcontrol.pdf "$2"/schaltplan.pdf
	mv "$2"/doc/dokumentation.pdf "$2"/
	mv "$2"/doc/moistcontrol.pap "$2"/programmablaufplan.pap

	cd "$2"/firmware
	make clean
}

project=moistcontrol
default_compress=zip
makerelease "$@"
bues.ch cgit interface