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

(Failed) attempt at conan integration #11

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
105 changes: 70 additions & 35 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
46 changes: 46 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>, Chun-Xun Lin <[email protected]>, 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"]
6 changes: 6 additions & 0 deletions conanfile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[requires]
bison/3.7.6
flex/2.6.4

[generators]
cmake
35 changes: 35 additions & 0 deletions conaninfo.txt
Original file line number Diff line number Diff line change
@@ -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]