-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathbuild
More file actions
executable file
·112 lines (101 loc) · 2.4 KB
/
build
File metadata and controls
executable file
·112 lines (101 loc) · 2.4 KB
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
109
110
111
#!/bin/bash
set -e
# options:
# all (default): build lib, doc and examples + run tests
# examples : build only example
# doc : build doc with image
# docrelease : build and push public documentation
# run : run all examples
function build_examples {
echo "building examples ..."
for i in $(find examples/ -name "*.rs" | cut -d/ -f2 | cut -d. -f1); do
echo "-> example $i ..."
cargo build --example $i
done
}
function run_examples {
echo "run examples ..."
for i in $(find examples/ -name "*.rs" | cut -d/ -f2 | cut -d. -f1); do
echo "-> example $i ..."
cargo run --example $i
done
}
function build_doc {
DST=target/doc/
cargo doc
cargo run --example linear_regression -- --nokey
convert -trim /tmp/linreg_plot.png $DST/linreg_plot.png
cargo run --example image_grid -- --nokey
convert -resize x246 /tmp/grid.png $DST/digits_grid.png
cargo run --example gradient_descent -- --nokey
convert -trim /tmp/3dplot.png $DST/gradient_descent.png
if [ ! -e target/doc/nn_example.png -o `stat -c "%Y" examples/plots.rs` -gt `stat -c "%Y" target/doc/nn_example.png` ]; then
cargo run --example plots -- --nokey
convert -trim /tmp/plot_normal_1.png $DST/plot_normal_1.png
convert -trim /tmp/plot_mixture.png $DST/plot_mixture.png
convert -trim /tmp/plot_knn_boundary.png $DST/plot_knn_boundary.png
convert -trim /tmp/nn.png $DST/nn.png
convert -trim /tmp/nn_example.png $DST/nn_example.png
fi
}
function build_all {
echo "build all"
echo "clean"
cargo clean
echo "building lib ..."
cargo build
echo "doc"
cargo doc
echo "running test"
cargo test
build_examples
}
function build_doc_release {
echo "build doc release"
pushd /tmp
if [ ! -e docrelease ]; then
echo "Cloning ..."
git clone git@github.com:daniel-e/rustml.git docrelease
cd docrelease/
else
echo "Pulling ..."
cd docrelease
git pull
fi
echo "change branch ..."
git checkout gh-pages
if [ `git status | grep "On branch gh-pages" | wc -l` -ne 1 ]; then
echo "something went wrong!"
popd
exit 1
fi
popd
build_doc # build documentation with images
rsync --delete -r target/doc/* /tmp/docrelease/
pushd /tmp/docrelease/
git add -A
git commit -m "update to current version"
echo "pushing ..."
git push
echo "done"
}
case $1 in
all)
echo "all"
;;
examples)
build_examples
;;
doc)
build_doc
;;
docrelease)
build_doc_release
;;
run)
run_examples
;;
*)
build_all
;;
esac