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