main.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (c) 2021, Itamar S. <itamar8910@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include "ConnectionFromClient.h"
  7. #include "Tests.h"
  8. #include <LibCore/ArgsParser.h>
  9. #include <LibCore/EventLoop.h>
  10. #include <LibCore/LocalServer.h>
  11. #include <LibCore/System.h>
  12. #include <LibIPC/SingleServer.h>
  13. #include <LibMain/Main.h>
  14. static ErrorOr<int> mode_server();
  15. ErrorOr<int> serenity_main(Main::Arguments arguments)
  16. {
  17. bool tests = false;
  18. Core::ArgsParser parser;
  19. parser.add_option(tests, "Run tests", "tests", 't');
  20. parser.parse(arguments);
  21. if (tests)
  22. return run_tests();
  23. return mode_server();
  24. }
  25. ErrorOr<int> mode_server()
  26. {
  27. Core::EventLoop event_loop;
  28. TRY(Core::System::pledge("stdio unix recvfd rpath"));
  29. auto client = TRY(IPC::take_over_accepted_client_from_system_server<LanguageServers::Cpp::ConnectionFromClient>());
  30. TRY(Core::System::pledge("stdio recvfd rpath"));
  31. TRY(Core::System::unveil("/usr/include", "r"));
  32. // unveil will be sealed later, when we know the project's root path.
  33. return event_loop.exec();
  34. }