Skip to content

Commit 4bffc3c

Browse files
committed
feat(examples/vhdl/external_buffer): add option '--build'
1 parent 274e7ec commit 4bffc3c

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

  • examples/vhdl/external_buffer

examples/vhdl/external_buffer/run.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,28 @@
2626
"""
2727

2828
from vunit import VUnit
29+
from sys import argv
2930
from os import popen
3031
from os.path import join, dirname
3132
import inspect
33+
from shutil import copyfile
3234

3335

36+
# TODO https://github.com/VUnit/vunit/issues/478
37+
def preconf(output_path):
38+
global opath
39+
opath = output_path
40+
return True
41+
42+
43+
global opath
44+
opath = ''
3445
src_path = join(dirname(__file__), 'src')
3546
ext_srcs = join(dirname(inspect.getfile(VUnit)), 'vhdl', 'data_types', 'src', 'external')
47+
build_only = False
48+
if '--build' in argv:
49+
argv.remove('--build')
50+
build_only = True
3651

3752
# Compile C applications to an objects
3853
c_iobj = join(src_path, 'imain.o')
@@ -66,5 +81,17 @@
6681
for tb in lib.get_test_benches(pattern='*tb_ext*_integer*', allow_empty=False):
6782
tb.set_sim_option('ghdl.elab_flags', ['-Wl,' + c_iobj, '-Wl,-Wl,--version-script=' + join(ext_srcs, 'grt.ver')], overwrite=True)
6883

84+
for tb in lib.get_test_benches(pattern='*', allow_empty=False):
85+
tb.set_pre_config(preconf)
86+
6987
if __name__ == '__main__':
70-
ui.main()
88+
if build_only:
89+
ui.set_sim_option("ghdl.elab_e", True)
90+
ui._args.elaborate = True
91+
try:
92+
ui.main()
93+
except SystemExit as exc:
94+
if exc.code is not 0:
95+
exit(exc.code)
96+
if build_only and len(opath):
97+
copyfile(join(opath, 'ghdl', 'args.txt'), join(dirname(__file__), 'args.txt'))

0 commit comments

Comments
 (0)