Skip to content

Commit

Permalink
verilator: disable v1 in test_package
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed Nov 4, 2023
1 parent 0879a22 commit 0b799de
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
15 changes: 6 additions & 9 deletions recipes/verilator/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ def layout(self):

def requirements(self):
if self.settings.os == "Windows":
self.requires("strawberryperl/5.32.1.1", visible=False)
self.requires("strawberryperl/5.32.1.1", run=True)
if self._needs_old_bison:
# don't upgrade to bison 3.7.0 or above, or it fails to build
# because of https://github.com/verilator/verilator/pull/2505
self.requires("winflexbison/2.5.22", visible=False)
self.requires("winflexbison/2.5.22", run=True, visible=False)
else:
self.requires("winflexbison/2.5.25", visible=False)
self.requires("winflexbison/2.5.25", run=True, visible=False)
if is_msvc(self):
self.requires("dirent/1.24", visible=False)
else:
self.requires("flex/2.6.4", visible=False)
if is_msvc(self):
self.requires("dirent/1.24", visible=False)
self.requires("flex/2.6.4", run=True, visible=False)

def package_id(self):
# Verilator is an executable-only package, so the compiler does not matter
Expand Down Expand Up @@ -77,10 +77,7 @@ def build_requirements(self):
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
self.tool_requires("msys2/cci.latest")
self.tool_requires("automake/1.16.5")
self.tool_requires("winflexbison/<host_version>")
self.tool_requires("strawberryperl/<host_version>")
else:
self.tool_requires("flex/<host_version>")
if self._needs_old_bison:
# don't upgrade to bison 3.7.0 or above, or it fails to build
# because of https://github.com/verilator/verilator/pull/2505
Expand Down
20 changes: 15 additions & 5 deletions recipes/verilator/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import os

from conan import ConanFile
from conan import ConanFile, conan_version
from conan.tools.apple import is_apple_os
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain
from conan.tools.files import save, load
from conan.tools.scm import Version


Expand Down Expand Up @@ -37,17 +38,26 @@ def generate(self):
tc = CMakeToolchain(self)
tc.variables["BUILD_SYSTEMC"] = self._with_systemc_example
tc.generate()
save(self, os.path.join(self.build_folder, "verilator_path"),
os.path.join(self.dependencies["verilator"].package_folder, "bin", "verilator"))

@property
def _can_build(self):
# In Conan v1 the generated verilator-config.cmake tries to incorrectly load flex and fails
return conan_version > 2

def build(self):
if can_run(self):
if can_run(self) and self._can_build:
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if can_run(self):
verilator_path = os.path.join(self.dependencies["verilator"].package_folder, "bin", "verilator")
self.run(f"perl {verilator_path} --version")
if not can_run(self):
return
verilator_path = load(self, os.path.join(self.build_folder, "verilator_path"))
self.run(f"perl {verilator_path} --version")
if self._can_build:
bin_path = os.path.join(self.cpp.build.bindir, "blinky")
self.run(bin_path, env="conanrun")
if self._with_systemc_example:
Expand Down

0 comments on commit 0b799de

Please sign in to comment.