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

[VeriblePreProcessor][4]: Handling file inclusion in "VerilogPreprocess" class. #1375

Closed

Conversation

karimtera
Copy link
Contributor

NOTE: This is a part of the sequentially splitted PRs from PR #1360.

Description:

  • Added a feature to VerilogPreprocess which allows to store paths,
    That can be used later to find the SV file to include.
  • The preprocessor tool takes these paths from the user,
    as a +incdir+<path>[+<another_path>] and set them in VerilogPreprocess.
  • The included files macros and conditionals can be expanded and evaluated.
  • Some limitations exists and were written as TODOs in place,
    need to open issues for these.

karimtera added 10 commits July 21, 2022 13:59
…o generate all variants with the new mode generate-variants
"verible::CmdPositionalArguments" class only supports these types so far: SV files, +define+<name>[=<value>], and +incdir+<dir>.
- Adding an interface function "AddDefineFromCmdLine" to use the macro added by +define+<foo> argument to "VerilogPreprocess".
- Added a feature to VerilogPreprocess which allows to store paths,
  That can be used later to find the SV file to include.
- The preprocessor tool takes these paths from the user,
  as a +incdir+<path>[+<another_path>] and set then in VerilogPreprocess.
- The included files macros and conditionals can be expanded and evaluated.
- Some limitations exists and were written as TODOs in place,
  need to open issues for these.
@hzeller
Copy link
Collaborator

hzeller commented Aug 15, 2022

Let's await until we're done with the other PRs, to not have too many review comments going on in parallel that might be harder to merge later.
With regard to include files it might be worthwhile looking around what happens in the context of the verilog project supprt verilog/analysis/verilog_project.h which is used by the Kythe indexer and the symbol table.

Not everything might apply, but it is good to have a look to have an informed choice knowing what already exists and could be re-used.

Comment on lines +134 to +138
absl::Status AddDefineFromCmdLine(
std::pair<absl::string_view, absl::string_view> define);

// Add search directory paths passed to the tool with +incdir+<path>.
absl::Status AddIncludeDirFromCmdLine(absl::string_view include_dir_path);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will start by replacing both of these functions with SetFileList().

@@ -219,6 +235,9 @@ class VerilogPreprocess {
bool current_branch_condition_met_;
};

// Paths to search into during handling `include
std::vector<std::string> search_paths_;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be the FileList containing defines, incdirs and SystemVerilog files.

A question: The SystemVerilog files will not be needed here, is there a way to make use of it? or remove it?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can change everything as needed.
Maybe we have a sub-type in FileList that contain preprocessing information.

struct FileList {
   struct PreprocessingInfo {
         std::vector<std::string> include_dirs;
         // ... macro defintions
   };
   std::vector<std::string> file_paths;
   PreprocessingInfo preprocessing;
};

Then use that type with only the relevant parts:

   FileList::PreprocessingInfo

Might need to change all the places the current FileList is used, but it is worthwhile to improve clarity.

Copy link
Contributor Author

@karimtera karimtera Sep 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a cycle in dependency problem whenever I try to include verilog_project.h in verilog_preprocess.h, because the former includes verilog_analyzer.h, which also includes verilog_preprocess.h.

Would it be a good idea if I isolate the definition of the FileList in a separte file?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. Put FileList in a separate file.

@hzeller
Copy link
Collaborator

hzeller commented Sep 7, 2022

Do you want to rebase this one or create a fresh new one as it might be easier ?

@karimtera
Copy link
Contributor Author

I will create a fresh branch for this.

@karimtera
Copy link
Contributor Author

Closed by #1482

@karimtera karimtera closed this Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants