Kshitij Sisodia | f9efe0d | 2022-09-30 16:42:50 +0100 | [diff] [blame] | 1 | # SPDX-FileCopyrightText: Copyright 2021-2022 Arm Limited and/or its affiliates <open-source-office@arm.com> |
| 2 | # SPDX-License-Identifier: Apache-2.0 |
| 3 | """ |
| 4 | This script executes SWIG commands to generate C++ library wrappers. |
| 5 | """ |
| 6 | import subprocess |
| 7 | from pathlib import Path |
| 8 | |
| 9 | __current_dir = Path(__file__).parent.absolute() |
| 10 | |
| 11 | |
| 12 | def generate_wrap(name, extr_includes): |
| 13 | print('Generating wrappers for {}'.format(name)) |
| 14 | subprocess.check_output("swig -v -c++ -python" + |
| 15 | " -Wall" + |
| 16 | " -o {}/src/ethosu_driver/_generated/{}_wrap.cpp ".format(__current_dir, name) + |
| 17 | "-outdir {}/src/ethosu_driver/_generated ".format(__current_dir) + |
| 18 | "{} ".format(extr_includes) + |
| 19 | "-I{}/src/ethosu_driver/swig ".format(__current_dir) + |
| 20 | "{}/src/ethosu_driver/swig/{}.i".format(__current_dir, name), |
| 21 | shell=True, |
| 22 | stderr=subprocess.STDOUT) |
| 23 | |
| 24 | |
| 25 | if __name__ == "__main__": |
| 26 | includes = ["{}/../../driver_library/include".format(__current_dir)] |
| 27 | generate_wrap('driver', "-I{} ".format(' -I'.join(includes))) |