blob: 8394d968ab363ab2fb75b8cff314277ca0d81199 [file] [log] [blame]
Mikael Olssone87446c2023-12-15 17:17:06 +01001# SPDX-FileCopyrightText: Copyright 2021-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
Kshitij Sisodiaf9efe0d2022-09-30 16:42:50 +01002# SPDX-License-Identifier: Apache-2.0
3"""
4This script executes SWIG commands to generate C++ library wrappers.
5"""
6import subprocess
7from pathlib import Path
8
9__current_dir = Path(__file__).parent.absolute()
10
11
12def generate_wrap(name, extr_includes):
13 print('Generating wrappers for {}'.format(name))
14 subprocess.check_output("swig -v -c++ -python" +
15 " -Wall" +
Mikael Olssone87446c2023-12-15 17:17:06 +010016 " -DSWIGWORDSIZE64 " + # Force 64-bit word size for uint64_t vector to work
Kshitij Sisodiaf9efe0d2022-09-30 16:42:50 +010017 " -o {}/src/ethosu_driver/_generated/{}_wrap.cpp ".format(__current_dir, name) +
18 "-outdir {}/src/ethosu_driver/_generated ".format(__current_dir) +
19 "{} ".format(extr_includes) +
20 "-I{}/src/ethosu_driver/swig ".format(__current_dir) +
21 "{}/src/ethosu_driver/swig/{}.i".format(__current_dir, name),
22 shell=True,
23 stderr=subprocess.STDOUT)
24
25
26if __name__ == "__main__":
27 includes = ["{}/../../driver_library/include".format(__current_dir)]
28 generate_wrap('driver', "-I{} ".format(' -I'.join(includes)))