aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/develop.py
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/develop.py')
-rwxr-xr-xlinden/indra/develop.py125
1 files changed, 91 insertions, 34 deletions
diff --git a/linden/indra/develop.py b/linden/indra/develop.py
index a0b11c6..830f74d 100755
--- a/linden/indra/develop.py
+++ b/linden/indra/develop.py
@@ -53,6 +53,16 @@ def mkdir(path):
53 if err.errno != errno.EEXIST or not os.path.isdir(path): 53 if err.errno != errno.EEXIST or not os.path.isdir(path):
54 raise 54 raise
55 55
56def getcwd():
57 cwd = os.getcwd()
58 if 'a' <= cwd[0] <= 'z' and cwd[1] == ':':
59 # CMake wants DOS drive letters to be in uppercase. The above
60 # condition never asserts on platforms whose full path names
61 # always begin with a slash, so we don't need to test whether
62 # we are running on Windows.
63 cwd = cwd[0].upper() + cwd[1:]
64 return cwd
65
56def quote(opts): 66def quote(opts):
57 return '"' + '" "'.join([ opt.replace('"', '') for opt in opts ]) + '"' 67 return '"' + '" "'.join([ opt.replace('"', '') for opt in opts ]) + '"'
58 68
@@ -65,6 +75,7 @@ class PlatformSetup(object):
65 build_type = build_types['relwithdebinfo'] 75 build_type = build_types['relwithdebinfo']
66 standalone = 'FALSE' 76 standalone = 'FALSE'
67 unattended = 'FALSE' 77 unattended = 'FALSE'
78 project_name = 'Imprudence'
68 distcc = True 79 distcc = True
69 cmake_opts = [] 80 cmake_opts = []
70 81
@@ -141,7 +152,7 @@ class PlatformSetup(object):
141 # do a sanity check to make sure we have a generator 152 # do a sanity check to make sure we have a generator
142 if not hasattr(self, 'generator'): 153 if not hasattr(self, 'generator'):
143 raise "No generator available for '%s'" % (self.__name__,) 154 raise "No generator available for '%s'" % (self.__name__,)
144 cwd = os.getcwd() 155 cwd = getcwd()
145 created = [] 156 created = []
146 try: 157 try:
147 for d in self.build_dirs(): 158 for d in self.build_dirs():
@@ -223,6 +234,10 @@ class UnixSetup(PlatformSetup):
223class LinuxSetup(UnixSetup): 234class LinuxSetup(UnixSetup):
224 def __init__(self): 235 def __init__(self):
225 super(LinuxSetup, self).__init__() 236 super(LinuxSetup, self).__init__()
237 try:
238 self.debian_sarge = open('/etc/debian_version').read().strip() == '3.1'
239 except:
240 self.debian_sarge = False
226 241
227 def os(self): 242 def os(self):
228 return 'linux' 243 return 'linux'
@@ -230,10 +245,17 @@ class LinuxSetup(UnixSetup):
230 def build_dirs(self): 245 def build_dirs(self):
231 # Only build the server code if (a) we have it and (b) we're 246 # Only build the server code if (a) we have it and (b) we're
232 # on 32-bit x86. 247 # on 32-bit x86.
248 platform_build = '%s-%s' % (self.platform(), self.build_type.lower())
249
233 if self.arch() == 'i686' and self.is_internal_tree(): 250 if self.arch() == 'i686' and self.is_internal_tree():
234 return ['viewer-' + self.platform(), 'server-' + self.platform()] 251 return ['viewer-' + platform_build, 'server-' + platform_build]
252 elif self.arch() == 'x86_64' and self.is_internal_tree():
253 # the viewer does not build in 64bit -- kdu5 issues
254 # we can either use openjpeg, or overhaul our viewer to handle kdu5 or higher
255 # doug knows about kdu issues
256 return ['server-' + platform_build]
235 else: 257 else:
236 return ['viewer-' + self.platform()] 258 return ['viewer-' + platform_build]
237 259
238 def find_in_path(self, name, defval=None, basename=False): 260 def find_in_path(self, name, defval=None, basename=False):
239 for p in os.getenv('PATH', '/usr/bin').split(':'): 261 for p in os.getenv('PATH', '/usr/bin').split(':'):
@@ -251,7 +273,8 @@ class LinuxSetup(UnixSetup):
251 opts=quote(opts), 273 opts=quote(opts),
252 standalone=self.standalone, 274 standalone=self.standalone,
253 unattended=self.unattended, 275 unattended=self.unattended,
254 type=self.build_type.upper() 276 type=self.build_type.upper(),
277 project_name=self.project_name
255 ) 278 )
256 if not self.is_internal_tree(): 279 if not self.is_internal_tree():
257 args.update({'cxx':'g++', 'server':'FALSE', 'viewer':'TRUE'}) 280 args.update({'cxx':'g++', 'server':'FALSE', 'viewer':'TRUE'})
@@ -263,22 +286,20 @@ class LinuxSetup(UnixSetup):
263 distcc = [] 286 distcc = []
264 baseonly = False 287 baseonly = False
265 if 'server' in build_dir: 288 if 'server' in build_dir:
266 gcc33 = distcc + self.find_in_path('g++-3.3', 'g++', baseonly) 289 gcc = distcc + self.find_in_path(
267 args.update({'cxx':' '.join(gcc33), 'server':'TRUE', 290 self.debian_sarge and 'g++-3.3' or 'g++-4.1',
268 'viewer':'FALSE'}) 291 'g++', baseonly)
292 args.update({'cxx': ' '.join(gcc), 'server': 'TRUE',
293 'viewer': 'FALSE'})
269 else: 294 else:
270 gcc41 = distcc + self.find_in_path('g++-4.1', 'g++', baseonly) 295 gcc41 = distcc + self.find_in_path('g++-4.1', 'g++', baseonly)
271 args.update({'cxx': ' '.join(gcc41), 'server':'FALSE', 296 args.update({'cxx': ' '.join(gcc41), 'server':'FALSE',
272 'viewer':'TRUE'}) 297 'viewer':'TRUE'})
273 #if simple:
274 # return (('cmake %(opts)s '
275 # '-DSERVER:BOOL=%(server)s '
276 # '-DVIEWER:BOOL=%(viewer)s '
277 # '%(dir)r') % args)
278 cmd = (('cmake -DCMAKE_BUILD_TYPE:STRING=%(type)s ' 298 cmd = (('cmake -DCMAKE_BUILD_TYPE:STRING=%(type)s '
279 '-G %(generator)r -DSERVER:BOOL=%(server)s ' 299 '-G %(generator)r -DSERVER:BOOL=%(server)s '
280 '-DVIEWER:BOOL=%(viewer)s -DSTANDALONE:BOOL=%(standalone)s ' 300 '-DVIEWER:BOOL=%(viewer)s -DSTANDALONE:BOOL=%(standalone)s '
281 '-DUNATTENDED:BOOL=%(unattended)s ' 301 '-DUNATTENDED:BOOL=%(unattended)s '
302 '-DROOT_PROJECT_NAME:STRING=%(project_name)s '
282 '%(opts)s %(dir)r') 303 '%(opts)s %(dir)r')
283 % args) 304 % args)
284 if 'CXX' not in os.environ: 305 if 'CXX' not in os.environ:
@@ -381,6 +402,7 @@ class DarwinSetup(UnixSetup):
381 opts=quote(opts), 402 opts=quote(opts),
382 standalone=self.standalone, 403 standalone=self.standalone,
383 unattended=self.unattended, 404 unattended=self.unattended,
405 project_name=self.project_name,
384 universal='', 406 universal='',
385 type=self.build_type.upper() 407 type=self.build_type.upper()
386 ) 408 )
@@ -392,11 +414,12 @@ class DarwinSetup(UnixSetup):
392 '-DCMAKE_BUILD_TYPE:STRING=%(type)s ' 414 '-DCMAKE_BUILD_TYPE:STRING=%(type)s '
393 '-DSTANDALONE:BOOL=%(standalone)s ' 415 '-DSTANDALONE:BOOL=%(standalone)s '
394 '-DUNATTENDED:BOOL=%(unattended)s ' 416 '-DUNATTENDED:BOOL=%(unattended)s '
417 '-DROOT_PROJECT_NAME:STRING=%(project_name)s '
395 '%(universal)s ' 418 '%(universal)s '
396 '%(opts)s %(dir)r' % args) 419 '%(opts)s %(dir)r' % args)
397 420
398 def run_build(self, opts, targets): 421 def run_build(self, opts, targets):
399 cwd = os.getcwd() 422 cwd = getcwd()
400 if targets: 423 if targets:
401 targets = ' '.join(['-target ' + repr(t) for t in targets]) 424 targets = ' '.join(['-target ' + repr(t) for t in targets])
402 else: 425 else:
@@ -439,7 +462,7 @@ class WindowsSetup(PlatformSetup):
439 462
440 def _get_generator(self): 463 def _get_generator(self):
441 if self._generator is None: 464 if self._generator is None:
442 for version in 'vc71 vc80 vc90'.split(): 465 for version in 'vc80 vc90 vc71'.split():
443 if self.find_visual_studio(version): 466 if self.find_visual_studio(version):
444 self._generator = version 467 self._generator = version
445 print 'Building with ', self.gens[version]['gen'] 468 print 'Building with ', self.gens[version]['gen']
@@ -467,12 +490,14 @@ class WindowsSetup(PlatformSetup):
467 opts=quote(opts), 490 opts=quote(opts),
468 standalone=self.standalone, 491 standalone=self.standalone,
469 unattended=self.unattended, 492 unattended=self.unattended,
493 project_name=self.project_name
470 ) 494 )
471 #if simple: 495 #if simple:
472 # return 'cmake %(opts)s "%(dir)s"' % args 496 # return 'cmake %(opts)s "%(dir)s"' % args
473 return ('cmake -G "%(generator)s" ' 497 return ('cmake -G "%(generator)s" '
474 '-DSTANDALONE:BOOL=%(standalone)s ' 498 '-DSTANDALONE:BOOL=%(standalone)s '
475 '-DUNATTENDED:BOOL=%(unattended)s ' 499 '-DUNATTENDED:BOOL=%(unattended)s '
500 '-DROOT_PROJECT_NAME:STRING=%(project_name)s '
476 '%(opts)s "%(dir)s"' % args) 501 '%(opts)s "%(dir)s"' % args)
477 502
478 def find_visual_studio(self, gen=None): 503 def find_visual_studio(self, gen=None):
@@ -503,11 +528,11 @@ class WindowsSetup(PlatformSetup):
503 if self.gens[self.generator]['ver'] in [ r'8.0', r'9.0' ]: 528 if self.gens[self.generator]['ver'] in [ r'8.0', r'9.0' ]:
504 config = '\"%s|Win32\"' % config 529 config = '\"%s|Win32\"' % config
505 530
506 return "buildconsole Imprudence.sln /build %s" % config 531 return "buildconsole %s.sln /build %s" % (self.project_name, config)
507 532
508 # devenv.com is CLI friendly, devenv.exe... not so much. 533 # devenv.com is CLI friendly, devenv.exe... not so much.
509 return ('"%sdevenv.com" Imprudence.sln /build %s' % 534 return ('"%sdevenv.com" %s.sln /build %s' %
510 (self.find_visual_studio(), self.build_type)) 535 (self.find_visual_studio(), self.project_name, self.build_type))
511 536
512 # this override of run exists because the PlatformSetup version 537 # this override of run exists because the PlatformSetup version
513 # uses Unix/Mac only calls. Freakin' os module! 538 # uses Unix/Mac only calls. Freakin' os module!
@@ -524,17 +549,26 @@ class WindowsSetup(PlatformSetup):
524 '''Override to add the vstool.exe call after running cmake.''' 549 '''Override to add the vstool.exe call after running cmake.'''
525 PlatformSetup.run_cmake(self, args) 550 PlatformSetup.run_cmake(self, args)
526 if self.unattended == 'FALSE': 551 if self.unattended == 'FALSE':
527 for build_dir in self.build_dirs(): 552 self.run_vstool()
528 vstool_cmd = os.path.join('tools','vstool','VSTool.exe') \ 553
529 + ' --solution ' \ 554 def run_vstool(self):
530 + os.path.join(build_dir,'Imprudence.sln') \ 555 for build_dir in self.build_dirs():
531 + ' --config RelWithDebInfo' \ 556 stamp = os.path.join(build_dir, 'vstool.txt')
532 + ' --startup imprudence-bin' 557 try:
533 print 'Running %r in %r' % (vstool_cmd, os.getcwd()) 558 prev_build = open(stamp).read().strip()
534 self.run(vstool_cmd) 559 except IOError:
560 prev_build = ''
561 vstool_cmd = (os.path.join('tools','vstool','VSTool.exe') +
562 ' --solution ' +
563 os.path.join(build_dir,'Imprudence.sln') +
564 ' --config ' + self.build_type +
565 ' --startup imprudence-bin')
566 print 'Running %r in %r' % (vstool_cmd, getcwd())
567 self.run(vstool_cmd)
568 print >> open(stamp, 'w'), self.build_type
535 569
536 def run_build(self, opts, targets): 570 def run_build(self, opts, targets):
537 cwd = os.getcwd() 571 cwd = getcwd()
538 build_cmd = self.get_build_cmd() 572 build_cmd = self.get_build_cmd()
539 573
540 for d in self.build_dirs(): 574 for d in self.build_dirs():
@@ -565,12 +599,14 @@ class CygwinSetup(WindowsSetup):
565 opts=quote(opts), 599 opts=quote(opts),
566 standalone=self.standalone, 600 standalone=self.standalone,
567 unattended=self.unattended, 601 unattended=self.unattended,
602 project_name=self.project_name
568 ) 603 )
569 #if simple: 604 #if simple:
570 # return 'cmake %(opts)s "%(dir)s"' % args 605 # return 'cmake %(opts)s "%(dir)s"' % args
571 return ('cmake -G "%(generator)s" ' 606 return ('cmake -G "%(generator)s" '
572 '-DUNATTENDED:BOOl=%(unattended)s ' 607 '-DUNATTENDED:BOOl=%(unattended)s '
573 '-DSTANDALONE:BOOL=%(standalone)s ' 608 '-DSTANDALONE:BOOL=%(standalone)s '
609 '-DROOT_PROJECT_NAME:STRING=%(project_name)s '
574 '%(opts)s "%(dir)s"' % args) 610 '%(opts)s "%(dir)s"' % args)
575 611
576setup_platform = { 612setup_platform = {
@@ -582,7 +618,7 @@ setup_platform = {
582 618
583 619
584usage_msg = ''' 620usage_msg = '''
585Usage: develop.py [options] command [command-options] 621Usage: develop.py [options] [command [command-options]]
586 622
587Options: 623Options:
588 -h | --help print this help message 624 -h | --help print this help message
@@ -595,12 +631,26 @@ Options:
595 Windows: VC71 or VS2003 (default), VC80 (VS2005) or VC90 (VS2008) 631 Windows: VC71 or VS2003 (default), VC80 (VS2005) or VC90 (VS2008)
596 Mac OS X: Xcode (default), Unix Makefiles 632 Mac OS X: Xcode (default), Unix Makefiles
597 Linux: Unix Makefiles (default), KDevelop3 633 Linux: Unix Makefiles (default), KDevelop3
634 -p | --project=NAME set the root project name. (Doesn't effect makefiles)
635
598Commands: 636Commands:
599 build configure and build default target 637 build configure and build default target
600 clean delete all build directories (does not affect sources) 638 clean delete all build directories (does not affect sources)
601 configure configure project by running cmake 639 configure configure project by running cmake
602 640
603If you do not specify a command, the default is "configure". 641Command-options for "configure":
642 We use cmake variables to change the build configuration.
643 -DSERVER:BOOL=OFF Don't configure simulator/dataserver/etc
644 -DVIEWER:BOOL=OFF Don't configure the viewer
645 -DPACKAGE:BOOL=ON Create "package" target to make installers
646 -DLOCALIZESETUP:BOOL=ON Create one win_setup target per supported language
647
648Examples:
649 Set up a viewer-only project for your system:
650 develop.py configure -DSERVER:BOOL=OFF
651
652 Set up a Visual Studio 2005 project with "package" target:
653 develop.py -G vc80 configure -DPACKAGE:BOOL=ON
604''' 654'''
605 655
606def main(arguments): 656def main(arguments):
@@ -608,10 +658,14 @@ def main(arguments):
608 try: 658 try:
609 opts, args = getopt.getopt( 659 opts, args = getopt.getopt(
610 arguments, 660 arguments,
611 '?hNt:G:', 661 '?hNt:p:G:',
612 ['help', 'standalone', 'no-distcc', 'unattended', 'type=', 'incredibuild', 'generator=']) 662 ['help', 'standalone', 'no-distcc', 'unattended', 'type=', 'incredibuild', 'generator=', 'project='])
613 except getopt.GetoptError, err: 663 except getopt.GetoptError, err:
614 print >> sys.stderr, 'Error:', err 664 print >> sys.stderr, 'Error:', err
665 print >> sys.stderr, """
666Note: You must pass -D options to cmake after the "configure" command
667For example: develop.py configure -DSERVER:BOOL=OFF"""
668 print >> sys.stderr, usage_msg.strip()
615 sys.exit(1) 669 sys.exit(1)
616 670
617 for o, a in opts: 671 for o, a in opts:
@@ -637,6 +691,8 @@ def main(arguments):
637 setup.generator = a 691 setup.generator = a
638 elif o in ('-N', '--no-distcc'): 692 elif o in ('-N', '--no-distcc'):
639 setup.distcc = False 693 setup.distcc = False
694 elif o in ('-p', '--project'):
695 setup.project_name = a
640 elif o in ('--incredibuild'): 696 elif o in ('--incredibuild'):
641 setup.incredibuild = True 697 setup.incredibuild = True
642 else: 698 else:
@@ -664,13 +720,14 @@ def main(arguments):
664 print >> sys.stderr, 'Error: unknown subcommand', repr(cmd) 720 print >> sys.stderr, 'Error: unknown subcommand', repr(cmd)
665 print >> sys.stderr, "(run 'develop.py --help' for help)" 721 print >> sys.stderr, "(run 'develop.py --help' for help)"
666 sys.exit(1) 722 sys.exit(1)
667 except CommandError, err:
668 print >> sys.stderr, 'Error:', err
669 sys.exit(1)
670 except getopt.GetoptError, err: 723 except getopt.GetoptError, err:
671 print >> sys.stderr, 'Error with %r subcommand: %s' % (cmd, err) 724 print >> sys.stderr, 'Error with %r subcommand: %s' % (cmd, err)
672 sys.exit(1) 725 sys.exit(1)
673 726
674 727
675if __name__ == '__main__': 728if __name__ == '__main__':
676 main(sys.argv[1:]) 729 try:
730 main(sys.argv[1:])
731 except CommandError, err:
732 print >> sys.stderr, 'Error:', err
733 sys.exit(1)