Crafter.Debug/implementations/main.cpp

37 lines
1.4 KiB
C++
Raw Normal View History

// SPDX-License-Identifier: LGPL-3.0-only
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
// crafter-debug: Cli::Run with the QUIC transport.
import std;
import Crafter.Thread;
import Crafter.Debug.Core;
import Crafter.Debug.Cli;
using namespace Crafter::Debug;
int main(int argc, char** argv) {
// Crafter.Network reports some failures through the pool. One request
// at a time needs one worker.
Crafter::ThreadPool::Start(2);
const std::vector<std::string_view> args(argv + 1, argv + argc);
std::int32_t code = 0;
{
Cli::Environment environment;
environment.connect = Cli::ConnectQuic;
// Set by the project's launcher, build/crafter-debug.
if (const char* project = std::getenv("CRAFTER_DEBUG_PROJECT"); project != nullptr && *project != '\0') environment.project = project;
environment.lldb = [] {
for (const char* path : { "/app/bin/lldb", "/usr/bin/lldb" }) {
if (std::filesystem::exists(path)) return std::string(path);
}
return std::string();
};
// Run closes its connections before it returns.
code = Cli::Run(args, environment);
}
std::cout.flush();
std::cerr.flush();
std::fflush(nullptr);
// Not through exit: msquic's teardown at exit waits for connections,
// and the pool's workers would need stopping first.
std::_Exit(code);
}