From e1b74cd1565c57ce1181c36691cc8c64b515bf74 Mon Sep 17 00:00:00 2001 From: hwacha Date: Mon, 20 Apr 2026 18:31:27 +0900 Subject: [PATCH] Added LSP file auto-generator CMake will auto generate compile-commands.json file to help LSP find symbols. this file is gitignored and will be regenerated each build nothing else was changed, should work on any system, but please test --- .gitignore | 3 ++- Kernel/CMakeLists.txt | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 650360a..02ab928 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .build .vscode -.DS_Store \ No newline at end of file +.DS_Store +compile_commands.json \ No newline at end of file diff --git a/Kernel/CMakeLists.txt b/Kernel/CMakeLists.txt index 0f4e984..f6cbb61 100644 --- a/Kernel/CMakeLists.txt +++ b/Kernel/CMakeLists.txt @@ -91,3 +91,11 @@ add_custom_command(TARGET kernel.elf POST_BUILD COMMAND ${LLVM_OBJCOPY} -O binary kernel.elf kernel.bin COMMENT "kernel.elf -> kernel.bin" ) + +# --- SourceKit-LSP: generate compile_commands.json for Swift --- +set(_COMMON_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../Common") +set(_BRIDGING_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/Source/BridgingHeader.h") + +file(GENERATE OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/compile_commands.json" + CONTENT "[\n {\n \"file\": \"${SWIFT_SOURCES}\",\n \"directory\": \"${CMAKE_CURRENT_BINARY_DIR}\",\n \"arguments\": [\n \"${SWIFTC}\",\n \"-target\", \"aarch64-none-none-elf\",\n \"-enable-experimental-feature\", \"Embedded\",\n \"-parse-as-library\",\n \"-wmo\",\n \"-O\",\n \"-Xcc\", \"-fno-stack-protector\",\n \"-Xcc\", \"-I${_COMMON_DIR}\",\n \"-import-bridging-header\", \"${_BRIDGING_HEADER}\",\n \"-resource-dir\", \"${SWIFT_RESOURCE_DIR}\",\n \"${SWIFT_SOURCES}\"\n ]\n }\n]\n" +)