2 import sys
,os
,subprocess
,shutil
,platform
,time
,errno
3 import urllib
, tarfile
, zipfile
, sys
, os
, shutil
, glob
, stat
9 ("OSGColladaSrcDir", "http://sourceforge.net/projects/collada-dom/files/Collada%20DOM/Collada%20DOM%202.2/Collada%20DOM%202.2.zip/download", "Collada DOM 2.2.zip", "collada-dom"),\
10 ("OSGLibMiniSrcDir", "http://stereofx.org/download/mini/MINI-9.8.zip", None, "mini"),\
11 ("OSGOpenNurbsSrcDir", "http://files.na.mcneel.com/opennurbs/5.0/2011-11-22/opennurbs_20111122.zip", None, None),\
12 ("OSGGLEWSrcDir", "http://sourceforge.net/projects/glew/files/glew/1.7.0/glew-1.7.0.zip/download", None, None)\
15 bq_deps_src
= [("BOOST_ROOT", "http://sourceforge.net/projects/boost/files/boost/1.44.0/boost_1_44_0.zip/download", None, None), \
16 ("BOOST_JAM", "http://sourceforge.net/projects/boost/files/boost-jam/3.1.18/boost-jam-3.1.18-1-ntx86.zip/download", None, None),\
17 ("QT_ROOT", "ftp://ftp.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.7.4.zip", None, None) \
20 win_deps_src
= [("OSGZLibSrcDir", "http://sourceforge.net/projects/libpng/files/zlib/1.2.5/zlib125.zip/download", None, None), \
21 ("OSGFreeGlutSrcDir", "http://sourceforge.net/projects/freeglut/files/freeglut/freeglut-2.6.0.tar.gz/download", None, None),\
22 ("OSGLibPNGSrcDir", "http://sourceforge.net/projects/libpng/files/libpng15/older-releases/1.5.4/lpng154.zip/download", None, None),\
23 ("OSGJpegLibSrcDir", "http://sourceforge.net/projects/libjpeg/files/libjpeg/6b/jpegsr6.zip/download", None, "jpeg-6b"),\
24 ("OSGTiffLibSrcDir", "http://download.osgeo.org/libtiff/tiff-3.8.2.zip", None, None),\
25 ("OSGPcreSrcDir","http://sourceforge.net/projects/pcre/files/pcre/8.12/pcre-8.12.zip/download", None, None),\
26 ("OSGOpenExrSrcDir", "http://download.savannah.nongnu.org/releases/openexr/openexr-1.7.0.tar.gz", None, None),\
27 ("OSGIlmBaseSrcDir", "http://download.savannah.nongnu.org/releases/openexr/ilmbase-1.0.2.tar.gz", None, None),\
28 ("OSGGdalSrcDir", "http://download.osgeo.org/gdal/gdal180.zip", None, "gdal-1.8.0"),\
29 ("OSGExpatSrcDir", "http://sourceforge.net/projects/expat/files/expat/2.0.1/expat-2.0.1.tar.gz/download", None, None),\
30 ("OSGLibXml2SrcDir", "ftp://xmlsoft.org/libxml2/libxml2-2.7.8.tar.gz", None, None), \
33 linux_deps_src
= [("OSGDoxygenSrcDir", "http://opensg.fraunhofer.sg/user/gerrit/OpenSG.Support/doxygen_r752.tar.gz", None, None) ]
36 ("OSGColladaSrcDir", "http://opensg.fraunhofer.sg/user/gerrit/OpenSG.Support/Collada%20DOM%202.2.zip", "Collada DOM 2.2.zip", "collada-dom"),\
37 ("OSGLibMiniSrcDir", "http://opensg.fraunhofer.sg/user/gerrit/OpenSG.Support/MINI-9.8.zip", None, "mini"),\
38 ("OSGOpenNurbsSrcDir", "http://opensg.fraunhofer.sg/user/gerrit/OpenSG.Support/opennurbs_20111122.zip", None, None),\
39 ("OSGGLEWSrcDir", "http://opensg.fraunhofer.sg/user/gerrit/OpenSG.Support/glew-1.7.0.zip", None, None)\
42 bq_deps_fhg
= [("BOOST_ROOT", "http://opensg.fraunhofer.sg/user/gerrit/OpenSG.Support/boost_1_44_0.zip", None, None), \
43 ("BOOST_JAM", "http://opensg.fraunhofer.sg/user/gerrit/OpenSG.Support/boost-jam-3.1.18-1-ntx86.zip", None, None),\
44 ("QT_ROOT", "http://opensg.fraunhofer.sg/user/gerrit/OpenSG.Support//qt-everywhere-opensource-src-4.7.4.zip", None, None), \
47 win_deps_fhg
= [("OSGZLibSrcDir", "http://opensg.fraunhofer.sg/user/gerrit/OpenSG.Support/zlib125.zip", None, None), \
48 ("OSGFreeGlutSrcDir", "http://opensg.fraunhofer.sg/user/gerrit/OpenSG.Support/freeglut-2.6.0.tar.gz", None, None),\
49 ("OSGLibPNGSrcDir", "http://opensg.fraunhofer.sg/user/gerrit/OpenSG.Support/lpng154.zip", None, None),\
50 ("OSGJpegLibSrcDir", "http://opensg.fraunhofer.sg/user/gerrit/OpenSG.Support/jpegsr6.zip", None, "jpeg-6b"),\
51 ("OSGTiffLibSrcDir", "http://opensg.fraunhofer.sg/user/gerrit/OpenSG.Support/tiff-3.8.2.zip", None, None),\
52 ("OSGPcreSrcDir","http://opensg.fraunhofer.sg/user/gerrit/OpenSG.Support/pcre-8.12.zip", None, None),\
53 ("OSGOpenExrSrcDir", "http://opensg.fraunhofer.sg/user/gerrit/OpenSG.Support/openexr-1.7.0.tar.gz", None, None),\
54 ("OSGIlmBaseSrcDir", "http://opensg.fraunhofer.sg/user/gerrit/OpenSG.Support/ilmbase-1.0.2.tar.gz", None, None),\
55 ("OSGGdalSrcDir", "http://opensg.fraunhofer.sg/user/gerrit/OpenSG.Support/gdal180.zip", None, "gdal-1.8.0"),\
56 ("OSGExpatSrcDir", "http://opensg.fraunhofer.sg/user/gerrit/OpenSG.Support/expat-2.0.1.tar.gz", None, None),\
57 ("OSGLibXml2SrcDir", "http://opensg.fraunhofer.sg/user/gerrit/OpenSG.Support/libxml2-2.7.8.tar.gz", None, None), \
60 linux_deps_fhg
= linux_deps_src
62 failed_support_libs
= []
64 ##############################################
66 ##############################################
83 self
.startup_path
= startup_path
84 self
.download_path
= os
.path
.join(self
.startup_path
, "Downloads")
85 self
.unpack_path
= os
.path
.join(self
.startup_path
, "Unpack")
86 self
.build_path
= os
.path
.join(self
.startup_path
, subDir
)
87 self
.suppBuild_path
= os
.path
.join(self
.startup_path
, subDir
, "OpenSG.Support.build")
88 self
.suppInst_path
= os
.path
.join(self
.startup_path
, subDir
, "OpenSG.Support.install").replace('\\', '/')
90 self
.osg_path
= os
.path
.join(self
.startup_path
, "OpenSG")
91 self
.dbgBuild_path
= os
.path
.join(self
.startup_path
, subDir
, "OpenSG.build")
92 self
.optBuild_path
= os
.path
.join(self
.startup_path
, subDir
, "OpenSG.build.opt")
93 self
.osgInst_path
= os
.path
.join(self
.startup_path
, subDir
, "OpenSG.install").replace('\\', '/')
95 self
.osgaddons_path
= os
.path
.join(self
.startup_path
, "OSGAddOns").replace('\\', '/')
96 self
.dbgBuildAddOns_path
= os
.path
.join(self
.startup_path
, subDir
, "OSGAddOns.build")
97 self
.optBuildAddOns_path
= os
.path
.join(self
.startup_path
, subDir
, "OSGAddOns.build.opt")
98 self
.osgAddonsInst_path
= os
.path
.join(self
.startup_path
, subDir
, "OSGAddOns.install").replace('\\', '/')
100 self
.osgRel_path
= os
.path
.join("..", extraUp
, "OpenSG")
101 self
.osgBuildRel_path
= os
.path
.join("..", "OpenSG.build")
102 self
.suppRel_path
= os
.path
.join("..", extraUp
, "OpenSG", "Support")
104 self
.osgAddOnsRel_path
= os
.path
.join("..", extraUp
, "OSGAddOns")
105 self
.osgAddOnsBuildRel_path
= os
.path
.join("..", "OSGAddOns.build")
107 self
.buildSubDir
= subDir
109 self
.noSuppDirInit
= None
111 self
.boostroot_path
= None
112 self
.boostjam_path
= None
115 self
.qtroot_path
= None
116 self
.qtsrc_path
= None
118 self
.cmSuppArchFile
= os
.path
.join(self
.unpack_path
, "CMakeSupportArchs.txt")
119 self
.cmSupportFile
= os
.path
.join(self
.osg_path
, "CMakeSupport.txt")
120 self
.cmOSGFile
= os
.path
.join(self
.osg_path
, "CMakeOSG.txt")
121 self
.cmOSGAddOnsFile
= os
.path
.join(self
.osgaddons_path
, "CMakeOSGAddOns.txt")
123 self
.nodownload
= oOptions
.nodownload
# optNoDownload
124 self
.sgdownload
= oOptions
.sgdownload
# optSGDownload
125 self
.nounpack
= oOptions
.nounpack
# optNoUnpack
126 self
.nogitclone
= oOptions
.nogitclone
# optNoGitClone
127 self
.localgitclone
= oOptions
.localgitclone
# optLocalGitClone
128 self
.updatelocalgit
= oOptions
.updatelocalgit
130 self
.nosupportbuild
= oOptions
.nosupportbuild
# optNoSupportBuild
131 self
.noboostbuild
= oOptions
.noboostbuild
# optNoBoostBuild
132 self
.noqtbuild
= oOptions
.noqtbuild
# optNoQtBuild
133 self
.bqonly
= oOptions
.bqonly
134 self
.noosgbuild
= oOptions
.noosgbuild
# optNoOSGBuild
135 self
.nomssecure
= oOptions
.nomssecure
# optNoMSSecure
137 self
.nopython
= oOptions
.nopython
138 self
.builddebug
= oOptions
.builddebug
139 self
.buildrelease
= oOptions
.buildrelease
140 self
.builddebugopt
= oOptions
.builddebugopt
141 self
.buildreleasenoopt
= oOptions
.buildreleasenoopt
142 self
.buildall
= False
144 if self
.builddebug
== False and self
.buildrelease
== False and \
145 self
.builddebugopt
== False and self
.buildreleasenoopt
== False:
149 self
.nobuildaddons
= oOptions
.noaddonsbuild
150 self
.addonswithosg
= oOptions
.instaddonswithosg
152 self
.noSuppDirInit
= oOptions
.nosuppdirinit
153 self
.useVS2008
= oOptions
.useVS2008
163 if self
.sgdownload
== True:
164 self
.common_deps
= common_deps_fhg
165 self
.bq_deps
= bq_deps_fhg
166 self
.win_deps
= win_deps_fhg
167 self
.linux_deps
= linux_deps_fhg
169 self
.common_deps
= common_deps_src
170 self
.bq_deps
= bq_deps_src
171 self
.win_deps
= win_deps_src
172 self
.linux_deps
= linux_deps_src
174 if self
.buildSubDir
!= None and self
.buildSubDir
!= "" and not os
.path
.exists(self
.buildSubDir
):
175 os
.mkdir(self
.buildSubDir
)
181 if os
.path
.exists("log.txt") == True:
182 self
.logOut
= file("log.txt", "a")
184 self
.logOut
= file("log.txt", "w")
194 def handleRetCode(self
, rc
, info
):
197 print "%-27s : [Failed]" % info
198 self
.logOut
.write("%-27s : [Failed]\n" % info
)
200 os
.fsync(self
.logOut
.fileno())
203 print "%-27s : [Ok]" % info
204 self
.logOut
.write("%-27s : [Ok]\n" % info
)
206 os
.fsync(self
.logOut
.fileno())
208 def dumpOptions(self
):
210 print "download : ", not self
.nodownload
211 print "sgdownload : ", self
.sgdownload
213 print "unpack : ", not self
.nounpack
215 print "gitclone : ", not self
.nogitclone
216 print "localgitclone : ", self
.localgitclone
217 print "updatelocalgit : ", self
.updatelocalgit
218 print "support build : ", not self
.nosupportbuild
220 print "boost build : ", not self
.noboostbuild
221 print "qt build : ", not self
.noqtbuild
222 print "bq build : ", self
.bqonly
224 print "osg build : ", not self
.noosgbuild
225 print "osg addons build : ", not self
.nobuildaddons
226 print "inst addons with osg : ", self
.addonswithosg
227 print "ms secure : ", self
.nomssecure
228 print "vs2008 : ", self
.useVS2008
230 print "python : ", not self
.nopython
231 print "debug : ", self
.builddebug
232 print "release : ", self
.buildrelease
233 print "debugopt : ", self
.builddebugopt
234 print "releasenoopt : ", self
.buildreleasenoopt
235 print "all : ", self
.buildall
237 print "build subdir : ", self
.buildSubDir
238 print "No SuppDir init : ", self
.noSuppDirInit
240 print "build : ", self
.build_path
241 print "supp.build : ", self
.suppBuild_path
242 print "supp.inst : ", self
.suppInst_path
244 print "osg.dbg.build : ", self
.dbgBuild_path
245 print "osg.opt.build : ", self
.optBuild_path
246 print "osg.install : ", self
.osgInst_path
249 def which(self
, program
):
252 return os
.path
.exists(fpath
) and os
.access(fpath
, os
.X_OK
)
254 fpath
, fname
= os
.path
.split(program
)
260 for path
in os
.environ
["PATH"].split(os
.pathsep
):
261 exe_file
= os
.path
.join(path
, program
)
266 for path
in self
.fallbackPaths
:
267 exe_file
= os
.path
.join(path
, program
)
274 def removeTree(self
, dirname
):
276 if os
.path
.isdir(dirname
):
277 shutil
.rmtree(dirname
)
279 def initDir(self
, dirname
, createDir
= True):
281 print "init dir ", dirname
283 # if os.path.isdir(dirname):
284 # shutil.rmtree(dirname)
285 self
.removeTree(dirname
)
287 if createDir
== True:
290 def progress(self
, count
, blocksize
, size
):
292 text
="%d / %d" % (count
* blocksize
, size
)
293 text
+= len(text
) * '\b'
294 sys
.stdout
.write(text
)
297 def getUrl(self
, url
, file):
299 if os
.path
.exists(file):
300 print "%s exists, not downloading." % file
303 sys
.stdout
.write("Downloading %s: " % file)
304 urllib
.urlretrieve(url
=url
, filename
=file, reporthook
=self
.progress
)
308 def prepareArchives(self
, cmCfgFileOut
, deps
):
310 print "downloading to %s" % self
.download_path
312 os
.chdir(self
.download_path
)
314 for var
, url
, arcfile
, dir in deps
:
316 print "processing dep %s | %s | %s | %s" % (var
, url
, arcfile
, dir)
318 # Get filename from URL, if not provided explicitly
320 arcfile
=url
.rsplit('/', 1)[1]
322 if arcfile
== "download":
323 arcfile
=url
.rsplit('/', 2)[1]
325 if self
.nodownload
== False:
327 self
.getUrl(url
, arcfile
)
329 print "################"
330 print "#### failed ####"
331 print "################"
332 failed_support_libs
.append(url
)
336 if arcfile
.endswith(".tar.gz") or arcfile
.endswith(".tar"):
339 if arcfile
.endswith(".tar.gz"):
341 elif arcfile
.endswith(".tar"):
344 dir = os
.path
.join(self
.unpack_path
, dir)
346 print "untar %s | %s" % (arcfile
, dir)
348 if not os
.path
.exists(dir):
350 print "Untarring %s..." % arcfile
352 t
= tarfile
.open(arcfile
, "r")
353 t
.extractall(path
=dir)
356 print "################"
357 print "#### failed ####"
358 print "################"
359 failed_support_libs
.append(url
)
362 elif arcfile
.endswith(".zip"):
367 dir = os
.path
.join(self
.unpack_path
, dir)
369 print "bar %s | %s " % (arcfile
, dir)
371 if not os
.path
.exists(dir):
372 print "Unzipping %s..." % arcfile
375 z
= zipfile
.ZipFile(arcfile
, "r")
376 z
.extractall(path
=dir)
380 # if os.path.exists(dir):
384 unzipCmd
= self
.which("unzip")
387 uzCmd
= [unzipCmd
, "-q", arcfile
, "-d", dir]
391 retcode
= subprocess
.call(uzCmd
)
394 print "################"
395 print "#### failed ####"
396 print "################"
397 failed_support_libs
.append(url
)
401 print "################"
402 print "#### failed ####"
403 print "################"
404 failed_support_libs
.append(url
)
407 print "################"
408 print "#### failed ####"
409 print "################"
410 failed_support_libs
.append(url
)
414 print "Unknown file type for '%s', aborting!" % file
418 # Only one dir? Move up
419 files
= glob
.glob(os
.path
.join(dir, "*"))
423 if len(files
)==1 and os
.path
.isdir(files
[0]):
424 print "Just one dir, moving up."
425 tmpDir
= os
.path
.join(self
.unpack_path
, "bootstrap_dummy" + arcfile
)
427 print "foo %s | %s | %s" % (tmpDir
, dir, files
[0])
429 shutil
.move(files
[0], tmpDir
)
431 os
.rename(tmpDir
, dir)
433 cmCfgFileOut
.write(('SET(%s "%s" CACHE PATH "")\n' % (var
, dir)).replace('\\', '/'))
435 if var
== "BOOST_ROOT":
436 self
.boostroot_path
= dir.replace('\\', '/')
438 if var
== "BOOST_JAM":
439 self
.boostjam_path
= dir.replace('\\', '/')
441 os
.chdir(self
.startup_path
)
443 def prepareSupportArchives(self
):
445 if self
.nodownload
== False:
446 self
.initDir(self
.download_path
)
448 if self
.nounpack
== False:
449 self
.initDir(self
.unpack_path
)
451 cmSupportOut
= file(self
.cmSuppArchFile
, "w")
452 cmSupportOut
.write("# Auto-downloaded support libs defines\n\n")
454 if self
.sgdownload
== True:
456 self
.getUrl("http://opensg.fraunhofer.sg/user/gerrit/OpenSG.Support/wake_up_server.txt", "wake_up_server.txt")
460 if os
.path
.exists("wake_up_server.txt") == True:
461 os
.remove("wake_up_server.txt")
463 if self
.bqonly
== False:
464 self
.prepareArchives(cmSupportOut
, self
.common_deps
)
466 if system
== "windows":
467 if self
.bqonly
== False:
468 self
.prepareArchives(cmSupportOut
, self
.win_deps
)
470 self
.prepareArchives(cmSupportOut
, self
.bq_deps
)
473 self
.prepareArchives(cmSupportOut
, self
.linux_deps
)
475 cmSupportOut
.write('\n')
479 def prepareOSGSupport(self
):
481 self
.prepareSupportArchives()
483 cmSupportOut
= file(self
.cmSupportFile
, "w")
485 cmSuppArchOut
= file(self
.cmSuppArchFile
, "r")
487 for line
in cmSuppArchOut
.readlines():
488 cmSupportOut
.write(line
)
490 cmSuppArchOut
.close()
492 cmSupportOut
.write('SET(CMAKE_INSTALL_PREFIX "%s" CACHE PATH "")\n' % self
.suppInst_path
)
493 cmSupportOut
.write('SET(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "" FORCE)\n')
494 cmSupportOut
.write('SET(CMAKE_BUILD_TYPE Release CACHE STRING "xxx" FORCE)\n\n')
496 cmSupportOut
.write('IF(WIN32)\n')
497 cmSupportOut
.write(' SET(Boost_USE_STATIC_LIBS ON CACHE INTERNAL "")\n')
498 if self
.nomssecure
== True:
499 cmSupportOut
.write(' OPTION(OSG_DISABLE_MICROSOFT_SECURE_CXXX "" ON)\n')
500 cmSupportOut
.write('ENDIF(WIN32)\n\n')
502 cmSupportOut
.write('OPTION(OSG_USE_OSGSUPPORT_LIBS "" ON)\n')
503 cmSupportOut
.write('OPTION(OSG_USE_STATIC_SUPPORT_LIBS "" ON)\n')
509 if self
.nogitclone
== True:
515 self
.initDir("OpenSG", False)
517 if self
.localgitclone
== False:
518 gitCloneCmd
= [self
.gitCmd
, "clone", "git://opensg.git.sourceforge.net/gitroot/opensg/opensg", "OpenSG"]
521 if self
.updatelocalgit
== True:
523 os
.chdir("OpenSG.repo")
526 gitCmd
= [self
.gitCmd
, "fetch"]
528 retcode
= subprocess
.call(gitCmd
)
530 self
.handleRetCode(retcode
, "update local fetch")
533 gitCmd
= [self
.gitCmd
, "pull", ".", "remotes/origin/master"]
535 retcode
= subprocess
.call(gitCmd
)
537 self
.handleRetCode(retcode
, "update local pull")
540 os
.chdir(self
.startup_path
)
543 gitCloneCmd
= [self
.gitCmd
, "clone", "OpenSG.repo", "OpenSG"]
546 retcode
= subprocess
.call(gitCloneCmd
)
548 self
.handleRetCode(retcode
, "Cloning git")
552 self
.initDir("OSGAddOns", False)
554 if self
.localgitclone
== False:
555 gitCloneCmd
= [self
.gitCmd
, "clone", "git://github.com/vossg/OSGAddOnsGV.git", "OSGAddOns"]
558 if self
.updatelocalgit
== True:
560 os
.chdir("OSGAddOns.repo")
563 gitCmd
= [self
.gitCmd
, "fetch"]
565 retcode
= subprocess
.call(gitCmd
)
567 self
.handleRetCode(retcode
, "update local fetch")
570 gitCmd
= [self
.gitCmd
, "pull", ".", "remotes/origin/master"]
572 retcode
= subprocess
.call(gitCmd
)
574 self
.handleRetCode(retcode
, "update local pull")
577 os
.chdir(self
.startup_path
)
580 gitCloneCmd
= [self
.gitCmd
, "clone", "OSGAddOns.repo", "OSGAddOns"]
582 retcode
= subprocess
.call(gitCloneCmd
)
584 self
.handleRetCode(retcode
, "Cloning OSGAddOns git")
586 def buildBoost(self
):
588 print "Building boost ...."
593 print "Building qt ...."
596 def buildOSGSupport(self
):
598 if self
.noSuppDirInit
== False:
599 self
.initDir(self
.suppBuild_path
)
600 self
.initDir(self
.suppInst_path
)
602 if system
== "windows":
605 if system
== "windows":
608 if self
.bqonly
== True:
611 os
.chdir(self
.suppBuild_path
)
613 cmCfgCmd
= [self
.cmakeCmd
,
620 print "Supp cmake : ", cmCfgCmd
622 retcode
= subprocess
.call(cmCfgCmd
)
624 self
.handleRetCode(retcode
, "Support Initial CMake")
626 os
.chdir(self
.startup_path
)
632 if self
.noosgbuild
== False:
633 self
.initDir(self
.osgInst_path
)
635 # if system == "windows":
636 # self.checkBoostPath()
638 cmOSGOut
= file(self
.cmOSGFile
, "w")
639 cmOSGOut
.write("# OSG libs defines\n\n")
640 cmOSGOut
.write('SET(CMAKE_INSTALL_PREFIX "%s" CACHE PATH "")\n' % self
.osgInst_path
)
641 cmOSGOut
.write('SET(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "" FORCE)\n')
643 if self
.vcvars
!= None:
644 cmOSGOut
.write('SET(BOOST_ROOT "%s" CACHE PATH "" FORCE)\n' % self
.suppInst_path
)
645 cmOSGOut
.write('SET(QT_QMAKE_EXECUTABLE "%s/qt/bin/qmake.exe" CACHE FILEPATH "" FORCE)\n' % self
.suppInst_path
)
647 cmOSGOut
.write('SET(OSG_USE_OSGSUPPORT_LIBS ON CACHE BOOL "")\n')
648 cmOSGOut
.write('SET(OSG_SUPPORT_ROOT "%s" CACHE PATH "")\n' % self
.suppInst_path
)
649 cmOSGOut
.write('SET(OSG_USE_STATIC_SUPPORT_LIBS OFF CACHE BOOL "")\n')
651 cmOSGOut
.write('SET(OSGBUILD_EXAMPLES_SIMPLE ON CACHE BOOL "")\n')
652 cmOSGOut
.write('SET(OSGBUILD_EXAMPLES_ADVANCED ON CACHE BOOL "")\n')
653 cmOSGOut
.write('SET(OSGBUILD_EXAMPLES_TUTORIAL ON CACHE BOOL "")\n')
654 cmOSGOut
.write('SET(OSG_INSTALL_EXAMPLES ON CACHE BOOL "")\n')
656 cmOSGOut
.write('SET(OSG_DOXY_DOC_TYPE Developer CACHE STRING "" FORCE)\n\n')
658 cmOSGOut
.write('SET(OSG_ENABLE_DEFAULT_READONLY_CHANGELIST ON CACHE BOOL "")\n')
659 cmOSGOut
.write('SET(OSG_DISABLE_SOURCE_GROUPS ON CACHE BOOL "")\n\n')
661 cmOSGOut
.write('SET(OSGEXCLUDE_EXAMPLES_ADVANCED_FROM_ALL ON CACHE BOOL "")\n')
662 cmOSGOut
.write('SET(OSGEXCLUDE_EXAMPLES_SIMPLE_FROM_ALL ON CACHE BOOL "")\n')
663 cmOSGOut
.write('SET(OSGEXCLUDE_TESTS_FROM_ALL ON CACHE BOOL "")\n')
664 cmOSGOut
.write('SET(OSGEXCLUDE_UNITTESTS_FROM_ALL ON CACHE BOOL "")\n\n')
666 if self
.nopython
== False:
667 cmOSGOut
.write('# OpenSG Python\n\n')
669 cmOSGOut
.write('SET(OSG_PYTHON_MODULE_BASE_DIR "%s/Bindings/Python" CACHE PATH "" FORCE)\n\n' % self
.osgaddons_path
)
670 cmOSGOut
.write('SET(OSGBUILD_PYTHON_BINDINGS ON CACHE BOOL "" FORCE)\n\n')
672 cmOSGOut
.write('IF(WIN32)\n')
673 cmOSGOut
.write(' IF(CMAKE_SIZEOF_VOID_P EQUAL 8)\n')
674 cmOSGOut
.write(' SET(CG_ROOT "C:/Program Files (x86)/NVIDIA Corporation/Cg" CACHE PATH "" FORCE)\n')
675 cmOSGOut
.write(' ELSE(CMAKE_SIZEOF_VOID_P EQUAL 8)\n')
676 cmOSGOut
.write(' SET(CG_ROOT "C:/Program Files/NVIDIA Corporation/Cg" CACHE PATH "" FORCE)\n')
677 cmOSGOut
.write(' ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8)\n')
678 if self
.nomssecure
== True:
679 cmOSGOut
.write(' OPTION(OSG_DISABLE_MICROSOFT_SECURE_CXXX "" ON)\n')
680 cmOSGOut
.write('ENDIF(WIN32)\n\n')
682 cmOSGOut
.write('SET(OSGBUILD_OSGTestGroupLib OFF CACHE BOOL "")\n')
683 cmOSGOut
.write('SET(OSGBUILD_OSGTestSystemLib OFF CACHE BOOL "")\n')
687 def configureOSG(self
):
689 self
.initDir(self
.dbgBuild_path
)
691 os
.chdir(self
.dbgBuild_path
)
693 cmCfgCmd
= [self
.cmakeCmd
,
698 "-DCMAKE_BUILD_TYPE:STRING=Debug",
701 print "runnuing ", cmCfgCmd
703 retcode
= subprocess
.call(cmCfgCmd
)
705 self
.handleRetCode(retcode
, "OSG Initial CMake")
707 os
.chdir(self
.startup_path
)
709 def reconfigureOSG(self
, changeDir
= False):
711 if changeDir
== True:
712 os
.chdir(self
.dbgBuild_path
)
714 cmCfgCmd
= [self
.cmakeCmd
, "."]
716 print "runnuing ", cmCfgCmd
718 retcode
= subprocess
.call(cmCfgCmd
)
720 self
.handleRetCode(retcode
, "OSG cmake . Run")
722 if changeDir
== True:
723 os
.chdir(self
.startup_path
)
725 def reconfigureOSGAddOns(self
, changeDir
= False):
727 if changeDir
== True:
728 os
.chdir(self
.dbgBuildAddOns_path
)
730 cmCfgCmd
= [self
.cmakeCmd
, "."]
732 print "runnuing ", cmCfgCmd
734 retcode
= subprocess
.call(cmCfgCmd
)
736 self
.handleRetCode(retcode
, "OSGAddOns cmake . Run")
738 if changeDir
== True:
739 os
.chdir(self
.startup_path
)
741 def configureOSGAddOns(self
, Variant
= "Debug"):
743 if Variant
== "Debug":
744 workDir
= self
.dbgBuildAddOns_path
745 elif Variant
== "Release":
746 workDir
= self
.optBuildAddOns_path
750 self
.initDir(workDir
)
754 cmCfgCmd
= [self
.cmakeCmd
,
758 self
.cmOSGAddOnsFile
,
759 ("-DCMAKE_BUILD_TYPE:STRING=%s" % Variant
),
760 self
.osgAddOnsRel_path
]
762 print "runnuing ", cmCfgCmd
764 retcode
= subprocess
.call(cmCfgCmd
)
766 self
.handleRetCode(retcode
, "OSG Initial CMake")
768 os
.chdir(self
.startup_path
)
770 def prepOSGAddOns(self
):
772 if self
.nobuildaddons
== True:
775 if self
.nobuildaddons
== False or self
.addonswithosg
== False:
776 self
.initDir(self
.osgAddonsInst_path
)
778 cmOSGAddOnsOut
= file(self
.cmOSGAddOnsFile
, "w")
779 cmOSGAddOnsOut
.write("# OSG AddOns libs defines\n\n")
781 cmOSGAddOnsOut
.write('SET(OpenSG_DIR "%s" CACHE PATH "" FORCE)\n\n' % self
.osgInst_path
)
782 cmOSGAddOnsOut
.write('SET(OSG_BUILD_ACTIVE TRUE CACHE BOOL "" FORCE)\n\n')
784 cmOSGAddOnsOut
.write('# OpenSG Support\n\n')
786 cmOSGAddOnsOut
.write('# Initialized from OpenSG install, change only if really needed\n')
787 cmOSGAddOnsOut
.write('#SET(OSG_SUPPORT_ROOT "" CACHE PATH "" FORCE)\n\n')
789 cmOSGAddOnsOut
.write('#SET(OSG_USE_OSGSUPPORT_LIBS TRUE CACHE BOOL "" FORCE)\n\n')
791 if self
.nopython
== False:
792 cmOSGAddOnsOut
.write('# OpenSG Python\n\n')
794 cmOSGAddOnsOut
.write('SET(OSG_PYTHON_MODULE_BASE_DIR "%s/Bindings/Python" CACHE PATH "" FORCE)\n\n' % self
.osgaddons_path
)
795 cmOSGAddOnsOut
.write('SET(OSGBUILD_PYTHON_BINDINGS ON CACHE BOOL "" FORCE)\n\n')
797 cmOSGAddOnsOut
.write('# If OpenSG was build with CUDA enabled\n\n')
799 cmOSGAddOnsOut
.write('#SET(CUDA_TOOLKIT_ROOT_DIR "" CACHE PATH "" FORCE)\n\n')
801 cmOSGAddOnsOut
.write('#SET(OSG_ENABLE_CUDA ON CACHE BOOL "Build OpenSG with CUDA support" FORCE)\n\n')
803 cmOSGAddOnsOut
.write('# cmake\n\n')
805 cmOSGAddOnsOut
.write('SET(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "" FORCE)\n')
807 if self
.addonswithosg
== False:
808 cmOSGAddOnsOut
.write('SET(CMAKE_INSTALL_PREFIX "%s" CACHE PATH "" FORCE)\n\n' % self
.osgAddonsInst_path
)
810 cmOSGAddOnsOut
.write('SET(CMAKE_INSTALL_PREFIX "%s" CACHE PATH "")\n' % self
.osgInst_path
)
812 cmOSGAddOnsOut
.write('IF(WIN32)\n')
813 cmOSGAddOnsOut
.write(' SET(OSG_ENABLE_FCD2CODE OFF CACHE BOOL "" FORCE)\n')
814 cmOSGAddOnsOut
.write('ENDIF()\n\n')
816 cmOSGAddOnsOut
.write('# Sofa\n\n')
818 cmOSGAddOnsOut
.write('#SET(SOFA_ROOT "" CACHE PATH "" FORCE)\n\n')
820 cmOSGAddOnsOut
.close()
822 ##############################################
823 # Windows Base Builder
824 ##############################################
826 class OSGWinBaseBuilder(OSGBaseBuilder
):
832 buildSubDir
= "MSDefaults"
834 if oOptions
.nomssecure
== True:
835 buildSubDir
= "NoMSSec"
837 ##32 self.fallbackPaths = ["C:/Program Files/Microsoft Visual Studio 10.0/VC",
838 # "C:/Program Files/Git/bin"]
840 ##32 cmdirs = glob.glob("C:/Program Files/CMake *")
842 if oOptions
.useVS2008
== True:
843 self
.fallbackPaths
= ["C:/Program Files/Microsoft Visual Studio 9.0/VC",
844 "C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC",
845 "C:/Program Files/Git/bin",
846 "C:/Program Files (x86)/Git/bin"]
848 self
.boostToolset
= "toolset=msvc-9.0"
850 self
.fallbackPaths
= ["C:/Program Files/Microsoft Visual Studio 10.0/VC",
851 "C:/Program Files (x86)/Microsoft Visual Studio 10.0/VC",
852 "C:/Program Files/Git/bin",
853 "C:/Program Files (x86)/Git/bin"]
855 self
.boostToolset
= "toolset=msvc-10.0"
857 cmdirs
= glob
.glob("C:/Program Files*/CMake *")
860 self
.fallbackPaths
.append(os
.path
.join(path
, "bin").replace('\\', '/'))
862 print "cmd : ", cmdirs
865 OSGBaseBuilder
.__init
__(self
,
872 self
.boostCommonOpts
= ["-d+1",
874 "--stagedir=./stage." + self
.buildSubDir
,
875 "--build-dir=./bin.v2." + self
.buildSubDir
,
877 "variant=debug,release",
879 "link=shared,static",
880 "runtime-link=shared"]
882 # if self.vcvarsarch != None and self.vcvarsarch == "amd64":
883 # # boost.python fails to link on win64 (1.44), have to try a later release, was a python problem
884 # self.boostCommonOpts.append("--without-python")
886 self
.boostAddrOpt
= None
888 self
.boostMSDefines
= ["define=_CRT_SECURE_NO_DEPRECATE",
889 "define=_CRT_SECURE_NO_WARNINGS",
890 "define=_CRT_NONSTDC_NO_DEPRECATE",
891 "define=_SECURE_SCL=0",
892 "define=_SCL_SECURE_NO_WARNINGS",
893 "define=_SCL_SECURE_NO_DEPRECATE",
894 "define=_HAS_ITERATOR_DEBUGGING=0" ]
896 self
.qtPlatform
= None
899 self
.cmakeCmd
= self
.which("cmake.exe")
900 self
.vcvars
= self
.which("vcvarsall.bat")
901 self
.gitCmd
= self
.which("git.exe")
903 print "cm : ", self
.cmakeCmd
904 print "vcv : ", self
.vcvars
905 print "git : ", self
.gitCmd
907 if self
.cmakeCmd
== None:
908 print "Error could not find cmake"
911 if self
.vcvars
== None:
912 print "Error could not find vcvars.bat"
915 if self
.gitCmd
== None:
916 print "Error could not find git"
921 def handleRemoveReadonly(self
, func
, path
, exc
):
924 if func
in (os
.rmdir
, os
.remove
) and excvalue
.errno
== errno
.EACCES
:
925 # ensure parent directory is writeable too
926 pardir
= os
.path
.abspath(os
.path
.join(path
, os
.path
.pardir
))
928 if not os
.access(pardir
, os
.W_OK
):
929 os
.chmod(pardir
, stat
.S_IRWXU| stat
.S_IRWXG| stat
.S_IRWXO
)
931 os
.chmod(path
, stat
.S_IRWXU| stat
.S_IRWXG| stat
.S_IRWXO
) # 0777
936 def removeTree(self
, dirname
):
938 if os
.path
.isdir(dirname
):
939 shutil
.rmtree(dirname
, ignore_errors
= False, onerror
= self
.handleRemoveReadonly
)
940 # shutil.rmtree(dirname)
942 def checkBoostPath(self
):
944 if self
.boostroot_path
== None:
945 files
= glob
.glob(os
.path
.join(self
.unpack_path
, "boost_*"))
948 self
.boostroot_path
= files
[0].replace('\\', '/')
950 if self
.boostjam_path
== None:
951 files
= glob
.glob(os
.path
.join(self
.unpack_path
, "boost-jam*"))
954 self
.boostjam_path
= files
[0].replace('\\', '/')
956 if(self
.boostroot_path
== None or self
.boostjam_path
== None):
959 self
.boostjam
= os
.path
.join(self
.boostjam_path
, "bjam.exe")
961 print " boost path ", self
.boostroot_path
962 print " boost jam ", self
.boostjam_path
963 print " boost jam exe", self
.boostjam
965 def buildBoost(self
):
967 print "Building boost ...."
970 self
.checkBoostPath()
972 boostBaseCmd
= [self
.vcvars
, self
.vcvarsarch
, "&"]
973 boostBaseCmd
.extend([self
.boostjam
])
974 boostBaseCmd
.extend(self
.boostCommonOpts
)
975 boostBaseCmd
.extend(self
.boostAddrOpt
)
977 if self
.nomssecure
== True:
978 boostBaseCmd
.extend(self
.boostMSDefines
)
981 os
.chdir(self
.boostroot_path
)
985 boostBuildCmd
.extend(boostBaseCmd
)
987 boostBuildCmd
.extend(["stage"])
989 print "boost build cmd: ", boostBuildCmd
991 if self
.noboostbuild
== False:
992 retcode
= subprocess
.call(boostBuildCmd
)
994 self
.handleRetCode(retcode
, "Boost Build")
998 boostInstallCmd
.extend(boostBaseCmd
)
1000 boostInstallCmd
.extend(["--prefix=" + self
.suppInst_path
])
1001 boostInstallCmd
.extend(["install"])
1003 print "boost install cmd: ", boostInstallCmd
1005 if self
.noboostbuild
== False:
1006 retcode
= subprocess
.call(boostInstallCmd
)
1008 self
.handleRetCode(retcode
, "Boost Install")
1010 binPath
= os
.path
.join(self
.suppInst_path
, "bin")
1011 libPath
= os
.path
.join(self
.suppInst_path
, "lib")
1013 if self
.noboostbuild
== False:
1016 for file in os
.listdir(libPath
):
1017 if fnmatch
.fnmatch(file, '*.dll'):
1018 srcFile
= os
.path
.join(libPath
, file)
1019 dstFile
= os
.path
.join(binPath
, file)
1020 shutil
.move(srcFile
, dstFile
)
1022 os
.chdir(startup_path
)
1026 def checkQtPath(self
):
1028 if self
.qtsrc_path
== None:
1029 files
= glob
.glob(os
.path
.join(self
.unpack_path
, "qt-*"))
1030 print "br : ", files
1032 self
.qtsrc_path
= files
[0].replace('\\', '/')
1034 self
.qtroot_path
= os
.path
.join(self
.build_path
, "qt.build").replace('\\', '/')
1036 print " qt src path ", self
.qtsrc_path
1037 print " qt root path ", self
.qtroot_path
1040 print "win build qt"
1044 self
.initDir(self
.qtroot_path
, False)
1046 if not os
.path
.exists(self
.qtroot_path
):
1049 if self
.noqtbuild
== False:
1050 shutil
.copytree(self
.qtsrc_path
, self
.qtroot_path
);
1052 os
.mkdir(self
.qtroot_path
)
1054 os
.chdir(self
.qtroot_path
)
1056 qtBaseCmd
= [self
.vcvars
, self
.vcvarsarch
, "&"]
1059 qtConfigureCmd
.extend(qtBaseCmd
)
1061 qtConfigureCmd
.extend(["configure",
1063 "-platform", self
.qtPlatform
,
1064 "-nomake", "examples",
1067 "-debug-and-release",
1071 "-plugin-sql-sqlite",
1074 "-no-phonon-backend",
1078 if self
.nomssecure
== True:
1079 qtConfigureCmd
.extend(["-D", "_CRT_SECURE_NO_DEPRECATE",
1080 "-D", "_CRT_SECURE_NO_WARNINGS",
1081 "-D", "_CRT_NONSTDC_NO_DEPRECATE",
1082 "-D", "_SECURE_SCL=0",
1083 "-D", "_SCL_SECURE_NO_WARNINGS",
1084 "-D", "_SCL_SECURE_NO_DEPRECATE",
1085 "-D", "_HAS_ITERATOR_DEBUGGING=0"])
1088 qtConfigureCmd
.extend(["<",
1091 print "qt configure : ", qtConfigureCmd
1093 qtCfgAnswer
= file("yanswer", "w")
1094 qtCfgAnswer
.write("y")
1098 if self
.noqtbuild
== False:
1099 retcode
= subprocess
.call(qtConfigureCmd
)
1101 self
.handleRetCode(retcode
, "Qt Configure")
1104 qtBuildCmd
.extend(qtBaseCmd
)
1105 qtBuildCmd
.extend(["nmake"])
1107 print "qt build : ", qtBuildCmd
1109 if self
.noqtbuild
== False:
1110 retcode
= subprocess
.call(qtBuildCmd
)
1112 self
.handleRetCode(retcode
, "Qt Build")
1114 qtInstallBat
= file("qtinstall.bat", "w")
1116 (unpackDrive
, unpackTail
) = os
.path
.splitdrive(self
.unpack_path
);
1117 (qtDrive
, qtTail
) = os
.path
.splitdrive(self
.qtroot_path
);
1119 qtSetInstRoot
= "set INSTALL_ROOT=";
1120 qtSetInstRoot
+= unpackTail
;
1121 qtSetInstRoot
+= "\\qt.tmpinstall\n";
1123 print "foo ", qtSetInstRoot
;
1125 qtInstallBat
.write(qtSetInstRoot
)
1126 qtInstallBat
.write("\n")
1127 qtInstallBat
.write("nmake install\n\n")
1128 qtInstallBat
.close()
1131 qtInstallCmd
.extend(qtBaseCmd
)
1132 qtInstallCmd
.extend(["qtinstall.bat"])
1134 print "qt install tmp : ", qtInstallCmd
1136 if self
.noqtbuild
== False:
1137 retcode
= subprocess
.call(qtInstallCmd
)
1138 self
.handleRetCode(retcode
, "Qt Install")
1140 qtTmpInstallPath
= self
.unpack_path
+ "\\qt.tmpinstall";
1141 qtTmpInstallPath
+= qtTail
1142 qtFinalInstallPath
= self
.suppInst_path
+ "/qt"
1144 print "foo ", qtTmpInstallPath
.replace('\\', '/')
1145 print "bar ", qtFinalInstallPath
1147 if self
.noqtbuild
== False:
1148 shutil
.move(qtTmpInstallPath
.replace('\\', '/'), qtFinalInstallPath
)
1150 qtLocalConfigFile
= qtFinalInstallPath
+ "/bin/qt.conf"
1152 if self
.noqtbuild
== False:
1153 qtLocalConf
= file(qtLocalConfigFile
, "w")
1155 qtLocalConf
.write("[Paths]\n");
1156 qtLocalConf
.write("Prefix=\n");
1157 qtLocalConf
.write("Documentation=../doc\n");
1158 qtLocalConf
.write("Headers=../include\n");
1159 qtLocalConf
.write("Libraries=../lib\n");
1160 qtLocalConf
.write("Binaries=\n");
1161 qtLocalConf
.write("Plugins=../plugins\n");
1162 qtLocalConf
.write("Data=..\n");
1163 qtLocalConf
.write("Translations=../translations\n");
1164 qtLocalConf
.write("Settings=../etc\n");
1165 qtLocalConf
.write("Examples=../examples\n");
1166 qtLocalConf
.write("Demos=../demos\n");
1168 qtLocalConf
.close();
1170 os
.chdir(startup_path
)
1172 def buildOSGSupport(self
):
1174 if self
.nosupportbuild
== True:
1177 OSGBaseBuilder
.buildOSGSupport(self
)
1179 if self
.bqonly
== True:
1182 os
.chdir(self
.suppBuild_path
)
1184 print "building osg support"
1186 buildCmd
= [self
.vcvars
,
1194 "OpenSGSupport.sln"]
1196 retcode
= subprocess
.call(buildCmd
)
1198 self
.handleRetCode(retcode
, "Build OSG Support Debug")
1200 buildCmd
= [self
.vcvars
,
1208 "OpenSGSupport.sln"]
1210 retcode
= subprocess
.call(buildCmd
)
1212 self
.handleRetCode(retcode
, "Build OSG Support Release")
1214 print "building osg support"
1216 buildCmd
= [self
.vcvars
,
1224 "OpenSGSupport.sln"]
1226 retcode
= subprocess
.call(buildCmd
)
1228 self
.handleRetCode(retcode
, "Install OSG Support Debug")
1230 buildCmd
= [self
.vcvars
,
1238 "OpenSGSupport.sln"]
1240 retcode
= subprocess
.call(buildCmd
)
1242 self
.handleRetCode(retcode
, "Install OSG Support Release")
1244 os
.chdir(self
.startup_path
)
1246 def buildOpenSGVariant(self
, variant
):
1248 print "building osg variant : ", variant
1250 os
.chdir(self
.dbgBuild_path
)
1252 buildCmd
= [self
.vcvars
,
1262 print "build cmd : ", buildCmd
1263 retcode
= subprocess
.call(buildCmd
)
1265 self
.handleRetCode(retcode
, "Build OSG All")
1267 self
.reconfigureOSG(False)
1269 if self
.nopython
== False:
1270 buildCmd
= [self
.vcvars
,
1280 print "build py cmd : ", buildCmd
1281 retcode
= subprocess
.call(buildCmd
)
1283 self
.handleRetCode(retcode
, "Build OSGPy ")
1285 self
.reconfigureOSG(False)
1288 buildCmd
= [self
.vcvars
,
1298 print "install cmd : ", buildCmd
1299 retcode
= subprocess
.call(buildCmd
)
1301 self
.handleRetCode(retcode
, "Install OSG All")
1303 self
.reconfigureOSG(False)
1305 os
.chdir(self
.startup_path
)
1307 def buildOSGAddOnsVariant(self
, variant
):
1309 print "building osgaddons variant : ", variant
1311 os
.chdir(self
.dbgBuildAddOns_path
)
1313 buildCmd
= [self
.vcvars
,
1323 print "build cmd : ", buildCmd
1324 retcode
= subprocess
.call(buildCmd
)
1326 self
.handleRetCode(retcode
, "Build OSGAddOns All")
1328 self
.reconfigureOSGAddOns(False)
1330 if self
.nopython
== False:
1331 buildCmd
= [self
.vcvars
,
1341 print "build cmd : ", buildCmd
1342 retcode
= subprocess
.call(buildCmd
)
1344 self
.handleRetCode(retcode
, "Build OSGAddOns Py")
1346 self
.reconfigureOSGAddOns(False)
1349 buildCmd
= [self
.vcvars
,
1359 print "install cmd : ", buildCmd
1360 retcode
= subprocess
.call(buildCmd
)
1362 self
.handleRetCode(retcode
, "Install OSGAddOns All")
1364 self
.reconfigureOSGAddOns(False)
1366 os
.chdir(self
.startup_path
)
1368 def buildOpenSG(self
):
1370 if self
.noosgbuild
== True:
1373 OSGBaseBuilder
.configureOSG(self
)
1375 if self
.builddebug
== True or self
.buildall
== True:
1376 self
.buildOpenSGVariant("Debug")
1378 if self
.builddebugopt
== True or self
.buildall
== True:
1379 self
.buildOpenSGVariant("DebugOpt")
1381 if self
.buildreleasenoopt
== True or self
.buildall
== True:
1382 self
.buildOpenSGVariant("ReleaseNoOpt")
1384 if self
.buildrelease
== True or self
.buildall
== True:
1385 self
.buildOpenSGVariant("Release")
1387 def buildOSGAddOns(self
):
1389 if self
.nobuildaddons
== True:
1392 OSGBaseBuilder
.configureOSGAddOns(self
)
1394 if self
.builddebug
== True or self
.buildall
== True:
1395 self
.buildOSGAddOnsVariant("Debug")
1397 if self
.builddebugopt
== True or self
.buildall
== True:
1398 self
.buildOSGAddOnsVariant("DebugOpt")
1400 if self
.buildreleasenoopt
== True or self
.buildall
== True:
1401 self
.buildOSGAddOnsVariant("ReleaseNoOpt")
1403 if self
.buildrelease
== True or self
.buildall
== True:
1404 self
.buildOSGAddOnsVariant("Release")
1406 ##############################################
1408 ##############################################
1410 class OSGWin32Builder(OSGWinBaseBuilder
):
1416 self
.vcvarsarch
= "x86"
1418 OSGWinBaseBuilder
.__init
__(self
,
1422 if self
.useVS2008
== True:
1423 self
.cmakeGen
= "Visual Studio 2008 9"
1424 self
.qtPlatform
= "win32-msvc2008"
1426 self
.cmakeGen
= "Visual Studio 10"
1427 self
.qtPlatform
= "win32-msvc2010"
1429 self
.boostAddrOpt
= ["address-model=32"]
1432 print "Build for Win32"
1436 ##############################################
1438 ##############################################
1440 class OSGWin64Builder(OSGWinBaseBuilder
):
1446 self
.vcvarsarch
= "amd64"
1448 OSGWinBaseBuilder
.__init
__(self
,
1452 self
.boostAddrOpt
= ["address-model=64"]
1454 if self
.useVS2008
== True:
1455 self
.cmakeGen
= "Visual Studio 9 2008 Win64"
1456 self
.qtPlatform
= "win32-msvc2008"
1458 self
.cmakeGen
= "Visual Studio 10 Win64"
1459 self
.qtPlatform
= "win32-msvc2010"
1462 print "Build for Win64"
1467 ##############################################
1469 ##############################################
1471 class OSGUnixBaseBuilder(OSGBaseBuilder
):
1477 OSGBaseBuilder
.__init
__(self
,
1481 self
.cmakeCmd
= "cmake"
1482 self
.makeCmd
= "make"
1485 self
.cmakeGen
= "Unix Makefiles"
1489 def buildOSGSupport(self
):
1491 if self
.nosupportbuild
== True:
1494 OSGBaseBuilder
.buildOSGSupport(self
)
1496 os
.chdir(self
.suppBuild_path
)
1498 mkBldCmd
= [self
.makeCmd
]
1499 retcode
= subprocess
.call(mkBldCmd
)
1501 self
.handleRetCode(retcode
, "Build OSG Support Release")
1503 mkInstCmd
= [self
.makeCmd
, "install"]
1504 retcode
= subprocess
.call(mkInstCmd
)
1506 self
.handleRetCode(retcode
, "Install OSG Support Release")
1508 cmCfgOptCmd
= [self
.cmakeCmd
, "-DCMAKE_BUILD_TYPE:STRING=Debug", "."]
1509 retcode
= subprocess
.call(cmCfgOptCmd
)
1511 self
.handleRetCode(retcode
, "Configure OSG Support Debug")
1513 mkBldCmd
= [self
.makeCmd
]
1514 retcode
= subprocess
.call(mkBldCmd
)
1516 self
.handleRetCode(retcode
, "Build OSG Support Debug")
1518 mkInstCmd
= [self
.makeCmd
, "install"]
1519 retcode
= subprocess
.call(mkInstCmd
)
1521 self
.handleRetCode(retcode
, "Install OSG Support Debug")
1523 os
.chdir(self
.startup_path
)
1525 def buildOSGDbg(self
):
1527 if self
.noosgbuild
== True:
1530 OSGBaseBuilder
.configureOSG(self
)
1532 os
.chdir(self
.dbgBuild_path
)
1534 mkBldCmd
= [self
.makeCmd
, "OSGAll"]
1535 retcode
= subprocess
.call(mkBldCmd
)
1537 self
.handleRetCode(retcode
, "Build OSG Debug")
1539 if self
.nopython
== False:
1540 mkBldCmd
= [self
.makeCmd
, "OSGPy"]
1541 print "run : ", mkBldCmd
1543 retcode
= subprocess
.call(mkBldCmd
)
1545 self
.handleRetCode(retcode
, "Build OSG Py Debug")
1547 mkInstCmd
= [self
.makeCmd
, "install"]
1548 retcode
= subprocess
.call(mkInstCmd
)
1550 self
.handleRetCode(retcode
, "Install OSG Debug")
1552 os
.chdir(self
.startup_path
)
1554 def buildOSGOpt(self
):
1556 if self
.noosgbuild
== True:
1559 self
.initDir(self
.optBuild_path
)
1561 os
.chdir(self
.optBuild_path
)
1563 cmCfgCmd
= ["cmake",
1564 "-DOSG_BUILD_DEPENDEND:INTERNAL=true",
1565 "-DCMAKE_VERBOSE_MAKEFILE:INTERNAL=true",
1566 "-DOSG_REFERENCE_DIR:INTERNAL=" + self
.osgBuildRel_path
,
1567 "-DCMAKE_BUILD_TYPE:STRING=Release",
1569 print "runnuing ", cmCfgCmd
1570 retcode
= subprocess
.call(cmCfgCmd
)
1572 self
.handleRetCode(retcode
, "Configure OSG Release")
1574 mkBldCmd
= [self
.makeCmd
, "OSGAll"]
1575 retcode
= subprocess
.call(mkBldCmd
)
1577 self
.handleRetCode(retcode
, "Build OSG Release")
1579 if self
.nopython
== False:
1580 mkBldCmd
= [self
.makeCmd
, "OSGPy"]
1581 print "run : ", mkBldCmd
1583 retcode
= subprocess
.call(mkBldCmd
)
1585 self
.handleRetCode(retcode
, "Build OSG Py Relase")
1587 mkInstCmd
= [self
.makeCmd
, "install"]
1588 retcode
= subprocess
.call(mkInstCmd
)
1590 self
.handleRetCode(retcode
, "Install OSG Release")
1592 os
.chdir(self
.startup_path
)
1594 def buildOpenSG(self
):
1596 if self
.noosgbuild
== True:
1599 if self
.builddebug
== True or self
.buildall
== True:
1602 if self
.buildrelease
== True or self
.buildall
== True:
1605 def buildOSGAddOnsDbg(self
):
1607 if self
.nobuildaddons
== True:
1610 OSGBaseBuilder
.configureOSGAddOns(self
)
1612 os
.chdir(self
.dbgBuildAddOns_path
)
1614 mkBldCmd
= [self
.makeCmd
, "OSGAll"]
1615 print "run : ", mkBldCmd
1617 retcode
= subprocess
.call(mkBldCmd
)
1619 self
.handleRetCode(retcode
, "Build OSGAddOns Debug")
1621 if self
.nopython
== False:
1622 mkBldCmd
= [self
.makeCmd
, "OSGPy"]
1623 print "run : ", mkBldCmd
1625 retcode
= subprocess
.call(mkBldCmd
)
1627 self
.handleRetCode(retcode
, "Build OSGAddOns Py Debug")
1629 mkInstCmd
= [self
.makeCmd
, "install"]
1630 print "run : ", mkInstCmd
1632 retcode
= subprocess
.call(mkInstCmd
)
1634 self
.handleRetCode(retcode
, "Install OSGAddOns Debug")
1636 os
.chdir(self
.startup_path
)
1638 def buildOSGAddOnsOpt(self
):
1640 if self
.nobuildaddons
== True:
1643 OSGBaseBuilder
.configureOSGAddOns(self
, "Release")
1645 os
.chdir(self
.optBuildAddOns_path
)
1647 mkBldCmd
= [self
.makeCmd
, "OSGAll"]
1648 print "run : ", mkBldCmd
1649 retcode
= subprocess
.call(mkBldCmd
)
1651 self
.handleRetCode(retcode
, "Build OSGAddOns Release")
1653 if self
.nopython
== False:
1654 mkBldCmd
= [self
.makeCmd
, "OSGPy"]
1655 print "run : ", mkBldCmd
1656 retcode
= subprocess
.call(mkBldCmd
)
1658 self
.handleRetCode(retcode
, "Build OSGAddOns Py Release")
1660 mkInstCmd
= [self
.makeCmd
, "install"]
1661 print "run : ", mkInstCmd
1662 retcode
= subprocess
.call(mkInstCmd
)
1664 self
.handleRetCode(retcode
, "Install OSG Release")
1666 os
.chdir(self
.startup_path
)
1670 def buildOSGAddOns(self
):
1672 if self
.nobuildaddons
== True:
1675 if self
.builddebug
== True or self
.buildall
== True:
1676 self
.buildOSGAddOnsDbg()
1678 if self
.buildrelease
== True or self
.buildall
== True:
1679 self
.buildOSGAddOnsOpt()
1681 ##############################################
1683 ##############################################
1685 class OSGLinuxBuilder(OSGUnixBaseBuilder
):
1691 OSGUnixBaseBuilder
.__init
__(self
,
1695 print "Build for Linux"
1699 ##############################################
1701 ##############################################
1703 class OSGOSXBuilder(OSGUnixBaseBuilder
):
1709 OSGUnixBaseBuilder
.__init
__(self
,
1713 print "Build for OSX"
1724 startup_path
= os
.getcwd()
1726 m_parser
= optparse
.OptionParser();
1729 m_parser
.add_option("-d",
1731 action
="store_true",
1734 help="no archive download (reuse existing)",
1736 m_parser
.add_option("--sg-download",
1737 action
="store_true",
1740 help="download from sg mirror",
1742 m_parser
.add_option("-u",
1744 action
="store_true",
1747 help="no archive unpacking (reuse existing), warning download will not run if --no-unpack is set !",
1749 m_parser
.add_option("-g",
1751 action
="store_true",
1754 help="no git clone (re use existing repo)",
1756 m_parser
.add_option("-l",
1758 action
="store_true",
1760 dest
="localgitclone",
1761 help="clone from OpenSG.repo in the current directory",
1763 m_parser
.add_option("--update-localgit",
1764 action
="store_true",
1766 dest
="updatelocalgit",
1767 help="update local git repo before cloning",
1769 m_parser
.add_option("-s",
1770 "--no-supportbuild",
1771 action
="store_true",
1773 dest
="nosupportbuild",
1774 help="no support build (reuse existing)",
1776 m_parser
.add_option("-b",
1778 action
="store_true",
1780 dest
="noboostbuild",
1781 help="no boost build (just install existing)",
1783 m_parser
.add_option("-q",
1785 action
="store_true",
1788 help="no qt build (just install existing)",
1790 m_parser
.add_option("--bq-only",
1791 action
="store_true",
1794 help="only build boost and qt",
1796 m_parser
.add_option("-o",
1798 action
="store_true",
1801 help="no osg build (reuse existing)",
1804 m_parser
.add_option("-a",
1806 action
="store_true",
1808 dest
="noaddonsbuild",
1809 help="no osg addons build",
1812 m_parser
.add_option("--addonWithOpenSGInst",
1813 action
="store_true",
1815 dest
="instaddonswithosg",
1816 help="install AddOns with OpenSG",
1819 m_parser
.add_option("-p",
1821 action
="store_true",
1824 help="no osg python bindings build",
1827 m_parser
.add_option("--debug",
1828 action
="store_true",
1834 m_parser
.add_option("--release",
1835 action
="store_true",
1837 dest
="buildrelease",
1838 help="build release",
1841 m_parser
.add_option("--debugopt",
1842 action
="store_true",
1844 dest
="builddebugopt",
1845 help="build debugopt (win32)",
1848 m_parser
.add_option("--releasenoopt",
1849 action
="store_true",
1851 dest
="buildreleasenoopt",
1852 help="build releasenoopt (win32)",
1856 m_parser
.add_option("--no-mssecure",
1857 action
="store_true",
1860 help="disable ms secure/debug settings",
1863 m_parser
.add_option("--force-win32",
1864 action
="store_true",
1867 help="force win32 build on win64 machines",
1870 m_parser
.add_option("--no-suppdirinit",
1871 action
="store_true",
1873 dest
="nosuppdirinit",
1874 help="do not clear and init Support build/inst subdirs",
1877 m_parser
.add_option("--vs2008",
1878 action
="store_true",
1884 args
= sys
.argv
[1:];
1886 (m_options
, m_args
) = m_parser
.parse_args(args
);
1888 print "sys : ", platform
.system()
1889 print "arch : ", platform
.architecture()
1890 print "mach : ", platform
.machine()
1891 print "plat : ", platform
.platform()
1892 print "uname : ", platform
.uname()
1895 # ----- defines -----
1896 if(platform
.system() == "Microsoft" or platform
.system() == "Windows"):
1899 if platform
.machine() == "AMD64" and not m_options
.forceWin32
:
1900 builder
= OSGWin64Builder(startup_path
,
1903 builder
= OSGWin32Builder(startup_path
,
1906 elif(platform
.system() == "Linux"):
1909 builder
= OSGLinuxBuilder(startup_path
,
1912 if(platform
.system() == "Darwin"):
1915 builder
= OSGOSXBuilder(startup_path
,
1918 builder
.dumpOptions()
1920 print "Building OpenSG for %s in %s" % (system
, startup_path
)
1926 builder
.prepareOSGSupport()
1928 if len(failed_support_libs
) != 0:
1929 print "##########################################################"
1930 print "the following support downloads/archives contains errors: "
1932 for var
in failed_support_libs
:
1935 print "##########################################################"
1937 builder
.handleRetCode(1, "Prepare SupportArchives")
1939 builder
.handleRetCode(0, "Prepare SupportArchives")
1941 builder
.buildOSGSupport()
1945 builder
.buildOpenSG()
1947 builder
.prepOSGAddOns()
1949 builder
.buildOSGAddOns()