Skip to content

Commit

Permalink
Merge pull request #996 from diffblue/verilog-include-paths
Browse files Browse the repository at this point in the history
Verilog: remove dependency on `util/config.h`
  • Loading branch information
tautschnig authored Feb 18, 2025
2 parents 52181a6 + 402089f commit b5a624c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 14 deletions.
20 changes: 10 additions & 10 deletions src/ebmc/transition_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@ int preprocess(const cmdlinet &cmdline, message_handlert &message_handler)
return 1;
}

// do -I
if(cmdline.isset('I'))
config.verilog.include_paths = cmdline.get_values('I');

auto language = get_language_from_filename(filename);

if(language == nullptr)
Expand All @@ -110,9 +106,12 @@ int preprocess(const cmdlinet &cmdline, message_handlert &message_handler)
}

optionst options;

// do -I
if(cmdline.isset('I'))
options.set_option("I", cmdline.get_values('I'));

options.set_option("force-systemverilog", cmdline.isset("systemverilog"));
options.set_option("vl2smv-extensions", cmdline.isset("vl2smv-extensions"));
options.set_option("warn-implicit-nets", cmdline.isset("warn-implicit-nets"));

// do -D
if(cmdline.isset('D'))
Expand Down Expand Up @@ -162,6 +161,11 @@ static bool parse(
languaget &language = *lf.language;

optionst options;

// do -I
if(cmdline.isset('I'))
options.set_option("I", cmdline.get_values('I'));

options.set_option("force-systemverilog", cmdline.isset("systemverilog"));
options.set_option("vl2smv-extensions", cmdline.isset("vl2smv-extensions"));
options.set_option("warn-implicit-nets", cmdline.isset("warn-implicit-nets"));
Expand Down Expand Up @@ -242,10 +246,6 @@ int get_transition_system(
{
messaget message(message_handler);

// do -I
if(cmdline.isset('I'))
config.verilog.include_paths = cmdline.get_values('I');

if(cmdline.isset("preprocess"))
return preprocess(cmdline, message_handler);

Expand Down
3 changes: 2 additions & 1 deletion src/verilog/verilog_language.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ void verilog_languaget::set_language_options(
{
force_systemverilog = options.get_bool_option("force-systemverilog");
vl2smv_extensions = options.get_bool_option("vl2smv-extensions");
include_paths = options.get_list_option("I");
initial_defines = options.get_list_option("defines");
warn_implicit_nets = options.get_bool_option("warn-implicit-nets");
}
Expand Down Expand Up @@ -107,7 +108,7 @@ bool verilog_languaget::preprocess(
message_handlert &message_handler)
{
verilog_preprocessort preprocessor(
instream, outstream, message_handler, path, initial_defines);
instream, outstream, message_handler, path, include_paths, initial_defines);

try { preprocessor.preprocessor(); }
catch(int e) { return true; }
Expand Down
1 change: 1 addition & 0 deletions src/verilog/verilog_language.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class verilog_languaget:public languaget
bool force_systemverilog = false;
bool vl2smv_extensions = false;
bool warn_implicit_nets = false;
std::list<std::string> include_paths;
std::list<std::string> initial_defines;
verilog_parse_treet parse_tree;
};
Expand Down
3 changes: 1 addition & 2 deletions src/verilog/verilog_preprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Author: Daniel Kroening, [email protected]

#include "verilog_preprocessor.h"

#include <util/config.h>
#include <util/unicode.h>

#include "expr2verilog.h"
Expand Down Expand Up @@ -136,7 +135,7 @@ std::filesystem::path verilog_preprocessort::find_include_file(
}

// Then try include paths in given order.
for(const auto &include_path : config.verilog.include_paths)
for(const auto &include_path : include_paths)
{
auto full_name = std::filesystem::path{include_path}.append(given_filename);
if(std::filesystem::directory_entry(full_name).exists())
Expand Down
3 changes: 3 additions & 0 deletions src/verilog/verilog_preprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ class verilog_preprocessort:public preprocessort
std::ostream &_out,
message_handlert &_message_handler,
const std::string &_filename,
const std::list<std::string> &_include_paths,
const std::list<std::string> &_initial_defines)
: preprocessort(_in, _out, _message_handler, _filename),
include_paths(_include_paths),
initial_defines(_initial_defines)
{
condition=true;
Expand All @@ -33,6 +35,7 @@ class verilog_preprocessort:public preprocessort

protected:
// from the command line
const std::list<std::string> &include_paths;
const std::list<std::string> &initial_defines;

using tokent = verilog_preprocessor_token_sourcet::tokent;
Expand Down
2 changes: 1 addition & 1 deletion src/vlindex/verilog_indexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ std::string verilog_indexert::preprocess(const std::string &file_name)

console_message_handlert message_handler;
verilog_preprocessort preprocessor(
in_stream, preprocessed, message_handler, file_name, {});
in_stream, preprocessed, message_handler, file_name, {}, {});

try
{
Expand Down

0 comments on commit b5a624c

Please sign in to comment.