OLD | NEW |
| (Empty) |
1 #!/usr/bin/env python | |
2 # Copyright 2016 The Chromium 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 # mojom_tool.py invokes the mojom tool built for the operating system and | |
7 # architecture on which this script is run. It forwards all of its command | |
8 # line arguments to the mojom tool blindly. This script's exit code is the | |
9 # mojom tool's exit code. | |
10 | |
11 import os | |
12 import platform | |
13 import subprocess | |
14 import sys | |
15 | |
16 def main(args): | |
17 # We assume this script is located in the Mojo SDK in tools/bindings. | |
18 this_dir = os.path.abspath(os.path.dirname(__file__)) | |
19 | |
20 system_dirs = { | |
21 ('Linux', '64bit'): 'linux64', | |
22 ('Darwin', '64bit'): 'mac64', | |
23 } | |
24 system = (platform.system(), platform.architecture()[0]) | |
25 if system not in system_dirs: | |
26 raise Exception('The mojom tool only supports Linux or Mac 64 bits.') | |
27 | |
28 mojom_tool = os.path.join( | |
29 this_dir, 'mojom_tool', 'bin', system_dirs[system], 'mojom') | |
30 | |
31 if not os.path.exists(mojom_tool): | |
32 raise Exception( | |
33 "The mojom tool could not be found at %s. " | |
34 "You may need to run gclient sync." | |
35 % mojom_tool) | |
36 | |
37 cmd = [mojom_tool] | |
38 cmd.extend(args) | |
39 | |
40 process = subprocess.Popen(cmd) | |
41 return process.wait() | |
42 | |
43 if __name__ == "__main__": | |
44 sys.exit(main(sys.argv[1:])) | |
OLD | NEW |