-
Notifications
You must be signed in to change notification settings - Fork 94
/
makeDist
executable file
·609 lines (468 loc) · 14.7 KB
/
makeDist
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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
#!/bin/bash
libName="libQGLViewer"
version="2.9.1"
WebURL="http://www.libqglviewer.com"
version_major=`echo $version | cut -d"." -f1`
version_minor=`echo $version | cut -d"." -f2`
version_release=`echo $version | cut -d"." -f3`
libNameVersion="$libName-$version"
tmpDir="/tmp/$libNameVersion"
QGLViewerRootDir=$(pwd)
echo $QGLViewerRootDir > /tmp/QGLViewerRootDir
allTarGZ="$libNameVersion-all.tar.gz"
cd $QGLViewerRootDir
DOS2UNIX="" #"dos2unix -o -q"
UNIX2DOS="" #"unix2dos -o -q"
DOXYGEN=$(which doxygen)
function error
{
echo $1
exit 1
}
if [[ $@ != 0 ]] && [[ $1 = "web" ]]
then
echo "--- Publishing libQGLViewer version $version ---"
WebDir="/www"
SrcDir="src"
#echo "TEST mode $WebDir" && mkdir -p $WebDir/$SrcDir && touch $WebDir/$SrcDir/oldContent
cd ~/.tmp
test -f $allTarGZ || error "No archive file in .tmp dir."
rm $WebDir/*.html $WebDir/*.css
rm -rf $WebDir/examples $WebDir/images $WebDir/refManual
tar xzf $allTarGZ
mv $libNameVersion.tar.gz $libNameVersion.zip libqglviewer*$version*.deb $libName*$version*.rpm $WebDir/$SrcDir
cd $WebDir
cd $SrcDir
test -f md5sum.txt && rm md5sum.txt
md5sum `find . -type f | sort` > md5sum.txt
ls -1 | grep -v "^lib" | grep -v "index.php" | grep -v "md5sum.txt" | grep -v "licenseQGLViewer.pdf" && echo "Extra files in src"
cd - > /dev/null
echo "Checking links..."
checkLinks.pl -r
exit
fi # Fin option web
function checkGrep()
{
grep "$TARGET" $FILE > /dev/null
if [[ "$?" -ne "0" ]]
then
echo
echo "ERROR : $TARGET not found in $FILE"
exit 1
fi
}
function checkVersion()
{
grep "^$START$VERSION" $FILE > /dev/null
if [[ "$?" -ne "0" ]]
then
echo
echo "Version found in $FILE is not $VERSION - Patching"
sed s~"^$START.*"~"$START$VERSION"~ $FILE > /tmp/makeDist
cp /tmp/makeDist $FILE
fi
}
function makeDist()
{
for source in $SOURCES
do
if [[ $source =~ ^ui_.*\.h$ ]] ; then continue; fi
dir=$tmpDir/$TARGET/$(dirname $source)
test -d $dir || mkdir -p $dir
#echo "### cp $source $dir depuis $(pwd)"
cp $source $dir
done
}
echo "--- Packaging libQGLViewer version $version ---"
##################################################################
############ Checking version coherence ############
##################################################################
echo -n "Checking : "
echo -n "version"
VERSION=$version_major
START="%define version_major "
FILE="QGLViewer/qglviewer.spec"
checkVersion
VERSION=$version_minor
START="%define version_minor "
FILE="QGLViewer/qglviewer.spec"
checkVersion
VERSION=$version_release
START="%define version_revision "
FILE="QGLViewer/qglviewer.spec"
checkVersion
VERSION=$version
START="VERSION = "
FILE="QGLViewer/QGLViewer.pro"
checkVersion
vrelease=$(echo "obase=16; ${version_release}" | bc | awk '{printf "%02s\n",$0}')
hexVersion="0x0${version_major}0${version_minor}${vrelease}"
VERSION=$hexVersion
START="#define QGLVIEWER_VERSION "
FILE="QGLViewer/config.h"
checkVersion
VERSION="$version\""
START="PROJECT_NUMBER = \"Version "
FILE="doc/Doxyfile"
checkVersion
VERSION="$version"
START="\!define VERSION " # protect ! from back
FILE="libQGLViewer.nsi"
checkVersion
VERSION="$version"
START="VIProductVersion "
FILE="libQGLViewer.nsi"
checkVersion
VERSION="$version"
START="QHP_NAMESPACE = com.libqglviewer."
FILE="doc/Doxyfile"
checkVersion
VERSION="$version)"
START="project(libQGLViewer LANGUAGES CXX VERSION "
FILE="CmakeLists.txt"
checkVersion
##################################################################
############ Checking file integrity ############
##################################################################
echo -n " files"
# Convert possible Windows encoding
if [[ $DOS2UNIX ]]
then
find . -type f -a \( -name '*.cpp' -o -name '*.h' -o -name '*.ui' -o -name '*.html' -o -name '*.txt' -o -name '*.pro' -o -name '*.pri' -o -name '*.ui' -o -name '*.ago' -o -name '*.css' -o -name '*.bwb' \) -exec $DOS2UNIX {} \; > /tmp/error 2>&1
grep -v "/\.svn/" /tmp/error
if [[ "$?" -eq "0" ]]
then
echo "Error while converting newlines, see /tmp/error"
grep -v "/\.svn/" /tmp/error
exit 1
fi
fi
TARGET="Gilles Debunne <[email protected]> $version"
FILE="QGLViewer/qglviewer.spec"
checkGrep
TARGET="<a href=\"changeLog.html\">.*$version"
FILE="doc/index.html"
checkGrep
TARGET="$version</h2>"
FILE="doc/changeLog.html"
checkGrep
for f in `ls QGLViewer/QGLViewer.pro examples/*/*.pro examples/contribs/*/*.pro examples/contribs/*/*/*.pro`
do
case "$f" in
"QGLViewer/QGLViewer.pro"|"examples/debug/debug.pro"|"examples/contribs/contribs.pro"|"examples/contribs/agora/agora.pro"|"examples/contribs/blobWar/blobWar.pro")
continue
;;
esac
TARGET="^include.*examples\.pri"
FILE="$f"
checkGrep
done
TARGET="^URL.*$WebURL"
FILE="QGLViewer/qglviewer.spec"
checkGrep
TARGET="^\!define URL $WebURL"
FILE="libQGLViewer.nsi"
checkGrep
echo
##################################################################
############ Collecting sources ###########
##################################################################
echo -n "Collecting : "
test -d $tmpDir && rm -rf $tmpDir
test -d $tmpDir || mkdir -p $tmpDir
# ----------------------------------------------
SOURCES="CHANGELOG INSTALL README LICENCE GPL_EXCEPTION gpl-header libQGLViewer.pro"
if [[ $DOS2UNIX ]]
then
$DOS2UNIX $SOURCES &> /tmp/error
test -s /tmp/error && more /tmp/error && error "Error while converting newlines to Unix"
fi
TARGET=""
makeDist
# ----------------------------------------------
echo -n "sources"
cd QGLViewer
rm -f ui_*.h
SOURCES="*.h *.cpp QGLViewer*.pro *.ui qglviewer_*.ts qglviewer-icon.xpm qglviewer.icns VRender/*.h VRender/*.cpp"
TARGET="QGLViewer"
makeDist
cd - > /dev/null
# ----------------------------------------------
echo -n " examples"
function makeDistExample()
{
#echo "makeDistExample sur $DIR"
name=$(basename $DIR)
test -f $DIR/$name.pro || error "No example $name.pro file - Aborting"
TARGET="$name"
FILE="$(dirname $DIR)/$(basename $(dirname $DIR)).pro"
checkGrep
dotPro="$DIR/$name.pro"
grep 'SUBDIRS.*\\.*' $dotPro && echo "Unhandled backslash in SUBDIRS"
subDirs=$(grep "SUBDIRS" $dotPro | sed s%"SUBDIRS *= *"%%)
if [[ ! -z $subDirs ]]
then
for subDir in $subDirs
do
oldDir=$DIR
oldName=$name
DIR="$DIR/$subDir"
makeDistExample
DIR=$oldDir
name=$oldName
done
SOURCES="$DIR/$name.pro"
TARGET=""
makeDist
else
TARGET="^include( \.\./.*examples.pri )"
FILE="$dotPro"
checkGrep
SOURCES="$name.pro *.cpp"
distFiles=$(grep "DISTFILES" $dotPro | sed s%"DISTFILES.*= *"%%)
SOURCES="$SOURCES $distFiles"
TARGET="$DIR"
cd $DIR
ls *.h &> /dev/null && SOURCES="$SOURCES *.h"
ls *.ui &> /dev/null && SOURCES="$SOURCES *.ui"
ls *.vcproj &> /dev/null && SOURCES="$SOURCES *.vcproj"
#echo "Example sources=$SOURCES"
makeDist
cd - > /dev/null
fi
}
cd examples
SOURCES="examples.pro qglviewer.rc qglviewer.ico examples.pri contribs/contribs.pro"
TARGET="examples"
makeDist
cd - > /dev/null
for dir in $(ls -d examples/* examples/contribs/*)
do
test -d $dir || continue
if [ $dir == "examples/contribs" ]
then
continue 2
fi
DIR="$dir"
makeDistExample
done
# ----------------------------------------------
echo -n " doc"
cd doc
SOURCES="*.html *.css Doxyfile tabs.awk images/*jpg images/*png images/*gif images/qglviewer.ico" #cwExtractor
TARGET="doc"
makeDist
cd - > /dev/null
# ----------------------------------------------
cd designerPlugin
SOURCES="*.h *.cpp *.pro *.json"
TARGET="designerPlugin"
makeDist
cd - > /dev/null
echo
##################################################################
############ Filtering sources ############
##################################################################
echo -n "Filtering : "
cd $tmpDir
########### Filter root files
export LC_TIME="en"
date=`date "+%B %-d, %Y"`
for f in "gpl-header" "CHANGELOG" "INSTALL" "LICENCE" "README" "GPL_EXCEPTION" "libQGLViewer.pro"
do
sed s:"#VERSION#":"$version":g $f | sed s%"#WEBURL#"%"$WebURL"%g | sed s:"#DATE#":"$date":g > $f.filtered
mv $f.filtered $f
done
mv "libQGLViewer.pro" "$libNameVersion.pro"
########### Filter translations
echo -n "sources"
cd QGLViewer
lupdate QGLViewer.pro 2> /dev/null > /dev/null
lrelease QGLViewer.pro 2> /dev/null > /tmp/lrelease
if [ `grep "0 unfinished" /tmp/lrelease | wc -l` != 1 ]
then
echo
echo "Untranslated QString exist - Aborting"
exit
fi
if [ `grep "untranslated" /tmp/lrelease | wc -l` -gt 0 ]
then
echo
echo "Untranslated QString exist - Aborting"
exit
fi
if [ `grep "type=\"obsolete\"" qglviewer_fr.ts | wc -l` -gt 0 ]
then
echo
echo "Obsolete translations in qglviewer_fr.ts - Aborting"
exit
fi
cd - > /dev/null
########### Create examples' web pages
echo -n " examples"
cd examples
$QGLViewerRootDir/examples/makeDist || error "Error in examples' makeDist"
cd - > /dev/null
########### Add GPL warnings
echo -n " copyright"
for f in `find . -name '*.h' -o -name '*.cpp'`
do
cat gpl-header $f > $f.bak
mv $f.bak $f
done
rm gpl-header
vRenderCopyright="$QGLViewerRootDir/QGLViewer/VRender/copyright"
test -f $vRenderCopyright || error "No copyright in VRender"
if [[ $DOS2UNIX ]]
then
$DOS2UNIX $vRenderCopyright
fi
for f in `find QGLViewer/VRender -name '*.h' -o -name '*.cpp'`
do
cat $vRenderCopyright $f > $f.bak
mv $f.bak $f
done
########### Filter doc
echo -n " doc"
cd doc
### Date and version ###
for f in `ls *.html`
do
date=`stat -f "%Sm" -t "%A, %B %d, %Y"`
#date=`date -r $f "+%A, %B %-d, %Y"`
sed s:"#VERSION#":"$version":g $f | sed s:"#VERSION_MAJOR#":"$version_major":g | sed s%"#WEBURL#"%"$WebURL"%g > /tmp/filtered
sed s:"#DATE#":"$date":g /tmp/filtered > $f
done
################################ Doxygen ###
if [[ -f $DOXYGEN ]]
then
$DOXYGEN Doxyfile
else
echo
echo "Doxygen not found ($DOXYGEN)"
exit 1
fi
#cd latex ; make clear ; make pdf > /dev/null ; cp refman.pdf $WebDir/qglviewer.pdf
rm doxygen.css Doxyfile
cd refManual
#doxytag -s search.idx >& /dev/null
test -f installdox && rm installdox
## Changing header menu in doxygen pages ##
# Removing unused pages
if [[ -f patchingDoxygenIsPainful ]]
then
rm -f files.html globals.html globals_*.html *_8*.html namespace*.html dir_*.html dirs.html functions_rela.html functions_vars.html functions_0x*.html classes.html
# Patching functions pages
for f in $(ls functions_*.html)
do
newName=$(echo $f | sed s%"_func"%%)
grep -v "^Here is a list" $f | sed s%"functions_func"%"functions"%g | sed s%"| <a[^>]*>Variables</a>"%""%g | sed s%"| <a[^>]*>Related Functions</a>"%""%g | sed s%"<a[^>]*>All</a> |"%""%g > $newName-bis
rm -r $f
mv $newName-bis $newName
done
# Changing header menus
for f in $(ls *.html)
do
No time to keep up with doxygen output changes
awk -f ../tabs.awk $f > /tmp/tabs
mv /tmp/tabs $f
done
# Removing useless empty lines
for f in `ls *.html`
do
awk '/<tr><td colspan="2"><p><a class="anchor"/ { skip=1; next} { if (skip==1) { skip=0; next } print} GILLES' $f > $f.tmp
mv $f.tmp $f
done
fi
# Changing hierarchy page
sed s%"This inheritance.*alphabetically:"%% hierarchy.html > /tmp/hierarchy.html
awk '/<h1>Class Hierarchy<\/h1>/ { print "<p>You can add the libQGLViewer <code>.qch<\/code> file in Qt assistant to make it able to browse this documentation.<\/p>"} {print}' /tmp/hierarchy.html > hierarchy.html
# Changing QGLViewer:: enums
for f in $(ls class*.html)
do
sed s%">QGLViewer::\([A-Z_]*\)</a>"%">\1</a>"%g $f > /tmp/qgl
mv /tmp/qgl $f
done
# Changing link to main page
for f in $(ls *.html)
do
sed s%"<a href=\"index.html\"><span>Main"%"<a href=\"../index.html\"><span>Main"%g $f > /tmp/qgl
mv /tmp/qgl $f
done
rm ../tabs.awk
# Removing auto-links
for f in `ls class*.html | grep -v -- "-members.html"`
do
sed s%"<a[^<]* href=\"$f\"[^<]*>\([^<]*\)</a>"%"\1"%g $f > $f.tmp
mv $f.tmp $f
done
# Adding icon and libQGLViewer version
for f in $(ls *.html)
do
awk '/link.*doxygen.css/ {print "<link rel=\"shortcut icon\" href=\"../images/qglviewer.ico\" type=\"image/x-icon\" />"; print "<link rel=\"icon\" href=\"../images/qglviewer.icon.png\" type=\"image/png\" />";} {print $0;}' $f > $f.tmp
sed s/"Generated by "/"libQGLViewer $version documentation generated by"/g $f.tmp > $f
sed s/"<img[^>]*src=\"doxygen.png\"[^>]*\/>"/"doxygen"/ $f > $f.tmp
mv $f.tmp $f
done
# Creating assistant qch file
#awk '/<section title="Files"/ { skip=1 } /<\/toc>/ { print" </section>"; skip=0 } { if (skip==0) print }' index.qhp > index.filtered.qhp
#awk '/<section title="libQGLViewer Version $version" ref="/ { print" <section title=\"libQGLViewer Version $version\">"; next; } {print;}' index.filtered.qhp > index.qhp
#qhelpgenerator index.qhp -o ../libQGLViewer-$version.qch > /dev/null
#rm index.qhp index.filtered.qhp
cd - > /dev/null
# cwExtrator
#./cwExtractor
#cp qglviewer.cw ../QGLViewer
#mv qglviewer.cw ../examples/interface
#rm cwExtractor
echo
############################################################
############ Packages ############
############################################################
echo -n "Packaging :"
cd $tmpDir
export LC_ALL="C"
export LANGUAGE="C"
# Tar
echo -n " tar"
cd ..
tar -czf $libNameVersion.tar.gz $libNameVersion
cd - > /dev/null
echo -n " zip"
mv CHANGELOG changeLog.txt
mv INSTALL install.txt
mv LICENCE licence.txt
mv README readMe.txt
mv GPL_EXCEPTION GPL_exception.txt
function addNamespace()
{
TARGET="class QGLVIEWER_EXPORT $1 : public $2"
FILE="QGLViewer/$3.h"
checkGrep
sed s%"$TARGET"%"class QGLVIEWER_EXPORT $1 : public qglviewer::$2"% $FILE > /tmp/addNamespace
mv /tmp/addNamespace QGLViewer/$3.h
}
#addNamespace SpinningFrame Frame spinningFrame
addNamespace ManipulatedFrame Frame manipulatedFrame
addNamespace ManipulatedCameraFrame ManipulatedFrame manipulatedCameraFrame
# vcproj are now added to all packages, just in case
#for vcproj in $(find $QGLViewerRootDir/ -name '*.vcproj' -type f)
#do
# target=$(echo $vcproj | sed s%"$QGLViewerRootDir/"%""%)
# cp $vcproj $target
#done
if [[ $UNIX2DOS ]]
then
find . -type f -a \( -name '*.cpp' -o -name '*.h' -o -name '*.ui' -o -name '*.html' -o -name '*.txt' -o -name '*.pro' -o -name '*.pri' -o -name '*.ui' -o -name '*.ago' -o -name '*.css' -o -name '*.bwb' -o -name '*.vcproj' \) -exec $UNIX2DOS {} \; &> /tmp/error
test -s /tmp/error && more /tmp/error && error "Error while converting newlines to DOS"
fi
cd ..
zip -qr $libNameVersion.zip $libNameVersion
echo
echo
echo "> Done, all files set in $tmpDir"
echo "> Update website with these lines:"
echo
echo "git switch gh-pages"
echo "\\cp -rf ${tmpDir}/doc/* ."
echo "cp /tmp/$libNameVersion.tar.gz /tmp/$libNameVersion.zip src"