CIRCT 23.0.0git
Loading...
Searching...
No Matches
utils.py
Go to the documentation of this file.
1# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2# See https://llvm.org/LICENSE.txt for license information.
3# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5import platform
6from pathlib import Path
7import subprocess
8import sys
9
10_thisdir = Path(__file__).absolute().parent
11
12
14 """Run the esiquery executable with the same arguments as this script."""
15 if platform.system() == "Windows":
16 esiquery = _thisdir / "esiquery.exe"
17 else:
18 esiquery = _thisdir / "bin" / "esiquery"
19 return subprocess.call([esiquery] + sys.argv[1:])
20
21
23 """Run the esi-cosim.py script with the same arguments as this script."""
24 import importlib.util
25 if platform.system() == "Windows":
26 esi_cosim = _thisdir / "esi-cosim.py"
27 else:
28 esi_cosim = _thisdir / "bin" / "esi-cosim.py"
29 spec = importlib.util.spec_from_file_location("esi_cosim", esi_cosim)
30 assert spec is not None
31 assert spec.loader is not None
32 cosim_import = importlib.util.module_from_spec(spec)
33 spec.loader.exec_module(cosim_import)
34 return cosim_import.__main__(sys.argv)
35
36
38 from . import codegen
39 return codegen.run()
40
41
42def get_cmake_dir() -> Path:
43 return _thisdir / "cmake"
44
45
46def get_dll_dir() -> Path:
47 """Return the directory where the ESI dll's are located"""
48 import sys
49 import os
50 if sys.platform == "win32":
51 dll_name = "ESICppRuntime.dll"
52 for dir in [_thisdir, _thisdir.parent, _thisdir.parent.parent]:
53 if (dir / dll_name).exists():
54 return dir
55 raise FileNotFoundError("ESICppRuntime.dll not found")
56 else:
57 so_name = "libESICppRuntime.so"
58 for dir in [_thisdir, _thisdir.parent, _thisdir.parent.parent]:
59 if (dir / "lib" / so_name).exists():
60 return dir / "lib"
61 raise FileNotFoundError("libESICppRuntime.so not found")
Path get_dll_dir()
Definition utils.py:46
run_esi_cosim()
Definition utils.py:22
Path get_cmake_dir()
Definition utils.py:42