yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Yong HeLanguage Server Enhancements (#7604)b4fc380af

master
1.1 KiB37 linesraw
1// main.cpp
2
3// This file implements the entry point for `slangd`, the daemon process of Slang's language server.
4
5#include "../../source/core/slang-basic.h"
6#include "../../source/slang/slang-language-server.h"
7
8#include <thread>
9
10int main(int argc, const char* const* argv)
11{
12    bool isDebug = false;
13    for (auto i = 1; i < argc; i++)
14    {
15        if (Slang::UnownedStringSlice(argv[i]) == "--debug")
16        {
17            isDebug = true;
18        }
19        else if (Slang::UnownedStringSlice(argv[i]) == "--print-builtin-module" && i < argc - 1)
20        {
21            Slang::UnownedStringSlice moduleName = Slang::UnownedStringSlice(argv[++i]);
22            Slang::ComPtr<slang::IBlob> code;
23            Slang::getBuiltinModuleSource(moduleName, code.writeRef());
24            printf("%s\n", (const char*)code->getBufferPointer());
25            return 0;
26        }
27    }
28    if (isDebug)
29    {
30        std::this_thread::sleep_for(std::chrono::seconds(10));
31    }
32    Slang::LanguageServerStartupOptions options;
33    options.parse(argc, argv);
34    auto result = Slang::runLanguageServer(options);
35    slang::shutdown();
36    return result;
37}