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