summaryrefslogtreecommitdiffstats
path: root/makerelease.sh
blob: 4ad64b301f42a57ed01a30f5882cdf24326bb82b (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
52
53
54
55
56
57
#!/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/firmware/version.h"
	local regex='#define[[:space:]]VERSION[[:space:]]'
	version="$(grep -e "$regex" "$file" | head -n1 | cut -d'"' -f2)"
}

hook_testbuild()
{
	default_hook_testbuild "$1/firmware"
}

hook_regression_tests()
{
	make -C "$1/firmware" tests
}

hook_pre_archives()
{
	# Build the hex files.
	make -C "$2/firmware" all
	make -C "$2/firmware" clean
	mv "$2"/firmware/*.hex "$2"

	# Move the documentation.
	mv "$2"/schematics-lf1600/lf1600.pdf "$2"/schematics-lf1600.pdf

	# Update the README
	local makefile="$2/firmware/Makefile"
	local lfuse="$(grep -e 'LFUSE[[:space:]]*:=' "$makefile" | head -n1 | cut -d'=' -f2 | tr -d '[[:space:]]')"
	local hfuse="$(grep -e 'HFUSE[[:space:]]*:=' "$makefile" | head -n1 | cut -d'=' -f2 | tr -d '[[:space:]]')"
	local efuse="$(grep -e 'EFUSE[[:space:]]*:=' "$makefile" | head -n1 | cut -d'=' -f2 | tr -d '[[:space:]]')"
	sed -i -e 's/%%LFUSE%%/'"$lfuse"'/g' \
	       -e 's/%%HFUSE%%/'"$hfuse"'/g' \
	       -e 's/%%EFUSE%%/'"$efuse"'/g' \
	       "$2/README"
}

project=xytronic-lf
default_archives="tar.xz"
makerelease "$@"
bues.ch cgit interface