Skip to content

Commit

Permalink
Warn when duplicate cores are encountered
Browse files Browse the repository at this point in the history
The rules for how several cores with the same VLNV are handled is
clearly defined. It is however very easy to miss if users have made
a mistake. FuseSoC printed a debug message about this, but it is
likely more user-friendly to print this as a warning instead.
  • Loading branch information
olofk committed Nov 16, 2023
1 parent e111d44 commit 456c2ae
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fusesoc/coremanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def add(self, core, library):
logger.debug("Adding core " + name)
if name in self._cores:
_s = "Replacing {} in {} with the version found in {}"
logger.debug(
logger.warning(
_s.format(name, self._cores[name]["core"].core_root, core.core_root)
)
self._cores[name] = {"core": core, "library": library}
Expand Down
9 changes: 9 additions & 0 deletions tests/capi2_cores/override/1/basic.core
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CAPI=2:
# Copyright FuseSoC contributors
# Licensed under the 2-Clause BSD License, see LICENSE for details.
# SPDX-License-Identifier: BSD-2-Clause

name: ::basic:0

targets:
default: {}
9 changes: 9 additions & 0 deletions tests/capi2_cores/override/2/basic.core
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CAPI=2:
# Copyright FuseSoC contributors
# Licensed under the 2-Clause BSD License, see LICENSE for details.
# SPDX-License-Identifier: BSD-2-Clause

name: ::basic:0

targets:
default: {}
20 changes: 20 additions & 0 deletions tests/test_coremanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,26 @@ def test_export():
]:
assert os.path.isfile(os.path.join(export_root, f))

def test_override(caplog):
import logging
import os
from fusesoc.config import Config
from fusesoc.coremanager import CoreManager
from fusesoc.librarymanager import Library
from fusesoc.vlnv import Vlnv

core_base_dir = os.path.join(os.path.dirname(__file__), "capi2_cores", "override")
cm = CoreManager(Config())
with caplog.at_level(logging.WARNING):
cm.add_library(Library("1", os.path.join(core_base_dir,"1")), [])
assert caplog.text == ""

with caplog.at_level(logging.WARNING):
cm.add_library(Library("2", os.path.join(core_base_dir,"2")), [])
assert "Replacing ::basic:0 in" in caplog.text

core = cm.get_core(Vlnv("::basic"))
assert core.core_root.endswith("2")

def test_virtual():
import os
Expand Down

0 comments on commit 456c2ae

Please sign in to comment.