Skip to content

Commit

Permalink
verilator: fix visibility of flex and other deps
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed Oct 28, 2023
1 parent bea1a31 commit 85b74ea
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
34 changes: 21 additions & 13 deletions recipes/verilator/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import cross_building
from conan.tools.env import Environment
from conan.tools.env import Environment, VirtualBuildEnv
from conan.tools.files import apply_conandata_patches, chdir, copy, export_conandata_patches, get, rename, replace_in_file, rm, rmdir
from conan.tools.gnu import Autotools, AutotoolsToolchain
from conan.tools.layout import basic_layout
from conan.tools.microsoft import is_msvc, unix_path
from conan.tools.scm import Version

required_conan_version = ">=1.47.0"
required_conan_version = ">=1.60.0 <2.0 || >=2.0.6"


class VerilatorConan(ConanFile):
Expand All @@ -37,13 +37,21 @@ def layout(self):

def requirements(self):
if self.settings.os == "Windows":
self.requires("strawberryperl/5.32.1.1")
self.requires("strawberryperl/5.32.1.1", visible=False)
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)
else:
self.requires("winflexbison/2.5.25", visible=False)
else:
self.requires("flex/2.6.4", visible=False)
if is_msvc(self):
self.requires("dirent/1.24", visible=False)

def package_id(self):
# Verilator is an executable-only package, so the compiler version does not matter
del self.info.settings.compiler.version
# Verilator is an executable-only package, so the compiler does not matter
del self.info.settings.compiler

def validate(self):
if hasattr(self, "settings_build") and cross_building(self):
Expand All @@ -69,15 +77,10 @@ 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")
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.tool_requires("winflexbison/2.5.22")
else:
self.tool_requires("winflexbison/2.5.25")
self.tool_requires("strawberryperl/5.32.1.1")
self.tool_requires("winflexbison/<host_version>")
self.tool_requires("strawberryperl/<host_version>")
else:
self.tool_requires("flex/2.6.4")
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 All @@ -91,6 +94,8 @@ def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
VirtualBuildEnv(self).generate()

tc = AutotoolsToolchain(self)
if self.settings.get_safe("compiler.libcxx") == "libc++":
tc.extra_cxxflags.append("-lc++")
Expand All @@ -99,6 +104,9 @@ def generate(self):
tc.extra_cxxflags.append("-FS")
tc.defines.append("YY_NO_UNISTD_H")
tc.configure_args += ["--datarootdir=${prefix}/bin/share"]
flex = "flex" if self.settings.os != "Windows" else "winflexbison"
tc.extra_cxxflags += [f"-I{unix_path(self, self.dependencies[flex].cpp_info.includedir)}"]
tc.extra_ldflags += [f"-L{unix_path(self, self.dependencies[flex].cpp_info.libdir)}"]
tc.generate()

tc.make_args += [
Expand Down
4 changes: 4 additions & 0 deletions recipes/verilator/all/test_package/blinky_sc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ SC_MODULE(BlinkyTop)
}
};

int sc_main(int argc, char **argv) {
return 0;
}

int main(int argc, char **argv) {
sc_clock clk("clk", sc_time(1, SC_NS), 0.5);

Expand Down
3 changes: 2 additions & 1 deletion recipes/verilator/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ class TestPackageConan(ConanFile):

def requirements(self):
self.requires(self.tested_reference_str)
self.requires("systemc/2.3.4")

def build_requirements(self):
self.tool_requires(self.tested_reference_str)
if self._with_systemc_example:
self.tool_requires("systemc/2.3.4")
self.tool_requires("systemc/<host_version>")

def layout(self):
cmake_layout(self)
Expand Down

0 comments on commit 85b74ea

Please sign in to comment.