Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sim_if/ghdl: remove 'ghdl.flags' #932

Merged
merged 1 commit into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/news.d/932.breaking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[GHDL] Remove ``ghdl.flags``; use ``ghdl.a_flags`` instead.

3 changes: 0 additions & 3 deletions docs/py/opts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ The following compilation options are known.
Extra arguments passed to ``ghdl -a`` command during compilation.
Must be a list of strings.

``ghdl.flags``
Deprecated alias of ``ghdl.a_flags``. It will be removed in future releases.

``incisive.irun_vhdl_flags``
Extra arguments passed to the Incisive ``irun`` command when compiling VHDL files.
Must be a list of strings.
Expand Down
2 changes: 1 addition & 1 deletion examples/vhdl/array/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

VU.add_library("lib").add_source_files([SRC_PATH / "*.vhd", SRC_PATH / "test" / "*.vhd"])

VU.set_compile_option("ghdl.flags", ["-frelaxed"])
VU.set_compile_option("ghdl.a_flags", ["-frelaxed"])
VU.set_sim_option("ghdl.elab_flags", ["-frelaxed"])

VU.set_compile_option("nvc.a_flags", ["--relaxed"])
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_ghdl_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def test_compile_project_extra_flags(self, check_output):
project = Project()
project.add_library("lib", "lib_path")
source_file = project.add_source_file("file.vhd", "lib", file_type="vhdl")
source_file.set_compile_option("ghdl.flags", ["custom", "flags"])
source_file.set_compile_option("ghdl.a_flags", ["custom", "flags"])
simif.compile_project(project)
check_output.assert_called_once_with(
[
Expand Down
28 changes: 14 additions & 14 deletions tests/unit/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ def test_should_recompile_files_after_changing_compile_options(self):
self.update(file3)
self.assert_should_recompile([])

file2.set_compile_option("ghdl.flags", ["--no-vital-checks"])
file2.set_compile_option("ghdl.a_flags", ["--no-vital-checks"])
self.assert_should_recompile([file2, file3])

def test_should_recompile_files_after_changing_vhdl_standard(self):
Expand All @@ -991,37 +991,37 @@ def test_should_recompile_files_after_changing_vhdl_standard(self):
def test_add_compile_option(self):
self.project.add_library("lib", "lib_path")
file1 = self.add_source_file("lib", "file.vhd", "")
file1.add_compile_option("ghdl.flags", ["--foo"])
self.assertEqual(file1.get_compile_option("ghdl.flags"), ["--foo"])
file1.add_compile_option("ghdl.flags", ["--bar"])
self.assertEqual(file1.get_compile_option("ghdl.flags"), ["--foo", "--bar"])
file1.set_compile_option("ghdl.flags", ["--xyz"])
self.assertEqual(file1.get_compile_option("ghdl.flags"), ["--xyz"])
file1.add_compile_option("ghdl.a_flags", ["--foo"])
self.assertEqual(file1.get_compile_option("ghdl.a_flags"), ["--foo"])
file1.add_compile_option("ghdl.a_flags", ["--bar"])
self.assertEqual(file1.get_compile_option("ghdl.a_flags"), ["--foo", "--bar"])
file1.set_compile_option("ghdl.a_flags", ["--xyz"])
self.assertEqual(file1.get_compile_option("ghdl.a_flags"), ["--xyz"])

def test_add_compile_option_does_not_mutate_argument(self):
self.project.add_library("lib", "lib_path")
file1 = self.add_source_file("lib", "file.vhd", "")
options = ["--foo"]
file1.add_compile_option("ghdl.flags", options)
file1.add_compile_option("ghdl.a_flags", options)
options[0] = "--xyz"
self.assertEqual(file1.get_compile_option("ghdl.flags"), ["--foo"])
file1.add_compile_option("ghdl.flags", ["--bar"])
self.assertEqual(file1.get_compile_option("ghdl.a_flags"), ["--foo"])
file1.add_compile_option("ghdl.a_flags", ["--bar"])
self.assertEqual(options, ["--xyz"])

def test_set_compile_option_does_not_mutate_argument(self):
self.project.add_library("lib", "lib_path")
file1 = self.add_source_file("lib", "file.vhd", "")
options = ["--foo"]
file1.set_compile_option("ghdl.flags", options)
file1.set_compile_option("ghdl.a_flags", options)
options[0] = "--xyz"
self.assertEqual(file1.get_compile_option("ghdl.flags"), ["--foo"])
self.assertEqual(file1.get_compile_option("ghdl.a_flags"), ["--foo"])

def test_compile_option_validation(self):
self.project.add_library("lib", "lib_path")
source_file = self.add_source_file("lib", "file.vhd", "")
self.assertRaises(ValueError, source_file.set_compile_option, "foo", None)
self.assertRaises(ValueError, source_file.set_compile_option, "ghdl.flags", None)
self.assertRaises(ValueError, source_file.add_compile_option, "ghdl.flags", None)
self.assertRaises(ValueError, source_file.set_compile_option, "ghdl.a_flags", None)
self.assertRaises(ValueError, source_file.add_compile_option, "ghdl.a_flags", None)
self.assertRaises(ValueError, source_file.get_compile_option, "foo")

def test_should_recompile_files_affected_by_change_with_later_timestamp(self):
Expand Down
16 changes: 8 additions & 8 deletions tests/unit/test_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,17 +925,17 @@ def test_compile_options(self):

# Use methods on all types of interface objects
for obj in [source_file, ui, lib, lib.get_source_files(file_name), ui.get_libraries("lib")]:
obj.set_compile_option("ghdl.flags", [])
self.assertEqual(source_file.get_compile_option("ghdl.flags"), [])
obj.set_compile_option("ghdl.a_flags", [])
self.assertEqual(source_file.get_compile_option("ghdl.a_flags"), [])

obj.add_compile_option("ghdl.flags", ["1"])
self.assertEqual(source_file.get_compile_option("ghdl.flags"), ["1"])
obj.add_compile_option("ghdl.a_flags", ["1"])
self.assertEqual(source_file.get_compile_option("ghdl.a_flags"), ["1"])

obj.add_compile_option("ghdl.flags", ["2"])
self.assertEqual(source_file.get_compile_option("ghdl.flags"), ["1", "2"])
obj.add_compile_option("ghdl.a_flags", ["2"])
self.assertEqual(source_file.get_compile_option("ghdl.a_flags"), ["1", "2"])

obj.set_compile_option("ghdl.flags", ["3"])
self.assertEqual(source_file.get_compile_option("ghdl.flags"), ["3"])
obj.set_compile_option("ghdl.a_flags", ["3"])
self.assertEqual(source_file.get_compile_option("ghdl.a_flags"), ["3"])

def test_default_vhdl_standard_is_used(self):
file_name = "foo.vhd"
Expand Down
17 changes: 5 additions & 12 deletions vunit/sim_if/ghdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import shutil
from json import dump
from sys import stdout # To avoid output catched in non-verbose mode
from warnings import warn
from ..exceptions import CompileError
from ..ostools import Process
from . import SimulatorInterface, ListOfStringOption, StringOption, BooleanOption
Expand All @@ -38,7 +37,7 @@ class GHDLInterface(SimulatorInterface): # pylint: disable=too-many-instance-at

compile_options = [
ListOfStringOption("ghdl.a_flags"),
ListOfStringOption("ghdl.flags"),
ListOfStringOption("ghdl.flags"), # Removed in v5.0.0
]

sim_options = [
Expand Down Expand Up @@ -237,6 +236,9 @@ def compile_vhdl_file_command(self, source_file):
"""
Returns the command to compile a vhdl file
"""
if source_file.compile_options.get("ghdl.flags", []) != []:
raise RuntimeError("'ghdl.flags was removed in v5.0.0; use 'ghdl.a_flags' instead")

cmd = [
str(Path(self._prefix) / self.executable),
"-a",
Expand All @@ -247,16 +249,7 @@ def compile_vhdl_file_command(self, source_file):
for library in self._project.get_libraries():
cmd += [f"-P{library.directory!s}"]

a_flags = source_file.compile_options.get("ghdl.a_flags", [])
flags = source_file.compile_options.get("ghdl.flags", [])
if flags != []:
warn(
("'ghdl.flags' is deprecated and it will be removed in future releases; use 'ghdl.a_flags' instead"),
Warning,
)
a_flags += flags

cmd += a_flags
cmd += source_file.compile_options.get("ghdl.a_flags", [])

if source_file.compile_options.get("enable_coverage", False):
# Add gcc compilation flags for coverage
Expand Down