OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/python | |
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 | |
4 # found in the LICENSE file. | |
5 # | |
6 # MIPS32 TOOLCHAIN SETTINGS FOR TRUSTED CODE | |
Mark Seaborn
2012/09/18 03:24:34
This script is based on setup_arm_trusted_toolchai
petarj
2012/09/19 17:27:51
Done.
| |
7 # | |
8 # This can either be imported as a python script | |
9 # or used in a shell script, by doing: | |
10 # eval "$(tools/llvm/setup_mips32_trusted_toolchain.py)" | |
11 # | |
12 # | |
13 # If imported as a python script, it provides two variables: | |
14 # mips32_env = dictionary of MIPS32 environment | |
15 # shell_exports = keys which are normally exported to the shell environment | |
16 | |
17 import os | |
18 import sys | |
19 | |
20 if os.path.basename(os.getcwd()) != 'native_client': | |
21 print "Error: Run this script from native_client/" | |
22 sys.exit(1) | |
23 | |
24 # Alias for convenience | |
25 J = os.path.join | |
26 | |
27 NACL_ROOT = os.getcwd() | |
28 BASE_DIR = J(NACL_ROOT, 'toolchain', 'linux_mips-trusted') | |
29 MIPS32_CROSS_TARGET = 'mips-linux-gnu' | |
30 CODE_SOURCERY_PREFIX = J(BASE_DIR, 'mips-release', 'bin', MIPS32_CROSS_TARGET) | |
31 CODE_SOURCERY_JAIL = J(BASE_DIR, 'mips-release', MIPS32_CROSS_TARGET, 'libc', 'e l') | |
32 LD_SCRIPT_TRUSTED = J(BASE_DIR, 'ld_script_mips_trusted') | |
33 | |
34 BASE_CC = ("%s-%%s -Werror -O2 %%s " | |
35 "-fdiagnostics-show-option " | |
36 "-I%s/usr/include -march=mips32r2 -EL " | |
37 "-Wl,-EL -Wl,-T -Wl,%s") % (CODE_SOURCERY_PREFIX, | |
38 CODE_SOURCERY_JAIL, | |
39 LD_SCRIPT_TRUSTED) | |
40 | |
41 # Shell exports | |
42 MIPS32_CC = BASE_CC % ('gcc', '-std=gnu99') | |
43 MIPS32_CXX = BASE_CC % ('g++', '') | |
44 MIPS32_LD = '%s-ld' % CODE_SOURCERY_PREFIX | |
45 MIPS32_LINKFLAGS = '' | |
46 MIPS32_LIB_DIR = J(CODE_SOURCERY_JAIL, 'usr', 'lib') | |
47 MIPS32_EMU = J(BASE_DIR, 'run_under_qemu_mips32') | |
48 | |
49 # Don't actually emit BASE_CC | |
50 del BASE_CC | |
51 | |
52 shell_exports = [ | |
53 'NACL_ROOT', | |
54 'MIPS32_CC', | |
55 'MIPS32_CXX', | |
56 'MIPS32_LD', | |
57 'MIPS32_LINKFLAGS', | |
58 'MIPS32_LIB_DIR', | |
59 'MIPS32_EMU' | |
60 ] | |
61 | |
62 # Store the values into a dict | |
63 mips32_env = {} | |
64 for k,v in dict(globals()).iteritems(): | |
65 if k.startswith('_') or not isinstance(v, str): | |
66 continue | |
67 mips32_env[k] = v | |
68 | |
69 if __name__ == '__main__': | |
70 # Print the values out, for use in a shell script | |
71 for k,v in mips32_env.iteritems(): | |
72 if k in shell_exports: | |
73 prefix = 'export ' | |
74 else: | |
75 prefix = '' | |
76 print '%s%s="%s";' % (prefix,k,v) | |
OLD | NEW |