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

Passing external defines and incdirs to the preprocessor. #1440

Merged
merged 2 commits into from
Sep 16, 2022

Conversation

karimtera
Copy link
Contributor

@karimtera karimtera commented Sep 9, 2022

"VerilogPreprocess":

  • Adds "PreprocessingInfo" to storing external defines and incdirs.
  • Adds a public function "SetPreprocessingInfo()" to set these info.

The preprocessor tool:

  • Modifies "PreprocessSingleFile()" arguments to accept a "PreprocessingInfo", rather than just defines.

Implementation details:

  • Needed to move FileList to a separate file outside verilog_project.h to avoid dependency cycle.

@karimtera
Copy link
Contributor Author

I don't understand why there was a conflict on preprocessor/BUILD.

Copy link
Collaborator

@hzeller hzeller left a comment

Choose a reason for hiding this comment

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

I think we should move the actual implementation of the include feature to its own pull request (see comment, I think we should see if we can re-use some functionality).

So in this change, just breaking out the FileList into its own file and the corresponding changes. Then we can concentrate on the actual include implementation.

@@ -552,6 +553,134 @@ absl::Status VerilogPreprocess::HandleEndif(
return absl::OkStatus();
}

// Handle `include directives.
absl::Status VerilogPreprocess::HandleInclude(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you have a look how the kythe extractor and/or project_tool (I forgot where ti is implemented) does the include handling ?
Ideally we keep the ownership of the full file in one place (and then the string ownership where the tokens are pointing to is clear).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I will try to find it.

@hzeller
Copy link
Collaborator

hzeller commented Sep 10, 2022

w.r.t the BUILD conflict, I was running buildifier, so that moved some lines around.

essentially

buildifier $(find . -name BUILD)

This was the change 5910541

@karimtera karimtera changed the title Handling includes in the preprocessor. Passing external defines and incdirs to the preprocessor. Sep 12, 2022
@codecov-commenter
Copy link

Codecov Report

Merging #1440 (9407e13) into master (d7d3259) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #1440   +/-   ##
=======================================
  Coverage   92.94%   92.94%           
=======================================
  Files         342      343    +1     
  Lines       24158    24159    +1     
=======================================
+ Hits        22453    22454    +1     
  Misses       1705     1705           
Impacted Files Coverage Δ
verilog/analysis/verilog_project.h 100.00% <ø> (ø)
verilog/preprocessor/verilog_preprocess.h 100.00% <ø> (ø)
verilog/analysis/verilog_filelist.h 100.00% <100.00%> (ø)
verilog/analysis/verilog_project.cc 94.44% <100.00%> (ø)
verilog/preprocessor/verilog_preprocess.cc 92.74% <100.00%> (+0.04%) ⬆️
verilog/tools/kythe/verilog_kythe_extractor.cc 77.02% <100.00%> (ø)
verilog/tools/preprocessor/verilog_preprocessor.cc 89.83% <100.00%> (-0.09%) ⬇️
verilog/tools/project/project_tool.cc 93.20% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@karimtera karimtera requested a review from hzeller September 14, 2022 08:51
@hzeller hzeller merged commit 3a4325b into chipsalliance:master Sep 16, 2022
@hzeller
Copy link
Collaborator

hzeller commented Sep 16, 2022

LGTM! Thanks, merged.

@karimtera karimtera deleted the file_inclusion branch September 17, 2022 21:41
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.

3 participants