forked from vrjuggler/vrjuggler
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build_windows.py
executable file
·2825 lines (2366 loc) · 112 KB
/
build_windows.py
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
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#python
# ************** <auto-copyright.pl BEGIN do not edit this line> **************
#
# VR Juggler is (C) Copyright 1998-2011 by Iowa State University
#
# Original Authors:
# Allen Bierbaum, Christopher Just,
# Patrick Hartling, Kevin Meinert,
# Carolina Cruz-Neira, Albert Baker
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library 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
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# *************** <auto-copyright.pl END do not edit this line> ***************
import glob
import os, os.path
import fnmatch
import re
import shutil
import sys
import time
import traceback
import getopt
import subprocess
pj = os.path.join
EXIT_STATUS_SUCCESS = 0
EXIT_STATUS_NO_MSVS = 1
EXIT_STATUS_MISSING_DATA_FILE = 2
EXIT_STATUS_MSVS_START_ERROR = 3
EXIT_STATUS_INVALID_PATH = 4
EXIT_STATUS_MISSING_REQ_VALUE = 5
EXIT_STATUS_UNSUPPORTED_COMPILER = 6
EXIT_STATUS_INVALID_ARGUMENT = 7
gJugglerDir = os.path.dirname(os.path.abspath(sys.argv[0]))
gOptionsFileName = "options.cache"
gBuild64 = False
gUnattended = False
gJobLimit = None
gInstallDebug = False
gValidBuildConfigs = ("ReleaseDLL", "DebugDLL", "DebugRtDll")
gJdomJars = [
'jdom.jar',
'jaxen-core.jar',
'jar',
'jaxen-jdom.jar',
'xerces.jar',
'xml-apis.jar',
'saxpath.jar'
]
gTweekJars = [
'Tweek.jar',
'TweekBeanDelivery.jar',
'TweekBeans.jar',
'TweekEvents.jar',
'TweekNet.jar',
'TweekServices.jar',
'kunststoff-mod.jar'
]
gTweekExtJars = [
'ui.jar',
'wizard.jar'
]
gJcclJars = [
'jccl_config.jar',
'jccl_editors.jar'
]
gJcclRtrcJars = [
'jccl_rtrc.jar'
]
gHaveTk = False
try:
import Tkinter
import tkMessageBox
import tkFileDialog
import threading
gHaveTk = True
except ImportError, ex:
print ex
class BuildOption:
def __init__(self, envVar, desc, defaultValue, isDirectory = True,
required = True):
self.envVar = envVar
self.desc = desc
self.default = defaultValue
self.required = required
self.isDirectory = isDirectory
def detectVisualStudioVersion(reattempt = False):
(cl_stdin, cl_stdout, cl_stderr) = os.popen3('cl')
cl_version_line = cl_stderr.readline()
cl_ver_match = re.compile(r'Compiler Version ((\d+)\.(\d+)\.(\d+))')
ver_string_match = cl_ver_match.search(cl_version_line)
cl_major = 0
cl_minor = 0
if ver_string_match is not None:
cl_major = int(ver_string_match.group(2))
cl_minor = int(ver_string_match.group(3))
if cl_major <= 14:
printStatus("Visual Studio 2005 and older are not supported")
sys.exit(EXIT_STATUS_UNSUPPORTED_COMPILER)
elif cl_major == 15:
vs_ver = '2008'
else:
printStatus("Warning: unrecognized compiler version %s.%s, will treat it like VS2010"
% (cl_major, cl_minor))
vs_ver = '2010'
printStatus("It appears that we will be using Visual Studio %s"%vs_ver)
#printStatus(" compiler version: %s.%s"%(cl_major,cl_minor))
in_status = cl_stdin.close()
out_status = cl_stdout.close()
err_status = cl_stderr.close()
# If there was an error closing any of the streams returned by
# os.popen3(), then the command was not opened correctly. That means
# that CL.EXE is not in the user's path.
if in_status is not None or out_status is not None or err_status is not None:
# If this is not a reattempt to guess the Visual Studio version, then
# be nice and extend the user's path to include their Visual Studio
# installation.
if not reattempt:
printStatus("Visual studio not in path, attempting to find...")
# Common installation directories for Visual Studio.
vs_dirs = [r'C:\Program Files (x86)\Microsoft Visual Studio 10.0',
r'C:\Program Files (x86)\Microsoft Visual Studio 9.0',
r'C:\Program Files\Microsoft Visual Studio 9.0',
r'C:\Program Files\Microsoft Visual Studio 8'
]
for d in vs_dirs:
printStatus("Trying path: %s"%d)
if not os.path.exists(d):
printStatus(" does not exist.")
else:
printStatus(" Using: %s"%d)
printStatus(" " + d)
vs_path = [os.path.join(d, r'Common7\IDE'),
os.path.join(d, r'VC7\BIN'),
os.path.join(d, r'VC\BIN'),
os.path.join(d, r'Common7\Tools'),
os.path.join(d, r'Common7\Tools\bin\prerelease'),
os.path.join(d, r'Common7\Tools\bin')]
path_add = ';'.join(vs_path)
os.environ['PATH'] = path_add + os.pathsep + os.getenv('PATH', '')
# Try again to guess the Visual Studio version.
return detectVisualStudioVersion(True)
# If execution reaches this point, our attempts to guess the
# location of a Visual Studio 7.x installation failed.
noVisualStudioError()
# If this is a reattempt to guess the Visual Studio version, then
# something is wrong with the user's Visual Studio installation.
else:
noVisualStudioError()
return (cl_major, cl_minor)
def chooseVisualStudioDir():
(cl_ver_major, cl_ver_minor) = detectVisualStudioVersion()
needs_upgrade = False
# We do not support Visual Studio 2005 (version 8.0) or older.
if cl_ver_major <= 14:
print "ERROR: Visual C++ 8.0 and older are not supported!"
sys.exit(EXIT_STATUS_UNSUPPORTED_COMPILER)
# Otherwise, we use the solution in the vc9 subtree.
elif cl_ver_major == 15:
vc_dir = 'vc9'
else:
vc_dir = 'vc10'
if cl_ver_major > 16:
# Will need to upgrade the solution
needs_upgrade = True
return (cl_ver_major, cl_ver_minor, vc_dir, needs_upgrade)
def printStatus(msg):
'''
This is a simple wrapper around the standard Python print function.
We will use a wrapper function for key status messages so that they
can be redirected either to the console or to a GUI easily.
'''
print msg
def noVisualStudioError():
print "ERROR: Visual Studio commands are not in your path!"
print "Run vsvars32.bat in this shell or update the %PATH% environment"
print "variable on your system."
sys.exit(EXIT_STATUS_NO_MSVS)
def getCacheFileName():
return os.path.join(gJugglerDir, gOptionsFileName)
def processInput(optionDict, envVar, inputDesc, required = False):
default_value = optionDict[envVar]
if gUnattended:
print ' %s = "%s" (%s)' % (envVar, default_value, inputDesc)
input_str = ''
else:
print " %s [%s]: " % (inputDesc, default_value),
input_str = sys.stdin.readline().strip(" \n")
if input_str == '':
if required and (default_value is None or default_value == ''):
print "ERROR: %s value required" % inputDesc
sys.exit(EXIT_STATUS_MISSING_REQ_VALUE)
else:
value_str = default_value
else:
value_str = input_str
optionDict[envVar] = value_str
os.environ[envVar] = value_str
return value_str
def getDefaultVars(clVerMajor, clVerMinor):
required = []
required.append(BuildOption('BOOST_ROOT',
'Boost C++ installation directory', ''))
required.append(BuildOption('BOOST_VERSION', 'Boost C++ version',
'1_31', False))
required.append(BuildOption('BOOST_INCLUDES',
'Directory containing the Boost C++ header tree',
''))
required.append(BuildOption('CPPDOM_ROOT', 'CppDOM installation directory',
''))
required.append(BuildOption('CPPDOM_INCLUDES',
'Directory containing the CppDOM header tree',
''))
required.append(BuildOption('GMTL_ROOT', 'GMTL installation directory', ''))
required.append(BuildOption('GMTL_INCLUDES',
'Directory containing the GMTL header tree',
''))
optional = []
optional.append(BuildOption('JAVA_HOME', 'Java installation directory',
r'C:\java', required = False))
optional.append(BuildOption('JOGL_HOME', 'Jogl installation directory',
os.getenv('JAVA_HOME', ''), required = False))
optional.append(BuildOption('JAVA3D_HOME', 'Java 3D installation directory',
os.getenv('JAVA_HOME', ''), required = False))
optional.append(BuildOption('OMNIORB_ROOT',
'omniORB installation directory', '',
required = False))
optional.append(BuildOption('PFROOT',
'OpenGL Performer installation directory',
r'C:\Program Files\Silicon Graphics\OpenGL Performer',
required = False))
optional.append(BuildOption('MS_SPEECH_SDK_ROOT',
'Microsoft Speech SDK directory', '',
required = False))
optional.append(BuildOption('VRPN_ROOT', 'VRPN installation directory', '',
required = False))
optional.append(BuildOption('AUDIERE_ROOT',
'Audiere installation directory', '',
required = False))
optional.append(BuildOption('OPENAL_ROOT',
'OpenAL SDK installation directory', '',
required = False))
optional.append(BuildOption('ALUT_ROOT', 'ALUT SDK installation directory',
'', required = False))
optional.append(BuildOption('TRACKD_API_ROOT',
'TrackdAPI installation directory', '',
required = False))
optional.append(BuildOption('FTD2XX_ROOT',
'FTD2XX SDK installation directory', '',
required = False))
optional.append(BuildOption('MOTION_NODE_SDK_ROOT',
'MotionNode SDK installation directory', '',
required = False))
optional.append(BuildOption('DOOZER_ROOT',
'Doozer installation directory', '',
required = False))
optional.append(BuildOption('SDL_ROOT',
'Simple DirectMedia Layer installation directory', '',
required = False))
options = {
'prefix' : r'C:\vrjuggler',
'deps-prefix' : r'C:\vrjuggler-deps'
}
for opt in required + optional:
options[opt.envVar] = os.getenv(opt.envVar, opt.default)
# If there are cached options, read them in.
cache_file = getCacheFileName()
if os.path.exists(cache_file):
execfile(cache_file)
return required, optional, options
def setVars(clVerMajor, clVerMinor):
required, optional, options = getDefaultVars(clVerMajor, clVerMinor)
print "+++ Required Settings"
processInput(options, 'prefix', 'Installation prefix', True)
boost_dir = ''
boost_ver = ''
for opt in required:
result = processInput(options, opt.envVar, opt.desc, opt.required)
# The following is a little hack to get a reasonable default set for
# the BOOST_INCLUDES variable before the user has to enter it manually.
if opt.envVar == 'BOOST_ROOT':
boost_dir = result
elif opt.envVar == 'BOOST_VERSION' and \
options.get('BOOST_INCLUDES', '') == '':
boost_ver = result
options['BOOST_INCLUDES'] = boost_dir + r'\include\boost-' + boost_ver
# The following is a little hack to get a reasonable default set for
# the CPPDOM_INCLUDES variable before the user has to enter it manually.
if opt.envVar == 'CPPDOM_ROOT' and \
options.get('CPPDOM_INCLUDES', '') == '':
options['CPPDOM_INCLUDES'] = os.path.join(result, 'include')
# The following is a little hack to get a reasonable default set for
# the GMTL_INCLUDES variable before the user has to enter it manually.
if opt.envVar == 'GMTL_ROOT' and \
options.get('GMTL_INCLUDES', '') == '':
options['GMTL_INCLUDES'] = os.path.join(result, 'include')
print "+++ Optional Settings"
processInput(options, 'deps-prefix', 'Dependency installation prefix',
False)
for opt in optional:
processInput(options, opt.envVar, opt.desc, opt.required)
postProcessOptions(options)
writeCacheFile(options)
return options
def postProcessOptions(options):
os.environ['instprefix'] = options['prefix'].replace('\\', '\\\\')
# If the %JAVA_HOME% setting is a valid directory, add its bin subdirectory
# to the path.
if os.environ['JAVA_HOME'] != '' and os.path.exists(os.environ['JAVA_HOME']):
jdk_path = os.path.join(os.environ['JAVA_HOME'], 'bin')
os.environ['PATH'] = jdk_path + os.pathsep + os.environ['PATH']
os.environ['JACORB_PATH'] = os.path.join(gJugglerDir, r'external\JacORB')
if (os.environ['OMNIORB_ROOT'] != '' and
os.path.exists(os.environ['OMNIORB_ROOT'])):
# A 64-bit build of omniORB has to have been compiled against a 64-bit
# build of Python. Unfortunately, when omniidl.exe acts as the Python
# interpreter, it doesn't take care of setting PYTHONHOME, and this
# prevents it from being able to find core modules (such as sys.py or
# os.py). We'll assume that a 64-bit Python interpreter is being used
# to run this script and use its installation prefix as PYTHONHOME to
# help out omniidl.exe.
if gBuild64 and not os.environ.has_key('PYTHONHOME'):
os.environ['PYTHONHOME'] = sys.prefix
omni_bin = os.path.join(os.environ['OMNIORB_ROOT'], 'bin')
if os.path.exists(os.path.join(omni_bin, 'omniidl.exe')):
os.environ['OMNIORB_BIN'] = omni_bin
else:
os.environ['OMNIORB_BIN'] = os.path.join(omni_bin, 'x86_win32')
# Extend the path to include omniORB's bin directory.
os.environ['PATH'] = os.environ['OMNIORB_BIN'] + os.pathsep + os.environ['PATH']
omni_lib = os.path.join(os.environ['OMNIORB_ROOT'], 'lib')
if os.getenv('PYTHONPATH', '') != '':
os.environ['PYTHONPATH'] = os.path.join(omni_lib, 'python') + os.pathsep + os.environ['PYTHONPATH']
else:
os.environ['PYTHONPATH'] = os.path.join(omni_lib, 'python')
if os.path.exists(os.path.join(omni_lib, 'omnithread.lib')):
os.environ['OMNIORB_LIB'] = omni_lib
else:
os.environ['OMNIORB_LIB'] = os.path.join(omni_lib, 'x86_win32')
omni_glob = os.path.join(os.environ['OMNIORB_LIB'], 'omniORB*_rt.lib')
libs = glob.glob(omni_glob)
omni_ver_re = re.compile(r'omniORB(\d\d\d)_rt.lib')
for l in libs:
match = omni_ver_re.search(l)
if match is not None:
os.environ['OMNIORB_VERSION'] = match.group(1)
break
omnithread_glob = os.path.join(os.environ['OMNIORB_LIB'],
'omnithread*_rt.lib')
libs = glob.glob(omnithread_glob)
omnithread_ver_re = re.compile(r'omnithread(\d\d)_rt.lib')
for l in libs:
match = omnithread_ver_re.search(l)
if match is not None:
os.environ['OMNITHREAD_VERSION'] = match.group(1)
break
# Determine if al.h is in the base include directory or in include\AL.
if os.environ['OPENAL_ROOT'] != '':
if gBuild64:
subdir = 'Win64'
else:
subdir = 'Win32'
lib_dirs = [os.path.join(os.environ['OPENAL_ROOT'], 'lib'),
os.path.join(os.environ['OPENAL_ROOT'], 'libs'),
os.path.join(os.environ['OPENAL_ROOT'], 'libs', subdir)]
for l in lib_dirs:
openal_lib = os.path.join(l, 'OpenAL32.lib')
if os.path.exists(openal_lib):
os.environ['OPENAL_LIB_DIR'] = l
break
header_file = os.path.join(os.environ['OPENAL_ROOT'], 'include', 'AL',
'al.h')
# If the file is include\AL\al.h, then set the environment variable
# %HAVE_AL_AL_H% to the preprocessor symbol 'HAVE_AL_AL_H'.
# See modules/sonix/plugins/OpenAL/OpenALSoundImplementation.cpp.
if os.path.exists(header_file):
os.environ['HAVE_AL_AL_H'] = 'HAVE_AL_AL_H'
# Determine if alut.h is in the base include directory or in include\AL.
openal_envs = ['ALUT_ROOT', 'OPENAL_ROOT']
for env in openal_envs:
if os.environ[env] != '':
header_file = os.path.join(os.environ[env], 'include', 'AL', 'alut.h')
# If the file is include\AL\alut.h, then set the environment variable
# %HAVE_AL_ALUT_H% to the preprocessor symbol 'HAVE_AL_ALUT_H'.
# See modules/sonix/plugins/OpenAL/OpenALSoundImplementation.cpp.
if os.path.exists(header_file):
os.environ['HAVE_AL_ALUT_H'] = 'HAVE_AL_ALUT_H'
# If the ALUT installation directory is not set, then assume that it is the
# same as the OpenAL installation directory.
if os.environ['ALUT_ROOT'] == '' and os.environ['OPENAL_ROOT'] != '':
os.environ['ALUT_ROOT'] = os.environ['OPENAL_ROOT']
if os.environ['TRACKD_API_ROOT'] != '' and os.path.exists(os.environ['TRACKD_API_ROOT']):
trackdapi_dir = os.environ['TRACKD_API_ROOT']
trackdapi_incdir = os.path.join(trackdapi_dir, 'include')
# Figure out which Trackd API header to include.
headers = ['trackdAPI.h', 'trackdAPI_CC.h']
for h in headers:
if os.path.exists(os.path.join(trackdapi_incdir, h)):
os.environ['GADGET_TRACKD_API_H'] = '<%s>' % h
break
# Determine if al.h is in the base include directory or in include\AL.
if os.environ['SDL_ROOT'] != '':
sdl2_path = os.path.join(os.environ['SDL_ROOT'], 'include', 'SDL2')
if os.path.exists(sdl2_path):
os.environ['HAVE_SDL2'] = 'HAVE_SDL2'
os.environ['SDL_LIB'] = 'SDL2.lib'
else:
os.environ['SDL_LIB'] = 'SDL.lib'
def writeCacheFile(optionDict):
cache_file = open(getCacheFileName(), 'w')
for k, v in optionDict.iteritems():
output = "options['%s'] = r'%s'\n" % (k, v)
cache_file.write(output)
cache_file.close()
def getBoostVersion():
boost_ver_re = re.compile(r'#define\s+BOOST_LIB_VERSION\s+"(.+)"')
info = ('0', '0', '0')
if os.environ.has_key('BOOST_INCLUDES'):
ver_file = open(os.path.join(os.environ['BOOST_INCLUDES'], 'boost',
'version.hpp'))
lines = ver_file.readlines()
ver_file.close()
for l in lines:
match = boost_ver_re.search(l)
if match is not None:
ver_info = match.group(1).split('_')
info = tuple(ver_info)
break
return info
def buildVersion(inputFile, exps):
ver_file = open(inputFile)
lines = ver_file.readlines()
ver_file.close()
nums = [0 for e in exps]
for l in lines:
i = 0
while i < len(exps):
match = exps[i].search(l)
if match is not None:
nums[i] = match.group(1)
break
i = i + 1
return tuple(nums)
def getCppDOMVersion():
exps = [
re.compile(r'#define\s+CPPDOM_VERSION_MAJOR\s+(\d+)'),
re.compile(r'#define\s+CPPDOM_VERSION_MINOR\s+(\d+)'),
re.compile(r'#define\s+CPPDOM_VERSION_PATCH\s+(\d+)')
]
info = (0, 0, 0)
if os.environ.has_key('CPPDOM_INCLUDES'):
info = buildVersion(os.path.join(os.environ['CPPDOM_INCLUDES'], 'cppdom',
'version.h'),
exps)
return info
def getGMTLVersion():
exps = [
re.compile(r'#define\s+GMTL_VERSION_MAJOR\s+(\d+)'),
re.compile(r'#define\s+GMTL_VERSION_MINOR\s+(\d+)'),
re.compile(r'#define\s+GMTL_VERSION_PATCH\s+(\d+)')
]
nums = [0, 0, 0]
if os.environ.has_key('GMTL_INCLUDES'):
info = buildVersion(os.path.join(os.environ['GMTL_INCLUDES'], 'gmtl',
'Version.h'),
exps)
return info
def updateVersions(vcDir, options):
class JugglerModule:
def __init__(self, srcDir, vcDir, projDir, versionEnvVar, substVars,
genFiles = None):
self.source_dir = os.path.join(gJugglerDir, srcDir)
self.version_params = os.path.join(self.source_dir,
'Makefile.inc.in')
self.version_file = os.path.join(self.source_dir, 'VERSION')
self.version_env_var = versionEnvVar
self.version_env_var_dot = versionEnvVar + '_DOT'
self.subst_vars = substVars
self.param_files = []
self.proj_dir = os.path.join(gJugglerDir, vcDir, projDir)
if genFiles is not None:
for f in genFiles:
output = os.path.join(self.proj_dir, f[0])
if len(f) == 1 or f[1] is None:
template = os.path.join(self.source_dir, f[0] + '.in')
else:
template = f[1]
self.param_files.append((output, template))
def updateParamFiles(self):
for (output, template) in self.param_files:
if os.path.exists(output):
mtime = os.path.getmtime
# This test to determine if the module's param header needs to
# be regenerated is equivalent to that used by the UNIX build
# system.
if mtime(self.version_file) > mtime(output) or \
mtime(template) > mtime(output):
self.__genParamFile(output, template)
else:
self.__genParamFile(output, template)
def getVersion(self, joinStr, versionInfo = None):
if versionInfo is None:
(version, major, minor, patch, build) = self.__getVersionInfo()
else:
(version, major, minor, patch, build) = versionInfo
return '%d%s%d%s%d' % (major, joinStr, minor, joinStr, patch)
def setVersionEnvVar(self):
vi = self.__getVersionInfo()
os.environ[self.version_env_var] = self.getVersion('_', vi)
os.environ[self.version_env_var_dot] = self.getVersion('.', vi)
def removeOldVersions(self):
output_files = []
for ext in ['lib', 'dll', 'exp', 'ilk', 'pdb']:
output_files += glob.glob(os.path.join(self.proj_dir, '*', '*',
'*.' + ext))
mtime = os.path.getmtime
for f in output_files:
if mtime(self.version_file) > mtime(f):
try:
os.remove(f)
except:
print "Failed to remove", f
version_re = re.compile(r'((\d+)\.(\d+)\.(\d+)-(\d+))\s')
branch_re = re.compile(r'BRANCH\s*=\s*(.+)')
canon_name_re = re.compile(r'CANON_NAME\s*=\s*(\S.+)')
subst_re = re.compile(r'@(\w+)@')
zero_strip_re = re.compile(r'^0*([^0]\d+)')
def __getVersionInfo(self):
ver_file = open(self.version_file)
cur_ver = ver_file.readline()
ver_file.close()
ver_match = self.version_re.match(cur_ver)
version = ver_match.group(1)
major = int(ver_match.group(2))
minor = int(ver_match.group(3))
patch = int(ver_match.group(4))
build = int(ver_match.group(5))
return (version, major, minor, patch, build)
def __genParamFile(self, output, template):
(version, major, minor, patch, build) = self.__getVersionInfo()
# NOTE: This will not always be identical to the UNIX version because
# Python does not have %e as a time formatting directive.
date = time.strftime('%b %d, %Y %H:%M:%S')
canon_name = ''
branch = ''
param_file = open(self.version_params, 'r')
params = param_file.readlines()
param_file.close()
# This is basically a poor man's grep. Can this be done better?
for line in params:
match = self.branch_re.match(line)
if match is not None:
branch = match.group(1)
continue
match = self.canon_name_re.match(line)
if match is not None:
canon_name = match.group(1)
continue
version_number = '%03d%03d%03d' % (major, minor, patch)
version_string = "\"v%s '%s' (BOOST) %s %s\"" % \
(version, canon_name, branch, date)
# Strip leading zeroes from version_number. Is there an easier way
# to do this?
version_number = self.zero_strip_re.match(version_number).group(1)
subst_vars = self.subst_vars
subst_vars['VER_NUMBER'] = version_number
subst_vars['MAJOR_VER_NUMBER'] = str(major)
subst_vars['MAJOR_VERSION'] = str(major)
subst_vars['MINOR_VER_NUMBER'] = str(minor)
subst_vars['MINOR_VERSION'] = str(minor)
subst_vars['PATCH_VER_NUMBER'] = str(patch)
subst_vars['MICRO_VERSION'] = str(patch)
subst_vars['BUILD_VER_NUMBER'] = str(build)
subst_vars['VER_STRING'] = version_string
subst_vars['VERSION_DOT'] = '%d.%d.%d' % (major, minor, patch)
subst_vars['SUBSYSTEM'] = 'BOOST'
subst_vars['PLATFORM'] = 'Windows'
subst_vars['data_subdir'] = 'share'
subst_vars['USE_GCC'] = 'no'
subst_vars['includedir'] = r'"${prefix}\include"'
subst_vars['libdir'] = r'${exec_prefix}\lib'
try:
input_file = open(template, 'r')
input_lines = input_file.readlines()
input_file.close()
for i in xrange(len(input_lines)):
input_lines[i] = \
self.subst_re.sub(lambda m: subst_vars.get(m.group(1), ''),
input_lines[i])
printStatus("Generating updated " + output)
param_header = open(output, 'w')
param_header.writelines(input_lines)
param_header.close()
except IOError, ex:
printStatus("ERROR: Could not read from %s" % template)
printStatus(ex)
printStatus("Cannot continue; exiting with error status.")
sys.exit(EXIT_STATUS_MISSING_DATA_FILE)
mods = []
rt_part = ""
vpr_subst_vars = {}
vpr_subst_vars['vpr_cxxflags'] = '/DBOOST_ALL_DYN_LINK /DCPPDOM_DYN_LINK /EHsc /GR'
vpr_subst_vars['vpr_ldflags'] = r'/libpath:"$libdir"'
vpr_subst_vars['vpr_libs'] = ''
#This is commented out to change windows platforms to use Boost.ASIO
#vpr_subst_vars['subsystem_libs'] = 'libnspr4.lib libplc4.lib'
vpr_subst_vars['subsystem_libs'] = ''
vpr_subst_vars['BOOST_ROOT'] = r'${fp_file_cwd}\..\..'
vpr_subst_vars['BOOST_VERSION_DOT'] = '.'.join(getBoostVersion())
vpr_subst_vars['BOOST_INCLUDES'] = r'/I"${prefix}\include"'
vpr_subst_vars['BOOST_LDFLAGS'] = r'/libpath:"${prefix}\lib"'
vpr_subst_vars['CPPDOM_VERSION'] = '.'.join(getCppDOMVersion())
vpr_subst_vars['LIBDIR_NAME'] = 'lib'
vpr_module = JugglerModule(r'modules\vapor', vcDir, 'VPR', 'VPR_VERSION',
vpr_subst_vars,
[(r'vpr\vprParam.h',), ('vpr.fpc',),
('boost.fpc',), ('boost_system.fpc',),
('boost_filesystem.fpc',),
('boost_signals.fpc',),
(r'vpr\version.rc',
os.path.join(gJugglerDir, 'version.rc.in'))])
mods.append(vpr_module)
# XXX: These are pretty weak assumptions.
tweek_have_cxx = options.get('OMNIORB_ROOT', '') != ''
tweek_have_java = options.get('JAVA_HOME', '') != ''
tweek_jars = []
hack_jars = ['looks.jar', 'liquidlnf.jar', 'metouia.jar']
for j in gTweekJars + hack_jars + gJdomJars:
tweek_jars.append(os.path.join('${prefix}', 'share', 'tweek', 'java', j))
tweek_ext_jars = []
for j in gTweekExtJars:
tweek_ext_jars.append(os.path.join('${prefix}', 'share', 'tweek',
'java', j))
tweek_subst_vars = {}
tweek_subst_vars['tweek_cxxflags'] = '/EHsc /GR'
if tweek_have_cxx:
tweek_subst_vars['tweek_cxxflags'] += ' /DTWEEK_HAVE_CXX /D__WIN32__=1 /D__x86__=1 /D__NT__=1 /D__OSVERSION__=5 /DUSE_core_stub_in_nt_dll /DUSE_core_stub_in_nt_dll_NOT_DEFINED_Subject /I"$prefix\\include\\tweek\\idl"'
tweek_subst_vars['tweek_extra_libs'] = \
'omnithread%s_rt.lib omniORB%s_rt.lib omniDynamic%s_rt.lib' % \
(os.environ['OMNITHREAD_VERSION'], os.environ['OMNIORB_VERSION'],
os.environ['OMNIORB_VERSION'])
tweek_subst_vars['tweek_ldflags'] = r'/libpath:"$libdir"'
tweek_subst_vars['tweek_libs'] = ''
tweek_subst_vars['tweek_idlflags_java'] = r'-I"$prefix\include"'
tweek_subst_vars['tweek_idlflags_cxx'] = r'-bcxx -Wbh=.h,s=.cpp -I"$prefix\include"'
tweek_subst_vars['tweek_idl_inc_flag_java'] = '-I'
tweek_subst_vars['tweek_idl_inc_flag_cxx'] = '-I'
tweek_subst_vars['tweek_idl_inc_flag_python'] = '-I'
tweek_subst_vars['tweek_idlgendir_java'] = '-d '
tweek_subst_vars['tweek_idlgendir_cxx'] = '-C'
tweek_subst_vars['tweek_idlgendir_python'] = '-C'
tweek_subst_vars['tweek_java_api_jars'] = ';'.join(tweek_jars)
tweek_subst_vars['tweek_ext_jars'] = ';'.join(tweek_ext_jars)
#tweek_subst_vars['CXX_ORB_DEPS'] = 'omniORB4 omnithread3 omniDynamic4'
tweek_subst_vars['VPR_VERSION'] = vpr_module.getVersion('.')
if tweek_have_cxx:
tweek_subst_vars['BUILD_CXX'] = 'Y'
else:
tweek_subst_vars['BUILD_CXX'] = 'N'
if tweek_have_java:
tweek_subst_vars['BUILD_JAVA'] = 'Y'
else:
tweek_subst_vars['BUILD_JAVA'] = 'N'
tweek_subst_vars['BUILD_PYTHON_IDL'] = 'N'
tweek_subst_vars['LIBDIR_NAME'] = 'lib'
tweek_module = JugglerModule(r'modules\tweek', vcDir, 'Tweek_CXX',
'TWEEK_VERSION', tweek_subst_vars,
[(r'tweek\tweekParam.h',), ('tweek.fpc',),
('tweek-java.fpc',), ('tweek-python.fpc',),
(r'tweek\version.rc',
os.path.join(gJugglerDir, 'version.rc.in'))])
mods.append(tweek_module)
jccl_jars = []
for j in gJcclJars + gJcclRtrcJars:
jccl_jars.append(os.path.join('${prefix}', 'share', 'jccl', 'java', j))
jccl_subst_vars = {}
jccl_subst_vars['jccl_cxxflags'] = '/EHsc /GR'
jccl_subst_vars['jccl_ldflags'] = r'/libpath:"$libdir"'
jccl_subst_vars['jccl_libs'] = ''
jccl_subst_vars['BUILD_CXX'] = tweek_subst_vars['BUILD_CXX']
jccl_subst_vars['BUILD_JAVA'] = tweek_subst_vars['BUILD_JAVA']
jccl_subst_vars['jccl_java_api_jars'] = ';'.join(jccl_jars)
jccl_subst_vars['VPR_VERSION'] = vpr_module.getVersion('.')
jccl_subst_vars['LIBDIR_NAME'] = 'lib'
jccl_module = JugglerModule(r'modules\jackal', vcDir, 'JCCL', 'JCCL_VERSION',
jccl_subst_vars,
[(r'jccl\jcclParam.h',
os.path.join(gJugglerDir,
r'modules\jackal\common\jccl\jcclParam.h.in')),
('jccl.fpc',),
(r'jccl\version.rc',
os.path.join(gJugglerDir, 'version.rc.in'))
])
mods.append(jccl_module)
snx_subst_vars = {}
snx_subst_vars['snx_cxxflags'] = '/EHsc /GR'
snx_subst_vars['snx_ldflags'] = r'/libpath:"$libdir"'
snx_subst_vars['snx_libs'] = ''
snx_subst_vars['VPR_VERSION'] = vpr_module.getVersion('.')
snx_subst_vars['MIN_GMTL_VERSION'] = '.'.join(getGMTLVersion())
snx_subst_vars['LIBDIR_NAME'] = 'lib'
snx_module = JugglerModule(r'modules\sonix', vcDir, 'Sonix', 'SNX_VERSION',
snx_subst_vars,
[(r'snx\snxParam.h',), ('sonix.fpc',),
(r'snx\version.rc',
os.path.join(gJugglerDir, 'version.rc.in'))])
mods.append(snx_module)
gadget_subst_vars = {}
gadget_subst_vars['gadget_cxxflags'] = '/EHsc /GR'
gadget_subst_vars['gadget_ldflags'] = r'/libpath:"$libdir"'
gadget_subst_vars['gadget_libs'] = ''
gadget_subst_vars['gadget_extra_libs'] = \
'comctl32.lib ws2_32.lib user32.lib'
gadget_subst_vars['VPR_VERSION'] = jccl_subst_vars['VPR_VERSION']
gadget_subst_vars['JCCL_VERSION'] = jccl_module.getVersion('.')
gadget_subst_vars['MIN_GMTL_VERSION'] = snx_subst_vars['MIN_GMTL_VERSION']
gadget_subst_vars['LIBDIR_NAME'] = 'lib'
gadget_module = JugglerModule(r'modules\gadgeteer', vcDir, 'Gadgeteer',
'GADGET_VERSION', gadget_subst_vars,
[(r'gadget\gadgetParam.h',),
('gadgeteer.fpc',),
(r'gadget\version.rc',
os.path.join(gJugglerDir, 'version.rc.in'))
])
mods.append(gadget_module)
vrj_subst_vars = {}
vrj_subst_vars['vrj_cxxflags'] = '/EHsc /GR'
vrj_subst_vars['vrj_ldflags'] = r'/libpath:"$libdir"'
vrj_subst_vars['vrj_libs'] = ''
vrj_subst_vars['vrj_d3d_lib'] = ''
vrj_subst_vars['vrj_ogl_lib'] = ''
vrj_subst_vars['vrj_pf_lib'] = ''
vrj_subst_vars['vrj_d3d_extra_libs'] = \
'd3dxof.lib dxguid.lib d3dx9d.lib d3d9.lib winmm.lib'
vrj_subst_vars['vrj_ogl_extra_libs'] = 'opengl32.lib glu32.lib'
vrj_subst_vars['vrj_pf_extra_libs'] = \
'/libpath:"${PFROOT}\lib" libpf.lib libpfdu-util.lib libpfui.lib opengl32.lib glu32.lib'
vrj_subst_vars['VPR_VERSION'] = jccl_subst_vars['VPR_VERSION']
vrj_subst_vars['JCCL_VERSION'] = gadget_subst_vars['JCCL_VERSION']
vrj_subst_vars['SNX_VERSION'] = snx_module.getVersion('.')
vrj_subst_vars['GADGET_VERSION'] = gadget_module.getVersion('.')
vrj_subst_vars['BOOST_ROOT'] = r'${fp_file_cwd}\..\..'
vrj_subst_vars['BOOST_VERSION_DOT'] = '.'.join(getBoostVersion())
vrj_subst_vars['BOOST_INCLUDES'] = r'/I"${prefix}\include"'
vrj_subst_vars['BOOST_LDFLAGS'] = r'/libpath:"${prefix}\lib"'
vrj_subst_vars['LIBDIR_NAME'] = 'lib'
vrj_module = JugglerModule(r'modules\vrjuggler', vcDir, 'VRJuggler',
'VRJ_VERSION', vrj_subst_vars,
[(r'vrj\vrjParam.h',), ('vrjuggler.fpc',),
('vrjuggler-direct3d.fpc',),
('vrjuggler-opengl.fpc',),
('vrjuggler-performer.fpc',),
('boost_program_options.fpc',),
(r'vrj\version.rc',
os.path.join(gJugglerDir, 'version.rc.in'))])
mods.append(vrj_module)
for m in mods:
m.setVersionEnvVar()
m.updateParamFiles()
m.removeOldVersions()
def generateAntBuildFiles(vcDir):
class AntTarget:
def __init__(self, srcdir, vcDir, moduleName, outputFile = 'build.xml',
topSubDir = None):
'''
__init__(srcdir, vcDir, moduleName, outputFile, topSubDir)
Arguments:
srcdir -- The location of the Java source to be compiled.
vcDir -- The root of the directory tree containing the Visual
C++ build system.
moduleName -- The name of the Visual C++ project (under the vcDir
subdirectory) associated with this Ant build. When
concatenated to vcDir, this is where the the .class
file(s) and the .jar file(s) will be created.
outputFile -- The name of the Ant build file to generate. If not
specified, this defaults to 'build.xml'.
topSubDir -- The root of the directory where all the work will be
done. This is needed for Ant builds that depend on
previously constructed JAR files that will most likely
exist somewhere in the vcDir directory tree. This
string is used as part of the replacment for the
string @topdir@ in the source build.xml.in file. If
not specified, this defaults to whatever value is
passed in for vcDir.
'''
if topSubDir is None:
topSubDir = vcDir
self.srcdir = os.path.join(gJugglerDir, srcdir)
self.topdir = os.path.join(gJugglerDir, topSubDir)
self.module_name = os.path.join(gJugglerDir, vcDir, moduleName)
self.output_file = os.path.join(self.module_name, outputFile)
if not os.path.exists(self.module_name):
os.mkdir(self.module_name)
elif not os.path.isdir(self.module_name):
printStatus("ERROR: %s exists, but it is not a directory!" % self.module_name)
sys.exit(EXIT_STATUS_INVALID_PATH)
self.tweek_jars = []
for j in gTweekJars:
self.tweek_jars.append(os.path.join(gJugglerDir, vcDir,
'Tweek_Java', j))
self.tweek_ext_jars = []
for j in gTweekExtJars:
self.tweek_jars.append(os.path.join(gJugglerDir, vcDir,
'Tweek_Java', j))
self.jccl_jars = []
for j in gJcclJars:
self.jccl_jars.append(os.path.join(gJugglerDir, vcDir,
'JCCL_Java', j))
self.jccl_rtrc_jars = []
for j in gJcclRtrcJars:
self.jccl_jars.append(os.path.join(gJugglerDir, vcDir,
'JCCL_Java',
'RTRC_Plugin_Java', j))
# This form of regular expressions appears to be necessary because
# the sub() method does not handle backslashes in the replacement string
# the way I would like.
srcdir_re = re.compile(r'^(.*)@srcdir@(.*)$')
topdir_re = re.compile(r'^(.*)@topdir@(.*)$')
juggler_root_re = re.compile(r'^(.*)@JUGGLERROOT_ABS@(.*)$')
jdom_jar_re = re.compile(r'^(.*)@JDOM_JAR@(.*)$')
tweek_jars_re = re.compile(r'^(.*)@TWEEK_JARS@(.*)$')
tweek_ext_jars_re = re.compile(r'^(.*)@TWEEK_EXT_JARS@(.*)$')
jccl_jars_re = re.compile(r'^(.*)@JCCL_JARS@(.*)$')
java_orb_jar_re = re.compile(r'^(.*)@JAVA_ORB_JAR@(.*)$')
jogl_jars_re = re.compile(r'^(.*)@JOGL_JARS@(.*)$')
java3d_jars_re = re.compile(r'^(.*)@JAVA3D_JAR@(.*)$')
jdom_jars = []
jdom_root = os.path.join(gJugglerDir, 'external', 'jdom')
for j in gJdomJars:
if j == 'jdom.jar':
jdom_jars.append(os.path.join(jdom_root, 'build', j))
else:
jdom_jars.append(os.path.join(jdom_root, 'lib', j))
jogl_jars = [
os.path.join(os.environ['JOGL_HOME'], 'jogl.jar'),
os.path.join(os.environ['JOGL_HOME'], 'jogl-demos-util.jar')
]
java3d_jars = [
os.path.join(os.environ['JAVA3D_HOME'], r'jre\lib\ext\j3daudio.jar'),
os.path.join(os.environ['JAVA3D_HOME'], r'jre\lib\ext\j3dcore.jar'),
os.path.join(os.environ['JAVA3D_HOME'], r'jre\lib\ext\j3dutils.jar'),
os.path.join(os.environ['JAVA3D_HOME'], r'jre\lib\ext\vecmath.jar')
]
def generateBuildFile(self):
input_file = open(os.path.join(self.srcdir, 'build.xml.in'), 'r')
input = input_file.readlines()
input_file.close()
for i in xrange(len(input)):
line = input[i]