forked from jethrogb/rust-core_io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.sh
87 lines (76 loc) · 1.72 KB
/
functions.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
#!/bin/bash
git_file_exists() {
[ "$(git ls-tree --name-only $IO_COMMIT -- $1)" = "$1" ]
}
git_extract() {
slashes=${1//[^\/]/}
git archive $IO_COMMIT $1|tar xf - -C src/$IO_COMMIT --strip-components=${#slashes}
}
git_commits_ordered() {
format="$1"
shift
if [ $# -ge 1 ]; then
git log --topo-order --no-walk=sorted --date=iso-local --pretty=format:"$format" "$@"
fi
echo
}
echo_lines() {
for i in "$@"; do
echo $i
done
}
get_io_commits() {
for COMPILER_COMMIT in $COMPILER_COMMITS; do
IO_COMMIT=$(git log -n1 --pretty=format:%H $COMPILER_COMMIT -- src/libstd/io)
if ! grep -q $COMPILER_COMMIT mapping.rs; then
echo "-Mapping(\"$COMPILER_COMMIT\",\"$IO_COMMIT\")" >> mapping.rs
fi
echo $IO_COMMIT
done
}
get_patch_commits() {
find $PATCH_DIR -type f -printf %f\\n|cut -d. -f1
}
prepare_version() {
mkdir src/$IO_COMMIT
git_extract src/libstd/io/
if git_file_exists src/libstd/sys_common/memchr.rs; then
git_extract src/libstd/sys_common/memchr.rs
elif git_file_exists src/libstd/sys/common/memchr.rs; then
git_extract src/libstd/sys/common/memchr.rs
else
git_extract src/libstd/memchr.rs
fi
rm -f src/$IO_COMMIT/stdio.rs src/$IO_COMMIT/lazy.rs
}
bold_arrow() {
echo -ne '\e[1;36m==> \e[0m'
}
custom_bashrc() {
echo '
if [ -f ~/.bashrc ]; then . ~/.bashrc; fi
try_patch() {
patch -p1 < ../../patches/$1.patch
}
'
}
bash_diff_loop() {
bash --rcfile <(custom_bashrc) <> /dev/stderr
while git diff --exit-code > /dev/null; do
bold_arrow; echo "$1"
while true; do
bold_arrow; echo -n "(T)ry again or (A)bort? "
read answer <> /dev/stderr
case "$answer" in
[tT])
break
;;
[aA])
bold_arrow; echo "Aborting..."
exit 1
;;
esac
done
bash <> /dev/stderr
done
}