# Auto generated by Edalize

def load_module_from_file(name, python_file):
    import importlib.util
    spec = importlib.util.spec_from_file_location(name, python_file)
    module = importlib.util.module_from_spec(spec)
    spec.loader.exec_module(module)
    return module

def load_runner_hooks(python_file = r'{{ vunit_runner_path }}'):
    if len(python_file) > 0:
        return load_module_from_file('vunit_runner_hooks', python_file)
    else:
        return __import__('edalize.vunit_hooks', fromlist=['vunit_hooks'])

runner = load_runner_hooks().VUnitRunner()

# Override this hook to allow custom creation configuration of the VUnit instance:
vu = runner.create()

{% for extlib in add_libraries %}
vu.add_{{ extlib }}()
{% endfor %}

{% for library, src_files in libraries.items() %}
lib = vu.add_library("{{ library }}")
{% for src_file in src_files if src_file|src_file_filter %}
{% if (src_file|src_file_vhdl_standard_filter) %}
lib.add_source_files("{{ src_file|src_file_filter }}", vhdl_standard="{{ src_file|src_file_vhdl_standard_filter }}")
{% else %}
lib.add_source_files("{{ src_file|src_file_filter }}")
{% endif %}
{% endfor %}
# Override this hook to customize the library, e.g. compile-flags etc.
# This allows full access to vunit.ui.Library interface:
runner.handle_library("{{ library }}", lib)

{% endfor %}

# override this hook to perform final customization and parametrization of VUnit, custom invokation, etc.
runner.main(vu)
