-
Notifications
You must be signed in to change notification settings - Fork 5
/
release.sh
executable file
·108 lines (87 loc) · 3.26 KB
/
release.sh
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/sh
# Copyright (c) 2016 The University of Manchester
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Build and package up a release of the SpiNNaker low-level tools. Builds SC&MP
# and all documentation in a clean check-out of the repository and packages
# a subset of build artefacts (e.g. PDFs and SC&MP binary).
if [ -z "$SPINN_DIRS" ]; then
echo "ERROR: \$SPINN_DIRS not defined. Did you source setup?"
exit 1
fi
cd "$SPINN_DIRS"
# Version low-level tools version number
VER=`grep SLLT_VER_STR include/version.h | awk '{ print $3 }' | sed s/\"//g`
# Release name
NAME=spinnaker_tools_$VER
# Location of released file
RELEASE_DIR=/tmp
RELEASE_FILE="$RELEASE_DIR/$NAME.tar.gz"
# Warn if there are uncommitted changes
if [ -n "$(git status --porcelain | grep -vx " M setup")" ]; then
echo "WARNING: There are some uncommitted changes."
git status --short
echo "Press <return> to build anyway or Ctrl+C to stop."
read REPLY
fi
# Warn if we're not in the master branch
if [ -z "$(git branch | grep -x "* master")" ]; then
echo "WARNING: Not in master branch."
git branch
echo "Press <return> to build anyway or Ctrl+C to stop."
read REPLY
fi
# Use a temporary working directory to produce the build
WORKING_DIR="$(mktemp -d)"
echo "Building in temporary dir: $WORKING_DIR"
cd "$WORKING_DIR"
git clone --quiet --depth 1 "file://$SPINN_DIRS" .
# Build SARK
echo "Building SARK"
(cd "$WORKING_DIR/sark" && make GNU=0 SPINN_DIRS=$WORKING_DIR) || exit 2
# Build SC&MP
echo "Building SC&MP"
(cd "$WORKING_DIR/scamp" && make GNU=0 install SPINN_DIRS=$WORKING_DIR) || exit 3
# Build documentation
for document_makefile in $(find docs/ -name Makefile); do
document_dir="$(dirname "$document_makefile")"
echo "Building $document_dir"
(cd "$document_dir" && make < /dev/null) || exit 4
done
# Package just the git-tracked files for the release
echo "Building release"
git archive --output "$NAME.tar" --prefix "$NAME/" HEAD \
README.md release.txt setup Makefile \
build include sark spin1_api lib make tools apps \
|| exit 5
# Add selected build artefacts
echo "Adding build artefacts"
(
# Directories for documentation
find docs -type d
# Documentation (excluding PDFs of figures)
for document_makefile in $(find docs/ -name Makefile); do
document_dir="$(dirname "$document_makefile")"
echo "$document_dir/$(basename "$document_dir").pdf"
done
# SC&MP binary
echo "tools/boot/scamp.boot"
) | xargs tar fr "$NAME.tar" --transform='s:.*:'"$NAME"'/\0:' --no-recursion \
|| exit 6
# Gzip the tar file and place this in the output directory
echo "Compressing archive"
mkdir -p "$RELEASE_DIR"
gzip -c "$NAME.tar" > "$RELEASE_FILE" || exit 7
echo "Removing temporary files"
rm -rf "$WORKING_DIR" || exit 8
echo "Release created: $RELEASE_FILE"