nixd
Loading...
Searching...
No Matches
nixd-attrset-eval.cpp
Go to the documentation of this file.
1#include "nixd-config.h"
2
5
6#include <llvm/Support/CommandLine.h>
8#include <nixt/InitEval.h>
9
10#include <unistd.h>
11
12using namespace llvm::cl;
13using namespace lspserver;
14using namespace nixd;
15
16namespace {
17
18OptionCategory Misc("miscellaneous options");
19OptionCategory Debug("debug-only options (for developers)");
20
22 "input-style",
23 desc("Input JSON stream encoding"),
24 values(
25 clEnumValN(JSONStreamStyle::Standard, "standard", "usual LSP protocol"),
26 clEnumValN(JSONStreamStyle::Delimited, "delimited",
27 "messages delimited by `// -----` lines, "
28 "with // comment support")),
29 init(JSONStreamStyle::Standard),
30 cat(Debug),
31 Hidden,
32};
33
35 "log", desc("Verbosity of log messages written to stderr"),
36 values(
37 clEnumValN(Logger::Level::Error, "error", "Error messages only"),
38 clEnumValN(Logger::Level::Info, "info", "High level execution tracing"),
39 clEnumValN(Logger::Level::Debug, "debug", "Debugging details"),
40 clEnumValN(Logger::Level::Verbose, "verbose", "Low level details")),
41 init(Logger::Level::Info), cat(Misc)};
42
43opt<bool> PrettyPrint{"pretty", desc("Pretty-print JSON output"), init(false),
44 cat(Debug)};
45
46const OptionCategory *Catogories[] = {&Misc, &Debug};
47
48} // namespace
49
50int main(int Argc, const char *Argv[]) {
51
52 SetVersionPrinter([](llvm::raw_ostream &OS) {
53 OS << "nixd-attrset-eval, version: ";
54#ifdef NIXD_VCS_TAG
56#else
58#endif
59 OS << "\n";
60 });
61
63 ParseCommandLineOptions(Argc, Argv, "nixd nixpkgs evaluator", nullptr,
64 "NIXD_NIXPKGS_EVAL_FLAGS");
65
66 if (LitTest) {
67 InputStyle = JSONStreamStyle::Delimited;
68 LogLevel = Logger::Level::Verbose;
69 PrettyPrint = true;
70 }
71
72 StreamLogger Logger(llvm::errs(), LogLevel);
74
76 auto In = std::make_unique<lspserver::InboundPort>(STDIN_FILENO, InputStyle);
77
78 auto Out = std::make_unique<lspserver::OutboundPort>(PrettyPrint);
79 nixd::AttrSetProvider Provider(std::move(In), std::move(Out));
80
81 Provider.run();
82}
Dedicated worker for evaluating attrset.
Interface to allow custom logging in clangd.
Definition Logger.h:13
Only one LoggingSession can be active at a time.
Definition Logger.h:91
Main RPC class for attrset provider.
Whether current platform treats paths case insensitively.
Definition Connection.h:11
bool fromJSON(const llvm::json::Value &Params, Configuration::Diagnostic &R, llvm::json::Path P)
llvm::cl::opt< bool > LitTest
Indicating that we are in lit-test mode.
Definition Options.cpp:8
void initEval()
Definition InitEval.h:9
int main(int Argc, const char *Argv[])