Parent: [b02242] (diff)

Download this file

ohbuild.sh    415 lines (361 with data), 13.0 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
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
#!/bin/sh
# Copyright (C) 2016 J.F.Dockes
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the
# Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Helper script for building the openhome libs prior to building
# sc2mpd and mpd2sc.
#
# Read about Openhome ohNet here: http://www.openhome.org/wiki/OhNet
#
# The source code we process is:
# Copyright 2011-14, Linn Products Ltd. All rights reserved.
# See the license files under the different subdirs. In a nutshell: BSD
#
# This is far from foolproof or knowledgeable, but it seems to get me
# usable (static) libs.
# There are 3 modes of operation:
# -c: clone, adjust, trim the source directories and produce a tar file
# -b: clone, adjust the source dirs and build
# -t: extract tar file and build.
#
# When cloning, we checkout a known ok version (it's more or less
# random, based on the last date I tried this, sometimes more recent
# versions don't build versions don't build), then build the different
# dirs.
#
# When producing the tar file, we get rid of the .git directory and a
# bunch of other things to reduce the size
fatal()
{
echo $*; exit 1
}
usage()
{
echo "Usage:"
echo "ohbuild.sh -c <topdir> : clone and adjust openhome directories"
echo " from the git repositories, and produce tar file in /tmp"
echo "ohbuild.sh -t <tarfile> <topdir> : extract tar file in top dir and"
echo " build openhome in there"
echo "ohbuild.sh -b <topdir> : clone and build, no cleaning up of unused"
echo " files, no tar file"
echo "ohbuild.sh <topdir> : just build, don't change the tree"
exit 1
}
opt_t=0
opt_c=0
opt_b=0
tarfile=''
opts=`getopt -n ohbuild.sh -o t:cb -- "$@"`
eval set -- "$opts"
while true ; do
case "$1" in
-t) opt_t=1; tarfile=$2 ; shift 2 ;;
-b) opt_b=1; shift ;;
-c) opt_c=1; shift ;;
--) shift ; break ;;
*) usage ;;
esac
done
echo opt_t $opt_t
echo opt_c $opt_c
echo opt_b $opt_b
echo tarfile $tarfile
test $# -eq 1 || usage
topdir=$1
echo topdir $topdir
# Only one of -tcb
tot=`expr $opt_t + $opt_c + $opt_b`
test $tot -le 1 || usage
arch=
debug=
test -d $topdir || mkdir $topdir || fatal "Can't create $topdir"
cd $topdir || exit 1
# Make topdir an absolute path
topdir=`pwd`
otherfiles=`echo *.*`
test "$otherfiles" != '*.*' && fatal topdir should not contain files
clone_oh()
{
echo "Cloning OpenHome from git repos into $topdir"
cd $topdir
for rep in \
https://github.com/openhome/ohNet.git \
https://github.com/openhome/ohdevtools.git \
https://github.com/openhome/ohNetGenerated.git \
https://github.com/openhome/ohTopology.git \
https://github.com/openhome/ohSongcast.git \
; do
dir=`echo $rep | sed -e 's+https://github.com/openhome/++' \
-e 's/\.git$//'`
echo $dir
test ! -d $dir && git clone $rep
done
cd $topdir/ohNet
# Mon Apr 24 15:23:27 2017
git checkout 1dd6411ffbe59fe09517162fb88e2405adb4990f || exit 1
git checkout Makefile
# Note: the 'make: o: Command not found' errors originate in
# common.mak and are due to variable t4 being undefined. t4 is
# normally defined as 'mono' in T4Linux.mak, included in Makefile
# only if 'uset4' is set (which it is not by default). Common.mak
# should heed uset4, but it does not. This does not seem to have
# consequences, and the errors are suppressed by defining t4 as 'echo'
# odroid64: aarch64-linux-gnu.
# odroid32,rasp30: arm-linux-gnueabihf,
# cubox: armv7hl-redhat-linux-gnueabi
patch -p1 << "EOF"
diff --git a/Makefile b/Makefile
index 29f2d6a..038b05e 100644
--- a/Makefile
+++ b/Makefile
@@ -82,12 +82,19 @@ else
ifneq (,$(findstring arm,$(gcc_machine)))
ifneq (,$(findstring linux-gnueabihf,$(gcc_machine)))
detected_openhome_architecture = armhf
+ else ifneq (,$(findstring armv7hl,$(gcc_machine)))
+ # cubox: armv7hl-redhat-linux-gnueabi
+ detected_openhome_architecture = armhf
else ifeq (${detected_openhome_system},Qnap)
detected_openhome_architecture = x19
else
detected_openhome_architecture = armel
endif
endif
+ ifneq (,$(findstring aarch64,$(gcc_machine)))
+ # odroid64: aarch64-linux-gnu
+ detected_openhome_architecture = arm64
+ endif
ifneq (,$(findstring i686,$(gcc_machine)))
detected_openhome_architecture = x86
endif
@@ -375,6 +382,10 @@ mkdir = mkdir -p
rmdir = rm -rf
uset4 = no
+# This avoids errors in Generated/Devices.mak (they apparently have no
+# consequences anyway because we use make native_only=yes)
+t4 = echo
+
ifeq ($(managed_only), yes)
build_targets_base = make_obj_dir ohNet.net.dll CpProxyDotNetAssemblies DvDeviceDotNetAssemblies
else
EOF
git checkout OpenHome/TestFramework/OptionParser.cpp
patch -p1 << "EOF"
diff --git a/OpenHome/TestFramework/OptionParser.cpp b/OpenHome/TestFramework/OptionParser.cpp
index fe90233..644fc0b 100644
--- a/OpenHome/TestFramework/OptionParser.cpp
+++ b/OpenHome/TestFramework/OptionParser.cpp
@@ -282,7 +282,7 @@ void OptionParser::SetUsage(const TChar* aUsage)
{
delete iUsage;
iUsage = NULL;
- iUsage = new TChar[strlen(iUsage)];
+ iUsage = new TChar[strlen(aUsage)];
(void)strcpy(iUsage, aUsage);
}
EOF
cd $topdir/ohNetGenerated
# Tue May 9 08:54:47 2017
git checkout e3edb912410d4c5a4d5323bb1e9c27660a42d78f || exit 1
git checkout Makefile
patch -p1 << "EOF"
diff --git a/Makefile b/Makefile
index bf7a1ba..49bffaf 100644
--- a/Makefile
+++ b/Makefile
@@ -70,14 +70,17 @@ else
else ifneq (,$(findstring linux,$(gcc_machine)))
detected_openhome_system = Linux
endif
- ifeq ($(gcc_machine),arm-none-linux-gnueabi)
- detected_openhome_architecture = armel
- endif
- ifeq ($(gcc_machine),arm-linux-gnueabi)
- detected_openhome_architecture = armel
- endif
- ifeq ($(gcc_machine),arm-linux-gnueabihf)
- detected_openhome_architecture = armhf
+ ifneq (,$(findstring arm,$(gcc_machine)))
+ ifneq (,$(findstring linux-gnueabihf,$(gcc_machine)))
+ detected_openhome_architecture = armhf
+ else ifneq (,$(findstring armv7hl,$(gcc_machine)))
+ # cubox: armv7hl-redhat-linux-gnueabi
+ detected_openhome_architecture = armhf
+ else ifeq (${detected_openhome_system},Qnap)
+ detected_openhome_architecture = x19
+ else
+ detected_openhome_architecture = armel
+ endif
endif
ifneq (,$(findstring i686,$(gcc_machine)))
detected_openhome_architecture = x86
EOF
patch -p1 << "EOF"
diff -u ./Common.mak ../../openhome/ohNetGenerated/Common.mak
--- ./Common.mak 2017-09-19 10:51:13.000000000 +0200
+++ ../../openhome/ohNetGenerated/Common.mak 2017-09-19 13:21:25.984071432 +0200
@@ -17,20 +17,6 @@
$(objdir)ohnet-generated.jar : CpProxyJavaClasses DvDeviceJavaClasses
$(jar) $(jarflags) $(objdir)ohnet-generated.jar -C $(objdir) org
-Generated$(dirsep)GenerateSourceFiles.mak : $(tt) OpenHome$(dirsep)Net$(dirsep)Service$(dirsep)Services.xml OpenHome/Net/T4/Templates/UpnpMakeT4.tt
- $(mkdir) Generated
- $(t4) -o Generated$(dirsep)GenerateSourceFiles.mak OpenHome/Net/T4/Templates/UpnpMakeT4.tt -a xml:OpenHome/Net/Service/Services.xml
- @echo Attention: a makefile has been re-generated.
-
-Generated$(dirsep)Proxies.mak : $(tt) OpenHome$(dirsep)Net$(dirsep)Service$(dirsep)Services.xml OpenHome/Net/T4/Templates/CpUpnpMakeProxies.tt
- $(mkdir) Generated
- $(t4) -o Generated$(dirsep)Proxies.mak OpenHome/Net/T4/Templates/CpUpnpMakeProxies.tt -a xml:OpenHome/Net/Service/Services.xml
- @echo Attention: a makefile has been re-generated.
-
-Generated$(dirsep)Devices.mak : $(tt) OpenHome$(dirsep)Net$(dirsep)Service$(dirsep)Services.xml OpenHome/Net/T4/Templates/DvUpnpMakeDevices.tt
- $(mkdir) Generated
- $(t4) -o Generated$(dirsep)Devices.mak OpenHome/Net/T4/Templates/DvUpnpMakeDevices.tt -a xml:OpenHome/Net/Service/Services.xml
- @echo Attention: a makefile has been re-generated.
native_targets = make_obj_dir copy_build_includes proxies devices
EOF
cd $topdir/ohTopology
# Wed Mar 22 11:15:28 2017 +0000
git checkout cc09c09da4be8d3d04adae5b8f0daaf8450906a3 || exit 1
cd $topdir/ohSongcast
# Tue Oct 18 08:34:33 2016 +0100
git checkout 3299eaedfea34993b79e6d30444792d4fb12a110 || exit 1
}
make_tarfile()
{
cd $topdir || exit 1
# Make space: get rid of the .git and other not useful data, then
# produce a tar file for reproduction
for dir in ohNet ohNetGenerated ohdevtools ohTopology ohSongcast;do
test -d $dir || fatal no "'$dir'" in "'$topdir'"
done
#rm -rf $topdir/ohNet/thirdparty
rm -rf $topdir/ohNetGenerated/OpenHome/Net/Bindings/Cs
rm -rf $topdir/ohNetGenerated/OpenHome/Net/Bindings/Java
rm -rf $topdir/ohNetGenerated/OpenHome/Net/Bindings/Js
rm -rf $topdir/ohNetGenerated/OpenHome/Net/T4/
rm -rf $topdir/ohSongcast/Docs/
rm -rf $topdir/ohSongcast/ohSongcast/Mac
rm -rf $topdir/ohSongcast/ohSongcast/Windows
rm -rf $topdir/ohTopology/waf
rm -rf $topdir/ohdevtools/nuget
dt=`date +%Y%m%d`
tar --exclude='.git' -czf $tarfile/tmp/openhome-sc2-${dt}.tar.gz .
}
build_ohNet()
{
dir=ohNet
echo;echo building $dir
cd $topdir/$dir || exit 1
make native_only=yes || exit 1
cd ..
}
build_ohNetGenerated()
{
dir=ohNetGenerated
echo;echo building $dir
cd $topdir/$dir || exit 1
# e.g. Linux-x64, Linux-armhf
arch=`basename $topdir/ohNet/Build/Bundles/ohNet-*-*.tar.gz | \
sed -e s/ohNet-// -e s/-[A-Z][a-z][a-z]*\.tar\.gz$//`
# e.g. Debug, Release
debug=`basename $topdir/ohNet/Build/Bundles/ohNet-*-*.tar.gz | \
sed -e s/.*-// -e s/\.tar\.gz$//`
sd=dependencies/${arch}
mkdir -p "$sd"
(cd $sd;
tar xvzf $topdir/ohNet/Build/Bundles/ohNet-${arch}-${debug}.tar.gz
) || exit 1
make native_only=yes
# Expect error here, but the relevant bits have been built
# Copy the includes from here to the ohNet dir where ohTopology
# will want them
tar cf - Build/Include | (cd $topdir/ohNet/;tar xvf -) || exit 1
}
build_ohdevtools()
{
dir=ohdevtools
echo;echo building $dir
cd $topdir/$dir || exit 1
# Nothing to build
}
# It appears that nothing compiled in topology is needed for Receivers
# or Senders, only managers of those. Some of the include files are
# needed (or at least used) though.
build_ohTopology()
{
dir=ohTopology
echo;echo building $dir
cd $topdir/$dir || exit 1
#./go fetch --all --clean
#./waf configure --ohnet=../ohNet --dest-platform=Linux-x86
# The build fails because of mono issues (trying to generate
# include files from templates, this is probably fixable as the e
# actual includes may exist somewhere).
#./waf build
mkdir -p build/Include/OpenHome/Av
cp -p OpenHome/Av/*.h build/Include/OpenHome/Av/
}
build_ohSongcast()
{
dir=ohSongcast
echo;echo building $dir
cd $topdir/$dir || exit 1
make release=1 Receiver WavSender
}
official_way()
{
# from README, actually Does not work, for reference. Issues probably have
# something to do with lacking mono or wrong version
cd ohNet
make ohNetCore proxies devices TestFramework
cd ../ohNetGenerated
./go fetch --all
make
cd ../ohNetmon
./go fetch --all
./waf configure --ohnet=../ohNet
./waf build
cd ../ohTopology
./go fetch --all
./waf configure --ohnet=../ohNet
./waf build
cd ../ohSongcast
make release=1
}
buildall()
{
echo "Building all in $topdir"
build_ohNet
build_ohNetGenerated
build_ohdevtools
build_ohTopology
build_ohSongcast
}
if test $opt_c -ne 0; then
test -d $topdir/ohNet && fatal target dir should be initially empty \
for producing a tar distribution
clone_oh || fatal clone failed
make_tarfile || fatal make_tarfile failed
exit 0
fi
# Extract tar, or clone git repos
if test $opt_t -eq 1; then
echo "Extracting tarfile in $topdir"
cd $topdir || exit 1
tar xf $tarfile
elif test $opt_b -eq 1; then
clone_oh
fi
buildall