forked from rabbitmq/rabbitmq-dotnet-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dist.sh
executable file
·300 lines (246 loc) · 8.74 KB
/
dist.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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
#! /bin/bash
## This source code is dual-licensed under the Apache License, version
## 2.0, and the Mozilla Public License, version 1.1.
##
## The APL v2.0:
##
##---------------------------------------------------------------------------
## Copyright (C) 2007-2014 GoPivotal, Inc.
##
## 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
##
## http:##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.
##---------------------------------------------------------------------------
##
## The MPL v1.1:
##
##---------------------------------------------------------------------------
## The contents of this file are subject to the Mozilla Public License
## Version 1.1 (the "License"); you may not use this file except in
## compliance with the License. You may obtain a copy of the License
## at http:##www.mozilla.org/MPL/
##
## Software distributed under the License is distributed on an "AS IS"
## basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
## the License for the specific language governing rights and
## limitations under the License.
##
## The Original Code is RabbitMQ.
##
## The Initial Developer of the Original Code is GoPivotal, Inc.
## Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
##---------------------------------------------------------------------------
### Fail on any non-zero return
set -e
### Print command traces
set -x
### Disable sharing files by default (it causes things not to work properly)
CYGWIN=nontsec
. dist-lib.sh
### Overrideable vars
test "$KEYFILE" || KEYFILE=rabbit-mock.snk
test "$RABBIT_VSN" || RABBIT_VSN=0.0.0.0
test "$WEB_URL" || WEB_URL=http://stage.rabbitmq.com/
test "$UNOFFICIAL_RELEASE" || UNOFFICIAL_RELEASE=
test "$MONO_DIST" || MONO_DIST=
### Other, general vars
NAME=rabbitmq-dotnet-client
NAME_VSN=$NAME-$RABBIT_VSN
RELEASE_DIR=release
if [ "$MONO_DIST" ] ; then
INCLUDE_WCF=true
MSBUILD=xbuild
DOTNET_PROGRAM_PREPEND="mono"
else
INCLUDE_WCF=true
MSBUILD=msbuild.exe
DOTNET_PROGRAM_PREPEND=
fi
assembly-version $RABBIT_VSN
function main {
### Remove everything in the release dir and create the dir again
safe-rm-deep-dir $RELEASE_DIR
mkdir -p $RELEASE_DIR
### Check keyfile exists and generate if necessary, or exit with error if
### we're building an official release
if [ ! -f "$KEYFILE" ]; then
if [ "$UNOFFICIAL_RELEASE" ]; then
sn -k $KEYFILE
else
echo "ERROR! Keyfile $KEYFILE not found."
exit 1
fi
fi
### Remove everything in tmp dir and create it again
safe-rm-deep-dir tmp
mkdir -p tmp
### Generate dist zip files
dist-zips
### Remove tmp
safe-rm-deep-dir tmp
echo "SUCCESS!"
}
function dist-zips {
# clean & build
dist-target-framework dotnet-4.0
### Source dist
src-dist
gendoc-dist \
build/bin/RabbitMQ.Client.xml \
$NAME_VSN-client-htmldoc.zip \
"/suppress:RabbitMQ.Client.Framing \
/suppress:RabbitMQ.Client.Framing.Impl \
/suppress:RabbitMQ.Client.Impl \
/suppress:RabbitMQ.Client.Apigen.Attributes" \
$NAME_VSN-tmp-xmldoc.zip \
projects/client/RabbitMQ.Client \
../../..
if [ -z "$MONO_DIST" ]; then
### HTML documentation for the WCF bindings library dist
gendoc-dist \
build/bin/RabbitMQ.ServiceModel.xml \
$NAME_VSN-wcf-htmldoc.zip \
"" \
"" \
projects/wcf/RabbitMQ.ServiceModel \
../../..
fi
}
function cp-license-to {
cp LICENSE $1
cp LICENSE-APACHE2 $1
cp LICENSE-MPL-RabbitMQ $1
}
function src-dist {
### Copy files to be zipped to tmp/srcdist/
mkdir -p tmp/srcdist/docs/specs tmp/srcdist/lib
cp RabbitMQDotNetClient.sln tmp/srcdist/
cp -r projects tmp/srcdist/
rm -f tmp/srcdist/projects/README
cp -r docs/specs/*.xml tmp/srcdist/docs/specs/
cp -r lib/MSBuild.Community.Tasks tmp/srcdist/lib/
cp -r lib/nunit tmp/srcdist/lib/
cp Local.props.example tmp/srcdist/
cp README.in tmp/srcdist/README
if [ -n "$NO_LINKS" ]; then
touch tmp/srcdist/README
else
links -dump ${WEB_URL}build-dotnet-client.html >> tmp/srcdist/README
fi
cp-license-to tmp/srcdist/
### Zip tmp/srcdist making $NAME_VSN the root dir in the archive
mv tmp/srcdist tmp/$NAME_VSN
mkdir tmp/srcdist
mv tmp/$NAME_VSN tmp/srcdist/
cd tmp/srcdist
zip -q -r ../../$RELEASE_DIR/$NAME_VSN.zip . -x \*.snk \*.resharper \*.csproj.user
cd ../..
### Remove tmp/srcdist
rm -rf tmp/srcdist
}
function dist-target-framework {
TARGET_FRAMEWORK="$1"
BUILD_WCF=
test -z "$MONO_DIST" && BUILD_WCF="true"
### Make sure we can use MSBuild.Community.Tasks.dll (it might be from a
### remote location)
chmod +x lib/MSBuild.Community.Tasks/MSBuild.Community.Tasks.dll
### Save current Local.props
LOCAL_PROPS_EXISTS=
test -f Local.props && LOCAL_PROPS_EXISTS="true"
test "$LOCAL_PROPS_EXISTS" && mv ./Local.props ./Local.props.user
### Overwrite Local.props with settings specific to dist
gen-props Dist-$TARGET_FRAMEWORK.props.in ./Local.props
mkdir -p tmp/dist/bin tmp/dist/projects/examples
### Clean
$MSBUILD /verbosity:quiet RabbitMQDotNetClient.sln /t:Clean /property:Configuration="Release"
### Copy examples code to be zipped to tmp/dist/
cp -r projects/examples/client tmp/dist/projects/examples/
test "$BUILD_WCF" && cp -r projects/examples/wcf tmp/dist/projects/examples/
### Build
$MSBUILD /verbosity:quiet RabbitMQDotNetClient.sln /t:Build /property:Configuration="Release"
### Copy bin files to be zipped to tmp/dist/
cp projects/client/RabbitMQ.Client/build/bin/RabbitMQ.Client.xml tmp/dist/bin/
cp projects/client/RabbitMQ.Client/build/bin/RabbitMQ.Client.dll tmp/dist/bin/
for example in $(ls projects/examples/client); do
cp projects/examples/client/$example/build/bin/$example.exe tmp/dist/bin/
done
test "$BUILD_WCF" && cp projects/wcf/RabbitMQ.ServiceModel/build/bin/RabbitMQ.ServiceModel.dll tmp/dist/bin/
cp-license-to tmp/dist/
### Zip tmp/dist
cd tmp/dist
zip -q -r ../../$RELEASE_DIR/$NAME_VSN-$TARGET_FRAMEWORK.zip .
cd ../..
### Remove tmp/dist
rm -rf tmp/dist
### Restore Local.props
rm -f ./Local.props
test "$LOCAL_PROPS_EXISTS" && mv ./Local.props.user ./Local.props || true
}
function gen-props {
if [ "$MONO_DIST" ]; then
USING_MONO="true"
else
USING_MONO="false"
fi
sed -e "s:@VERSION@:$ASSEMBLY_VSN:g" \
-e "s:@KEYFILE@:$KEYFILE:g" \
-e "s:@USINGMONO@:$USING_MONO:g" \
< $1 > $2
}
function gendoc-dist {
XML_SOURCE_FILE="$1"
ZIP_DESTINATION_FILENAME="$2"
EXTRA_NDOCPROC_ARGS="$3"
### If this is an empty string, the intermediate xml output will not be saved in a zip
ZIP_TMP_XML_DOC_FILENAME="$4"
PROJECT_DIR="$5"
RELATIVE_DIR="$6"
mkdir -p tmp/gendoc/xml tmp/gendoc/html
### Make sure we can use ndocproc (it might be from a remote location)
chmod +x lib/ndocproc-bin/bin/ndocproc.exe
cd $PROJECT_DIR
### Generate XMLs with ndocproc
$DOTNET_PROGRAM_PREPEND $RELATIVE_DIR/lib/ndocproc-bin/bin/ndocproc.exe \
$EXTRA_NDOCPROC_ARGS \
$RELATIVE_DIR/tmp/gendoc/xml \
$XML_SOURCE_FILE \
$RELATIVE_DIR/docs/namespaces.xml
cd $RELATIVE_DIR
### Zip ndocproc's output
if [ "$ZIP_TMP_XML_DOC_FILENAME" ]; then
cd tmp/gendoc/xml
zip -q -r ../../../$RELEASE_DIR/$ZIP_TMP_XML_DOC_FILENAME .
cd ../../..
fi
### Transform to html, using xsltproc
genhtml index index
genhtml namespace- namespace
genhtml type- type
### Remove generated XMLs and copy remaining files to be added to the .zip
rm -rf tmp/gendoc/xml
cp lib/ndocproc-bin/xsl/style.css tmp/gendoc/html/
cp-license-to tmp/gendoc/
### Zip tmp/gendoc
cd tmp/gendoc
zip -q -r ../../$RELEASE_DIR/$ZIP_DESTINATION_FILENAME .
cd ../..
### Remove tmp/gendoc
rm -rf tmp/gendoc
}
function genhtml {
for f in $(ls tmp/gendoc/xml/$1*.xml); do
f_base_name="${f##*/}"
echo "(xsltproc) Processing $f_base_name ..."
xsltproc -o tmp/gendoc/html/${f_base_name%.xml}.html --param config tmp/gendoc/xml/config.xml lib/ndocproc-bin/xsl/$2.xsl $f
done
}
main $@