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
This commit is contained in:
2026-04-20 18:31:27 +09:00
parent f3819a5450
commit e1b74cd156
2 changed files with 10 additions and 1 deletions
+1
View File
@@ -1,3 +1,4 @@
.build
.vscode
.DS_Store
compile_commands.json
+8
View File
@@ -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"
)