aboutsummaryrefslogtreecommitdiff
path: root/driver_library/python/swig_generate.py
diff options
context:
space:
mode:
authorKshitij Sisodia <kshitij.sisodia@arm.com>2022-09-30 16:42:50 +0100
committerKristofer Jonsson <kristofer.jonsson@arm.com>2022-10-25 16:36:45 +0000
commitf9efe0ddf865c55d28bcaa203fefffa94bf09b42 (patch)
tree928da5f68dafd7e5a0dee05a75f2f6fcd52df170 /driver_library/python/swig_generate.py
parent569aa558f5e7638852a928feede1f21e7323f664 (diff)
downloadethos-u-linux-driver-stack-f9efe0ddf865c55d28bcaa203fefffa94bf09b42.tar.gz
Added Python interface for Arm Ethos-U NPU driver library.22.11-rc1
Python `ethosu_driver` could be built as part of Arm Ethos-U Linux driver library CMake flow. See driver_library/python/README.md for more details. Change-Id: I177a890add5c13df9a839f4f43621f972afe5ab1 Signed-off-by: Kshitij Sisodia <kshitij.sisodia@arm.com>
Diffstat (limited to 'driver_library/python/swig_generate.py')
-rwxr-xr-xdriver_library/python/swig_generate.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/driver_library/python/swig_generate.py b/driver_library/python/swig_generate.py
new file mode 100755
index 0000000..bdd43a3
--- /dev/null
+++ b/driver_library/python/swig_generate.py
@@ -0,0 +1,27 @@
+# SPDX-FileCopyrightText: Copyright 2021-2022 Arm Limited and/or its affiliates <open-source-office@arm.com>
+# SPDX-License-Identifier: Apache-2.0
+"""
+This script executes SWIG commands to generate C++ library wrappers.
+"""
+import subprocess
+from pathlib import Path
+
+__current_dir = Path(__file__).parent.absolute()
+
+
+def generate_wrap(name, extr_includes):
+ print('Generating wrappers for {}'.format(name))
+ subprocess.check_output("swig -v -c++ -python" +
+ " -Wall" +
+ " -o {}/src/ethosu_driver/_generated/{}_wrap.cpp ".format(__current_dir, name) +
+ "-outdir {}/src/ethosu_driver/_generated ".format(__current_dir) +
+ "{} ".format(extr_includes) +
+ "-I{}/src/ethosu_driver/swig ".format(__current_dir) +
+ "{}/src/ethosu_driver/swig/{}.i".format(__current_dir, name),
+ shell=True,
+ stderr=subprocess.STDOUT)
+
+
+if __name__ == "__main__":
+ includes = ["{}/../../driver_library/include".format(__current_dir)]
+ generate_wrap('driver', "-I{} ".format(' -I'.join(includes)))