| #!/usr/bin/python |
| # Copyright (c) 2014 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. |
| # |
| |
| import sys |
| |
| class DriverState : |
| def __init__(self, tool): |
| self.config = { |
| 'compile' : False, |
| 'nostdinc' : False, |
| 'nostdlib' : False, |
| 'tool' : tool, |
| 'target' : tool.split('-') + '-unknown-nacl', |
| } |
| |
| self.switches = { |
| '-c' : ('compile', True), |
| '-nostdinc' : ('nostdinc', True), |
| '-nostdlib' : ('nostdlib', True), |
| '-m32' : ('arch', 'i686-unknown-nacl'), |
| '-m64' : ('arch', 'x86_64-unknown-nacl'), |
| '-marm' : ('arch', 'arm-unknown-nacl'), |
| } |
| self.root = os.path.dirname(os.path.dirname(tool)) |
| |
| def ParseArgs(self, argv): |
| for arg in argv: |
| if arg in self.switches: |
| xform = list(self.switches[arg]) |
| if len > 1: |
| key = xform[0] |
| val = xform[1] |
| else: |
| key = arg |
| val = xform[0] |
| data[key] = val |
| |
| def GetIncludes(self): |
| includes = [ |
| return includes |
| |
| def BuildCompileCommand(self, args): |
| out_args = [ |
| '-target=%s' % self.config['arch'], |
| '-integrated-as', |
| '-nostdinc', |
| '-nostdlib' |
| ] |
| if not self.config['nostdinc']: |
| out_args.append('-I' + os.path.join(self.root, 'include')) |
| |
| |
| |
| TARGET_MAP = { |
| 'x86_64-nacl' : 'x86_64-unknown-nacl', |
| 'i686-nacl' : 'i686-unknown-nacl', |
| 'arm-nacl' : 'arm-unknown-nacl', |
| } |
| |
| |
| def main(argv): |
| DriverState state(argv) |
| |
| |
| if __name__ == '__main__': |
| sys.exit(main(sys.argv)) |