The server advertises willRename and answers workspace/willRenameFiles with a WorkspaceEdit. A bounded core resolves quoted includes against the document directory and replaces only the spelling (relative stays relative, absolute stays absolute, angle includes untouched), with registered tests. EditorDiagnostics converts the byte edits to negotiated positions for every open overlay; a real stdio session returned the extra.hpp -> renamed.hpp edit.
215 lines
10 KiB
C++
215 lines
10 KiB
C++
#include <Void/Build.hpp>
|
|
|
|
#include <filesystem>
|
|
#include <stdexcept>
|
|
|
|
namespace {
|
|
|
|
std::filesystem::path prepared_voidlibrary() {
|
|
namespace fs = std::filesystem;
|
|
const auto store = fs::current_path() / "build" / "voidlibrary";
|
|
std::error_code ec;
|
|
const auto selected = fs::canonical(store / "current", ec);
|
|
if (ec)
|
|
throw std::runtime_error{"Run tools/prepare-voidlibrary before building VLS."};
|
|
const auto name = selected.filename().string();
|
|
if (selected.parent_path() != store / "sources" || name.size() != 64 ||
|
|
name.find_first_not_of("0123456789abcdef") != std::string::npos ||
|
|
!fs::is_regular_file(selected / "provenance.json") ||
|
|
!fs::is_regular_file(selected / "include/Void/Data/StrictJson.hpp") ||
|
|
!fs::is_directory(selected / "src/Core") || fs::exists(selected / "build.cpp"))
|
|
throw std::runtime_error{"Invalid VoidLibrary generation. Run tools/prepare-voidlibrary."};
|
|
return selected;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
void build(Void::Build::Project &project) {
|
|
using namespace Void::Build;
|
|
if (project.context().compiler != CompilerFamily::Gcc)
|
|
throw std::invalid_argument{"VLS requires GCC 16+ with C++26 reflection."};
|
|
|
|
auto library = project.dependency("VoidLibrary");
|
|
library.path(prepared_voidlibrary().string())
|
|
.native_builder(
|
|
{{"VOID_ENABLED_MODULES", "Configuration;Crypto;Data;Text;Unicode;System;Testing"},
|
|
{"BUILD_SHARED_LIBS", false}});
|
|
|
|
auto protocol = project.static_library("vls_protocol");
|
|
protocol.cxx_standard(CxxStandard::Cxx26)
|
|
.sources({"src/Protocol/Framing.cpp",
|
|
"src/Protocol/Json.cpp",
|
|
"src/Documents/DocumentSnapshot.cpp",
|
|
"src/Documents/DocumentStore.cpp",
|
|
"src/Documents/Position.cpp",
|
|
"src/Documents/Uri.cpp",
|
|
"src/Workspace/Configuration.cpp",
|
|
"src/Workspace/Trust.cpp",
|
|
"src/Build/Model.cpp",
|
|
"src/Build/ProviderFile.cpp",
|
|
"src/Build/CommandImport.cpp",
|
|
"src/Build/VbsProvider.cpp",
|
|
"src/Build/CompdbProvider.cpp",
|
|
"src/DocumentSync.cpp",
|
|
"src/WorkspaceSession.cpp",
|
|
"src/Server.cpp",
|
|
"src/semantic/Diagnostics.cpp",
|
|
"src/semantic/SourceCatalog.cpp",
|
|
"src/semantic/StockCompiler.cpp",
|
|
"src/semantic/EditorDiagnostics.cpp",
|
|
"src/semantic/Occurrences.cpp",
|
|
"src/scheduler/Scheduler.cpp",
|
|
"src/modules/ModuleGraph.cpp",
|
|
"src/modules/ArtifactCache.cpp",
|
|
"src/modules/GccArtifacts.cpp",
|
|
"src/modules/ScheduledArtifacts.cpp",
|
|
"src/index/SymbolIndex.cpp",
|
|
"src/navigation/Navigation.cpp",
|
|
"src/reflection/Provenance.cpp",
|
|
"src/features/Completion.cpp",
|
|
"src/features/IndexNavigation.cpp",
|
|
"src/features/SignatureHelp.cpp",
|
|
"src/features/DocumentSymbols.cpp",
|
|
"src/features/TextStructure.cpp",
|
|
"src/features/CodeActions.cpp",
|
|
"src/features/SemanticTokens.cpp",
|
|
"src/features/InlayHints.cpp",
|
|
"src/features/FileOperations.cpp",
|
|
"src/features/IncludeUpdate.cpp",
|
|
"src/debug/live/LiveSession.cpp",
|
|
"src/modules/ModuleWorkQueue.cpp",
|
|
"src/modules/GccScan.cpp",
|
|
"src/modules/ScanCommand.cpp"})
|
|
.include_directory("include", Visibility::Public)
|
|
.compile_option("-freflection", Visibility::Public)
|
|
.link(library.target("Void::Data"), Visibility::Public)
|
|
.link(library.target("Void::Unicode"))
|
|
.link(library.target("Void::Crypto"))
|
|
.link(library.target("Void::Text"))
|
|
.link(library.target("Void::System"));
|
|
|
|
auto server = project.executable("vls");
|
|
server.cxx_standard(CxxStandard::Cxx26)
|
|
.sources({"src/main.cpp"})
|
|
.link(protocol)
|
|
.link(library.target("Void::Configuration"))
|
|
.install("bin");
|
|
|
|
auto trace = project.static_library("vls_gcc_trace");
|
|
trace.cxx_standard(CxxStandard::Cxx26)
|
|
.sources(
|
|
{"experiments/frontend/gcc-worker/Trace.cpp", "src/debug/inspection/ReplaySession.cpp"})
|
|
.include_directory("experiments/frontend/gcc-worker", Visibility::Public)
|
|
.link(protocol)
|
|
.link(library.target("Void::Unicode"))
|
|
.link(library.target("Void::Crypto"));
|
|
auto dap = project.executable("vls-dap");
|
|
dap.cxx_standard(CxxStandard::Cxx26)
|
|
.sources({"src/debug/dap/Main.cpp", "src/debug/dap/Projection.cpp"})
|
|
.link(trace)
|
|
.link(protocol)
|
|
.install("bin");
|
|
project.executable("vls_gcc_probe")
|
|
.cxx_standard(CxxStandard::Cxx26)
|
|
.sources({"experiments/frontend/gcc-worker/Main.cpp",
|
|
"experiments/frontend/gcc-worker/Leaf.cpp",
|
|
"experiments/frontend/gcc-worker/Supervisor.cpp"})
|
|
.link(trace)
|
|
.link(protocol)
|
|
.link(library.target("Void::Crypto"))
|
|
.link(library.target("Void::System"));
|
|
|
|
auto suite = [&](const char *name, const SourceSet &sources) {
|
|
auto target = project.test(name);
|
|
target.cxx_standard(CxxStandard::Cxx26)
|
|
.sources(sources)
|
|
.link(protocol)
|
|
.link(library.target("Void::Testing"));
|
|
return target;
|
|
};
|
|
auto unit =
|
|
suite("vls_unit_tests", {"tests/FramingTests.cpp", "tests/JsonTests.cpp",
|
|
"tests/LifecycleTests.cpp", "tests/ProtocolEncodingTests.cpp"});
|
|
auto numbers = suite("vls_json_capabilities", {"tests/JsonCapabilities.cpp"});
|
|
auto process =
|
|
suite("vls_process_tests", {"tests/ProcessTests.cpp", "tests/ProviderProcessTests.cpp"});
|
|
auto documents = suite("vls_document_tests", {"tests/documents/DocumentTests.cpp",
|
|
"tests/documents/LongLineTests.cpp",
|
|
"tests/documents/BoundInputTests.cpp"});
|
|
auto workspace = suite("vls_workspace_tests", {"tests/workspace/WorkspaceTests.cpp",
|
|
"tests/workspace/ProviderSessionTests.cpp",
|
|
"tests/workspace/SemanticLeaseTests.cpp"});
|
|
auto model = suite("vls_build_model_tests", {"tests/providers/ModelTests.cpp"});
|
|
auto diagnostics = suite("vls_diagnostic_tests", {"tests/semantic/DiagnosticTests.cpp",
|
|
"tests/semantic/SourceCatalogTests.cpp",
|
|
"tests/semantic/OccurrenceTests.cpp"});
|
|
auto modules =
|
|
suite("vls_module_tests",
|
|
{"tests/modules/ModuleGraphTests.cpp", "tests/modules/ArtifactCacheTests.cpp",
|
|
"tests/modules/ModuleWorkQueueTests.cpp", "tests/modules/ScanCommandTests.cpp"});
|
|
auto scheduler_tests = suite("vls_scheduler_tests", {"tests/scheduler/SchedulerTests.cpp"});
|
|
auto index_tests = suite("vls_index_tests", {"tests/index/SymbolIndexTests.cpp"});
|
|
auto navigation_tests = suite("vls_navigation_tests", {"tests/navigation/NavigationTests.cpp"});
|
|
auto reflection_tests = suite("vls_reflection_tests", {"tests/reflection/ProvenanceTests.cpp"});
|
|
auto feature_tests =
|
|
suite("vls_feature_tests",
|
|
{"tests/features/CompletionTests.cpp", "tests/features/IndexNavigationTests.cpp",
|
|
"tests/features/SignatureHelpTests.cpp", "tests/features/DocumentSymbolsTests.cpp",
|
|
"tests/features/TextStructureTests.cpp", "tests/features/CodeActionsTests.cpp",
|
|
"tests/features/SemanticTokensTests.cpp", "tests/features/InlayHintsTests.cpp",
|
|
"tests/features/FileOperationsTests.cpp", "tests/features/IncludeUpdateTests.cpp"});
|
|
auto live_worker = project.executable("vls_live_worker_fixture");
|
|
live_worker.cxx_standard(CxxStandard::Cxx26)
|
|
.sources({"tests/debug/LiveWorkerFixture.cpp"})
|
|
.link(protocol);
|
|
auto live_tests = suite("vls_live_tests",
|
|
{"tests/debug/LiveSessionTests.cpp", "tests/debug/LiveDapTests.cpp"});
|
|
live_tests.link(library.target("Void::System")).depends_on(live_worker).depends_on(dap);
|
|
project.executable("vls_gcc_diagnostic_fixture")
|
|
.cxx_standard(CxxStandard::Cxx26)
|
|
.sources({"tests/semantic/GccDiagnosticFixture.cpp"})
|
|
.link(protocol);
|
|
project.executable("vls_module_scan_fixture")
|
|
.cxx_standard(CxxStandard::Cxx26)
|
|
.sources({"tests/modules/GccScanFixture.cpp"})
|
|
.link(protocol);
|
|
project.executable("vls_module_artifact_fixture")
|
|
.cxx_standard(CxxStandard::Cxx26)
|
|
.sources({"tests/modules/ModuleArtifactFixture.cpp"})
|
|
.link(protocol)
|
|
.link(library.target("Void::System"));
|
|
auto trace_tests =
|
|
suite("vls_trace_tests", {"tests/debug/TraceTests.cpp", "tests/debug/RecordingTests.cpp"});
|
|
trace_tests.link(trace);
|
|
auto dap_tests = suite("vls_dap_tests", {"tests/debug/DapReplayTests.cpp"});
|
|
dap_tests.link(trace).link(library.target("Void::System")).depends_on(dap);
|
|
auto providers = suite("vls_provider_tests", {"tests/providers/ProviderFileTests.cpp",
|
|
"tests/providers/VbsProviderTests.cpp",
|
|
"tests/providers/CompdbProviderTests.cpp",
|
|
"tests/providers/CommandImportTests.cpp"});
|
|
numbers.link(library.target("Void::System")).depends_on(server);
|
|
process.link(library.target("Void::System")).depends_on(server);
|
|
|
|
project.test("vls_test_registration")
|
|
.cxx_standard(CxxStandard::Cxx26)
|
|
.sources({"tests/NativeRegistration.cpp"})
|
|
.link(library.target("Void::System"))
|
|
.depends_on(unit)
|
|
.depends_on(numbers)
|
|
.depends_on(process)
|
|
.depends_on(documents)
|
|
.depends_on(workspace)
|
|
.depends_on(model)
|
|
.depends_on(diagnostics)
|
|
.depends_on(modules)
|
|
.depends_on(trace_tests)
|
|
.depends_on(dap_tests)
|
|
.depends_on(providers)
|
|
.depends_on(scheduler_tests)
|
|
.depends_on(index_tests)
|
|
.depends_on(navigation_tests)
|
|
.depends_on(reflection_tests)
|
|
.depends_on(feature_tests)
|
|
.depends_on(live_tests);
|
|
}
|