| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 from optparse import OptionParser | 6 from optparse import OptionParser |
| 7 import os | 7 import os |
| 8 import subprocess | 8 import subprocess |
| 9 import sys | 9 import sys |
| 10 | 10 |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 'WINDOWS' in define or | 202 'WINDOWS' in define or |
| 203 'WINVER' in define)] | 203 'WINVER' in define)] |
| 204 options += ['-D' + define for define in define_list] | 204 options += ['-D' + define for define in define_list] |
| 205 self.compile_options = options + ['-I' + name for name in self.inc_paths] | 205 self.compile_options = options + ['-I' + name for name in self.inc_paths] |
| 206 | 206 |
| 207 def BuildLinkOptions(self, options): | 207 def BuildLinkOptions(self, options): |
| 208 """Generates link options, called once by __init__.""" | 208 """Generates link options, called once by __init__.""" |
| 209 options = ArgToList(options) | 209 options = ArgToList(options) |
| 210 if self.toolname in ['glibc', 'newlib'] and self.mainarch == 'x86': | 210 if self.toolname in ['glibc', 'newlib'] and self.mainarch == 'x86': |
| 211 options += ['-B' + self.toollib] | 211 options += ['-B' + self.toollib] |
| 212 if self.outtype == 'nso': |
| 213 options += ['-Wl,-rpath-link,' + name for name in self.lib_paths] |
| 214 options += ['-shared'] |
| 215 options += ['-Wl,-soname,' + os.path.basename(self.name)] |
| 212 self.link_options = options + ['-L' + name for name in self.lib_paths] | 216 self.link_options = options + ['-L' + name for name in self.lib_paths] |
| 213 | 217 |
| 214 def BuildArchiveOptions(self): | 218 def BuildArchiveOptions(self): |
| 215 """Generates link options, called once by __init__.""" | 219 """Generates link options, called once by __init__.""" |
| 216 self.archive_options = [] | 220 self.archive_options = [] |
| 217 | 221 |
| 218 def Run(self, cmd_line, out): | 222 def Run(self, cmd_line, out): |
| 219 """Helper which runs a command line.""" | 223 """Helper which runs a command line.""" |
| 220 | 224 |
| 221 # For POSIX style path on windows for POSIX based toolchain | 225 # For POSIX style path on windows for POSIX based toolchain |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 err = self.Run(cmd_line, out) | 352 err = self.Run(cmd_line, out) |
| 349 if err: | 353 if err: |
| 350 ErrOut('\nFAILED with %d: %s\n\n' % (err, ' '.join(cmd_line))) | 354 ErrOut('\nFAILED with %d: %s\n\n' % (err, ' '.join(cmd_line))) |
| 351 return out | 355 return out |
| 352 | 356 |
| 353 def Generate(self, srcs): | 357 def Generate(self, srcs): |
| 354 """Generate final output file. | 358 """Generate final output file. |
| 355 | 359 |
| 356 Link or Archive the final output file, from the compiled sources. | 360 Link or Archive the final output file, from the compiled sources. |
| 357 """ | 361 """ |
| 358 if self.outtype == 'nexe': | 362 if self.outtype in ['nexe', 'nso']: |
| 359 out = self.Link(srcs) | 363 out = self.Link(srcs) |
| 360 if self.strip_debug: | 364 if self.strip_debug: |
| 361 self.Strip(out) | 365 self.Strip(out) |
| 362 elif self.outtype == 'nlib': | 366 elif self.outtype == 'nlib': |
| 363 self.Archive(srcs) | 367 self.Archive(srcs) |
| 364 | 368 |
| 365 | 369 |
| 366 def Main(argv): | 370 def Main(argv): |
| 367 parser = OptionParser() | 371 parser = OptionParser() |
| 368 parser.add_option('--empty', dest='empty', default=False, | 372 parser.add_option('--empty', dest='empty', default=False, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 out = build.Compile(filename) | 423 out = build.Compile(filename) |
| 420 if out: | 424 if out: |
| 421 objs.append(out) | 425 objs.append(out) |
| 422 # Do not link if building an object | 426 # Do not link if building an object |
| 423 if not options.compile_only: | 427 if not options.compile_only: |
| 424 build.Generate(objs) | 428 build.Generate(objs) |
| 425 return 0 | 429 return 0 |
| 426 | 430 |
| 427 if __name__ == '__main__': | 431 if __name__ == '__main__': |
| 428 sys.exit(Main(sys.argv)) | 432 sys.exit(Main(sys.argv)) |
| OLD | NEW |