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 |
| 33 for arch in ['i686', 'x86_64', 'arm']] |
28 private_libs = ['libnacl_sys_private', 'libpthread_private', 'libplatform', | 34 private_libs = ['libnacl_sys_private', 'libpthread_private', 'libplatform', |
29 'libimc', 'libimc_syscalls', 'libsrpc', 'libgio'] | 35 'libimc', 'libimc_syscalls', 'libsrpc', 'libgio'] |
30 arch_packages = ['libs_support_translator', 'compiler_rt'] | 36 arch_packages = ['libs_support_translator', 'compiler_rt'] |
31 arch_deps = [GSDJoin(p, arch) | 37 arch_deps = [GSDJoin(p, arch) |
32 for p in arch_packages for arch in arches] | 38 for p in arch_packages for arch in arches] |
33 | 39 |
34 | 40 |
35 def TranslatorLibDir(arch): | 41 def TranslatorLibDir(arch): |
36 return os.path.join('%(output)s', 'translator', | 42 return os.path.join('%(output)s', 'translator', |
37 pynacl.platform.GetArch3264(arch), 'lib') | 43 pynacl.platform.GetArch3264(arch), 'lib') |
38 translators = { | 44 translators = { |
39 # The translator build requires the PNaCl compiler, the le32 target libs, | 45 # 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 | 46 # 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 | 47 # 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. | 48 # are already built, so we copy those, and build the non-IRT libs here. |
43 'translator_compiler': { | 49 'translator_compiler': { |
44 'type': 'work', | 50 'type': 'work', |
45 'dependencies': ['target_lib_compiler'] + le32_packages + arch_deps, | 51 'dependencies': ['target_lib_compiler'] + ( |
| 52 le32_packages + arch_deps + naclclang_packages), |
46 'inputs': { | 53 'inputs': { |
47 'src_untrusted': os.path.join(NACL_DIR, 'src', 'untrusted'), | 54 'src_untrusted': os.path.join(NACL_DIR, 'src', 'untrusted'), |
48 'src_include': os.path.join(NACL_DIR, 'src', 'include'), | 55 'src_include': os.path.join(NACL_DIR, 'src', 'include'), |
49 'scons.py': os.path.join(NACL_DIR, 'scons.py'), | 56 'scons.py': os.path.join(NACL_DIR, 'scons.py'), |
50 'site_scons': os.path.join(NACL_DIR, 'site_scons'), | 57 'site_scons': os.path.join(NACL_DIR, 'site_scons'), |
51 }, | 58 }, |
52 'commands': [ | 59 'commands': [ |
53 # Copy the le32 bitcode libs | 60 # Copy the required libs |
54 command.CopyRecursive('%(' + p + ')s', '%(output)s') | 61 command.CopyRecursive('%(' + p + ')s', '%(output)s') |
55 for p in ['target_lib_compiler'] + le32_packages] + [ | 62 for p in ['target_lib_compiler'] + |
| 63 le32_packages + naclclang_packages] + [ |
56 # Build the non-IRT libs | 64 # Build the non-IRT libs |
57 command.Command([sys.executable, '%(scons.py)s', | 65 command.Command([sys.executable, '%(scons.py)s', |
58 '--verbose', 'bitcode=1', 'platform=x86-32', | 66 '--verbose', 'bitcode=1', 'platform=x86-32', |
59 'pnacl_newlib_dir=%(output)s'] + private_libs, | 67 'pnacl_newlib_dir=%(output)s'] + private_libs, |
60 cwd=NACL_DIR)] + [ | 68 cwd=NACL_DIR)] + [ |
61 command.Copy( | 69 command.Copy( |
62 os.path.join(NACL_DIR, 'scons-out', | 70 os.path.join(NACL_DIR, 'scons-out', |
63 'nacl-x86-32-pnacl-pexe-clang', 'lib', lib + '.a'), | 71 'nacl-x86-32-pnacl-pexe-clang', 'lib', lib + '.a'), |
64 os.path.join('%(output)s', 'le32-nacl', 'lib', lib + '.a')) | 72 os.path.join('%(output)s', 'le32-nacl', 'lib', lib + '.a')) |
65 for lib in private_libs] + [ | 73 for lib in private_libs] + [ |
(...skipping 10 matching lines...) Expand all Loading... |
76 'build': os.path.join(NACL_DIR, 'pnacl', 'build.sh'), | 84 'build': os.path.join(NACL_DIR, 'pnacl', 'build.sh'), |
77 '_': os.path.join(NACL_DIR, 'pnacl', 'scripts', 'common-tools.sh'), | 85 '_': os.path.join(NACL_DIR, 'pnacl', 'scripts', 'common-tools.sh'), |
78 }, | 86 }, |
79 'commands': [ | 87 'commands': [ |
80 command.Command(['%(abs_build)s', 'translator-all']), | 88 command.Command(['%(abs_build)s', 'translator-all']), |
81 command.Command(['%(abs_build)s', 'translator-prune']), | 89 command.Command(['%(abs_build)s', 'translator-prune']), |
82 ], | 90 ], |
83 }, | 91 }, |
84 } | 92 } |
85 return translators | 93 return translators |
OLD | NEW |