From e29c773ff9c7c1b8169b43abd512d802ed51996d Mon Sep 17 00:00:00 2001 From: Thomasb81 Date: Sat, 13 Jul 2024 15:31:05 +0200 Subject: [PATCH 01/34] Remove introduced line while processing `include --- grammars/verilogPreprocLexer.g4 | 8 ++++++-- src/verilogPreproc/out_buffer.cpp | 2 +- tests/sv_pp/expected/debug_macro.txt | 2 -- .../include_many_dir/dir0-a/dir1-a/spec_incdir.txt | 1 - .../dir0-a/local_include_higher_priority.txt | 1 - .../sv_pp/expected/include_many_dir/from_subdirectory.txt | 7 +------ tests/sv_pp/expected/include_many_dir/transitive.txt | 4 ---- tests/sv_pp/expected/include_same_dir/basic_include.txt | 1 - .../expected/include_same_dir/basic_include2times.txt | 3 --- tests/test_verilog_preproc_include.py | 3 +++ 10 files changed, 11 insertions(+), 21 deletions(-) diff --git a/grammars/verilogPreprocLexer.g4 b/grammars/verilogPreprocLexer.g4 index 8fb4adec..59cc0ee2 100644 --- a/grammars/verilogPreprocLexer.g4 +++ b/grammars/verilogPreprocLexer.g4 @@ -359,11 +359,15 @@ mode KEYWOORDS_MODE; // include argument processing mode INCLUDE_MODE; INCLUDE_MODE_STR - : STR -> type(STR),popMode + : STR -> type(STR) ; + INCLUDE_MODE_STR_CHEVRONS - : '<' ( ~('\\'|'>') )* '>' -> type(STR),popMode + : '<' ( ~('\\'|'>') )* '>' -> type(STR) ; + INCLUDE_LINE_COMMENT : LINE_COMMENT -> popMode,type(LINE_COMMENT),channel(CH_LINE_COMMENT); + INCLUDE_MODE_NEW_LINE: CRLF -> type(NEW_LINE),popMode,skip; + INCLUDE_MODE_MACRO_ENTER: '`' -> popMode,pushMode(DIRECTIVE_MODE),skip; INCLUDE_MODE_WS : WS ->skip; diff --git a/src/verilogPreproc/out_buffer.cpp b/src/verilogPreproc/out_buffer.cpp index 68d863e5..522f2ba1 100644 --- a/src/verilogPreproc/out_buffer.cpp +++ b/src/verilogPreproc/out_buffer.cpp @@ -60,7 +60,7 @@ VerilogPreprocOutBuffer& VerilogPreprocOutBuffer::operator<<( VerilogPreprocOutBuffer& VerilogPreprocOutBuffer::operator<<( const VerilogPreprocOutBuffer &other) { - (*this) << endl; + //(*this) << endl; (*static_cast(this)) << other.str(); for (auto &i : other.file_line_map) { FileLineMapItem i_new(i.line + output_line, i.file_override, diff --git a/tests/sv_pp/expected/debug_macro.txt b/tests/sv_pp/expected/debug_macro.txt index a1a5103d..8a8ee519 100644 --- a/tests/sv_pp/expected/debug_macro.txt +++ b/tests/sv_pp/expected/debug_macro.txt @@ -5,6 +5,4 @@ - - $display(">> %s, %d: %s", "sv_pp/src/debug_macro.txt", 3, "msg") diff --git a/tests/sv_pp/expected/include_many_dir/dir0-a/dir1-a/spec_incdir.txt b/tests/sv_pp/expected/include_many_dir/dir0-a/dir1-a/spec_incdir.txt index 807a1ca1..1124e96b 100644 --- a/tests/sv_pp/expected/include_many_dir/dir0-a/dir1-a/spec_incdir.txt +++ b/tests/sv_pp/expected/include_many_dir/dir0-a/dir1-a/spec_incdir.txt @@ -1,2 +1 @@ - "good content" \ No newline at end of file diff --git a/tests/sv_pp/expected/include_many_dir/dir0-a/local_include_higher_priority.txt b/tests/sv_pp/expected/include_many_dir/dir0-a/local_include_higher_priority.txt index 807a1ca1..1124e96b 100644 --- a/tests/sv_pp/expected/include_many_dir/dir0-a/local_include_higher_priority.txt +++ b/tests/sv_pp/expected/include_many_dir/dir0-a/local_include_higher_priority.txt @@ -1,2 +1 @@ - "good content" \ No newline at end of file diff --git a/tests/sv_pp/expected/include_many_dir/from_subdirectory.txt b/tests/sv_pp/expected/include_many_dir/from_subdirectory.txt index 8528768f..d1f22783 100644 --- a/tests/sv_pp/expected/include_many_dir/from_subdirectory.txt +++ b/tests/sv_pp/expected/include_many_dir/from_subdirectory.txt @@ -1,6 +1 @@ - -"file2-a.txt" - -"file2-a.txt" - -"file2-a.txt" +"file2-a.txt""file2-a.txt""file2-a.txt" \ No newline at end of file diff --git a/tests/sv_pp/expected/include_many_dir/transitive.txt b/tests/sv_pp/expected/include_many_dir/transitive.txt index a7c0eed4..92cde8dc 100644 --- a/tests/sv_pp/expected/include_many_dir/transitive.txt +++ b/tests/sv_pp/expected/include_many_dir/transitive.txt @@ -1,8 +1,4 @@ - "transitive-0" - "transitive-1" - "transitive-2" - "transitive-3" \ No newline at end of file diff --git a/tests/sv_pp/expected/include_same_dir/basic_include.txt b/tests/sv_pp/expected/include_same_dir/basic_include.txt index 12fb4c89..5e2ef389 100644 --- a/tests/sv_pp/expected/include_same_dir/basic_include.txt +++ b/tests/sv_pp/expected/include_same_dir/basic_include.txt @@ -1,4 +1,3 @@ - "a.vh" diff --git a/tests/sv_pp/expected/include_same_dir/basic_include2times.txt b/tests/sv_pp/expected/include_same_dir/basic_include2times.txt index dd0b6a63..5e2ef389 100644 --- a/tests/sv_pp/expected/include_same_dir/basic_include2times.txt +++ b/tests/sv_pp/expected/include_same_dir/basic_include2times.txt @@ -1,6 +1,3 @@ - "a.vh" - - diff --git a/tests/test_verilog_preproc_include.py b/tests/test_verilog_preproc_include.py index 92187d68..a906c78e 100644 --- a/tests/test_verilog_preproc_include.py +++ b/tests/test_verilog_preproc_include.py @@ -43,6 +43,9 @@ def test_basic_include2times(self): def test_from_subdirectory(self): self.run_test(["include_many_dir", "from_subdirectory.txt"], []) + + def test_from_subdirectory2(self): + self.run_test(["include_many_dir", "from_subdirectory2.txt"], []) def test_local_include_higher_priority(self): self.run_test( From d7230e54cf8253bd842ed6cde1a12cb11a614e16 Mon Sep 17 00:00:00 2001 From: Thomasb81 Date: Sun, 14 Jul 2024 15:26:11 +0200 Subject: [PATCH 02/34] - Create hdlConvertorToken which inherit from antlr4::CommonToken to enrich with file origine of the token. - Create the associated factory to instruct lexer to create token with our custom token The factory is responsible to use the file_line_map data. - Enrich CodePosition with fileName field. --- hdlConvertor/toPy.cpp | 2 + include/hdlConvertor/hdlAst/codePosition.h | 26 ++++-- include/hdlConvertor/hdlConvertorToken.h | 23 ++++++ .../hdlConvertor/hdlConvertorTokenFactory.h | 36 ++++++++ src/hdlAst/codePosition.cpp | 7 +- src/hdlConvertor.cpp | 28 +++++++ src/hdlConvertorToken.cpp | 38 +++++++++ src/hdlConvertorTokenFactory.cpp | 82 +++++++++++++++++++ src/meson.build | 2 + src/toString.cpp | 1 + 10 files changed, 236 insertions(+), 9 deletions(-) create mode 100644 include/hdlConvertor/hdlConvertorToken.h create mode 100644 include/hdlConvertor/hdlConvertorTokenFactory.h create mode 100644 src/hdlConvertorToken.cpp create mode 100644 src/hdlConvertorTokenFactory.cpp diff --git a/hdlConvertor/toPy.cpp b/hdlConvertor/toPy.cpp index d250a717..778f5edc 100644 --- a/hdlConvertor/toPy.cpp +++ b/hdlConvertor/toPy.cpp @@ -190,6 +190,8 @@ PyObject* ToPy::toPy(const CodePosition o) { return nullptr; if (toPy_property(py_inst, "stop_column", o.stop_column)) return nullptr; + if (toPy_property(py_inst, "file_name", o.file_name)) + return nullptr; return py_inst; } diff --git a/include/hdlConvertor/hdlAst/codePosition.h b/include/hdlConvertor/hdlAst/codePosition.h index 07e0e058..eb0f66d6 100644 --- a/include/hdlConvertor/hdlAst/codePosition.h +++ b/include/hdlConvertor/hdlAst/codePosition.h @@ -2,6 +2,8 @@ #include #include +#include + namespace hdlConvertor { namespace hdlAst { @@ -13,22 +15,34 @@ namespace hdlAst { class CodePosition { public: static constexpr size_t INVALID = std::numeric_limits::max(); + static constexpr char INVALID_STR[] = ""; size_t start_line; size_t stop_line; size_t start_column; size_t stop_column; + std::string file_name; CodePosition(); CodePosition(size_t startLine, size_t stopLine, size_t startColumn, - size_t stopColumn); + size_t stopColumn, std::string fileName); template void update_from_elem(ELEM_T *elem) { - start_line = elem->getStart()->getLine(); - stop_line = elem->getStop()->getLine(); - start_column = elem->getStart()->getCharPositionInLine() + 1; - stop_column = elem->getStop()->getCharPositionInLine() + - (elem->getStop()->getStopIndex() - elem->getStop()->getStartIndex()) + 1; + /* + * Cast antlr4::CommonToken to our custum hdlConvertorToken + * So we can retrive the file name information of origin of + * current token. + */ + hdlConvertor::hdlConvertorToken * tokenStart_ptr = dynamic_cast(elem->getStart()); + hdlConvertor::hdlConvertorToken * tokenStop_ptr = dynamic_cast(elem->getStop()); + + /* pick up data from token */ + start_line = tokenStart_ptr->getLine(); + stop_line = tokenStop_ptr->getLine(); + start_column = tokenStart_ptr->getCharPositionInLine() + 1; + stop_column = tokenStop_ptr->getCharPositionInLine() + + (tokenStop_ptr->getStopIndex() - tokenStop_ptr->getStartIndex()) + 1; + file_name = tokenStart_ptr->getSrcName(); } bool isKnown() const; }; diff --git a/include/hdlConvertor/hdlConvertorToken.h b/include/hdlConvertor/hdlConvertorToken.h new file mode 100644 index 00000000..64e7720e --- /dev/null +++ b/include/hdlConvertor/hdlConvertorToken.h @@ -0,0 +1,23 @@ +#pragma once + +#include + +namespace hdlConvertor { + +class hdlConvertorToken : public antlr4::CommonToken { + public: + hdlConvertorToken(size_t type); + hdlConvertorToken(std::pair source, size_t type, size_t channel, size_t start, size_t stop); + hdlConvertorToken(size_t type, const std::string &text); + hdlConvertorToken(antlr4::Token *oldToken); + + void setSrcName(const std::string fileName); + std::string getSrcName(); + std::string toString() const override; + + private: + std::string srcName; + +}; + +} diff --git a/include/hdlConvertor/hdlConvertorTokenFactory.h b/include/hdlConvertor/hdlConvertorTokenFactory.h new file mode 100644 index 00000000..886ad04b --- /dev/null +++ b/include/hdlConvertor/hdlConvertorTokenFactory.h @@ -0,0 +1,36 @@ +#pragma once + +#include +#include +#include +namespace hdlConvertor { + +class hdlConvertorTokenFactory : public antlr4::CommonTokenFactory { + public: + static const std::unique_ptr> DEFAULT; + + hdlConvertorTokenFactory(bool copy_text); + hdlConvertorTokenFactory(); + void setFileLineMap( verilog_pp::FileLineMap * file_line_map); + + std::unique_ptr create( + std::pair source, + size_t type, + const std::string &text, + size_t channel, + size_t start, + size_t stop, + size_t line, + size_t charPositionInLine) override; + + std::unique_ptr create( + size_t type, + const std::string &text) override; + + + private: + static verilog_pp::FileLineMap *_file_line_map; + +}; + +} diff --git a/src/hdlAst/codePosition.cpp b/src/hdlAst/codePosition.cpp index 7c9f1fbf..105dfde6 100644 --- a/src/hdlAst/codePosition.cpp +++ b/src/hdlAst/codePosition.cpp @@ -4,20 +4,21 @@ namespace hdlConvertor { namespace hdlAst { CodePosition::CodePosition() : - CodePosition(INVALID, INVALID, INVALID, INVALID) { + CodePosition(INVALID, INVALID, INVALID, INVALID,INVALID_STR) { } CodePosition::CodePosition(size_t startLine, size_t stopLine, size_t startColumn, - size_t stopColumn) { + size_t stopColumn,std::string fileName) { this->start_line = startLine; this->stop_line = stopLine; this->start_column = startColumn; this->stop_column = stopColumn; + this->file_name = fileName; } bool CodePosition::isKnown() const { return start_line != INVALID || stop_line != INVALID || start_column != INVALID - || stop_column != INVALID; + || stop_column != INVALID || file_name != INVALID_STR; } } diff --git a/src/hdlConvertor.cpp b/src/hdlConvertor.cpp index 9af35b77..79f585a8 100644 --- a/src/hdlConvertor.cpp +++ b/src/hdlConvertor.cpp @@ -56,6 +56,14 @@ class SVParserContainer: public iParserContainer_parse(input_for_parser, hierarchyOnly); @@ -77,8 +85,28 @@ class SVParserContainer: public iParserContainerlanguage_version = lang; + + /* + * Customize Lexer with our hdlConvertorToken factory + * This allow us to enrich antlr4::CommonToken with filename on + * each token, then spread this kind of detail everywhere token are + * use + * */ + hdlConvertorTokenFactory factory; + factory.setFileLineMap(&file_line_map); + lexer.get()->setTokenFactory(factory.DEFAULT.get()); + + /* Debug print hdlConvertorToken list + tokens.get()->fill(); + for (auto token : tokens.get()->getTokens()) { + std::cout << token->toString() << std::endl; + } + */ + sv2017_antlr::sv2017Parser::Source_textContext *tree = antlrParser->source_text(); + + syntaxErrLogger.check_errors(); // Throw exception if errors hdlParser->visitSource_text(tree); } diff --git a/src/hdlConvertorToken.cpp b/src/hdlConvertorToken.cpp new file mode 100644 index 00000000..9d6fba90 --- /dev/null +++ b/src/hdlConvertorToken.cpp @@ -0,0 +1,38 @@ +#include + + +namespace hdlConvertor { + +using namespace std; + +hdlConvertorToken::hdlConvertorToken(size_t type) : CommonToken(type) { +} + +hdlConvertorToken::hdlConvertorToken(pair source, size_t type, size_t channel, size_t start, size_t stop) : + CommonToken(source,type,channel,start,stop),srcName("cornichon") { + +} + +hdlConvertorToken::hdlConvertorToken(size_t type, const std::string &text) : + CommonToken(type,text),srcName("corniChon") { +} + +hdlConvertorToken::hdlConvertorToken(antlr4::Token *oldToken) : + CommonToken(oldToken) { +} + + +void hdlConvertorToken::setSrcName(const string fileName) { + srcName = fileName; +} + +std::string hdlConvertorToken::getSrcName() { + return srcName; +} + +string hdlConvertorToken::toString() const { + string rt_value = srcName + CommonToken::toString(); + return rt_value; +} + +} diff --git a/src/hdlConvertorTokenFactory.cpp b/src/hdlConvertorTokenFactory.cpp new file mode 100644 index 00000000..d0b3e7eb --- /dev/null +++ b/src/hdlConvertorTokenFactory.cpp @@ -0,0 +1,82 @@ +#include + +namespace hdlConvertor { + +using namespace std; + +const std::unique_ptr> hdlConvertorTokenFactory::DEFAULT(new hdlConvertorTokenFactory); + +verilog_pp::FileLineMap* hdlConvertorTokenFactory::_file_line_map = nullptr; + + +hdlConvertorTokenFactory::hdlConvertorTokenFactory( + bool copyText) : + CommonTokenFactory(copyText) { +} + +hdlConvertorTokenFactory::hdlConvertorTokenFactory() { +} + +void hdlConvertorTokenFactory::setFileLineMap( verilog_pp::FileLineMap * file_line_map){ + hdlConvertorTokenFactory::_file_line_map = file_line_map; +} + +std::unique_ptr +hdlConvertorTokenFactory::create( + std::pair source, + size_t type, + const std::string &text, + size_t channel, + size_t start, + size_t stop, + size_t line, + size_t charPositionInLine) { + + bool found = false; + + std::unique_ptr t(new hdlConvertorToken( + source, type, channel, start, stop + ) + ); + + hdlConvertorToken * ptr = dynamic_cast(t.get()); + + std::vector::iterator fileLineMap_iter; + fileLineMap_iter = (*hdlConvertorTokenFactory::_file_line_map).begin(); + while (fileLineMap_iter != (*hdlConvertorTokenFactory::_file_line_map).end() && found==false) { + + if (line == (fileLineMap_iter->line+1)) { + found = true; + ptr->setLine(fileLineMap_iter->line_override+1); + ptr->setSrcName(fileLineMap_iter->file_override); + } + + fileLineMap_iter++; + } + if (found == false) { + ptr->setLine(line); + std::cout << "Drama! " + << text + << "line: "<< line << " not found" << std::endl; + } + ptr->setCharPositionInLine(charPositionInLine); + if (text != "") { + ptr->setText(text); + } else if (copyText && source.second != nullptr) { + ptr->setText(source.second->getText(antlr4::misc::Interval(start, stop))); + } + + return t; +} + + + +std::unique_ptr +hdlConvertorTokenFactory::create( + size_t type, + const std::string &text) { + return std::unique_ptr(new hdlConvertorToken(type, text)); + +} + +} diff --git a/src/meson.build b/src/meson.build index a139be7b..59fb4a3a 100644 --- a/src/meson.build +++ b/src/meson.build @@ -8,6 +8,8 @@ hdlConvertor_core_src = [ 'conversion_exception.cpp', 'universal_fs.cpp', 'encodingConversions.cpp', + 'hdlConvertorToken.cpp', + 'hdlConvertorTokenFactory.cpp' ] hdlConvertor_core_src += run_command(py3, '../utils/rec_glob.py', './hdlAst', '*.cpp', check:true)\ .stdout().strip().split('\n') diff --git a/src/toString.cpp b/src/toString.cpp index e6743bfb..2eb5354b 100644 --- a/src/toString.cpp +++ b/src/toString.cpp @@ -172,6 +172,7 @@ void ToString::dump(const CodePosition * o, int indent) { dump_size_t("stopLine", o->stop_line); dump_size_t("startColumn", o->start_column); dump_size_t("stopColumn", o->stop_column); + dump_size_t("fileName",o->file_name); indent -= INDENT_INCR; mkIndent(indent) << "}"; } From 4dc900c66ac4e1bd2f9bbabba0270303e73c5f0b Mon Sep 17 00:00:00 2001 From: Thomasb81 Date: Sun, 14 Jul 2024 15:35:29 +0200 Subject: [PATCH 03/34] Revert "trial replace python setup.py bdist_wheel -j 4" This reverts commit a2c943da258d271d31f24bd0e038b9acc7d344e1. --- .github/workflows/build_and_release.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_and_release.yml b/.github/workflows/build_and_release.yml index 41250330..ff9cd40e 100644 --- a/.github/workflows/build_and_release.yml +++ b/.github/workflows/build_and_release.yml @@ -91,9 +91,8 @@ jobs: # Use them with `-j 4` flag - name: Build Library run: | - #python setup.py bdist_wheel -j 4 - #auditwheel repair --plat manylinux_2_31_x86_64 dist/*.whl - pip install . + python setup.py bdist_wheel -j 4 + auditwheel repair --plat manylinux_2_31_x86_64 dist/*.whl - name: Archive Artifacts uses: actions/upload-artifact@v3 From 6d6fad011f3db0db2de1247e80572a9d26ce216e Mon Sep 17 00:00:00 2001 From: Thomasb81 Date: Sun, 14 Jul 2024 15:45:51 +0200 Subject: [PATCH 04/34] Fix typo --- include/hdlConvertor/hdlConvertor.h | 1 + src/hdlConvertor.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/hdlConvertor/hdlConvertor.h b/include/hdlConvertor/hdlConvertor.h index 66c0c180..faf031ab 100644 --- a/include/hdlConvertor/hdlConvertor.h +++ b/include/hdlConvertor/hdlConvertor.h @@ -12,6 +12,7 @@ #include #include #include +#include namespace hdlConvertor { diff --git a/src/hdlConvertor.cpp b/src/hdlConvertor.cpp index 79f585a8..17d4bb2f 100644 --- a/src/hdlConvertor.cpp +++ b/src/hdlConvertor.cpp @@ -56,7 +56,7 @@ class SVParserContainer: public iParserContainer Date: Sun, 14 Jul 2024 16:11:29 +0200 Subject: [PATCH 05/34] typo fix allowing to run regression --- src/hdlConvertor.cpp | 14 ++++++++++++++ src/hdlConvertorTokenFactory.cpp | 2 ++ 2 files changed, 16 insertions(+) diff --git a/src/hdlConvertor.cpp b/src/hdlConvertor.cpp index 17d4bb2f..b8e7c843 100644 --- a/src/hdlConvertor.cpp +++ b/src/hdlConvertor.cpp @@ -25,6 +25,20 @@ class VHDLParserContainer: public iParserContainer { using iParserContainer::iParserContainer; virtual void parseFn() override { + + /* + * Customize Lexer with our hdlConvertorToken factory + * This allow us to enrich antlr4::CommonToken with filename on + * each token, then spread this kind of detail everywhere token are + * use. + * Dummy structure for vhdl, since no processing step exist. + * */ + verilog_pp::FileLineMap dummy_file_line_map; + hdlConvertorTokenFactory factory; + factory.setFileLineMap(&dummy_file_line_map); + lexer.get()->setTokenFactory(factory.DEFAULT.get()); + + vhdl_antlr::vhdlParser::Design_fileContext *tree = antlrParser->design_file(); syntaxErrLogger.check_errors(); // Throw exception if errors diff --git a/src/hdlConvertorTokenFactory.cpp b/src/hdlConvertorTokenFactory.cpp index d0b3e7eb..dd80c03a 100644 --- a/src/hdlConvertorTokenFactory.cpp +++ b/src/hdlConvertorTokenFactory.cpp @@ -55,9 +55,11 @@ hdlConvertorTokenFactory::create( } if (found == false) { ptr->setLine(line); + /* line not found ! For time beeing keep original data std::cout << "Drama! " << text << "line: "<< line << " not found" << std::endl; + */ } ptr->setCharPositionInLine(charPositionInLine); if (text != "") { From 7c00e7b262a1329546de982d999e8297bc7e3c99 Mon Sep 17 00:00:00 2001 From: Thomasb81 Date: Sun, 14 Jul 2024 16:14:55 +0200 Subject: [PATCH 06/34] Add missing testcase files --- tests/sv_pp/expected/include_many_dir/from_subdirectory2.txt | 3 +++ tests/sv_pp/src/include_many_dir/dir0-a/dir1-a/file2-b.txt | 1 + tests/sv_pp/src/include_many_dir/from_subdirectory2.txt | 3 +++ 3 files changed, 7 insertions(+) create mode 100644 tests/sv_pp/expected/include_many_dir/from_subdirectory2.txt create mode 100644 tests/sv_pp/src/include_many_dir/dir0-a/dir1-a/file2-b.txt create mode 100644 tests/sv_pp/src/include_many_dir/from_subdirectory2.txt diff --git a/tests/sv_pp/expected/include_many_dir/from_subdirectory2.txt b/tests/sv_pp/expected/include_many_dir/from_subdirectory2.txt new file mode 100644 index 00000000..53e98acd --- /dev/null +++ b/tests/sv_pp/expected/include_many_dir/from_subdirectory2.txt @@ -0,0 +1,3 @@ +"file2-a.txt" +"file2-a.txt" +"file2-a.txt" diff --git a/tests/sv_pp/src/include_many_dir/dir0-a/dir1-a/file2-b.txt b/tests/sv_pp/src/include_many_dir/dir0-a/dir1-a/file2-b.txt new file mode 100644 index 00000000..ba5cbc4f --- /dev/null +++ b/tests/sv_pp/src/include_many_dir/dir0-a/dir1-a/file2-b.txt @@ -0,0 +1 @@ +"file2-a.txt" diff --git a/tests/sv_pp/src/include_many_dir/from_subdirectory2.txt b/tests/sv_pp/src/include_many_dir/from_subdirectory2.txt new file mode 100644 index 00000000..dbf9d3d1 --- /dev/null +++ b/tests/sv_pp/src/include_many_dir/from_subdirectory2.txt @@ -0,0 +1,3 @@ +`include "dir0-a/dir1-a/file2-b.txt" +`include "./dir0-a/dir1-a/file2-b.txt" +`include "./dir0-a/../dir0-a/dir1-a/file2-b.txt" From b195e8e0d5959a730268478c16f465ecf22eb524 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Sep 2024 22:12:38 +0000 Subject: [PATCH 07/34] Bump actions/download-artifact from 3 to 4.1.7 in /.github/workflows Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 3 to 4.1.7. - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](https://github.com/actions/download-artifact/compare/v3...v4.1.7) --- updated-dependencies: - dependency-name: actions/download-artifact dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- .github/workflows/build_and_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_release.yml b/.github/workflows/build_and_release.yml index ff9cd40e..bafe3846 100644 --- a/.github/workflows/build_and_release.yml +++ b/.github/workflows/build_and_release.yml @@ -160,7 +160,7 @@ jobs: steps: - name: Download Package Built - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4.1.7 with: name: PythonPackage path: dist From 3ef1693eaf1c69c4920f66a4c15900b5f40a0108 Mon Sep 17 00:00:00 2001 From: Nic30 Date: Tue, 10 Jun 2025 17:01:15 +0200 Subject: [PATCH 08/34] test: appveyor use Python312-x64 --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index 92f1417a..13e6a44a 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -13,7 +13,7 @@ environment: - GENERATOR: -G"Visual Studio 16 2019" -A x64 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 BUILD_TYPE: Release - PYTHON: "C:\\Python39-x64" + PYTHON: "C:\\Python312-x64" # add to path otherwise Cython is not found PATH: C:\Program Files\Java\jdk11\bin;$(PYTHON)\Scripts;$(PATH) PLATFORM: x64 From c29c62e26f8c840a230046a5aac91be71cf1db06 Mon Sep 17 00:00:00 2001 From: Nic30 Date: Tue, 10 Jun 2025 17:01:41 +0200 Subject: [PATCH 09/34] build: upgrade antlr4==4.13.2 --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 199820b4..9e7be881 100644 --- a/meson.build +++ b/meson.build @@ -50,7 +50,7 @@ endif antlr4_runtime_opt.set_install(false) # because meson-python does not know where to install it antlr4_runtime_proj = cmake.subproject('antlr4-runtime', options: antlr4_runtime_opt) antlr4_cpp_dep = antlr4_runtime_proj.dependency('antlr4_static') - antlr4_cpp_version = '4.13.1' + antlr4_cpp_version = '4.13.2' # :note: must match version in antlr4-runtime.wrap import('java') # to check that java is installed antlr4_jar = join_paths(meson.current_build_dir() , 'antlr4-complete.jar') fs = import('fs') From 695af823584c1fb2cb782ecbc229c28972897762 Mon Sep 17 00:00:00 2001 From: Nic30 Date: Tue, 10 Jun 2025 17:02:12 +0200 Subject: [PATCH 10/34] build: upgrade antlr==4.13.2 --- subprojects/antlr4-runtime.wrap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/antlr4-runtime.wrap b/subprojects/antlr4-runtime.wrap index 3809ea71..c677cfa5 100644 --- a/subprojects/antlr4-runtime.wrap +++ b/subprojects/antlr4-runtime.wrap @@ -1,5 +1,5 @@ [wrap-git] url = https://github.com/antlr/antlr4.git -revision = 4.13.1 +revision = 4.13.2 diff_files=0001-add-CMakeLists.txt-to-root.patch depth=1 \ No newline at end of file From 111b7ae6b1fc1fd7d5087881e6149fa6a125dd71 Mon Sep 17 00:00:00 2001 From: Nic30 Date: Tue, 10 Jun 2025 17:13:58 +0200 Subject: [PATCH 11/34] test: update ubuntu version for github actions --- .github/workflows/build_and_release.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_and_release.yml b/.github/workflows/build_and_release.yml index bafe3846..72c5903a 100644 --- a/.github/workflows/build_and_release.yml +++ b/.github/workflows/build_and_release.yml @@ -8,7 +8,7 @@ permissions: jobs: # Create a Debug build and test it. build_and_test: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: @@ -63,8 +63,8 @@ jobs: strategy: matrix: - python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11", "3.12" ] - runs-on: ubuntu-20.04 + python-version: [ "3.9", "3.10", "3.11", "3.12" ] + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: @@ -105,7 +105,7 @@ jobs: # Developer can still build on their machine with the source bundle # (i.e. the original `pip install` flow if the platform is not included by above steps) build_sdist: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest if: ${{ success() }} needs: @@ -117,7 +117,7 @@ jobs: submodules: recursive - uses: actions/setup-python@v5 with: - python-version: "3.9" + python-version: "3.12" - name: Install Dependencies run: | sudo apt update -y From 5468896449c465a2d555a4342c87e7a59e5d0955 Mon Sep 17 00:00:00 2001 From: Nic30 Date: Tue, 10 Jun 2025 17:45:06 +0200 Subject: [PATCH 12/34] test: github actions: upgrade to download-artifact@v4.1.7 --- .github/workflows/build_and_release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_and_release.yml b/.github/workflows/build_and_release.yml index 72c5903a..54d1ff50 100644 --- a/.github/workflows/build_and_release.yml +++ b/.github/workflows/build_and_release.yml @@ -95,7 +95,7 @@ jobs: auditwheel repair --plat manylinux_2_31_x86_64 dist/*.whl - name: Archive Artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4.1.7 with: name: PythonPackage path: | @@ -133,7 +133,7 @@ jobs: python setup.py sdist - name: Archive Artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4.1.7 with: name: PythonPackage path: | From 31ea10733ff1119c63ba7c7df2423f227775b6ce Mon Sep 17 00:00:00 2001 From: Nic30 Date: Tue, 10 Jun 2025 17:46:00 +0200 Subject: [PATCH 13/34] build(windows): update EXTRA_CXX_FLAGS --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 9e7be881..989c6eda 100644 --- a/meson.build +++ b/meson.build @@ -23,7 +23,7 @@ cc = meson.get_compiler('cpp') EXTRA_CXX_FLAGS = [] EXTRA_LD_FLAGS = [] if meson.get_compiler('cpp').get_id() == 'msvc' - EXTRA_CXX_FLAGS.append('/bigobj') + EXTRA_CXX_FLAGS += ['-MP /wd4251', '/bigobj'] # https://github.com/antlr/antlr4/blob/dev/runtime/Cpp/demo/CMakeLists.txt # using /MD flag for antlr4_runtime (for Visual C++ compilers only) elif host_machine.system() == 'cygwin' EXTRA_CXX_FLAGS += ['-Wa,-mbig-obj'] From 455736ec7fa03652eb3d8b0c29396c7ce4b0b7cc Mon Sep 17 00:00:00 2001 From: Nic30 Date: Tue, 10 Jun 2025 17:52:58 +0200 Subject: [PATCH 14/34] test(github actions): use *-artifact@v4 --- .github/workflows/build_and_release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_and_release.yml b/.github/workflows/build_and_release.yml index 54d1ff50..1d59dbbd 100644 --- a/.github/workflows/build_and_release.yml +++ b/.github/workflows/build_and_release.yml @@ -95,7 +95,7 @@ jobs: auditwheel repair --plat manylinux_2_31_x86_64 dist/*.whl - name: Archive Artifacts - uses: actions/upload-artifact@v4.1.7 + uses: actions/upload-artifact@v4 with: name: PythonPackage path: | @@ -133,7 +133,7 @@ jobs: python setup.py sdist - name: Archive Artifacts - uses: actions/upload-artifact@v4.1.7 + uses: actions/upload-artifact@v4 with: name: PythonPackage path: | @@ -160,7 +160,7 @@ jobs: steps: - name: Download Package Built - uses: actions/download-artifact@v4.1.7 + uses: actions/download-artifact@v4 with: name: PythonPackage path: dist From 4cc0fa2de4aa23f73d8367ffa86c69295ade9585 Mon Sep 17 00:00:00 2001 From: Nic30 Date: Tue, 10 Jun 2025 18:07:36 +0200 Subject: [PATCH 15/34] test(github actions): update build script --- .github/workflows/build_and_release.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_and_release.yml b/.github/workflows/build_and_release.yml index 1d59dbbd..e68a3bb0 100644 --- a/.github/workflows/build_and_release.yml +++ b/.github/workflows/build_and_release.yml @@ -36,16 +36,17 @@ jobs: - name: Build run: | - echo Your Build Script here - echo Make sure the Debug and Coverage Switch is on, only in this job. + python3 -m build -Ccompile-args="--verbose" -Ccompile-args="-j4" . # -j4 because we do not have enough RAM + pip3 install dist/*.whl + rm -rf $MODULE_NAME - name: Test run: | - echo Your Test Script here + python3 -m tests.all - name: Extract Coverage Report run: | - echo Your Coverage Report + echo "[todo] Coverage Report" # Build on Different Platform. @@ -79,6 +80,7 @@ jobs: libantlr4-runtime-dev antlr4 libssl-dev -yq pip install setuptools wheel cmake ninja patchelf auditwheel pip install -r requirements.txt + pip install build # Include ANTLR4's License file as we are redistributing their binary - name: Adding ANTLR4 License @@ -91,7 +93,7 @@ jobs: # Use them with `-j 4` flag - name: Build Library run: | - python setup.py bdist_wheel -j 4 + python -m build . auditwheel repair --plat manylinux_2_31_x86_64 dist/*.whl - name: Archive Artifacts From f6653e45db00851ad19b12cf68a21cdd266eb67a Mon Sep 17 00:00:00 2001 From: Nic30 Date: Tue, 10 Jun 2025 18:09:32 +0200 Subject: [PATCH 16/34] test(github actions): use python instead of python3 --- .github/workflows/build_and_release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_and_release.yml b/.github/workflows/build_and_release.yml index e68a3bb0..369ca730 100644 --- a/.github/workflows/build_and_release.yml +++ b/.github/workflows/build_and_release.yml @@ -36,13 +36,13 @@ jobs: - name: Build run: | - python3 -m build -Ccompile-args="--verbose" -Ccompile-args="-j4" . # -j4 because we do not have enough RAM - pip3 install dist/*.whl + python -m build -Ccompile-args="--verbose" -Ccompile-args="-j4" . # -j4 because we do not have enough RAM + pip install dist/*.whl rm -rf $MODULE_NAME - name: Test run: | - python3 -m tests.all + python -m tests.all - name: Extract Coverage Report run: | From beb963b10ec601ffdc116176ebb21353050f1917 Mon Sep 17 00:00:00 2001 From: Nic30 Date: Tue, 10 Jun 2025 18:30:19 +0200 Subject: [PATCH 17/34] build: fix keyword -> keywords --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 588b6a5b..51dae703 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,7 @@ dynamic = ["version", ] # specified in meson.build # readme = {file = ["README.md"]} readme = "README.md" license = { file = 'LICENSE' } -keyword = ['FPGA', 'ASIC', 'compiler', 'RTL', 'synthesis', 'logicsynthesis', +keywords = ['FPGA', 'ASIC', 'compiler', 'RTL', 'synthesis', 'logicsynthesis', 'hdl', 'vhdl', 'parser', 'preprocessor', 'antlr4', 'verification', 'Verilog', 'SystemVerilog', 'system verilog'] authors = [ From 6637c7ec51f482a8365d742e74f7a2ecce5add29 Mon Sep 17 00:00:00 2001 From: Nic30 Date: Tue, 10 Jun 2025 18:30:57 +0200 Subject: [PATCH 18/34] build: explicitly exclude tests from sdist --- MANIFEST.in | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MANIFEST.in b/MANIFEST.in index 29ee9b88..336d6404 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -12,3 +12,10 @@ recursive-include grammars *.g4 recursive-include hdlConvertor *.cpp *.h *.txt *.pyx *.py global-include *.gcno +exclude .appveyor.yml +exclude .circleci/ +exclude .github +exclude Dockerfile .dockerignore +exclude tests/ +exclude notebooks/ +exclude .gitignore .gitmodules From 883c26ca74c32be22f4eb843dcd7f1ad3e055fc4 Mon Sep 17 00:00:00 2001 From: Nic30 Date: Tue, 10 Jun 2025 18:33:19 +0200 Subject: [PATCH 19/34] build: recursively explicitly remove tests from sdist --- MANIFEST.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 336d6404..b70c2d4f 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -13,9 +13,9 @@ recursive-include hdlConvertor *.cpp *.h *.txt *.pyx *.py global-include *.gcno exclude .appveyor.yml -exclude .circleci/ +recursive-exclude .circleci/ exclude .github exclude Dockerfile .dockerignore -exclude tests/ -exclude notebooks/ +recursive-exclude tests/ +recursive-exclude notebooks/ exclude .gitignore .gitmodules From c517e89b1457f0802242f9e5efc0d8edf6463659 Mon Sep 17 00:00:00 2001 From: Nic30 Date: Tue, 10 Jun 2025 18:51:28 +0200 Subject: [PATCH 20/34] build: use .gitattributes instead of MANIFEST.in (as meson uses it) --- .gitattributes | 9 +++++++++ MANIFEST.in | 21 --------------------- 2 files changed, 9 insertions(+), 21 deletions(-) create mode 100644 .gitattributes delete mode 100644 MANIFEST.in diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..0209a562 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,9 @@ +.appveyor.yml export-ignore +.circleci/ export-ignore +.github export-ignore +Dockerfile export-ignore +.dockerignore export-ignore +tests export-ignore +notebooks export-ignore +.gitignore export-ignore +.gitmodules export-ignore \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index b70c2d4f..00000000 --- a/MANIFEST.in +++ /dev/null @@ -1,21 +0,0 @@ -include *.txt *.md -include MANIFEST.in -include README.md -include setup.py -include setup.cfg -include pyproject.toml -include LICENSE - -recursive-include include *.h -recursive-include src *.cpp *.h *.txt -recursive-include grammars *.g4 -recursive-include hdlConvertor *.cpp *.h *.txt *.pyx *.py -global-include *.gcno - -exclude .appveyor.yml -recursive-exclude .circleci/ -exclude .github -exclude Dockerfile .dockerignore -recursive-exclude tests/ -recursive-exclude notebooks/ -exclude .gitignore .gitmodules From 1e0f5257f86f03587b8e200d92943f177a660678 Mon Sep 17 00:00:00 2001 From: Nic30 Date: Tue, 10 Jun 2025 18:52:03 +0200 Subject: [PATCH 21/34] build(github actions): install "build" python package --- .github/workflows/build_and_release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_and_release.yml b/.github/workflows/build_and_release.yml index 369ca730..31bdeed2 100644 --- a/.github/workflows/build_and_release.yml +++ b/.github/workflows/build_and_release.yml @@ -15,7 +15,7 @@ jobs: submodules: recursive - uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: "3.12" # Don't need to install Python / Create venv, as you are running in a container. # You don't even need to install g++/cmake as it comes with the docker image. @@ -26,6 +26,7 @@ jobs: libantlr4-runtime-dev antlr4 libssl-dev -yq pip install setuptools wheel cmake ninja patchelf auditwheel pip install -r requirements.txt + pip install build - name: Check Your Environment run: | From d9582f6002210ad27c4ff62103c8c5cf34a70572 Mon Sep 17 00:00:00 2001 From: Nic30 Date: Tue, 10 Jun 2025 19:28:48 +0200 Subject: [PATCH 22/34] build: tests/** export-ignore --- .gitattributes | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitattributes b/.gitattributes index 0209a562..ce67ee9b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,7 +3,7 @@ .github export-ignore Dockerfile export-ignore .dockerignore export-ignore -tests export-ignore +tests/** export-ignore notebooks export-ignore .gitignore export-ignore -.gitmodules export-ignore \ No newline at end of file +.gitmodules export-ignore From 2ee212d276ab3a156cc9f0cdbbfd66119813cc04 Mon Sep 17 00:00:00 2001 From: Nic30 Date: Tue, 10 Jun 2025 20:10:35 +0200 Subject: [PATCH 23/34] build: mark tests as test data --- meson.build | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/meson.build b/meson.build index 989c6eda..f6e9e0f7 100644 --- a/meson.build +++ b/meson.build @@ -164,3 +164,10 @@ subdir('src') if get_option('python_package') subdir('hdlConvertor') endif + +if fs.exists('tests/yosys/CHANGELOG') + # if tests files are in the package mark them as test data + test_data = run_command(python_prog, 'utils/rec_glob.py', 'tests', '*', check:true)\ + .stdout().strip().split('\n') + install_data(test_data, install_tag : 'test') +endif From a8a9e54fadf6c46b709767f7400c6571d4974c3c Mon Sep 17 00:00:00 2001 From: Nic30 Date: Tue, 10 Jun 2025 20:10:47 +0200 Subject: [PATCH 24/34] build: update build-system deps --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 51dae703..05f31ba7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,8 +3,8 @@ requires = [ "wheel", # python package distribution lib. "Cython", "cmake>=3.26.3", # cmake buildsystem for antrl - "meson>=1.1.0", # meson buildsystem - 'meson-python>=0.12.1', # meson to pip adapter + "meson>=1.8.2", # meson buildsystem + 'meson-python>=0.18.0', # meson to pip adapter "pybind11>=2.10.4", # c++ to Python binding "ninja>=1.11.1", # build tool for meson to use ] From 545578b607eae0c8905dfba421a1ad874a2e6f17 Mon Sep 17 00:00:00 2001 From: Nic30 Date: Tue, 10 Jun 2025 20:24:51 +0200 Subject: [PATCH 25/34] build: fix check for test files --- meson.build | 11 +++++------ utils/rec_glob.py | 9 +++++++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/meson.build b/meson.build index f6e9e0f7..268e3739 100644 --- a/meson.build +++ b/meson.build @@ -165,9 +165,8 @@ if get_option('python_package') subdir('hdlConvertor') endif -if fs.exists('tests/yosys/CHANGELOG') - # if tests files are in the package mark them as test data - test_data = run_command(python_prog, 'utils/rec_glob.py', 'tests', '*', check:true)\ - .stdout().strip().split('\n') - install_data(test_data, install_tag : 'test') -endif +# if tests files are in the package mark them as test data +test_data = run_command(python_prog, 'utils/rec_glob.py', 'tests', '*', check:true)\ + .stdout().strip().split('\n') +install_data(test_data, install_tag : 'test') + diff --git a/utils/rec_glob.py b/utils/rec_glob.py index 5e15f65c..487769b3 100644 --- a/utils/rec_glob.py +++ b/utils/rec_glob.py @@ -7,7 +7,7 @@ def call_glob(): if len(sys.argv) != 3: - print("[Error] Usage `glob.py path 'module'|pattern`, but provided `%r`" % sys.argv, file=sys.stderr) + print("[Error] Usage `glob.py path 'module'|any|pattern`, but provided `%r`" % sys.argv, file=sys.stderr) sys.exit(1) root, mode = sys.argv[1:] @@ -23,10 +23,15 @@ def call_glob(): print(d) seen_module_directories.add(d) + elif mode == '*': + for path in Path(root).rglob(mode): + if path.is_file(): + print(path.as_posix()) else: # list files by extension in a folder for path in Path(root).glob(mode): - print(path.as_posix()) + if path.is_file(): + print(path.as_posix()) if __name__ == "__main__": From e533fa46ab6fb4ce2fa14b418656356dfe540cc0 Mon Sep 17 00:00:00 2001 From: Nic30 Date: Tue, 10 Jun 2025 20:37:03 +0200 Subject: [PATCH 26/34] build: rm .gitattributes and .gitignore from .gitattributes --- .gitattributes | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitattributes b/.gitattributes index ce67ee9b..b720bee4 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,6 +4,5 @@ Dockerfile export-ignore .dockerignore export-ignore tests/** export-ignore +#tests/ivtest export-ignore notebooks export-ignore -.gitignore export-ignore -.gitmodules export-ignore From c5621c21a47834aefdd247cfde685842a7b21402 Mon Sep 17 00:00:00 2001 From: Nic30 Date: Tue, 10 Jun 2025 20:40:37 +0200 Subject: [PATCH 27/34] build: try to explicitly export-ignore files from tests/ --- .gitattributes | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index b720bee4..06fbaefd 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,5 +4,7 @@ Dockerfile export-ignore .dockerignore export-ignore tests/** export-ignore -#tests/ivtest export-ignore +tests/ghdl/** export-ignore +tests/ghdl/ export-ignore +tests/ghdl/logo.png export-ignore notebooks export-ignore From 8874dfe03ce489edeae28483bd1b0340dbd71018 Mon Sep 17 00:00:00 2001 From: Nic30 Date: Tue, 10 Jun 2025 20:45:00 +0200 Subject: [PATCH 28/34] build: rm install_data for test files --- meson.build | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index 268e3739..e3e33c12 100644 --- a/meson.build +++ b/meson.build @@ -166,7 +166,9 @@ if get_option('python_package') endif # if tests files are in the package mark them as test data -test_data = run_command(python_prog, 'utils/rec_glob.py', 'tests', '*', check:true)\ - .stdout().strip().split('\n') -install_data(test_data, install_tag : 'test') +#test_data = run_command(python_prog, 'utils/rec_glob.py', 'tests', '*', check:true)\ +# .stdout().strip().split('\n') +#message('test_data:\n' + '\n'.join(test_data)) +# +#install_data(test_data, install_tag : 'test') From 7c441ab595c5d41263a6ff41704e0579f5ddbdc1 Mon Sep 17 00:00:00 2001 From: Nic30 Date: Tue, 10 Jun 2025 20:49:26 +0200 Subject: [PATCH 29/34] build: add 'tests' tag for test files --- meson.build | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/meson.build b/meson.build index e3e33c12..8a601b5f 100644 --- a/meson.build +++ b/meson.build @@ -166,9 +166,9 @@ if get_option('python_package') endif # if tests files are in the package mark them as test data -#test_data = run_command(python_prog, 'utils/rec_glob.py', 'tests', '*', check:true)\ -# .stdout().strip().split('\n') -#message('test_data:\n' + '\n'.join(test_data)) -# -#install_data(test_data, install_tag : 'test') +test_data = run_command(python_prog, 'utils/rec_glob.py', 'tests', '*', check:true)\ + .stdout().strip().split('\n') +message('test_data:\n' + '\n'.join(test_data)) + +install_data(test_data, install_tag : 'tests') From 1276d1031e1a4d191b6f35ff30737bf6e3e38db6 Mon Sep 17 00:00:00 2001 From: Nic30 Date: Tue, 10 Jun 2025 22:15:32 +0200 Subject: [PATCH 30/34] build(github): fix rm of python sources before test exe --- .github/workflows/build_and_release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_and_release.yml b/.github/workflows/build_and_release.yml index 31bdeed2..cf5d4637 100644 --- a/.github/workflows/build_and_release.yml +++ b/.github/workflows/build_and_release.yml @@ -39,11 +39,12 @@ jobs: run: | python -m build -Ccompile-args="--verbose" -Ccompile-args="-j4" . # -j4 because we do not have enough RAM pip install dist/*.whl - rm -rf $MODULE_NAME - name: Test run: | + mv hdlConvertor tmp_hdlConvertor python -m tests.all + mv tmp_hdlConvertor hdlConvertor - name: Extract Coverage Report run: | From e505d4be4d530d15d1eab52101c0b0d37cf2802e Mon Sep 17 00:00:00 2001 From: Nic30 Date: Tue, 10 Jun 2025 22:27:09 +0200 Subject: [PATCH 31/34] build(github): add missing install of nbconvert --- .github/workflows/build_and_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_release.yml b/.github/workflows/build_and_release.yml index cf5d4637..5a7e6419 100644 --- a/.github/workflows/build_and_release.yml +++ b/.github/workflows/build_and_release.yml @@ -26,7 +26,7 @@ jobs: libantlr4-runtime-dev antlr4 libssl-dev -yq pip install setuptools wheel cmake ninja patchelf auditwheel pip install -r requirements.txt - pip install build + pip install build nbconvert - name: Check Your Environment run: | From 0e97626b90c082df4e8abc8cb5cbd5656f03bcd7 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 15 Jun 2025 12:18:00 +0200 Subject: [PATCH 32/34] Remove new_line from preprocessor --- grammars/verilogPreprocLexer.g4 | 8 ++++++-- src/verilogPreproc/out_buffer.cpp | 2 +- tests/sv_pp/expected/debug_macro.txt | 2 -- .../include_many_dir/dir0-a/dir1-a/spec_incdir.txt | 1 - .../dir0-a/local_include_higher_priority.txt | 1 - .../sv_pp/expected/include_many_dir/from_subdirectory.txt | 7 +------ .../expected/include_many_dir/from_subdirectory2.txt | 3 +++ tests/sv_pp/expected/include_many_dir/transitive.txt | 4 ---- tests/sv_pp/expected/include_same_dir/basic_include.txt | 1 - .../expected/include_same_dir/basic_include2times.txt | 3 --- .../sv_pp/src/include_many_dir/dir0-a/dir1-a/file2-b.txt | 1 + tests/sv_pp/src/include_many_dir/from_subdirectory2.txt | 3 +++ tests/test_verilog_preproc_include.py | 3 +++ 13 files changed, 18 insertions(+), 21 deletions(-) create mode 100644 tests/sv_pp/expected/include_many_dir/from_subdirectory2.txt create mode 100644 tests/sv_pp/src/include_many_dir/dir0-a/dir1-a/file2-b.txt create mode 100644 tests/sv_pp/src/include_many_dir/from_subdirectory2.txt diff --git a/grammars/verilogPreprocLexer.g4 b/grammars/verilogPreprocLexer.g4 index 8fb4adec..59cc0ee2 100644 --- a/grammars/verilogPreprocLexer.g4 +++ b/grammars/verilogPreprocLexer.g4 @@ -359,11 +359,15 @@ mode KEYWOORDS_MODE; // include argument processing mode INCLUDE_MODE; INCLUDE_MODE_STR - : STR -> type(STR),popMode + : STR -> type(STR) ; + INCLUDE_MODE_STR_CHEVRONS - : '<' ( ~('\\'|'>') )* '>' -> type(STR),popMode + : '<' ( ~('\\'|'>') )* '>' -> type(STR) ; + INCLUDE_LINE_COMMENT : LINE_COMMENT -> popMode,type(LINE_COMMENT),channel(CH_LINE_COMMENT); + INCLUDE_MODE_NEW_LINE: CRLF -> type(NEW_LINE),popMode,skip; + INCLUDE_MODE_MACRO_ENTER: '`' -> popMode,pushMode(DIRECTIVE_MODE),skip; INCLUDE_MODE_WS : WS ->skip; diff --git a/src/verilogPreproc/out_buffer.cpp b/src/verilogPreproc/out_buffer.cpp index 68d863e5..522f2ba1 100644 --- a/src/verilogPreproc/out_buffer.cpp +++ b/src/verilogPreproc/out_buffer.cpp @@ -60,7 +60,7 @@ VerilogPreprocOutBuffer& VerilogPreprocOutBuffer::operator<<( VerilogPreprocOutBuffer& VerilogPreprocOutBuffer::operator<<( const VerilogPreprocOutBuffer &other) { - (*this) << endl; + //(*this) << endl; (*static_cast(this)) << other.str(); for (auto &i : other.file_line_map) { FileLineMapItem i_new(i.line + output_line, i.file_override, diff --git a/tests/sv_pp/expected/debug_macro.txt b/tests/sv_pp/expected/debug_macro.txt index a1a5103d..8a8ee519 100644 --- a/tests/sv_pp/expected/debug_macro.txt +++ b/tests/sv_pp/expected/debug_macro.txt @@ -5,6 +5,4 @@ - - $display(">> %s, %d: %s", "sv_pp/src/debug_macro.txt", 3, "msg") diff --git a/tests/sv_pp/expected/include_many_dir/dir0-a/dir1-a/spec_incdir.txt b/tests/sv_pp/expected/include_many_dir/dir0-a/dir1-a/spec_incdir.txt index 807a1ca1..1124e96b 100644 --- a/tests/sv_pp/expected/include_many_dir/dir0-a/dir1-a/spec_incdir.txt +++ b/tests/sv_pp/expected/include_many_dir/dir0-a/dir1-a/spec_incdir.txt @@ -1,2 +1 @@ - "good content" \ No newline at end of file diff --git a/tests/sv_pp/expected/include_many_dir/dir0-a/local_include_higher_priority.txt b/tests/sv_pp/expected/include_many_dir/dir0-a/local_include_higher_priority.txt index 807a1ca1..1124e96b 100644 --- a/tests/sv_pp/expected/include_many_dir/dir0-a/local_include_higher_priority.txt +++ b/tests/sv_pp/expected/include_many_dir/dir0-a/local_include_higher_priority.txt @@ -1,2 +1 @@ - "good content" \ No newline at end of file diff --git a/tests/sv_pp/expected/include_many_dir/from_subdirectory.txt b/tests/sv_pp/expected/include_many_dir/from_subdirectory.txt index 8528768f..d1f22783 100644 --- a/tests/sv_pp/expected/include_many_dir/from_subdirectory.txt +++ b/tests/sv_pp/expected/include_many_dir/from_subdirectory.txt @@ -1,6 +1 @@ - -"file2-a.txt" - -"file2-a.txt" - -"file2-a.txt" +"file2-a.txt""file2-a.txt""file2-a.txt" \ No newline at end of file diff --git a/tests/sv_pp/expected/include_many_dir/from_subdirectory2.txt b/tests/sv_pp/expected/include_many_dir/from_subdirectory2.txt new file mode 100644 index 00000000..53e98acd --- /dev/null +++ b/tests/sv_pp/expected/include_many_dir/from_subdirectory2.txt @@ -0,0 +1,3 @@ +"file2-a.txt" +"file2-a.txt" +"file2-a.txt" diff --git a/tests/sv_pp/expected/include_many_dir/transitive.txt b/tests/sv_pp/expected/include_many_dir/transitive.txt index a7c0eed4..92cde8dc 100644 --- a/tests/sv_pp/expected/include_many_dir/transitive.txt +++ b/tests/sv_pp/expected/include_many_dir/transitive.txt @@ -1,8 +1,4 @@ - "transitive-0" - "transitive-1" - "transitive-2" - "transitive-3" \ No newline at end of file diff --git a/tests/sv_pp/expected/include_same_dir/basic_include.txt b/tests/sv_pp/expected/include_same_dir/basic_include.txt index 12fb4c89..5e2ef389 100644 --- a/tests/sv_pp/expected/include_same_dir/basic_include.txt +++ b/tests/sv_pp/expected/include_same_dir/basic_include.txt @@ -1,4 +1,3 @@ - "a.vh" diff --git a/tests/sv_pp/expected/include_same_dir/basic_include2times.txt b/tests/sv_pp/expected/include_same_dir/basic_include2times.txt index dd0b6a63..5e2ef389 100644 --- a/tests/sv_pp/expected/include_same_dir/basic_include2times.txt +++ b/tests/sv_pp/expected/include_same_dir/basic_include2times.txt @@ -1,6 +1,3 @@ - "a.vh" - - diff --git a/tests/sv_pp/src/include_many_dir/dir0-a/dir1-a/file2-b.txt b/tests/sv_pp/src/include_many_dir/dir0-a/dir1-a/file2-b.txt new file mode 100644 index 00000000..ba5cbc4f --- /dev/null +++ b/tests/sv_pp/src/include_many_dir/dir0-a/dir1-a/file2-b.txt @@ -0,0 +1 @@ +"file2-a.txt" diff --git a/tests/sv_pp/src/include_many_dir/from_subdirectory2.txt b/tests/sv_pp/src/include_many_dir/from_subdirectory2.txt new file mode 100644 index 00000000..dbf9d3d1 --- /dev/null +++ b/tests/sv_pp/src/include_many_dir/from_subdirectory2.txt @@ -0,0 +1,3 @@ +`include "dir0-a/dir1-a/file2-b.txt" +`include "./dir0-a/dir1-a/file2-b.txt" +`include "./dir0-a/../dir0-a/dir1-a/file2-b.txt" diff --git a/tests/test_verilog_preproc_include.py b/tests/test_verilog_preproc_include.py index 92187d68..a906c78e 100644 --- a/tests/test_verilog_preproc_include.py +++ b/tests/test_verilog_preproc_include.py @@ -43,6 +43,9 @@ def test_basic_include2times(self): def test_from_subdirectory(self): self.run_test(["include_many_dir", "from_subdirectory.txt"], []) + + def test_from_subdirectory2(self): + self.run_test(["include_many_dir", "from_subdirectory2.txt"], []) def test_local_include_higher_priority(self): self.run_test( From 647205facddd29a93478da2e1822ed86ddc0bf37 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 15 Jun 2025 12:22:56 +0200 Subject: [PATCH 33/34] Remove commented code --- src/verilogPreproc/out_buffer.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/verilogPreproc/out_buffer.cpp b/src/verilogPreproc/out_buffer.cpp index 522f2ba1..ee11c42d 100644 --- a/src/verilogPreproc/out_buffer.cpp +++ b/src/verilogPreproc/out_buffer.cpp @@ -60,7 +60,6 @@ VerilogPreprocOutBuffer& VerilogPreprocOutBuffer::operator<<( VerilogPreprocOutBuffer& VerilogPreprocOutBuffer::operator<<( const VerilogPreprocOutBuffer &other) { - //(*this) << endl; (*static_cast(this)) << other.str(); for (auto &i : other.file_line_map) { FileLineMapItem i_new(i.line + output_line, i.file_override, From 7de6dd17ba13827ace33d1a834d75c9ecbad9ef1 Mon Sep 17 00:00:00 2001 From: Nic30 Date: Tue, 24 Jun 2025 13:55:18 +0200 Subject: [PATCH 34/34] fix(meson): add missing dependency on generated parsers #202 --- meson.build | 4 ++++ src/meson.build | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index 8a601b5f..bdf3d8e9 100644 --- a/meson.build +++ b/meson.build @@ -88,6 +88,7 @@ curSrcDir = meson.current_source_dir() mainIncludeDir = 'include/' mainIncludeDir_inc = include_directories(mainIncludeDir) all_parser_libs = [] +all_parser_deps = [] foreach parserTuple : ANTLR_PARSERS name = parserTuple[0] folder_name = parserTuple[1] @@ -157,6 +158,9 @@ foreach parserTuple : ANTLR_PARSERS include_directories: [mainIncludeDir_inc, include_directories(genIncludeDir)], ) all_parser_libs += parser_lib + parser_lib_dependency = declare_dependency( + link_with : [parser_lib],) + all_parser_deps += parser_lib_dependency endforeach subdir('src') diff --git a/src/meson.build b/src/meson.build index a139be7b..9ca74da1 100644 --- a/src/meson.build +++ b/src/meson.build @@ -17,7 +17,7 @@ hdlConvertor_core_src += run_command(py3, '../utils/rec_glob.py', './baseHdlPars hdlConvertor_core_static_lib = static_library('hdlConvertor_core_static', hdlConvertor_core_src, cpp_args: EXTRA_CXX_FLAGS, - dependencies: [antlr4_cpp_dep], + dependencies: [antlr4_cpp_dep, all_parser_deps], include_directories: [mainIncludeDir_inc], #link_with: [libtracker_common], ) @@ -34,7 +34,7 @@ if get_option('python_package') hdlConvertor_cpp_static = static_library('hdlConvertor_cpp_static', hdlConvertor_cpp_src, cpp_args: EXTRA_CXX_FLAGS, - dependencies: [antlr4_cpp_dep], + dependencies: [antlr4_cpp_dep, all_parser_deps], include_directories: [mainIncludeDir_inc], link_with: [hdlConvertor_core_static_lib, all_parser_libs], ) @@ -44,7 +44,7 @@ else hdlConvertor_cpp_shared = shared_library('hdlConvertor_cpp_shared', hdlConvertor_cpp_src, cpp_args: EXTRA_CXX_FLAGS, - dependencies: [antlr4_cpp_dep], + dependencies: [antlr4_cpp_dep, ] + all_parser_deps, include_directories: [mainIncludeDir_inc], link_with: [hdlConvertor_core_static_lib, all_parser_libs], )