From f0c538244774dfda90c2bbacb4608b79ab9996e5 Mon Sep 17 00:00:00 2001 From: Xavier Bestel Date: Wed, 16 Mar 2022 10:46:36 +0100 Subject: [PATCH 1/2] add packaging for conan local --- CMakeLists.txt | 105 ++++++++++++++++++++++++++++++++----------------- conanfile.py | 46 ++++++++++++++++++++++ conaninfo.txt | 35 +++++++++++++++++ 3 files changed, 151 insertions(+), 35 deletions(-) create mode 100644 conanfile.py create mode 100644 conaninfo.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index b362caa..6e595ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ -cmake_minimum_required(VERSION 3.9) +cmake_minimum_required(VERSION 3.9) -project(Parser-Verilog LANGUAGES CXX) -include(CTest) +project(Parser-Verilog LANGUAGES CXX) +include(CTest) # Turn on the verbose set(CMAKE_VERBOSE_MAKEFILE ON) @@ -23,49 +23,84 @@ include_directories(parser-verilog) find_package(BISON REQUIRED) find_package(FLEX REQUIRED) -BISON_TARGET(verilog_parser - ${PROJECT_SOURCE_DIR}/parser-verilog/verilog_parser.yy - ${CMAKE_CURRENT_BINARY_DIR}/verilog_parser.tab.cc) -FLEX_TARGET(verilog_lexer - ${PROJECT_SOURCE_DIR}/parser-verilog/verilog_lexer.l - ${CMAKE_CURRENT_BINARY_DIR}/verilog_lexer.yy.cc) -ADD_FLEX_BISON_DEPENDENCY(verilog_lexer verilog_parser) +bison_target( + verilog_parser + ${PROJECT_SOURCE_DIR}/parser-verilog/verilog_parser.yy + ${CMAKE_CURRENT_BINARY_DIR}/verilog_parser.tab.cc +) +flex_target( + verilog_lexer + ${PROJECT_SOURCE_DIR}/parser-verilog/verilog_lexer.l + ${CMAKE_CURRENT_BINARY_DIR}/verilog_lexer.yy.cc +) +add_flex_bison_dependency(verilog_lexer verilog_parser) # ----------------------------------------------------------------------------- -# Example program +# Library export # ----------------------------------------------------------------------------- -# Set the output folder to example -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/example) - -# A sample parser -add_executable(sample_parser - ${PROJECT_SOURCE_DIR}/example/sample_parser.cpp +add_library( + parser-verilog ${FLEX_verilog_lexer_OUTPUTS} ${BISON_verilog_parser_OUTPUTS} ) -# A drop-in replacement OpenTimer Verilog parser -add_executable(ot_parser - ${PROJECT_SOURCE_DIR}/example/ot_parser.cpp - ${FLEX_verilog_lexer_OUTPUTS} - ${BISON_verilog_parser_OUTPUTS} +set( + MYLIB_HDRS + parser-verilog/verilog_driver.hpp + parser-verilog/verilog_scanner.hpp + parser-verilog/verilog_data.hpp + ${CMAKE_BINARY_DIR}/verilog_parser.tab.hh + ${CMAKE_BINARY_DIR}/location.hh ) +set_property(TARGET parser-verilog PROPERTY PUBLIC_HEADER ${MYLIB_HDRS}) +install( + TARGETS parser-verilog DESTINATION "." + PUBLIC_HEADER DESTINATION include + RUNTIME DESTINATION bin + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib +) -# ----------------------------------------------------------------------------- -# Unittest -# ----------------------------------------------------------------------------- - -enable_testing() -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/unittest) - -# Regression -set(VP_UTEST_DIR ${PROJECT_SOURCE_DIR}/unittest) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${VP_UTEST_DIR}) - -add_executable(regression unittest/regression.cpp ${FLEX_verilog_lexer_OUTPUTS} ${BISON_verilog_parser_OUTPUTS}) -add_test(regression ${VP_UTEST_DIR}/regression) +## ----------------------------------------------------------------------------- +## Example program +## ----------------------------------------------------------------------------- +# +## Set the output folder to example +#set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/example) +# +## A sample parser +#add_executable( +# sample_parser +# ${PROJECT_SOURCE_DIR}/example/sample_parser.cpp +# ${FLEX_verilog_lexer_OUTPUTS} +# ${BISON_verilog_parser_OUTPUTS} +#) +# +## A drop-in replacement OpenTimer Verilog parser +#add_executable( +# ot_parser +# ${PROJECT_SOURCE_DIR}/example/ot_parser.cpp +# ${FLEX_verilog_lexer_OUTPUTS} +# ${BISON_verilog_parser_OUTPUTS} +#) +# +# +# +## ----------------------------------------------------------------------------- +## Unittest +## ----------------------------------------------------------------------------- +# +#enable_testing() +#set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/unittest) +# +## Regression +#set(VP_UTEST_DIR ${PROJECT_SOURCE_DIR}/unittest) +#set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${VP_UTEST_DIR}) +# +#add_executable(regression unittest/regression.cpp ${FLEX_verilog_lexer_OUTPUTS} ${BISON_verilog_parser_OUTPUTS}) +#add_test(regression ${VP_UTEST_DIR}/regression) diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000..1a0438b --- /dev/null +++ b/conanfile.py @@ -0,0 +1,46 @@ +from conans import ConanFile +from conan.tools.cmake import CMakeToolchain, CMake +from conan.tools.layout import cmake_layout + + +class ParserVerilogConan(ConanFile): + name = "parser-verilog" + version = "0.1" + + # Optional metadata + license = "MIT" + author = "Tsung-Wei Huang , Chun-Xun Lin , Martin Wong" + url = "https://github.com/OpenTimer/Parser-Verilog" + description = "A Standalone Structural Verilog Parser" + topics = ("lex, eda, verilog, cpp17, circuit, computer-aided-design, vlsi-physical-design, electronic-design-automation, vlsi-circuits, bison-yacc") + + # Binary configuration + settings = "os", "compiler", "build_type", "arch" + options = {"shared": [True, False], "fPIC": [True, False]} + default_options = {"shared": False, "fPIC": True} + + # Sources are located in the same place as this recipe, copy them to the recipe + exports_sources = "CMakeLists.txt", "parser-verilog/*" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def layout(self): + cmake_layout(self) + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["parser-verilog"] diff --git a/conaninfo.txt b/conaninfo.txt new file mode 100644 index 0000000..bd676cd --- /dev/null +++ b/conaninfo.txt @@ -0,0 +1,35 @@ +[settings] + arch=x86_64 + build_type=Release + compiler=gcc + compiler.libcxx=libstdc++11 + compiler.version=11.2 + os=Linux + +[requires] + + +[options] + fPIC=True + shared=False + +[full_settings] + arch=x86_64 + build_type=Release + compiler=gcc + compiler.libcxx=libstdc++11 + compiler.version=11.2 + os=Linux + +[full_requires] + + +[full_options] + fPIC=True + shared=False + +[recipe_hash] + + +[env] + From 3deede204eefc5bed15bca825351e3be2a89af16 Mon Sep 17 00:00:00 2001 From: Xavier Bestel Date: Mon, 28 Mar 2022 10:40:10 +0200 Subject: [PATCH 2/2] add explicit bison dependency --- conanfile.txt | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 conanfile.txt diff --git a/conanfile.txt b/conanfile.txt new file mode 100644 index 0000000..e95b8ce --- /dev/null +++ b/conanfile.txt @@ -0,0 +1,6 @@ +[requires] +bison/3.7.6 +flex/2.6.4 + +[generators] +cmake