diff --git a/Lab3/user/chcore-libc/CMakeLists.txt b/Lab3/user/chcore-libc/CMakeLists.txt index 8d8a6a81..5006139e 100644 --- a/Lab3/user/chcore-libc/CMakeLists.txt +++ b/Lab3/user/chcore-libc/CMakeLists.txt @@ -95,7 +95,7 @@ add_custom_target(libc-configure ALL # Compile libc add_custom_target(libc-build ALL WORKING_DIRECTORY ${_libc_target_dir} - COMMAND make -j${_nproc} + COMMAND bear make -j${_nproc} DEPENDS libc-configure) # Install libc as usual diff --git a/Lab4/ramdisk/tmpfs.srv b/Lab4/ramdisk/tmpfs.srv index 9007e9ee..628b2cc6 100755 Binary files a/Lab4/ramdisk/tmpfs.srv and b/Lab4/ramdisk/tmpfs.srv differ diff --git a/Lab4/user/chcore-libc/CMakeLists.txt b/Lab4/user/chcore-libc/CMakeLists.txt index 8d8a6a81..5006139e 100644 --- a/Lab4/user/chcore-libc/CMakeLists.txt +++ b/Lab4/user/chcore-libc/CMakeLists.txt @@ -95,7 +95,7 @@ add_custom_target(libc-configure ALL # Compile libc add_custom_target(libc-build ALL WORKING_DIRECTORY ${_libc_target_dir} - COMMAND make -j${_nproc} + COMMAND bear make -j${_nproc} DEPENDS libc-configure) # Install libc as usual diff --git a/Lab5/user/chcore-libc/CMakeLists.txt b/Lab5/user/chcore-libc/CMakeLists.txt index 8d8a6a81..5006139e 100644 --- a/Lab5/user/chcore-libc/CMakeLists.txt +++ b/Lab5/user/chcore-libc/CMakeLists.txt @@ -95,7 +95,7 @@ add_custom_target(libc-configure ALL # Compile libc add_custom_target(libc-build ALL WORKING_DIRECTORY ${_libc_target_dir} - COMMAND make -j${_nproc} + COMMAND bear make -j${_nproc} DEPENDS libc-configure) # Install libc as usual diff --git a/Lab5/user/system-services/system-servers/fs_base/fs_vnode.c b/Lab5/user/system-services/system-servers/fs_base/fs_vnode.c index 271b5f2a..96b6cf5e 100644 --- a/Lab5/user/system-services/system-servers/fs_base/fs_vnode.c +++ b/Lab5/user/system-services/system-servers/fs_base/fs_vnode.c @@ -18,7 +18,7 @@ #include "fs_vnode.h" #include "fs_page_cache.h" -static int comp_vnode_key(const void *key, const struct rb_node *node) +__attribute__((unused)) static int comp_vnode_key(const void *key, const struct rb_node *node) { struct fs_vnode *vnode = rb_entry(node, struct fs_vnode, node); ino_t vnode_id = *(ino_t *)key; diff --git a/Scripts/kernel.mk b/Scripts/kernel.mk index fd6fc14a..bfe78c49 100644 --- a/Scripts/kernel.mk +++ b/Scripts/kernel.mk @@ -23,12 +23,13 @@ defconfig: build: $(Q)test -f $(LABDIR)/.config || $(CHBUILD) defconfig $(Q)$(CHBUILD) build - $(Q)find $(LABDIR) -path */compile_commands.json \ + $(Q)find -L $(LABDIR) -path */compile_commands.json \ ! -path $(LABDIR)/compile_commands.json -print \ | $(SCRIPTS)/merge_compile_commands.py clean: $(Q)$(CHBUILD) clean + $(Q)find -L $(LABDIR) -path */compile_commands.json -exec rm {} \; distclean: $(Q)$(CHBUILD) distclean diff --git a/Scripts/merge_compile_commands.py b/Scripts/merge_compile_commands.py index f17d45b7..a7c03c92 100755 --- a/Scripts/merge_compile_commands.py +++ b/Scripts/merge_compile_commands.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import json import os +import re import sys commands = [] @@ -8,19 +9,36 @@ file = file.strip() with open(file, "r") as f: for item in json.load(f): - if item.get("command"): - argv = item.get("command").split() + if argv := item.get("command"): + argv = argv.split() if "musl-gcc" in argv[0]: - item["command"] = ( - " ".join( - [ - "/usr/bin/aarch64-linux-gnu-gcc", - "-nostdinc", - "-I{}/build/chcore-libc/include".format(os.getenv("LABDIR")), - ] - + argv[1:] - ) + item["command"] = " ".join( + [ + "/usr/bin/aarch64-linux-gnu-gcc", + "-nostdinc", + "-I{}/build/chcore-libc/include".format( + os.getenv("LABDIR") + ), + ] + + argv[1:] ) + + directory: str = item.get("directory") + + if argv := item.get("arguments"): + for i, arg in enumerate(argv): + if include := re.match(r"^-I([^/]+/(.*))$", arg): + argv[i] = "-I" + "/".join([directory, include.group(1)]) + elif not arg.startswith("-I"): + if file := re.match(r"^[^/]+/(.*)$", arg): + argv[i] = "/".join([directory, arg]) + item["command"] = " ".join(argv) + item.pop("arguments") + + file: str = item.get("file") + if not file.startswith("/"): + item["file"] = "/".join([directory, file]) + commands.append(item) with open("compile_commands.json", "w") as f: