| 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 """NEXE building script | 6 """NEXE building script |
| 7 | 7 |
| 8 This module will take a set of source files, include paths, library paths, and | 8 This module will take a set of source files, include paths, library paths, and |
| 9 additional arguments, and use them to build. | 9 additional arguments, and use them to build. |
| 10 """ | 10 """ |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 import time | 24 import time |
| 25 import traceback | 25 import traceback |
| 26 import urllib2 | 26 import urllib2 |
| 27 | 27 |
| 28 from build_nexe_tools import (CommandRunner, Error, FixPath, | 28 from build_nexe_tools import (CommandRunner, Error, FixPath, |
| 29 IsFile, MakeDir, RemoveFile) | 29 IsFile, MakeDir, RemoveFile) |
| 30 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) | 30 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) |
| 31 import pynacl.platform | 31 import pynacl.platform |
| 32 | 32 |
| 33 | 33 |
| 34 # When a header file defining NACL_BUILD_SUBARCH is introduced, |
| 35 # we can simply remove this map. |
| 36 # cf) https://code.google.com/p/chromium/issues/detail?id=440012. |
| 37 NACL_BUILD_ARCH_MAP = { |
| 38 'x86-32': ['NACL_BUILD_ARCH=x86', 'NACL_BUILD_SUBARCH=32'], |
| 39 'x86-32-nonsfi': ['NACL_BUILD_ARCH=x86', 'NACL_BUILD_SUBARCH=32'], |
| 40 'x86-64': ['NACL_BUILD_ARCH=x86', 'NACL_BUILD_SUBARCH=64'], |
| 41 'arm': ['NACL_BUILD_ARCH=arm', 'NACL_BUILD_SUBARCH=32'], |
| 42 'arm-nonsfi': ['NACL_BUILD_ARCH=arm', 'NACL_BUILD_SUBARCH=32'], |
| 43 'mips': ['NACL_BUILD_ARCH=mips', 'NACL_BUILD_SUBARCH=32'], |
| 44 'pnacl': ['NACL_BUILD_ARCH=pnacl'], |
| 45 } |
| 46 |
| 47 |
| 34 def RemoveQuotes(opt): | 48 def RemoveQuotes(opt): |
| 35 if opt and opt[0] == '"': | 49 if opt and opt[0] == '"': |
| 36 assert opt[-1] == '"', opt | 50 assert opt[-1] == '"', opt |
| 37 return opt[1:-1].replace('\\"', '"') | 51 return opt[1:-1].replace('\\"', '"') |
| 38 return opt | 52 return opt |
| 39 | 53 |
| 40 | 54 |
| 41 def ArgToList(opt): | 55 def ArgToList(opt): |
| 42 outlist = [] | 56 outlist = [] |
| 43 if opt is None: | 57 if opt is None: |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 define.startswith('NACL_BUILD_ARCH=') or | 344 define.startswith('NACL_BUILD_ARCH=') or |
| 331 define.startswith('NACL_BUILD_SUBARCH=') or | 345 define.startswith('NACL_BUILD_SUBARCH=') or |
| 332 define == 'COMPONENT_BUILD' or | 346 define == 'COMPONENT_BUILD' or |
| 333 'WIN32' in define or | 347 'WIN32' in define or |
| 334 'WINDOWS' in define or | 348 'WINDOWS' in define or |
| 335 'WINVER' in define)] | 349 'WINVER' in define)] |
| 336 define_list.extend(['NACL_WINDOWS=0', | 350 define_list.extend(['NACL_WINDOWS=0', |
| 337 'NACL_OSX=0', | 351 'NACL_OSX=0', |
| 338 'NACL_LINUX=0', | 352 'NACL_LINUX=0', |
| 339 'NACL_ANDROID=0']) | 353 'NACL_ANDROID=0']) |
| 340 if arch == 'pnacl': | 354 define_list.extend(NACL_BUILD_ARCH_MAP[arch]) |
| 341 define_list.extend(['NACL_BUILD_ARCH=pnacl']) | |
| 342 options += ['-D' + define for define in define_list] | 355 options += ['-D' + define for define in define_list] |
| 343 self.compile_options = options + ['-I' + name for name in self.inc_paths] | 356 self.compile_options = options + ['-I' + name for name in self.inc_paths] |
| 344 | 357 |
| 345 def BuildLinkOptions(self, options): | 358 def BuildLinkOptions(self, options): |
| 346 """Generates link options, called once by __init__.""" | 359 """Generates link options, called once by __init__.""" |
| 347 options = ArgToList(options) | 360 options = ArgToList(options) |
| 348 if self.outtype == 'nso': | 361 if self.outtype == 'nso': |
| 349 options += ['-Wl,-rpath-link,' + name for name in self.lib_paths] | 362 options += ['-Wl,-rpath-link,' + name for name in self.lib_paths] |
| 350 options += ['-shared'] | 363 options += ['-shared'] |
| 351 options += ['-Wl,-soname,' + os.path.basename(self.Soname())] | 364 options += ['-Wl,-soname,' + os.path.basename(self.Soname())] |
| (...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1018 if build is not None: | 1031 if build is not None: |
| 1019 build.EmitDeferredLog() | 1032 build.EmitDeferredLog() |
| 1020 return 1 | 1033 return 1 |
| 1021 except: | 1034 except: |
| 1022 if build is not None: | 1035 if build is not None: |
| 1023 build.EmitDeferredLog() | 1036 build.EmitDeferredLog() |
| 1024 raise | 1037 raise |
| 1025 | 1038 |
| 1026 if __name__ == '__main__': | 1039 if __name__ == '__main__': |
| 1027 sys.exit(Main(sys.argv)) | 1040 sys.exit(Main(sys.argv)) |
| OLD | NEW |