44#
55# Copyright (c) 2014-2023, Lars Asplund lars.anders.asplund@gmail.com
66
7+ """
8+ Temporary helper module to compile C-code used by python_pkg.
9+ """
710from pathlib import Path
811from glob import glob
912import subprocess
1013import sys
1114
1215
1316def compile_vhpi_application (run_script_root , vu ):
17+ """
18+ Compile VHPI application used by Aldec's simulators.
19+ """
1420 path_to_shared_lib = (run_script_root / "vunit_out" / vu .get_simulator_name () / "libraries" ).resolve ()
1521 if not path_to_shared_lib .exists ():
1622 path_to_shared_lib .mkdir (parents = True , exist_ok = True )
@@ -20,31 +26,34 @@ def compile_vhpi_application(run_script_root, vu):
2026 python_shared_lib = f"python{ sys .version_info [0 ]} { sys .version_info [1 ]} "
2127 path_to_python_pkg = Path (__file__ ).parent .resolve () / "vhdl" / "python" / "src"
2228 c_file_paths = [path_to_python_pkg / "python_pkg_vhpi.c" , path_to_python_pkg / "python_pkg.c" ]
23- path_to_simulator = Path (vu ._simulator_class .find_prefix ()).resolve ()
29+ path_to_simulator = Path (vu ._simulator_class .find_prefix ()).resolve () # pylint: disable=protected-access
2430 ccomp_executable = path_to_simulator / "ccomp.exe"
2531
26- proc = subprocess .run ([
27- str (ccomp_executable ),
28- "-vhpi" ,
29- "-dbg" ,
30- "-verbose" ,
31- "-o" ,
32- '"' + str (shared_lib ) + '"' ,
33- "-l" ,
34- python_shared_lib ,
35- "-l" ,
36- "python3" ,
37- "-l" ,
38- "_tkinter" ,
39- "-I" ,
40- '"' + str (path_to_python_include ) + '"' ,
41- "-I" ,
42- '"' + str (path_to_python_pkg ) + '"' ,
43- "-L" ,
44- '"' + str (path_to_python_libs ) + '"' ,
45- " " .join (['"' + str (path ) + '"' for path in c_file_paths ])],
32+ proc = subprocess .run (
33+ [
34+ str (ccomp_executable ),
35+ "-vhpi" ,
36+ "-dbg" ,
37+ "-verbose" ,
38+ "-o" ,
39+ '"' + str (shared_lib ) + '"' ,
40+ "-l" ,
41+ python_shared_lib ,
42+ "-l" ,
43+ "python3" ,
44+ "-l" ,
45+ "_tkinter" ,
46+ "-I" ,
47+ '"' + str (path_to_python_include ) + '"' ,
48+ "-I" ,
49+ '"' + str (path_to_python_pkg ) + '"' ,
50+ "-L" ,
51+ '"' + str (path_to_python_libs ) + '"' ,
52+ " " .join (['"' + str (path ) + '"' for path in c_file_paths ]),
53+ ],
4654 capture_output = True ,
4755 text = True ,
56+ check = False ,
4857 )
4958
5059 if proc .returncode != 0 :
@@ -53,8 +62,11 @@ def compile_vhpi_application(run_script_root, vu):
5362 raise RuntimeError ("Failed to compile VHPI application" )
5463
5564
56- def compile_fli_application (run_script_root , vu ):
57- path_to_simulator = Path (vu ._simulator_class .find_prefix ()).resolve ()
65+ def compile_fli_application (run_script_root , vu ): # pylint: disable=too-many-locals
66+ """
67+ Compile FLI application used by Questa.
68+ """
69+ path_to_simulator = Path (vu ._simulator_class .find_prefix ()).resolve () # pylint: disable=protected-access
5870 path_to_simulator_include = (path_to_simulator / ".." / "include" ).resolve ()
5971
6072 # 32 or 64 bit installation?
@@ -63,6 +75,7 @@ def compile_fli_application(run_script_root, vu):
6375 [vsim_executable , "-version" ],
6476 capture_output = True ,
6577 text = True ,
78+ check = False ,
6679 )
6780 if proc .returncode != 0 :
6881 print (proc .stderr )
@@ -94,16 +107,17 @@ def compile_fli_application(run_script_root, vu):
94107 args += ["-ansi" , "-pedantic" ]
95108
96109 args += [
97- '-I' + str (path_to_simulator_include ),
98- '-I' + str (path_to_python_include ),
110+ "-I" + str (path_to_simulator_include ),
111+ "-I" + str (path_to_python_include ),
99112 "-freg-struct-return" ,
100- str (c_file_path )
113+ str (c_file_path ),
101114 ]
102115
103116 proc = subprocess .run (
104117 args ,
105118 capture_output = True ,
106119 text = True ,
120+ check = False ,
107121 )
108122 if proc .returncode != 0 :
109123 print (proc .stdout )
@@ -139,6 +153,7 @@ def compile_fli_application(run_script_root, vu):
139153 args ,
140154 capture_output = True ,
141155 text = True ,
156+ check = False ,
142157 )
143158 if proc .returncode != 0 :
144159 print (proc .stdout )
0 commit comments