mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:27:35 +00:00
LanguageServers/Cpp: Port to LibMain :^)
This commit is contained in:
parent
9d4c946515
commit
54155f8c64
2 changed files with 11 additions and 21 deletions
|
@ -17,4 +17,4 @@ serenity_bin(CppLanguageServer)
|
||||||
|
|
||||||
# We link with LibGUI because we use GUI::TextDocument to update
|
# We link with LibGUI because we use GUI::TextDocument to update
|
||||||
# the content of files according to the edit actions we receive over IPC.
|
# the content of files according to the edit actions we receive over IPC.
|
||||||
target_link_libraries(CppLanguageServer LibIPC LibCpp LibGUI LibLanguageServer)
|
target_link_libraries(CppLanguageServer LibIPC LibCpp LibGUI LibLanguageServer LibMain)
|
||||||
|
|
|
@ -9,48 +9,38 @@
|
||||||
#include <AK/LexicalPath.h>
|
#include <AK/LexicalPath.h>
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
#include <LibCore/EventLoop.h>
|
#include <LibCore/EventLoop.h>
|
||||||
#include <LibCore/File.h>
|
|
||||||
#include <LibCore/LocalServer.h>
|
#include <LibCore/LocalServer.h>
|
||||||
#include <LibIPC/ClientConnection.h>
|
#include <LibIPC/ClientConnection.h>
|
||||||
#include <sys/stat.h>
|
#include <LibMain/Main.h>
|
||||||
|
#include <LibSystem/Wrappers.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
static int mode_server();
|
static ErrorOr<int> mode_server();
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
{
|
{
|
||||||
bool tests = false;
|
bool tests = false;
|
||||||
|
|
||||||
Core::ArgsParser parser;
|
Core::ArgsParser parser;
|
||||||
parser.add_option(tests, "Run tests", "tests", 't');
|
parser.add_option(tests, "Run tests", "tests", 't');
|
||||||
parser.parse(argc, argv);
|
parser.parse(arguments);
|
||||||
|
|
||||||
if (tests) {
|
if (tests)
|
||||||
return run_tests();
|
return run_tests();
|
||||||
}
|
|
||||||
|
|
||||||
return mode_server();
|
return mode_server();
|
||||||
}
|
}
|
||||||
|
|
||||||
int mode_server()
|
ErrorOr<int> mode_server()
|
||||||
{
|
{
|
||||||
Core::EventLoop event_loop;
|
Core::EventLoop event_loop;
|
||||||
if (pledge("stdio unix recvfd rpath ", nullptr) < 0) {
|
TRY(System::pledge("stdio unix recvfd rpath ", nullptr));
|
||||||
perror("pledge");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto socket = Core::LocalSocket::take_over_accepted_socket_from_system_server();
|
auto socket = Core::LocalSocket::take_over_accepted_socket_from_system_server();
|
||||||
IPC::new_client_connection<LanguageServers::Cpp::ClientConnection>(socket.release_nonnull(), 1);
|
IPC::new_client_connection<LanguageServers::Cpp::ClientConnection>(socket.release_nonnull(), 1);
|
||||||
if (pledge("stdio recvfd rpath", nullptr) < 0) {
|
|
||||||
perror("pledge");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (unveil("/usr/include", "r") < 0) {
|
TRY(System::pledge("stdio recvfd rpath", nullptr));
|
||||||
perror("unveil");
|
TRY(System::unveil("/usr/include", "r"));
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// unveil will be sealed later, when we know the project's root path.
|
// unveil will be sealed later, when we know the project's root path.
|
||||||
return event_loop.exec();
|
return event_loop.exec();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue