diff options
Diffstat (limited to '')
-rwxr-xr-x | linden/indra/develop.py | 118 |
1 files changed, 80 insertions, 38 deletions
diff --git a/linden/indra/develop.py b/linden/indra/develop.py index 8edfccc..c4a9d0d 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 | ||
56 | def 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 | |||
56 | def quote(opts): | 66 | def quote(opts): |
57 | return '"' + '" "'.join([ opt.replace('"', '') for opt in opts ]) + '"' | 67 | return '"' + '" "'.join([ opt.replace('"', '') for opt in opts ]) + '"' |
58 | 68 | ||
@@ -63,8 +73,8 @@ class PlatformSetup(object): | |||
63 | build_types[t.lower()] = t | 73 | build_types[t.lower()] = t |
64 | 74 | ||
65 | build_type = build_types['relwithdebinfo'] | 75 | build_type = build_types['relwithdebinfo'] |
66 | standalone = 'FALSE' | 76 | standalone = 'OFF' |
67 | unattended = 'FALSE' | 77 | unattended = 'OFF' |
68 | distcc = True | 78 | distcc = True |
69 | cmake_opts = [] | 79 | cmake_opts = [] |
70 | 80 | ||
@@ -141,7 +151,7 @@ class PlatformSetup(object): | |||
141 | # do a sanity check to make sure we have a generator | 151 | # do a sanity check to make sure we have a generator |
142 | if not hasattr(self, 'generator'): | 152 | if not hasattr(self, 'generator'): |
143 | raise "No generator available for '%s'" % (self.__name__,) | 153 | raise "No generator available for '%s'" % (self.__name__,) |
144 | cwd = os.getcwd() | 154 | cwd = getcwd() |
145 | created = [] | 155 | created = [] |
146 | try: | 156 | try: |
147 | for d in self.build_dirs(): | 157 | for d in self.build_dirs(): |
@@ -218,11 +228,15 @@ class UnixSetup(PlatformSetup): | |||
218 | elif cpu == 'Power Macintosh': | 228 | elif cpu == 'Power Macintosh': |
219 | cpu = 'ppc' | 229 | cpu = 'ppc' |
220 | return cpu | 230 | return cpu |
221 | 231 | ||
222 | 232 | ||
223 | class LinuxSetup(UnixSetup): | 233 | class LinuxSetup(UnixSetup): |
224 | def __init__(self): | 234 | def __init__(self): |
225 | super(LinuxSetup, self).__init__() | 235 | super(LinuxSetup, self).__init__() |
236 | try: | ||
237 | self.debian_sarge = open('/etc/debian_version').read().strip() == '3.1' | ||
238 | except: | ||
239 | self.debian_sarge = False | ||
226 | 240 | ||
227 | def os(self): | 241 | def os(self): |
228 | return 'linux' | 242 | return 'linux' |
@@ -230,10 +244,17 @@ class LinuxSetup(UnixSetup): | |||
230 | def build_dirs(self): | 244 | def build_dirs(self): |
231 | # Only build the server code if (a) we have it and (b) we're | 245 | # Only build the server code if (a) we have it and (b) we're |
232 | # on 32-bit x86. | 246 | # on 32-bit x86. |
247 | platform_build = '%s-%s' % (self.platform(), self.build_type.lower()) | ||
248 | |||
233 | if self.arch() == 'i686' and self.is_internal_tree(): | 249 | if self.arch() == 'i686' and self.is_internal_tree(): |
234 | return ['viewer-' + self.platform(), 'server-' + self.platform()] | 250 | return ['viewer-' + platform_build, 'server-' + platform_build] |
251 | elif self.arch() == 'x86_64' and self.is_internal_tree(): | ||
252 | # the viewer does not build in 64bit -- kdu5 issues | ||
253 | # we can either use openjpeg, or overhaul our viewer to handle kdu5 or higher | ||
254 | # doug knows about kdu issues | ||
255 | return ['server-' + platform_build] | ||
235 | else: | 256 | else: |
236 | return ['viewer-' + self.platform()] | 257 | return ['viewer-' + platform_build] |
237 | 258 | ||
238 | def find_in_path(self, name, defval=None, basename=False): | 259 | def find_in_path(self, name, defval=None, basename=False): |
239 | for p in os.getenv('PATH', '/usr/bin').split(':'): | 260 | for p in os.getenv('PATH', '/usr/bin').split(':'): |
@@ -254,7 +275,7 @@ class LinuxSetup(UnixSetup): | |||
254 | type=self.build_type.upper() | 275 | type=self.build_type.upper() |
255 | ) | 276 | ) |
256 | if not self.is_internal_tree(): | 277 | if not self.is_internal_tree(): |
257 | args.update({'cxx':'g++', 'server':'FALSE', 'viewer':'TRUE'}) | 278 | args.update({'cxx':'g++', 'server':'OFF', 'viewer':'ON'}) |
258 | else: | 279 | else: |
259 | if self.distcc: | 280 | if self.distcc: |
260 | distcc = self.find_in_path('distcc') | 281 | distcc = self.find_in_path('distcc') |
@@ -263,18 +284,16 @@ class LinuxSetup(UnixSetup): | |||
263 | distcc = [] | 284 | distcc = [] |
264 | baseonly = False | 285 | baseonly = False |
265 | if 'server' in build_dir: | 286 | if 'server' in build_dir: |
266 | gcc33 = distcc + self.find_in_path('g++-3.3', 'g++', baseonly) | 287 | gcc = distcc + self.find_in_path( |
267 | args.update({'cxx':' '.join(gcc33), 'server':'TRUE', | 288 | self.debian_sarge and 'g++-3.3' or 'g++-4.1', |
268 | 'viewer':'FALSE'}) | 289 | 'g++', baseonly) |
290 | args.update({'cxx': ' '.join(gcc), 'server': 'ON', | ||
291 | 'viewer': 'OFF'}) | ||
269 | else: | 292 | else: |
270 | gcc41 = distcc + self.find_in_path('g++-4.1', 'g++', baseonly) | 293 | gcc41 = distcc + self.find_in_path('g++-4.1', 'g++', baseonly) |
271 | args.update({'cxx': ' '.join(gcc41), 'server':'FALSE', | 294 | args.update({'cxx': ' '.join(gcc41), |
272 | 'viewer':'TRUE'}) | 295 | 'server': 'OFF', |
273 | #if simple: | 296 | 'viewer': 'ON'}) |
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 ' | 297 | cmd = (('cmake -DCMAKE_BUILD_TYPE:STRING=%(type)s ' |
279 | '-G %(generator)r -DSERVER:BOOL=%(server)s ' | 298 | '-G %(generator)r -DSERVER:BOOL=%(server)s ' |
280 | '-DVIEWER:BOOL=%(viewer)s -DSTANDALONE:BOOL=%(standalone)s ' | 299 | '-DVIEWER:BOOL=%(viewer)s -DSTANDALONE:BOOL=%(standalone)s ' |
@@ -369,7 +388,7 @@ class DarwinSetup(UnixSetup): | |||
369 | return 'darwin' | 388 | return 'darwin' |
370 | 389 | ||
371 | def arch(self): | 390 | def arch(self): |
372 | if self.unattended == 'TRUE': | 391 | if self.unattended == 'ON': |
373 | return 'universal' | 392 | return 'universal' |
374 | else: | 393 | else: |
375 | return UnixSetup.arch(self) | 394 | return UnixSetup.arch(self) |
@@ -384,7 +403,7 @@ class DarwinSetup(UnixSetup): | |||
384 | universal='', | 403 | universal='', |
385 | type=self.build_type.upper() | 404 | type=self.build_type.upper() |
386 | ) | 405 | ) |
387 | if self.unattended == 'TRUE': | 406 | if self.unattended == 'ON': |
388 | args['universal'] = '-DCMAKE_OSX_ARCHITECTURES:STRING=\'i386;ppc\'' | 407 | args['universal'] = '-DCMAKE_OSX_ARCHITECTURES:STRING=\'i386;ppc\'' |
389 | #if simple: | 408 | #if simple: |
390 | # return 'cmake %(opts)s %(dir)r' % args | 409 | # return 'cmake %(opts)s %(dir)r' % args |
@@ -396,7 +415,7 @@ class DarwinSetup(UnixSetup): | |||
396 | '%(opts)s %(dir)r' % args) | 415 | '%(opts)s %(dir)r' % args) |
397 | 416 | ||
398 | def run_build(self, opts, targets): | 417 | def run_build(self, opts, targets): |
399 | cwd = os.getcwd() | 418 | cwd = getcwd() |
400 | if targets: | 419 | if targets: |
401 | targets = ' '.join(['-target ' + repr(t) for t in targets]) | 420 | targets = ' '.join(['-target ' + repr(t) for t in targets]) |
402 | else: | 421 | else: |
@@ -439,7 +458,7 @@ class WindowsSetup(PlatformSetup): | |||
439 | 458 | ||
440 | def _get_generator(self): | 459 | def _get_generator(self): |
441 | if self._generator is None: | 460 | if self._generator is None: |
442 | for version in 'vc71 vc80 vc90'.split(): | 461 | for version in 'vc80 vc90 vc71'.split(): |
443 | if self.find_visual_studio(version): | 462 | if self.find_visual_studio(version): |
444 | self._generator = version | 463 | self._generator = version |
445 | print 'Building with ', self.gens[version]['gen'] | 464 | print 'Building with ', self.gens[version]['gen'] |
@@ -523,18 +542,30 @@ class WindowsSetup(PlatformSetup): | |||
523 | def run_cmake(self, args=[]): | 542 | def run_cmake(self, args=[]): |
524 | '''Override to add the vstool.exe call after running cmake.''' | 543 | '''Override to add the vstool.exe call after running cmake.''' |
525 | PlatformSetup.run_cmake(self, args) | 544 | PlatformSetup.run_cmake(self, args) |
526 | if self.unattended == 'FALSE': | 545 | if self.unattended == 'OFF': |
527 | for build_dir in self.build_dirs(): | 546 | self.run_vstool() |
528 | vstool_cmd = os.path.join('tools','vstool','VSTool.exe') \ | 547 | |
529 | + ' --solution ' \ | 548 | def run_vstool(self): |
530 | + os.path.join(build_dir,'SecondLife.sln') \ | 549 | for build_dir in self.build_dirs(): |
531 | + ' --config RelWithDebInfo' \ | 550 | stamp = os.path.join(build_dir, 'vstool.txt') |
532 | + ' --startup secondlife-bin' | 551 | try: |
533 | print 'Running %r in %r' % (vstool_cmd, os.getcwd()) | 552 | prev_build = open(stamp).read().strip() |
534 | self.run(vstool_cmd) | 553 | except IOError: |
554 | prev_build = '' | ||
555 | if prev_build == self.build_type: | ||
556 | # Only run vstool if the build type has changed. | ||
557 | continue | ||
558 | vstool_cmd = (os.path.join('tools','vstool','VSTool.exe') + | ||
559 | ' --solution ' + | ||
560 | os.path.join(build_dir,'SecondLife.sln') + | ||
561 | ' --config ' + self.build_type + | ||
562 | ' --startup secondlife-bin') | ||
563 | print 'Running %r in %r' % (vstool_cmd, getcwd()) | ||
564 | self.run(vstool_cmd) | ||
565 | print >> open(stamp, 'w'), self.build_type | ||
535 | 566 | ||
536 | def run_build(self, opts, targets): | 567 | def run_build(self, opts, targets): |
537 | cwd = os.getcwd() | 568 | cwd = getcwd() |
538 | build_cmd = self.get_build_cmd() | 569 | build_cmd = self.get_build_cmd() |
539 | 570 | ||
540 | for d in self.build_dirs(): | 571 | for d in self.build_dirs(): |
@@ -555,7 +586,7 @@ class WindowsSetup(PlatformSetup): | |||
555 | class CygwinSetup(WindowsSetup): | 586 | class CygwinSetup(WindowsSetup): |
556 | def __init__(self): | 587 | def __init__(self): |
557 | super(CygwinSetup, self).__init__() | 588 | super(CygwinSetup, self).__init__() |
558 | self.generator = 'vc71' | 589 | self.generator = 'vc80' |
559 | 590 | ||
560 | def cmake_commandline(self, src_dir, build_dir, opts, simple): | 591 | def cmake_commandline(self, src_dir, build_dir, opts, simple): |
561 | dos_dir = commands.getoutput("cygpath -w %s" % src_dir) | 592 | dos_dir = commands.getoutput("cygpath -w %s" % src_dir) |
@@ -601,6 +632,13 @@ Commands: | |||
601 | configure configure project by running cmake | 632 | configure configure project by running cmake |
602 | 633 | ||
603 | If you do not specify a command, the default is "configure". | 634 | If you do not specify a command, the default is "configure". |
635 | |||
636 | Examples: | ||
637 | Set up a viewer-only project for your system: | ||
638 | develop.py configure -DSERVER:BOOL=OFF | ||
639 | |||
640 | Set up a Visual Studio 2005 project with package target (to build installer): | ||
641 | develop.py -G vc80 configure -DPACKAGE:BOOL=ON | ||
604 | ''' | 642 | ''' |
605 | 643 | ||
606 | def main(arguments): | 644 | def main(arguments): |
@@ -612,6 +650,9 @@ def main(arguments): | |||
612 | ['help', 'standalone', 'no-distcc', 'unattended', 'type=', 'incredibuild', 'generator=']) | 650 | ['help', 'standalone', 'no-distcc', 'unattended', 'type=', 'incredibuild', 'generator=']) |
613 | except getopt.GetoptError, err: | 651 | except getopt.GetoptError, err: |
614 | print >> sys.stderr, 'Error:', err | 652 | print >> sys.stderr, 'Error:', err |
653 | print >> sys.stderr, """ | ||
654 | Note: You must pass -D options to cmake after the "configure" command | ||
655 | For example: develop.py configure -DSERVER:BOOL=OFF""" | ||
615 | sys.exit(1) | 656 | sys.exit(1) |
616 | 657 | ||
617 | for o, a in opts: | 658 | for o, a in opts: |
@@ -619,9 +660,9 @@ def main(arguments): | |||
619 | print usage_msg.strip() | 660 | print usage_msg.strip() |
620 | sys.exit(0) | 661 | sys.exit(0) |
621 | elif o in ('--standalone',): | 662 | elif o in ('--standalone',): |
622 | setup.standalone = 'TRUE' | 663 | setup.standalone = 'ON' |
623 | elif o in ('--unattended',): | 664 | elif o in ('--unattended',): |
624 | setup.unattended = 'TRUE' | 665 | setup.unattended = 'ON' |
625 | elif o in ('-t', '--type'): | 666 | elif o in ('-t', '--type'): |
626 | try: | 667 | try: |
627 | setup.build_type = setup.build_types[a.lower()] | 668 | setup.build_type = setup.build_types[a.lower()] |
@@ -664,13 +705,14 @@ def main(arguments): | |||
664 | print >> sys.stderr, 'Error: unknown subcommand', repr(cmd) | 705 | print >> sys.stderr, 'Error: unknown subcommand', repr(cmd) |
665 | print >> sys.stderr, "(run 'develop.py --help' for help)" | 706 | print >> sys.stderr, "(run 'develop.py --help' for help)" |
666 | sys.exit(1) | 707 | sys.exit(1) |
667 | except CommandError, err: | ||
668 | print >> sys.stderr, 'Error:', err | ||
669 | sys.exit(1) | ||
670 | except getopt.GetoptError, err: | 708 | except getopt.GetoptError, err: |
671 | print >> sys.stderr, 'Error with %r subcommand: %s' % (cmd, err) | 709 | print >> sys.stderr, 'Error with %r subcommand: %s' % (cmd, err) |
672 | sys.exit(1) | 710 | sys.exit(1) |
673 | 711 | ||
674 | 712 | ||
675 | if __name__ == '__main__': | 713 | if __name__ == '__main__': |
676 | main(sys.argv[1:]) | 714 | try: |
715 | main(sys.argv[1:]) | ||
716 | except CommandError, err: | ||
717 | print >> sys.stderr, 'Error:', err | ||
718 | sys.exit(1) | ||