summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAetias <144526980+AetiasHax@users.noreply.github.com>2026-04-18 10:50:01 +0200
committerGitHub <noreply@github.com>2026-04-18 10:50:01 +0200
commitfe6681a298f089c5bbbee077ad9c06dc801df476 (patch)
tree65f1d232a40e3ced0000de1f5f25a9187d76e0a0
parent38e9378f8f4bc465a09305e5021ead2eb89afb2b (diff)
Set up clangd (#148)
* Set up clangd * configure.py: Specify Generator type arguments
-rw-r--r--.clangd10
-rw-r--r--.gitignore1
-rwxr-xr-xtools/configure.py23
3 files changed, 32 insertions, 2 deletions
diff --git a/.clangd b/.clangd
new file mode 100644
index 00000000..617e5d9b
--- /dev/null
+++ b/.clangd
@@ -0,0 +1,10 @@
+CompileFlags:
+ Add:
+ - -m32
+ - -nostdinc
+ - -Iinclude
+ - -Ilibs/c/include
+ - -Ilibs/cpp/include
+ - -Ilibs/nds/include
+ - -Ilibs/nitro/include
+ - -Ilibs/nns/include
diff --git a/.gitignore b/.gitignore
index 1e38a48e..c2dff043 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,3 +19,4 @@ build.ninja
.ninja_deps
/wibo
/sjiswrap.exe
+/compile_commands.json
diff --git a/tools/configure.py b/tools/configure.py
index 01ada8b9..17f0e870 100755
--- a/tools/configure.py
+++ b/tools/configure.py
@@ -6,7 +6,7 @@ from pathlib import Path
import argparse
import sys
import subprocess
-from typing import Any
+from typing import Any, Generator
import ninja_syntax
from get_platform import Platform, get_platform
@@ -165,9 +165,12 @@ class Project:
def build_rom_config(self) -> Path:
return self.game_build / "build" / "rom_config.yaml"
+ def source_files(self) -> Generator[Path, None, None]:
+ yield from get_c_cpp_files([src_path, libs_path])
+
def source_object_files(self) -> list[str]:
files: list[str] = []
- for source_file in get_c_cpp_files([src_path, libs_path]):
+ for source_file in self.source_files():
src_obj_path = self.game_build / source_file
files.append(str(src_obj_path.with_suffix(".o")))
return files
@@ -361,6 +364,8 @@ def main():
)
n.newline()
+ create_compilation_database(project)
+
add_download_tool_builds(n, project)
add_configure_build(n, project)
@@ -735,5 +740,19 @@ def get_config_files(game_config: Path, name: str) -> list[str]:
]
+def create_compilation_database(project: Project):
+ db_path = root_path / "compile_commands.json"
+ db: list[dict] = []
+ abs_root_path = root_path.absolute()
+ for src_file in project.source_files():
+ db.append({
+ "directory": str(abs_root_path),
+ "arguments": ["#"], # clangd ignores entries with empty arguments
+ "file": str(src_file)
+ })
+ with db_path.open("w") as f:
+ f.write(json.dumps(db))
+
+
if __name__ == "__main__":
main()