Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2015 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2015 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 """Recipes for PNaCl sandboxed translator packages.""" | 6 """Recipes for PNaCl sandboxed translator packages.""" |
| 7 | 7 |
| 8 import os | 8 import os |
| 9 import sys | 9 import sys |
| 10 | 10 |
| 11 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) | 11 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) |
| 12 import pynacl.gsd_storage | 12 import pynacl.gsd_storage |
| 13 import pynacl.platform | 13 import pynacl.platform |
| 14 | 14 |
| 15 import command | 15 import command |
| 16 | 16 |
| 17 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | 17 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 18 NACL_DIR = os.path.dirname(SCRIPT_DIR) | 18 NACL_DIR = os.path.dirname(SCRIPT_DIR) |
| 19 | 19 |
| 20 | 20 |
| 21 def GSDJoin(*args): | 21 def GSDJoin(*args): |
| 22 return '_'.join([pynacl.gsd_storage.LegalizeName(arg) for arg in args]) | 22 return '_'.join([pynacl.gsd_storage.LegalizeName(arg) for arg in args]) |
| 23 | 23 |
| 24 | 24 |
| 25 def SandboxedTranslators(arches): | 25 def SandboxedTranslators(arches): |
| 26 le32_packages = ['newlib_le32', 'libcxx_le32', 'libs_support_le32', | 26 le32_packages = ['newlib_le32', 'libcxx_le32', 'libs_support_le32', |
| 27 'core_sdk_libs_le32', 'metadata', 'compiler_rt_bc_le32'] | 27 'core_sdk_libs_le32', 'metadata', 'compiler_rt_bc_le32'] |
| 28 # These are required for building IRT-environment targets, which SCons does | |
| 29 # as a side effect of building the same targets in the le32 environment. | |
| 30 # (e.g. when you build libnacl_sys_private, that gets built in both the IRT | |
| 31 # and pexe environments). | |
| 32 naclclang_packages = ['newlib_%s' % arch for arch in ['i686', 'x86_64','arm']] | |
|
Mark Seaborn
2015/03/25 08:37:00
Nit: add space after ',' (but then wrap to 80 char
Derek Schuff
2015/03/25 18:04:20
(Busted!) Done.
| |
| 28 private_libs = ['libnacl_sys_private', 'libpthread_private', 'libplatform', | 33 private_libs = ['libnacl_sys_private', 'libpthread_private', 'libplatform', |
| 29 'libimc', 'libimc_syscalls', 'libsrpc', 'libgio'] | 34 'libimc', 'libimc_syscalls', 'libsrpc', 'libgio'] |
| 30 arch_packages = ['libs_support_translator', 'compiler_rt'] | 35 arch_packages = ['libs_support_translator', 'compiler_rt'] |
| 31 arch_deps = [GSDJoin(p, arch) | 36 arch_deps = [GSDJoin(p, arch) |
| 32 for p in arch_packages for arch in arches] | 37 for p in arch_packages for arch in arches] |
| 33 | 38 |
| 34 | 39 |
| 35 def TranslatorLibDir(arch): | 40 def TranslatorLibDir(arch): |
| 36 return os.path.join('%(output)s', 'translator', | 41 return os.path.join('%(output)s', 'translator', |
| 37 pynacl.platform.GetArch3264(arch), 'lib') | 42 pynacl.platform.GetArch3264(arch), 'lib') |
| 38 translators = { | 43 translators = { |
| 39 # The translator build requires the PNaCl compiler, the le32 target libs, | 44 # The translator build requires the PNaCl compiler, the le32 target libs, |
| 40 # the le32 core SDK libs, the native translator libs for the target arches | 45 # the le32 core SDK libs, the native translator libs for the target arches |
| 41 # and the le32 private (non-IRT) libs. All except the last | 46 # and the le32 private (non-IRT) libs. All except the last |
| 42 # are already built, so we copy those, and build the non-IRT libs here. | 47 # are already built, so we copy those, and build the non-IRT libs here. |
| 43 'translator_compiler': { | 48 'translator_compiler': { |
| 44 'type': 'work', | 49 'type': 'work', |
| 45 'dependencies': ['target_lib_compiler'] + le32_packages + arch_deps, | 50 'dependencies': ['target_lib_compiler'] + ( |
| 51 le32_packages + arch_deps + naclclang_packages), | |
| 46 'inputs': { | 52 'inputs': { |
| 47 'src_untrusted': os.path.join(NACL_DIR, 'src', 'untrusted'), | 53 'src_untrusted': os.path.join(NACL_DIR, 'src', 'untrusted'), |
| 48 'src_include': os.path.join(NACL_DIR, 'src', 'include'), | 54 'src_include': os.path.join(NACL_DIR, 'src', 'include'), |
| 49 'scons.py': os.path.join(NACL_DIR, 'scons.py'), | 55 'scons.py': os.path.join(NACL_DIR, 'scons.py'), |
| 50 'site_scons': os.path.join(NACL_DIR, 'site_scons'), | 56 'site_scons': os.path.join(NACL_DIR, 'site_scons'), |
| 51 }, | 57 }, |
| 52 'commands': [ | 58 'commands': [ |
| 53 # Copy the le32 bitcode libs | 59 # Copy the required libs |
| 54 command.CopyRecursive('%(' + p + ')s', '%(output)s') | 60 command.CopyRecursive('%(' + p + ')s', '%(output)s') |
| 55 for p in ['target_lib_compiler'] + le32_packages] + [ | 61 for p in ['target_lib_compiler'] + |
| 62 le32_packages + naclclang_packages] + [ | |
| 56 # Build the non-IRT libs | 63 # Build the non-IRT libs |
| 57 command.Command([sys.executable, '%(scons.py)s', | 64 command.Command([sys.executable, '%(scons.py)s', |
| 58 '--verbose', 'bitcode=1', 'platform=x86-32', | 65 '--verbose', 'bitcode=1', 'platform=x86-32', |
| 59 'pnacl_newlib_dir=%(output)s'] + private_libs, | 66 'pnacl_newlib_dir=%(output)s'] + private_libs, |
| 60 cwd=NACL_DIR)] + [ | 67 cwd=NACL_DIR)] + [ |
| 61 command.Copy( | 68 command.Copy( |
| 62 os.path.join(NACL_DIR, 'scons-out', | 69 os.path.join(NACL_DIR, 'scons-out', |
| 63 'nacl-x86-32-pnacl-pexe-clang', 'lib', lib + '.a'), | 70 'nacl-x86-32-pnacl-pexe-clang', 'lib', lib + '.a'), |
| 64 os.path.join('%(output)s', 'le32-nacl', 'lib', lib + '.a')) | 71 os.path.join('%(output)s', 'le32-nacl', 'lib', lib + '.a')) |
| 65 for lib in private_libs] + [ | 72 for lib in private_libs] + [ |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 76 'build': os.path.join(NACL_DIR, 'pnacl', 'build.sh'), | 83 'build': os.path.join(NACL_DIR, 'pnacl', 'build.sh'), |
| 77 '_': os.path.join(NACL_DIR, 'pnacl', 'scripts', 'common-tools.sh'), | 84 '_': os.path.join(NACL_DIR, 'pnacl', 'scripts', 'common-tools.sh'), |
| 78 }, | 85 }, |
| 79 'commands': [ | 86 'commands': [ |
| 80 command.Command(['%(abs_build)s', 'translator-all']), | 87 command.Command(['%(abs_build)s', 'translator-all']), |
| 81 command.Command(['%(abs_build)s', 'translator-prune']), | 88 command.Command(['%(abs_build)s', 'translator-prune']), |
| 82 ], | 89 ], |
| 83 }, | 90 }, |
| 84 } | 91 } |
| 85 return translators | 92 return translators |
| OLD | NEW |