diff --git a/Makefile b/Makefile index 6d4e088..16a8252 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,7 @@ LIBC_OBJ := $(addprefix $(BUILD_DIR)/,$(LIBC_C_FILES:.c=.o)) BUILD_ID := $(shell tools/generate_build_id.py --arch $(ARCH)) CFLAGS := $(CFLAGS) -DBUILD_ID=\"$(BUILD_ID)\" -g -Wall -Werror -pedantic \ - "-I$(ROOT_DIR)/include" "-I$(ROOT_DIR)/arch/$(ARCH)/include" "-I$(ROOT_DIR)/libc/include" + -Iinclude -Iarch/$(ARCH)/include -Ilibc/include ASMFLAGS := $(ASMFLAGS) -DBUILD_ID=\"$(BUILD_ID)\" LDFLAGS := $(LDFLAGS) -g diff --git a/sandbox/Makefile b/sandbox/Makefile index 21fe1a8..ee45611 100644 --- a/sandbox/Makefile +++ b/sandbox/Makefile @@ -7,7 +7,7 @@ BUILD_DIR := $(SANDBOX_BASE_DIR)/../build/sandbox include $(SANDBOX_BASE_DIR)/../tools/make/gcc-host.mk EXEC_NAME := sandbox DIR_LIST := memblock vm base -INCLUDE_DIRS := $(foreach dir,$(DIR_LIST),"-I$(dir)/include") +INCLUDE_DIRS := $(foreach dir,$(DIR_LIST),-I$(dir)/include) SRC := $(foreach dir,$(DIR_LIST),$(wildcard $(dir)/*.c)) OBJ := $(addprefix $(BUILD_DIR)/,$(SRC:.c=.o)) @@ -25,7 +25,7 @@ $(BUILD_DIR)/$(EXEC_NAME): $(OBJ) @$(CC) $^ -o $@ $(CFLAGS) $(LDFLAGS) $(BUILD_DIR)/%.o: %.c - @printf " \033[1;32mHOSTCC\033[0m sandbox/$<\n" + @printf " \033[1;32mHOSTCC\033[0m \033[35msandbox\033[0m/$<\n" @mkdir -p $(@D) @$(CC) $< -o $@ -c $(CFLAGS) diff --git a/sandbox/sandbox-config.mk b/sandbox/sandbox-config.mk deleted file mode 100644 index c81a9f4..0000000 --- a/sandbox/sandbox-config.mk +++ /dev/null @@ -1,11 +0,0 @@ -THIS_FILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) -SANDBOX_PROG_MAKEFILE_PATH := $(abspath $(firstword $(MAKEFILE_LIST))) -SANDBOX_BASE_DIR := $(patsubst %/,%,$(dir $(THIS_FILE_PATH))) -SANDBOX_PROG_DIR := $(patsubst %/,%,$(dir $(SANDBOX_PROG_MAKEFILE_PATH))) - -include $(SANDBOX_BASE_DIR)/../tools/make/gcc-host.mk - -SANDBOX_PROG_NAME := $(notdir $(SANDBOX_PROG_DIR)) - -SANDBOX_BUILD_DIR := $(SANDBOX_BASE_DIR)/../build/sandbox -BUILD_DIR := $(SANDBOX_BUILD_DIR)/$(SANDBOX_PROG_NAME) diff --git a/sandbox/sandbox-template.mk b/sandbox/sandbox-template.mk deleted file mode 100644 index 893cc88..0000000 --- a/sandbox/sandbox-template.mk +++ /dev/null @@ -1,24 +0,0 @@ -BUILD_DIR := $(SANDBOX_BUILD_DIR)/$(SANDBOX_PROG_NAME) - -SRC := $(wildcard *.c) -OBJ := $(addprefix $(BUILD_DIR)/,$(SRC:.c=.o)) - -CFLAGS := -g "-I$(SANDBOX_BASE_DIR)/include" - -$(BUILD_DIR)/$(SANDBOX_PROG_NAME): $(OBJ) - @mkdir -p $(@D) - - @printf " \033[1;36mHOSTLD\033[0m \033[1msandbox/\033[35m$(SANDBOX_PROG_NAME)\n" - @$(CC) $^ -o $@ $(CFLAGS) $(LDFLAGS) - -$(BUILD_DIR)/%.o: %.c - @printf " \033[1;32mHOSTCC\033[0m sandbox/\033[35m$(SANDBOX_PROG_NAME)\033[0m/$<\n" - @mkdir -p $(@D) - - @$(CC) $< -o $@ -c $(CFLAGS) - -all: $(SANDBOX_PROG_NAME) - -clean: - @printf " \033[1;93mRM\033[0m Deleting sandbox/$(SANDBOX_PROG_NAME)\n" - @rm -rf $(BUILD_DIR) diff --git a/tools/make/generate_compile_commands.py b/tools/make/generate_compile_commands.py index 9bd2e2d..e2ac0ad 100755 --- a/tools/make/generate_compile_commands.py +++ b/tools/make/generate_compile_commands.py @@ -7,11 +7,12 @@ import os def is_source_file(filepath): return filepath.endswith('.c') or filepath.endswith('.h') or filepath.endswith('.S') +dir_stack = [] rootdir = os.getcwd() compile_db = [] -make_output = subprocess.check_output(['make', '-n']).decode('utf-8') +make_output = subprocess.check_output(['make', '-nw']).decode('utf-8') make_output_lines = make_output.split('\n') @@ -19,6 +20,15 @@ for line in make_output_lines: line_parts = line.split(' ') new_line_parts = [] + if len(line_parts) >= 2 and 'Entering directory' in line: + new_dir = line[line.find('`') + 1:-1] + dir_stack.append(new_dir) + continue + + if len(line_parts) >= 2 and 'Leaving directory' in line: + dir_stack.pop() + continue; + if 'gcc' not in line_parts[0]: continue @@ -27,7 +37,7 @@ for line in make_output_lines: part = part.strip() if is_source_file(part): src_file = part - part = '../{}'.format(part) + part = os.path.join(dir_stack[-1], part) new_line_parts.append(part) @@ -35,9 +45,9 @@ for line in make_output_lines: continue db_entry = { - 'directory': '{}/build'.format(rootdir), + 'directory': dir_stack[-1], 'command': ' '.join(new_line_parts).strip(), - 'file': '{}/{}'.format(rootdir, src_file) + 'file': os.path.join(dir_stack[-1], src_file) } compile_db.append(db_entry)