| Index: tools/trusted_cross_toolchains/setup_mips32_trusted_toolchain.py
|
| diff --git a/tools/trusted_cross_toolchains/setup_mips32_trusted_toolchain.py b/tools/trusted_cross_toolchains/setup_mips32_trusted_toolchain.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..94701318b562c17228b28dda9aa062cd1ab4dccc
|
| --- /dev/null
|
| +++ b/tools/trusted_cross_toolchains/setup_mips32_trusted_toolchain.py
|
| @@ -0,0 +1,76 @@
|
| +#!/usr/bin/python
|
| +# Copyright (c) 2012 The Native Client Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +#
|
| +# MIPS32 TOOLCHAIN SETTINGS FOR TRUSTED CODE
|
| +#
|
| +# This can either be imported as a python script
|
| +# or used in a shell script, by doing:
|
| +# eval "$(tools/llvm/setup_mips32_trusted_toolchain.py)"
|
| +#
|
| +#
|
| +# If imported as a python script, it provides two variables:
|
| +# mips32_env = dictionary of MIPS32 environment
|
| +# shell_exports = keys which are normally exported to the shell environment
|
| +
|
| +import os
|
| +import sys
|
| +
|
| +if os.path.basename(os.getcwd()) != 'native_client':
|
| + print "Error: Run this script from native_client/"
|
| + sys.exit(1)
|
| +
|
| +# Alias for convenience
|
| +J = os.path.join
|
| +
|
| +NACL_ROOT = os.getcwd()
|
| +BASE_DIR = J(NACL_ROOT, 'toolchain', 'linux_mips-trusted')
|
| +MIPS32_CROSS_TARGET = 'mips-linux-gnu'
|
| +CODE_SOURCERY_PREFIX = J(BASE_DIR, 'mips-release', 'bin', MIPS32_CROSS_TARGET)
|
| +CODE_SOURCERY_JAIL = J(BASE_DIR, 'mips-release', MIPS32_CROSS_TARGET, 'libc', 'el')
|
| +LD_SCRIPT_TRUSTED = J(BASE_DIR, 'ld_script_mips_trusted')
|
| +
|
| +BASE_CC = ("%s-%%s -Werror -O2 %%s "
|
| + "-fdiagnostics-show-option "
|
| + "-I%s/usr/include -march=mips32r2 -EL "
|
| + "-Wl,-EL -Wl,-T -Wl,%s") % (CODE_SOURCERY_PREFIX,
|
| + CODE_SOURCERY_JAIL,
|
| + LD_SCRIPT_TRUSTED)
|
| +
|
| +# Shell exports
|
| +MIPS32_CC = BASE_CC % ('gcc', '-std=gnu99')
|
| +MIPS32_CXX = BASE_CC % ('g++', '')
|
| +MIPS32_LD = '%s-ld' % CODE_SOURCERY_PREFIX
|
| +MIPS32_LINKFLAGS = ''
|
| +MIPS32_LIB_DIR = J(CODE_SOURCERY_JAIL, 'usr', 'lib')
|
| +MIPS32_EMU = J(BASE_DIR, 'run_under_qemu_mips32')
|
| +
|
| +# Don't actually emit BASE_CC
|
| +del BASE_CC
|
| +
|
| +shell_exports = [
|
| + 'NACL_ROOT',
|
| + 'MIPS32_CC',
|
| + 'MIPS32_CXX',
|
| + 'MIPS32_LD',
|
| + 'MIPS32_LINKFLAGS',
|
| + 'MIPS32_LIB_DIR',
|
| + 'MIPS32_EMU'
|
| +]
|
| +
|
| +# Store the values into a dict
|
| +mips32_env = {}
|
| +for k,v in dict(globals()).iteritems():
|
| + if k.startswith('_') or not isinstance(v, str):
|
| + continue
|
| + mips32_env[k] = v
|
| +
|
| +if __name__ == '__main__':
|
| + # Print the values out, for use in a shell script
|
| + for k,v in mips32_env.iteritems():
|
| + if k in shell_exports:
|
| + prefix = 'export '
|
| + else:
|
| + prefix = ''
|
| + print '%s%s="%s";' % (prefix,k,v)
|
|
|