blob: 83351da29e070468344f2874974cba2b6b550dae (
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
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
|
#!/bin/bash
#
# usage: switch-config [configuration]
# switch-config -l
#
# Script to switch the "current" configuration of the CVC4 builds directory
# to another one. Without an argument, it switches to the next alphabetically.
# With an argument, it switches to that configuration. With -l, it lists the
# available configurations.
#
# Only configurations in the "current" architecture (that for which the build directory is currently
# configured) are considered.
#
# This script is useful because it's faster that re-configuring.
#
# Script assumes it lives under contrib/ in the root of the CVC4 source
# tree.
function usage {
echo "usage: `basename \"$0\"` [configuration]"
echo " `basename \"$0\"` -l"
}
if [ $# -gt 1 ]; then
usage
exit 1
fi
cd `dirname "$0"`/..
if ! [ -d builds ]; then
echo "No configurations are available (no builds/ directory)."
exit
fi
if ! [ -e builds/current ]; then
echo "Cannot get current configuration."
exit 1
fi
current=(`grep '^CURRENT_BUILD' builds/current | sed 's,^CURRENT_BUILD *= *\([^/]\+\)/\(.*\),\1 \2,'`)
arch=${current[0]}
build=${current[1]}
builds=(`ls "builds/$arch/"`)
if ! [ -d "builds/$arch" ] || ! [ -d "builds/$arch/$build" ] || [ ${#builds[@]} -eq 0 ]; then
echo "builds/ directory in malformed state."
echo "You might want to blow it away and start from scratch."
exit 1
fi
function switchto {
config/mkbuilddir "$arch" "$1" >/dev/null
#perl -pi -e 's,^CURRENT_BUILD *= *.*,CURRENT_BUILD = '$arch/$1',' builds/current
echo "Current build switched to \`$1'."
}
if [ $# -eq 0 ]; then
first=
last=
setbuild=
for d in `ls "builds/$arch/"`; do
if [ -z "$first" ]; then first=$d; fi
if [ "$last" = "$build" ]; then setbuild=$d; break; fi
last=$d
done
if [ -z "$setbuild" ]; then setbuild=$first; fi
if [ "$setbuild" = "$build" ]; then
echo "There is only one build profile (\`$build'), and it is current."
else
switchto "$setbuild"
fi
else
case $1 in
-l) for config in `ls -1 "builds/$arch/"`; do
if [ "$config" = "$build" ]; then
echo "$config" '*'
else
echo "$config"
fi
done ;;
-*) usage; exit 1 ;;
*) if ! [ -d "builds/$arch/$1" ]; then
echo "Build \`$1' does not exist."
exit 1
else
if [ "$1" = "$build" ]; then
echo "Build \`$1' is already the current build profile."
else
switchto "$1"
fi
fi ;;
esac
fi
|