fixed: auto_ptr -> unique_ptr
[opensg.git] / Tools / DailyBuild / buildOpenSG.py
blob2a9afdb2291d9525799fd13cb02a29b6a04aa262
2 import sys,os,subprocess,shutil,platform,time,errno
3 import urllib, tarfile, zipfile, sys, os, shutil, glob, stat
4 import commands
5 import optparse
6 import fnmatch
8 common_deps_src = [\
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) ]
35 common_deps_fhg = [\
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 ##############################################
65 # Base Builder
66 ##############################################
68 class OSGBaseBuilder:
70 def __init__(self,
71 startup_path,
72 oOptions ,
73 subDir = None ):
75 if subDir == None:
76 subDir = ""
78 extraUp = ""
80 if subDir != "":
81 extraUp = ".."
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
113 self.boostjam = 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:
147 self.buildall = True
149 self.nobuildaddons = oOptions.noaddonsbuild
150 self.addonswithosg = oOptions.instaddonswithosg
152 self.noSuppDirInit = oOptions.nosuppdirinit
153 self.useVS2008 = oOptions.useVS2008
156 self.cmakeCmd = None
157 self.makeCmd = None
159 self.vcvars = None
161 self.gitCmd = None
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
168 else:
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)
177 return
179 def openLog(self):
181 if os.path.exists("log.txt") == True:
182 self.logOut = file("log.txt", "a")
183 else:
184 self.logOut = file("log.txt", "w")
187 def closeLog(self):
188 self.logOut.close()
190 def exitOne(self):
191 self.closeLog()
192 sys.exit(1)
194 def handleRetCode(self, rc, info):
196 if rc != 0:
197 print "%-27s : [Failed]" % info
198 self.logOut.write("%-27s : [Failed]\n" % info)
199 self.logOut.flush()
200 os.fsync(self.logOut.fileno())
201 self.exitOne()
202 else:
203 print "%-27s : [Ok]" % info
204 self.logOut.write("%-27s : [Ok]\n" % info)
205 self.logOut.flush()
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):
251 def is_exe(fpath):
252 return os.path.exists(fpath) and os.access(fpath, os.X_OK)
254 fpath, fname = os.path.split(program)
256 if fpath:
257 if is_exe(program):
258 return program
259 else:
260 for path in os.environ["PATH"].split(os.pathsep):
261 exe_file = os.path.join(path, program)
263 if is_exe(exe_file):
264 return exe_file
266 for path in self.fallbackPaths:
267 exe_file = os.path.join(path, program)
269 if is_exe(exe_file):
270 return exe_file
272 return None
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:
288 os.mkdir(dirname)
290 def progress(self, count, blocksize, size):
292 text="%d / %d" % (count * blocksize, size)
293 text += len(text) * '\b'
294 sys.stdout.write(text)
295 sys.stdout.flush()
297 def getUrl(self, url, file):
299 if os.path.exists(file):
300 print "%s exists, not downloading." % file
301 return
303 sys.stdout.write("Downloading %s: " % file)
304 urllib.urlretrieve(url=url, filename=file, reporthook=self.progress)
305 print
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
319 if not arcfile:
320 arcfile=url.rsplit('/', 1)[1]
322 if arcfile == "download":
323 arcfile=url.rsplit('/', 2)[1]
325 if self.nodownload == False:
326 try:
327 self.getUrl(url, arcfile)
328 except:
329 print "################"
330 print "#### failed ####"
331 print "################"
332 failed_support_libs.append(url)
333 continue
336 if arcfile.endswith(".tar.gz") or arcfile.endswith(".tar"):
338 if not dir:
339 if arcfile.endswith(".tar.gz"):
340 dir = arcfile[:-7]
341 elif arcfile.endswith(".tar"):
342 dir = arcfile[:-4]
344 dir = os.path.join(self.unpack_path, dir)
346 print "untar %s | %s" % (arcfile, dir)
348 if not os.path.exists(dir):
349 try:
350 print "Untarring %s..." % arcfile
352 t = tarfile.open(arcfile, "r")
353 t.extractall(path=dir)
354 t.close()
355 except:
356 print "################"
357 print "#### failed ####"
358 print "################"
359 failed_support_libs.append(url)
360 continue
362 elif arcfile.endswith(".zip"):
364 if not dir:
365 dir = arcfile[:-4]
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
374 try:
375 z = zipfile.ZipFile(arcfile, "r")
376 z.extractall(path=dir)
377 z.close()
378 except:
380 # if os.path.exists(dir):
381 # shutil.rmtree(dir)
382 self.removeTree(dir)
384 unzipCmd = self.which("unzip")
386 if unzipCmd != None:
387 uzCmd = [unzipCmd, "-q", arcfile, "-d", dir]
388 print "uz : ", uzCmd
390 try:
391 retcode = subprocess.call(uzCmd)
393 if retcode != 0:
394 print "################"
395 print "#### failed ####"
396 print "################"
397 failed_support_libs.append(url)
398 continue
400 except:
401 print "################"
402 print "#### failed ####"
403 print "################"
404 failed_support_libs.append(url)
405 continue
406 else:
407 print "################"
408 print "#### failed ####"
409 print "################"
410 failed_support_libs.append(url)
411 continue
413 else:
414 print "Unknown file type for '%s', aborting!" % file
415 self.closeLog()
416 self.exitOne()
418 # Only one dir? Move up
419 files = glob.glob(os.path.join(dir, "*"))
421 print "foo ", files
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)
430 os.removedirs(dir)
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:
455 try:
456 self.getUrl("http://opensg.fraunhofer.sg/user/gerrit/OpenSG.Support/wake_up_server.txt", "wake_up_server.txt")
457 except:
458 print "don't care"
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)
472 if system == "unix":
473 self.prepareArchives(cmSupportOut, self.linux_deps)
475 cmSupportOut.write('\n')
477 cmSupportOut.close()
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')
505 cmSupportOut.close()
507 def cloneGit(self):
509 if self.nogitclone == True:
510 return
513 ## OpenSG
515 self.initDir("OpenSG", False)
517 if self.localgitclone == False:
518 gitCloneCmd = [self.gitCmd, "clone", "git://opensg.git.sourceforge.net/gitroot/opensg/opensg", "OpenSG"]
519 else:
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")
550 ## OSGAddOne
552 self.initDir("OSGAddOns", False)
554 if self.localgitclone == False:
555 gitCloneCmd = [self.gitCmd, "clone", "git://github.com/vossg/OSGAddOnsGV.git", "OSGAddOns"]
556 else:
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 ...."
589 return
591 def buildQt(self):
593 print "Building qt ...."
594 return
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":
603 self.buildBoost()
605 if system == "windows":
606 self.buildQt()
608 if self.bqonly == True:
609 return
611 os.chdir(self.suppBuild_path)
613 cmCfgCmd = [self.cmakeCmd,
614 "-G",
615 self.cmakeGen,
616 "-C",
617 self.cmSupportFile,
618 self.suppRel_path]
620 print "Supp cmake : ", cmCfgCmd
622 retcode = subprocess.call(cmCfgCmd)
624 self.handleRetCode(retcode, "Support Initial CMake")
626 os.chdir(self.startup_path)
630 def prepOSG(self):
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')
685 cmOSGOut.close()
687 def configureOSG(self):
689 self.initDir(self.dbgBuild_path)
691 os.chdir(self.dbgBuild_path)
693 cmCfgCmd = [self.cmakeCmd,
694 "-G",
695 self.cmakeGen,
696 "-C",
697 self.cmOSGFile,
698 "-DCMAKE_BUILD_TYPE:STRING=Debug",
699 self.osgRel_path]
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
747 else:
748 sys.exit(1);
750 self.initDir(workDir)
752 os.chdir(workDir)
754 cmCfgCmd = [self.cmakeCmd,
755 "-G",
756 self.cmakeGen,
757 "-C",
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:
773 return
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)
809 else:
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):
828 def __init__(self,
829 startup_path,
830 oOptions ):
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"
849 else:
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 *")
859 for path in cmdirs:
860 self.fallbackPaths.append(os.path.join(path, "bin").replace('\\', '/'))
862 print "cmd : ", cmdirs
865 OSGBaseBuilder.__init__(self,
866 startup_path,
867 oOptions,
868 buildSubDir )
870 #"-d+2",
871 #"-q",
872 self.boostCommonOpts = ["-d+1",
873 "--without-mpi",
874 "--stagedir=./stage." + self.buildSubDir,
875 "--build-dir=./bin.v2." + self.buildSubDir,
876 self.boostToolset,
877 "variant=debug,release",
878 "threading=multi",
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"
909 self.exitOne()
911 if self.vcvars == None:
912 print "Error could not find vcvars.bat"
913 self.exitOne()
915 if self.gitCmd == None:
916 print "Error could not find git"
917 self.exitOne()
919 return
921 def handleRemoveReadonly(self, func, path, exc):
922 excvalue = exc[1]
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
932 func(path)
933 else:
934 raise
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_*"))
946 print "br : ", files
947 if len(files) == 1:
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*"))
952 print "bj : ", files
953 if len(files) == 1:
954 self.boostjam_path = files[0].replace('\\', '/')
956 if(self.boostroot_path == None or self.boostjam_path == None):
957 self.exitOne()
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 ...."
968 print "win cfg:"
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)
984 boostBuildCmd = []
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")
996 boostInstallCmd = []
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:
1014 os.mkdir(binPath);
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)
1024 return
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
1031 if len(files) == 1:
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
1039 def buildQt(self):
1040 print "win build qt"
1042 self.checkQtPath()
1044 self.initDir(self.qtroot_path, False)
1046 if not os.path.exists(self.qtroot_path):
1047 print "copy qt"
1049 if self.noqtbuild == False:
1050 shutil.copytree(self.qtsrc_path, self.qtroot_path);
1051 else:
1052 os.mkdir(self.qtroot_path)
1054 os.chdir(self.qtroot_path)
1056 qtBaseCmd = [self.vcvars, self.vcvarsarch, "&"]
1058 qtConfigureCmd = []
1059 qtConfigureCmd.extend(qtBaseCmd)
1061 qtConfigureCmd.extend(["configure",
1062 "-opensource",
1063 "-platform", self.qtPlatform,
1064 "-nomake", "examples",
1065 "-nomake", "demos",
1066 "-nomake", "docs",
1067 "-debug-and-release",
1068 "-mmx",
1069 "-sse",
1070 "-sse2",
1071 "-plugin-sql-sqlite",
1072 "-no-dbus",
1073 "-no-phonon",
1074 "-no-phonon-backend",
1075 "-no-webkit",
1076 "-no-scripttools"])
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(["<",
1089 "yanswer"])
1091 print "qt configure : ", qtConfigureCmd
1093 qtCfgAnswer = file("yanswer", "w")
1094 qtCfgAnswer.write("y")
1095 qtCfgAnswer.close()
1098 if self.noqtbuild == False:
1099 retcode = subprocess.call(qtConfigureCmd)
1101 self.handleRetCode(retcode, "Qt Configure")
1103 qtBuildCmd = []
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()
1130 qtInstallCmd = []
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:
1175 return
1177 OSGBaseBuilder.buildOSGSupport(self)
1179 if self.bqonly == True:
1180 return
1182 os.chdir(self.suppBuild_path)
1184 print "building osg support"
1186 buildCmd = [self.vcvars,
1187 self.vcvarsarch,
1188 "&",
1189 "devenv",
1190 "/build",
1191 "Debug",
1192 "/project",
1193 "ALL_BUILD",
1194 "OpenSGSupport.sln"]
1196 retcode = subprocess.call(buildCmd)
1198 self.handleRetCode(retcode, "Build OSG Support Debug")
1200 buildCmd = [self.vcvars,
1201 self.vcvarsarch,
1202 "&",
1203 "devenv",
1204 "/build",
1205 "Release",
1206 "/project",
1207 "ALL_BUILD",
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,
1217 self.vcvarsarch,
1218 "&",
1219 "devenv",
1220 "/build",
1221 "Debug",
1222 "/project",
1223 "INSTALL",
1224 "OpenSGSupport.sln"]
1226 retcode = subprocess.call(buildCmd)
1228 self.handleRetCode(retcode, "Install OSG Support Debug")
1230 buildCmd = [self.vcvars,
1231 self.vcvarsarch,
1232 "&",
1233 "devenv",
1234 "/build",
1235 "Release",
1236 "/project",
1237 "INSTALL",
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,
1253 self.vcvarsarch,
1254 "&",
1255 "devenv",
1256 "/build",
1257 variant,
1258 "/project",
1259 "OSGAll",
1260 "OpenSG.sln"]
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,
1271 self.vcvarsarch,
1272 "&",
1273 "devenv",
1274 "/build",
1275 variant,
1276 "/project",
1277 "OSGPy",
1278 "OpenSG.sln"]
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,
1289 self.vcvarsarch,
1290 "&",
1291 "devenv",
1292 "/build",
1293 variant,
1294 "/project",
1295 "INSTALL",
1296 "OpenSG.sln"]
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,
1314 self.vcvarsarch,
1315 "&",
1316 "devenv",
1317 "/build",
1318 variant,
1319 "/project",
1320 "OSGAll",
1321 "OpenSGAddOns.sln"]
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,
1332 self.vcvarsarch,
1333 "&",
1334 "devenv",
1335 "/build",
1336 variant,
1337 "/project",
1338 "OSGPy",
1339 "OpenSGAddOns.sln"]
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,
1350 self.vcvarsarch,
1351 "&",
1352 "devenv",
1353 "/build",
1354 variant,
1355 "/project",
1356 "INSTALL",
1357 "OpenSGAddOns.sln"]
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:
1371 return
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:
1390 return
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 ##############################################
1407 # Win32 Builder
1408 ##############################################
1410 class OSGWin32Builder(OSGWinBaseBuilder):
1412 def __init__(self,
1413 startup_path,
1414 oOptions ):
1416 self.vcvarsarch = "x86"
1418 OSGWinBaseBuilder.__init__(self,
1419 startup_path,
1420 oOptions )
1422 if self.useVS2008 == True:
1423 self.cmakeGen = "Visual Studio 2008 9"
1424 self.qtPlatform = "win32-msvc2008"
1425 else:
1426 self.cmakeGen = "Visual Studio 10"
1427 self.qtPlatform = "win32-msvc2010"
1429 self.boostAddrOpt = ["address-model=32"]
1432 print "Build for Win32"
1434 return
1436 ##############################################
1437 # Win64 Builder
1438 ##############################################
1440 class OSGWin64Builder(OSGWinBaseBuilder):
1442 def __init__(self,
1443 startup_path,
1444 oOptions ):
1446 self.vcvarsarch = "amd64"
1448 OSGWinBaseBuilder.__init__(self,
1449 startup_path,
1450 oOptions )
1452 self.boostAddrOpt = ["address-model=64"]
1454 if self.useVS2008 == True:
1455 self.cmakeGen = "Visual Studio 9 2008 Win64"
1456 self.qtPlatform = "win32-msvc2008"
1457 else:
1458 self.cmakeGen = "Visual Studio 10 Win64"
1459 self.qtPlatform = "win32-msvc2010"
1462 print "Build for Win64"
1464 return
1467 ##############################################
1468 # Unix Base Builder
1469 ##############################################
1471 class OSGUnixBaseBuilder(OSGBaseBuilder):
1473 def __init__(self,
1474 startup_path,
1475 oOptions ):
1477 OSGBaseBuilder.__init__(self,
1478 startup_path,
1479 oOptions )
1481 self.cmakeCmd = "cmake"
1482 self.makeCmd = "make"
1483 self.gitCmd = "git"
1485 self.cmakeGen = "Unix Makefiles"
1487 return
1489 def buildOSGSupport(self):
1491 if self.nosupportbuild == True:
1492 return
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:
1528 return
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:
1557 return
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",
1568 self.osgRel_path]
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:
1597 return
1599 if self.builddebug == True or self.buildall == True:
1600 self.buildOSGDbg()
1602 if self.buildrelease == True or self.buildall == True:
1603 self.buildOSGOpt()
1605 def buildOSGAddOnsDbg(self):
1607 if self.nobuildaddons == True:
1608 return
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:
1641 return
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:
1673 return
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 ##############################################
1682 # Linux Builder
1683 ##############################################
1685 class OSGLinuxBuilder(OSGUnixBaseBuilder):
1687 def __init__(self,
1688 startup_path,
1689 oOptions ):
1691 OSGUnixBaseBuilder.__init__(self,
1692 startup_path,
1693 oOptions )
1695 print "Build for Linux"
1697 return
1699 ##############################################
1700 # OSX Builder
1701 ##############################################
1703 class OSGOSXBuilder(OSGUnixBaseBuilder):
1705 def __init__(self,
1706 startup_path,
1707 oOptions ):
1709 OSGUnixBaseBuilder.__init__(self,
1710 startup_path,
1711 oOptions )
1713 print "Build for OSX"
1715 return
1722 builder = None;
1724 startup_path = os.getcwd()
1726 m_parser = optparse.OptionParser();
1729 m_parser.add_option("-d",
1730 "--no-download",
1731 action="store_true",
1732 default=False,
1733 dest="nodownload",
1734 help="no archive download (reuse existing)",
1735 metavar="OpenSG");
1736 m_parser.add_option("--sg-download",
1737 action="store_true",
1738 default=False,
1739 dest="sgdownload",
1740 help="download from sg mirror",
1741 metavar="OpenSG");
1742 m_parser.add_option("-u",
1743 "--no-unpack",
1744 action="store_true",
1745 default=False,
1746 dest="nounpack",
1747 help="no archive unpacking (reuse existing), warning download will not run if --no-unpack is set !",
1748 metavar="OpenSG");
1749 m_parser.add_option("-g",
1750 "--no-gitclone",
1751 action="store_true",
1752 default=False,
1753 dest="nogitclone",
1754 help="no git clone (re use existing repo)",
1755 metavar="OpenSG");
1756 m_parser.add_option("-l",
1757 "--local-gitclone",
1758 action="store_true",
1759 default=False,
1760 dest="localgitclone",
1761 help="clone from OpenSG.repo in the current directory",
1762 metavar="OpenSG");
1763 m_parser.add_option("--update-localgit",
1764 action="store_true",
1765 default=False,
1766 dest="updatelocalgit",
1767 help="update local git repo before cloning",
1768 metavar="OpenSG");
1769 m_parser.add_option("-s",
1770 "--no-supportbuild",
1771 action="store_true",
1772 default=False,
1773 dest="nosupportbuild",
1774 help="no support build (reuse existing)",
1775 metavar="OpenSG");
1776 m_parser.add_option("-b",
1777 "--no-boostbuild",
1778 action="store_true",
1779 default=False,
1780 dest="noboostbuild",
1781 help="no boost build (just install existing)",
1782 metavar="OpenSG");
1783 m_parser.add_option("-q",
1784 "--no-qtbuild",
1785 action="store_true",
1786 default=False,
1787 dest="noqtbuild",
1788 help="no qt build (just install existing)",
1789 metavar="OpenSG");
1790 m_parser.add_option("--bq-only",
1791 action="store_true",
1792 default=False,
1793 dest="bqonly",
1794 help="only build boost and qt",
1795 metavar="OpenSG");
1796 m_parser.add_option("-o",
1797 "--no-osbbuild",
1798 action="store_true",
1799 default=False,
1800 dest="noosgbuild",
1801 help="no osg build (reuse existing)",
1802 metavar="OpenSG");
1804 m_parser.add_option("-a",
1805 "--no-addonsbuild",
1806 action="store_true",
1807 default=False,
1808 dest="noaddonsbuild",
1809 help="no osg addons build",
1810 metavar="OpenSG");
1812 m_parser.add_option("--addonWithOpenSGInst",
1813 action="store_true",
1814 default=False,
1815 dest="instaddonswithosg",
1816 help="install AddOns with OpenSG",
1817 metavar="OpenSG");
1819 m_parser.add_option("-p",
1820 "--no-python",
1821 action="store_true",
1822 default=False,
1823 dest="nopython",
1824 help="no osg python bindings build",
1825 metavar="OpenSG");
1827 m_parser.add_option("--debug",
1828 action="store_true",
1829 default=False,
1830 dest="builddebug",
1831 help="build debug",
1832 metavar="OpenSG");
1834 m_parser.add_option("--release",
1835 action="store_true",
1836 default=False,
1837 dest="buildrelease",
1838 help="build release",
1839 metavar="OpenSG");
1841 m_parser.add_option("--debugopt",
1842 action="store_true",
1843 default=False,
1844 dest="builddebugopt",
1845 help="build debugopt (win32)",
1846 metavar="OpenSG");
1848 m_parser.add_option("--releasenoopt",
1849 action="store_true",
1850 default=False,
1851 dest="buildreleasenoopt",
1852 help="build releasenoopt (win32)",
1853 metavar="OpenSG");
1856 m_parser.add_option("--no-mssecure",
1857 action="store_true",
1858 default=False,
1859 dest="nomssecure",
1860 help="disable ms secure/debug settings",
1861 metavar="OpenSG");
1863 m_parser.add_option("--force-win32",
1864 action="store_true",
1865 default=False,
1866 dest="forceWin32",
1867 help="force win32 build on win64 machines",
1868 metavar="OpenSG");
1870 m_parser.add_option("--no-suppdirinit",
1871 action="store_true",
1872 default=False,
1873 dest="nosuppdirinit",
1874 help="do not clear and init Support build/inst subdirs",
1875 metavar="OpenSG");
1877 m_parser.add_option("--vs2008",
1878 action="store_true",
1879 default=False,
1880 dest="useVS2008",
1881 help="use vs2008",
1882 metavar="OpenSG");
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"):
1898 system = "windows"
1899 if platform.machine() == "AMD64" and not m_options.forceWin32 :
1900 builder = OSGWin64Builder(startup_path,
1901 m_options )
1902 else:
1903 builder = OSGWin32Builder(startup_path,
1904 m_options )
1906 elif(platform.system() == "Linux"):
1908 system = "unix"
1909 builder = OSGLinuxBuilder(startup_path,
1910 m_options )
1912 if(platform.system() == "Darwin"):
1914 system = "unix"
1915 builder = OSGOSXBuilder(startup_path,
1916 m_options )
1918 builder.dumpOptions()
1920 print "Building OpenSG for %s in %s" % (system, startup_path)
1922 builder.openLog()
1924 builder.cloneGit()
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:
1933 print " ", var
1935 print "##########################################################"
1937 builder.handleRetCode(1, "Prepare SupportArchives")
1939 builder.handleRetCode(0, "Prepare SupportArchives")
1941 builder.buildOSGSupport()
1943 builder.prepOSG()
1945 builder.buildOpenSG()
1947 builder.prepOSGAddOns()
1949 builder.buildOSGAddOns()
1951 builder.closeLog()