-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathabacus.sh
executable file
·155 lines (143 loc) · 5.38 KB
/
abacus.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/bin/bash
set -e
if [ $# -eq 0 ]; then
echo "No arguments provided, options are:"
echo " --nu : Initilise Nuget dependencies."
echo " --clean : Remove generated code."
echo " --gen : Run T4 code generation."
echo " --build : Compile generated code."
echo " --test : Run tests for compiled code."
echo " --all : Runs all of the above."
echo " --docs : Generate Doxygen docs (CI Only)."
fi
while test $# -gt 0
do
case "$1" in
--nu)
task_nu=1
;;
--clean)
task_clean=1
;;
--gen)
task_gen=1
;;
--build)
task_build=1
;;
--test)
task_test=1
;;
--docs)
task_docs=1
;;
--all)
task_nu=1
task_clean=1
task_gen=1
task_build=1
task_test=1
;;
esac
shift
done
if [ "$task_nu" == 1 ]; then
echo "Initilising Nuget dependencies."
set -x
rm -rf packages/
nuget install -o packages/
set +x
fi
if [ "$task_clean" == 1 ]; then
echo "Removing generated code"
set -x
rm -rf ../../src/main/*
rm -rf ../../src/test/*
set +x
fi
if [ "$task_gen" == 1 ]; then
echo "Running T4 code generation."
set -x
startPath=`pwd`
find . -name .DS_Store -exec rm -rf {} \;
cd source/abacus/gen/main
find ./ ! -type d ! -name _tmp_ -exec sh -c 'expand -t 4 {} > _tmp_ && mv _tmp_ {}' \; # tabs to spaces
mono ../../../../packages/Mono.TextTransform.*/tools/TextTransform.exe -r 'System.Core' Abacus.Single.tt -o ../../src/main/Abacus.Single.cs
mono ../../../../packages/Mono.TextTransform.*/tools/TextTransform.exe -r 'System.Core' Abacus.Double.tt -o ../../src/main/Abacus.Double.cs
mono ../../../../packages/Mono.TextTransform.*/tools/TextTransform.exe -r 'System.Core' Abacus.Fixed32.tt -o ../../src/main/Abacus.Fixed32.cs
mono ../../../../packages/Mono.TextTransform.*/tools/TextTransform.exe -r 'System.Core' Abacus.Fixed64.tt -o ../../src/main/Abacus.Fixed64.cs
cd $startPath
cd source/abacus/gen/test
find ./ ! -type d ! -name _tmp_ -exec sh -c 'expand -t 4 {} > _tmp_ && mv _tmp_ {}' \; # tabs to spaces
mono ../../../../packages/Mono.TextTransform.*/tools/TextTransform.exe -r 'System.Core' Abacus.Single.Tests.tt -o ../../src/test/Abacus.Single.Tests.cs
mono ../../../../packages/Mono.TextTransform.*/tools/TextTransform.exe -r 'System.Core' Abacus.Double.Tests.tt -o ../../src/test/Abacus.Double.Tests.cs
mono ../../../../packages/Mono.TextTransform.*/tools/TextTransform.exe -r 'System.Core' Abacus.Fixed32.Tests.tt -o ../../src/test/Abacus.Fixed32.Tests.cs
mono ../../../../packages/Mono.TextTransform.*/tools/TextTransform.exe -r 'System.Core' Abacus.Fixed64.Tests.tt -o ../../src/test/Abacus.Fixed64.Tests.cs
cd $startPath
set +x
fi
if [ "$task_build" == 1 ]; then
echo "Compiling generated code."
set -x
rm -rf bin/
mkdir bin/
cp packages/NUnit.*/lib/nunit.framework.dll bin/
mcs \
-out:bin/abacus.dll \
-target:library \
-recurse:source/abacus/src/main/*.cs \
/doc:bin/abacus.xml \
-lib:bin/ \
-reference:System.Numerics.dll
mcs \
-out:bin/abacus.test.dll \
-target:library \
-recurse:source/abacus/src/test/*.cs \
-lib:bin/ \
-reference:abacus.dll \
-reference:nunit.framework.dll
set +x
fi
if [ "$task_test" == 1 ]; then
echo "Running tests for compiled code."
set -x
mono packages/NUnit.Runners.*/tools/nunit-console.exe bin/abacus.test.dll
set +x
fi
if [ "$task_docs" == 1 ]; then
echo "Generating Doxygen docs."
set -x
doxygen doxygen.conf
ls -lah docs/
git clone -b master https://github.com/sungiant/abacus.git main
git clone -b gh-pages https://github.com/sungiant/abacus.git temp
cd temp
git config --global push.default simple
git config user.name "Travis CI"
git config user.email "[email protected]"
rm -rf *
echo "" > .nojekyll
cd ../
mv docs/html/* temp/
cd temp
if [ -n "$(git status --porcelain)" ] && [ -f "index.html" ]; then
echo 'Uploading documentation to the gh-pages branch...'
git add --all
git commit -m "Deploy code docs to GitHub Pages Travis build: ${TRAVIS_BUILD_NUMBER}" -m "Commit: ${TRAVIS_COMMIT}"
openssl aes-256-cbc -k "$abacus_ci_password" -d -md sha256 -a -in ../main/abacus_ci.enc -out abacus_ci
echo "Host github.com" > ~/.ssh/config
echo " IdentityFile $(pwd)/abacus_ci" >> ~/.ssh/config
chmod 400 abacus_ci
echo "github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" > ~/.ssh/known_hosts
if ! git push --force [email protected]:sungiant/abacus.git ; then
_err "git push error"
fi
else
echo '' >&2
echo 'Warning: No documentation (html) files have been found!' >&2
echo 'Warning: Not going to push the documentation to GitHub!' >&2
exit 1
fi
set +x
fi
exit 0