blob: bdee0f80f11f0c73e6c5431a34acfb6f889b64f2 [file] [log] [blame]
Jeremy Johnsonbe1a9402021-12-15 17:14:56 +00001#!/usr/bin/env python3
2"""Mocked flatc compiler for testing."""
3# Copyright (c) 2021-2022, ARM Limited.
4# SPDX-License-Identifier: Apache-2.0
5from pathlib import Path
6
7
8def main(argv=None):
9 """Mock the required behaviour of the flatc compiler."""
10 import argparse
11
12 parser = argparse.ArgumentParser()
13 parser.add_argument(
14 "-o",
15 dest="output_dir",
16 type=Path,
17 help="output directory",
18 )
19 parser.add_argument(
20 "--json",
21 action="store_true",
22 help="convert to JSON",
23 )
24 parser.add_argument(
25 "--binary",
26 action="store_true",
27 help="convert to binary",
28 )
29 parser.add_argument(
30 "--raw-binary",
31 action="store_true",
32 help="convert from raw-binary",
33 )
34 parser.add_argument(
35 "path",
36 type=Path,
37 action="append",
38 nargs="*",
39 help="the path to fbs or files to convert",
40 )
41
42 args = parser.parse_args(argv)
43 path = args.path
44 if len(path) == 0:
45 print("ERROR: Missing fbs files and files to convert")
46 return 2
47 return 0
48
49
50if __name__ == "__main__":
51 exit(main())