OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import argparse | 6 import argparse |
7 import os.path | 7 import os.path |
8 import sys | 8 import sys |
9 | 9 |
10 def main(): | 10 def main(): |
11 parser = argparse.ArgumentParser( | 11 parser = argparse.ArgumentParser( |
12 description="GYP helper script for mapping mojoms => generated outputs.") | 12 description="GYP helper script for mapping mojoms => generated outputs.") |
13 parser.add_argument("--basedir", required=True) | 13 parser.add_argument("--basedir", required=True) |
| 14 parser.add_argument("--variant", required=True) |
14 parser.add_argument("mojom", nargs="*") | 15 parser.add_argument("mojom", nargs="*") |
15 | 16 |
16 args = parser.parse_args() | 17 args = parser.parse_args() |
17 | 18 |
| 19 variant = args.variant if args.variant != "none" else None |
| 20 |
18 for mojom in args.mojom: | 21 for mojom in args.mojom: |
19 full = os.path.join("<(SHARED_INTERMEDIATE_DIR)", args.basedir, mojom) | 22 full = os.path.join("<(SHARED_INTERMEDIATE_DIR)", args.basedir, mojom) |
20 base, ext = os.path.splitext(full) | 23 base, ext = os.path.splitext(full) |
21 assert ext == ".mojom", mojom | 24 |
| 25 # Ignore non-mojom files. |
| 26 if ext != ".mojom": |
| 27 continue |
| 28 |
22 # Fix filename escaping issues on Windows. | 29 # Fix filename escaping issues on Windows. |
23 base = base.replace("\\", "/") | 30 base = base.replace("\\", "/") |
24 print base + ".mojom.cc" | 31 if variant: |
25 print base + ".mojom.h" | 32 print base + ".mojom-%s.cc" % variant |
26 print base + ".mojom-internal.h" | 33 print base + ".mojom-%s.h" % variant |
27 print base + ".mojom.js" | 34 print base + ".mojom-%s-internal.h" % variant |
| 35 else: |
| 36 print base + ".mojom.cc" |
| 37 print base + ".mojom.h" |
| 38 print base + ".mojom-internal.h" |
| 39 print base + ".mojom.js" |
28 | 40 |
29 return 0 | 41 return 0 |
30 | 42 |
31 if __name__ == "__main__": | 43 if __name__ == "__main__": |
32 sys.exit(main()) | 44 sys.exit(main()) |
OLD | NEW |