| Index: pydir/build-pnacl-ir.py
|
| diff --git a/pydir/build-pnacl-ir.py b/pydir/build-pnacl-ir.py
|
| index 9395fc7f5777a5dfc25aabcc5e750efce3f30b08..608c574fe3c0d05d0891426cf9fedb28e9db734c 100755
|
| --- a/pydir/build-pnacl-ir.py
|
| +++ b/pydir/build-pnacl-ir.py
|
| @@ -2,35 +2,24 @@
|
|
|
| import argparse
|
| import os
|
| -import sys
|
| import tempfile
|
| from utils import shellcmd
|
| +from utils import FindBaseNaCl
|
|
|
| if __name__ == '__main__':
|
| argparser = argparse.ArgumentParser()
|
| argparser.add_argument('cfile', nargs='+', type=str,
|
| help='C file(s) to convert')
|
| - argparser.add_argument('--nacl_sdk_root', nargs='?', type=str,
|
| - help='Path to NACL_SDK_ROOT')
|
| argparser.add_argument('--dir', nargs='?', type=str, default='.',
|
| help='Output directory')
|
| argparser.add_argument('--disable-verify', action='store_true')
|
| args = argparser.parse_args()
|
|
|
| - nacl_sdk_root = os.environ.get('NACL_SDK_ROOT', None)
|
| - if args.nacl_sdk_root:
|
| - nacl_sdk_root = os.path.expanduser(args.nacl_sdk_root)
|
| -
|
| - if not nacl_sdk_root or not os.path.exists(nacl_sdk_root):
|
| - print '''\
|
| -Please set the NACL_SDK_ROOT environment variable or pass the path through
|
| ---nacl_sdk_root to point to a valid Native Client SDK installation.'''
|
| - sys.exit(1)
|
| -
|
| - includes_path = os.path.join(nacl_sdk_root, 'include')
|
| - toolchain_path = os.path.join(nacl_sdk_root, 'toolchain', 'linux_pnacl')
|
| - clang_path = os.path.join(toolchain_path, 'bin64', 'pnacl-clang')
|
| - opt_path = os.path.join(toolchain_path, 'host_x86_64', 'bin', 'opt')
|
| + nacl_root = FindBaseNaCl()
|
| + # Prepend bin to $PATH.
|
| + os.environ['PATH'] = (
|
| + nacl_root + '/toolchain/linux_x86/pnacl_newlib/bin' + os.pathsep +
|
| + os.pathsep + os.environ['PATH'])
|
|
|
| tempdir = tempfile.mkdtemp()
|
|
|
| @@ -40,11 +29,10 @@ Please set the NACL_SDK_ROOT environment variable or pass the path through
|
| pnaclname = basename + '.pnacl.ll'
|
| pnaclname = os.path.join(args.dir, pnaclname)
|
|
|
| - shellcmd(clang_path + ' -O2 -I{0} -c {1} -o {2}'.format(
|
| - includes_path, cname, llname))
|
| - shellcmd(opt_path +
|
| - ' -pnacl-abi-simplify-preopt -pnacl-abi-simplify-postopt' +
|
| - ('' if args.disable_verify else
|
| - ' -verify-pnaclabi-module -verify-pnaclabi-functions') +
|
| - ' -pnaclabi-allow-debug-metadata -disable-simplify-libcalls'
|
| - ' {0} -S -o {1}'.format(llname, pnaclname))
|
| + shellcmd('pnacl-clang -O2 -c {0} -o {1}'.format(cname, llname))
|
| + shellcmd('pnacl-opt ' +
|
| + '-pnacl-abi-simplify-preopt -pnacl-abi-simplify-postopt' +
|
| + ('' if args.disable_verify else
|
| + ' -verify-pnaclabi-module -verify-pnaclabi-functions') +
|
| + ' -pnaclabi-allow-debug-metadata'
|
| + ' {0} -S -o {1}'.format(llname, pnaclname))
|
|
|