diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index ada659f..3d96618 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -24,15 +24,28 @@ from pathlib import Path from subprocess import check_call +f4pga_environ = environ.copy() + ROOT = Path(__file__).resolve().parent -F4PGA_FAM = environ.get('F4PGA_FAM', 'xc7') -SH_SUBDIR = 'quicklogic' if F4PGA_FAM == 'eos-s3' else F4PGA_FAM +F4PGA_FAM = f4pga_environ.get('F4PGA_FAM', 'xc7') +isQuickLogic = F4PGA_FAM == 'eos-s3' +SH_SUBDIR = 'quicklogic' if isQuickLogic else F4PGA_FAM + +F4PGA_INSTALL_DIR = f4pga_environ.get('F4PGA_INSTALL_DIR') +if F4PGA_INSTALL_DIR is None: + raise(Exception("Required environment variable F4PGA_INSTALL_DIR is undefined!")) +F4PGA_INSTALL_DIR_PATH = Path(F4PGA_INSTALL_DIR) + +f4pga_environ['F4PGA_ENV_BIN'] = f4pga_environ.get('F4PGA_ENV_BIN', str(F4PGA_INSTALL_DIR_PATH / F4PGA_FAM / 'conda/bin')) +f4pga_environ['F4PGA_ENV_SHARE'] = f4pga_environ.get('F4PGA_ENV_SHARE', str(F4PGA_INSTALL_DIR_PATH / F4PGA_FAM / ( + 'share' if isQuickLogic else 'install/share/symbiflow' +))) def run_sh(script): stdout.flush() stderr.flush() - check_call([str(script)]+sys_argv[1:]) + check_call([str(script)]+sys_argv[1:], env=f4pga_environ) def generate_constraints(): diff --git a/test/test_wrappers.py b/test/test_wrappers.py index 069c1b9..d6ce1bb 100644 --- a/test/test_wrappers.py +++ b/test/test_wrappers.py @@ -1,28 +1,31 @@ +from os import environ from pytest import mark from sys import stdout, stderr from subprocess import check_call +wrappers = [ + 'symbiflow_generate_constraints', + 'symbiflow_pack', + 'symbiflow_place', + 'symbiflow_route', + 'symbiflow_synth', + 'symbiflow_write_bitstream', + 'symbiflow_write_fasm', + 'symbiflow_write_xml_rr_graph', + 'vpr_common', + 'symbiflow_analysis', + 'symbiflow_repack', + 'symbiflow_generate_bitstream', + 'symbiflow_generate_libfile', + 'ql_symbiflow' +] + @mark.xfail @mark.parametrize( "wrapper", - [ - 'symbiflow_generate_constraints', - 'symbiflow_pack', - 'symbiflow_place', - 'symbiflow_route', - 'symbiflow_synth', - 'symbiflow_write_bitstream', - 'symbiflow_write_fasm', - 'symbiflow_write_xml_rr_graph', - 'vpr_common', - 'symbiflow_analysis', - 'symbiflow_repack', - 'symbiflow_generate_bitstream', - 'symbiflow_generate_libfile', - 'ql_symbiflow' - ] + wrappers ) def test_shell_wrapper(wrapper): print(f"\n::group::Test {wrapper}") @@ -32,3 +35,20 @@ def test_shell_wrapper(wrapper): check_call(f"{wrapper}") finally: print("\n::endgroup::") + +@mark.xfail +@mark.parametrize( + "wrapper", + wrappers +) +def test_shell_wrapper_without_F4PGA_INSTALL_DIR(wrapper): + test_environ = environ.copy() + del test_environ['F4PGA_INSTALL_DIR'] + + print(f"\n::group::Test {wrapper}") + stdout.flush() + stderr.flush() + try: + check_call(f"{wrapper}", env=test_environ) + finally: + print("\n::endgroup::")