Skip to content

Commit d469223

Browse files
authored
[circt-verilog-lsp] Add -C command line option (#9003)
This PR extends the CIRCT Verilog LSP server with support for project command files (`-C` / `--command-file`) and improves robustness around source locations and diagnostics. - **Command file support** - Added `commandFiles` option to `VerilogServerOptions`. - Extended the CLI with `-C`/`--command-file` flags to pass one or more command files. - Each buffer’s `Driver` now processes command files, filtering out the current main buffer to avoid duplication. - Implemented `removeFileToTemp` helper to strip the main file from command files and materialize a temporary version. - **Source location handling** - Improved absolute/real path resolution when constructing LSP URIs. - Fallbacks added for when `slang::SourceManager` has no full path info. - **Compilation setup** - Ensure all definitions in the buffer/project scope are treated as top modules. - **Indexing improvements** - Skip top instances not defined in the current file. - Added guards against invalid or empty ranges (especially macro expansions).
1 parent ee12898 commit d469223

File tree

7 files changed

+331
-26
lines changed

7 files changed

+331
-26
lines changed

include/circt/Tools/circt-verilog-lsp-server/CirctVerilogLspServerMain.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,17 @@ namespace circt {
3535
namespace lsp {
3636
struct VerilogServerOptions {
3737
VerilogServerOptions(const std::vector<std::string> &libDirs,
38-
const std::vector<std::string> &extraSourceLocationDirs)
39-
: libDirs(libDirs), extraSourceLocationDirs(extraSourceLocationDirs) {}
38+
const std::vector<std::string> &extraSourceLocationDirs,
39+
const std::vector<std::string> &commandFiles)
40+
: libDirs(libDirs), extraSourceLocationDirs(extraSourceLocationDirs),
41+
commandFiles(commandFiles) {}
4042
/// Additional list of RTL directories to search.
4143
const std::vector<std::string> &libDirs;
42-
4344
/// Additional list of external source directories to search.
4445
const std::vector<std::string> &extraSourceLocationDirs;
46+
/// Additional list of command files that reference dependencies of the
47+
/// project.
48+
const std::vector<std::string> &commandFiles;
4549
};
4650
// namespace lsp
4751

lib/Tools/circt-verilog-lsp-server/LSPServer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "LSPServer.h"
1010
#include "VerilogServerImpl/VerilogServer.h"
11+
#include "llvm/Support/JSON.h"
1112
#include "llvm/Support/LSP/Protocol.h"
1213
#include "llvm/Support/LSP/Transport.h"
1314
#include <optional>

0 commit comments

Comments
 (0)