LanguageServers/Cpp: Port to LibMain :^)
This commit is contained in:
parent
9d4c946515
commit
54155f8c64
Notes:
sideshowbarker
2024-07-18 00:49:39 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/54155f8c646
2 changed files with 11 additions and 21 deletions
Userland/DevTools/HackStudio/LanguageServers/Cpp
|
@ -17,4 +17,4 @@ serenity_bin(CppLanguageServer)
|
|||
|
||||
# We link with LibGUI because we use GUI::TextDocument to update
|
||||
# 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 <LibCore/ArgsParser.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/LocalServer.h>
|
||||
#include <LibIPC/ClientConnection.h>
|
||||
#include <sys/stat.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <LibSystem/Wrappers.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;
|
||||
|
||||
Core::ArgsParser parser;
|
||||
parser.add_option(tests, "Run tests", "tests", 't');
|
||||
parser.parse(argc, argv);
|
||||
parser.parse(arguments);
|
||||
|
||||
if (tests) {
|
||||
if (tests)
|
||||
return run_tests();
|
||||
}
|
||||
|
||||
return mode_server();
|
||||
}
|
||||
|
||||
int mode_server()
|
||||
ErrorOr<int> mode_server()
|
||||
{
|
||||
Core::EventLoop event_loop;
|
||||
if (pledge("stdio unix recvfd rpath ", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
TRY(System::pledge("stdio unix recvfd rpath ", nullptr));
|
||||
|
||||
auto socket = Core::LocalSocket::take_over_accepted_socket_from_system_server();
|
||||
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) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
TRY(System::pledge("stdio recvfd rpath", nullptr));
|
||||
TRY(System::unveil("/usr/include", "r"));
|
||||
|
||||
// unveil will be sealed later, when we know the project's root path.
|
||||
return event_loop.exec();
|
||||
|
|
Loading…
Add table
Reference in a new issue