aboutsummaryrefslogtreecommitdiff
path: root/verif/tests/mock_flatc.py
blob: bdee0f80f11f0c73e6c5431a34acfb6f889b64f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python3
"""Mocked flatc compiler for testing."""
# Copyright (c) 2021-2022, ARM Limited.
# SPDX-License-Identifier: Apache-2.0
from pathlib import Path


def main(argv=None):
    """Mock the required behaviour of the flatc compiler."""
    import argparse

    parser = argparse.ArgumentParser()
    parser.add_argument(
        "-o",
        dest="output_dir",
        type=Path,
        help="output directory",
    )
    parser.add_argument(
        "--json",
        action="store_true",
        help="convert to JSON",
    )
    parser.add_argument(
        "--binary",
        action="store_true",
        help="convert to binary",
    )
    parser.add_argument(
        "--raw-binary",
        action="store_true",
        help="convert from raw-binary",
    )
    parser.add_argument(
        "path",
        type=Path,
        action="append",
        nargs="*",
        help="the path to fbs or files to convert",
    )

    args = parser.parse_args(argv)
    path = args.path
    if len(path) == 0:
        print("ERROR: Missing fbs files and files to convert")
        return 2
    return 0


if __name__ == "__main__":
    exit(main())