From df4a50806610ee68e0f735eaa0992c8dba995e15 Mon Sep 17 00:00:00 2001 From: Nathan Singer Date: Thu, 29 May 2025 10:50:23 -0400 Subject: [PATCH] adds a script to generate a clangd file for editor usage --- .gitignore | 1 + Makefile | 6 +++++- libc/include/stdio.h | 7 ------- util/gen-clangd.sh | 15 +++++++++++++++ 4 files changed, 21 insertions(+), 8 deletions(-) create mode 100755 util/gen-clangd.sh diff --git a/.gitignore b/.gitignore index 9f44571..d342f9c 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ bochslog.txt *.iso *.a *.elf +.clangd diff --git a/Makefile b/Makefile index 4d268be..394fbd2 100644 --- a/Makefile +++ b/Makefile @@ -27,10 +27,13 @@ libk_objs = $(free_objs) # binaries = libk.a libc.a # Not ready for libc yet binaries = libk.a -.PHONY: clean all run install-headers install-libs +.PHONY: clean all run install-headers install-libs env all: kernel.elf +env: install-headers install-libs + util/./gen-clangd.sh + kernel.elf: install-headers install-libs $(c_kern_objects) $(asm_kern_objects) $(CC) $(CFLAGS) -T $(shell find . -name "link.ld") -o $@ $(c_kern_objects) $(asm_kern_objects) -nostdlib -lk -lgcc @@ -65,3 +68,4 @@ clean: -rm $(shell find . -name "*.o") -rm $(shell find . -name "*.d") -rm *.iso *.elf *.a com1.out bochslog.txt + -rm .clangd diff --git a/libc/include/stdio.h b/libc/include/stdio.h index b3be14e..94bf59a 100644 --- a/libc/include/stdio.h +++ b/libc/include/stdio.h @@ -5,16 +5,9 @@ #define EOF (-1) -#ifdef __cplusplus -extern "C" { -#endif - int printf(const char* __restrict, ...); int putchar(int); int puts(const char*); -#ifdef __cplusplus -} -#endif #endif diff --git a/util/gen-clangd.sh b/util/gen-clangd.sh new file mode 100755 index 0000000..f3113d1 --- /dev/null +++ b/util/gen-clangd.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# This must be built with `make env` in the root folder +# otherwises the paths will be incorrect + +echo "CompileFlags: + Add: + - \"--sysroot=$(pwd)/sysroot\" + - \"-ffreestanding\" + - \"-Wpedantic\" + - \"-Werror\" + - \"-Wall\" + - \"-Wextra\" +" > .clangd +