From bc174890e5306667f3719de7a9113bab52933c09 Mon Sep 17 00:00:00 2001 From: Fernando Alberto Miranda Bonomi Date: Thu, 12 Jun 2025 08:31:38 -0300 Subject: [PATCH] Added target to generate vscode intellisense cfg Now the target `make config_vscode` creates or replaces `.vscode/c_cpp_properties.json` in the project directory, with an intellisense config containing include paths, defines and compiler path for the project; and setting the c standard to c99. --- module/base/makefile | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/module/base/makefile b/module/base/makefile index 1c97cd3..bb8897c 100644 --- a/module/base/makefile +++ b/module/base/makefile @@ -345,3 +345,38 @@ info: @echo Objetos: $(PROJECT_OBJ) @echo ------------------------------------------------------------------------------- @echo Definciones: $(DEFINES) + +################################################################################################## +# +COMMA := , +EMPTY := +SPACE := $(EMPTY) $(EMPTY) +TAB := $(EMPTY) $(EMPTY) +json_list = $(subst $(SPACE),$(COMMA)$(SPACE),$(strip $(foreach w,$1,"$w"))) + +MY_INCLUDES = $(strip $(foreach p,$(PROJECT_INC),$(subst $(abspath $(PROJECT_DIR)),$(PROJECT_DIR),$(call full_path,$(p))))) + +define vscode_c_config +{ + "configurations": [ + { + "name": "MUJU", + "includePath": [$(call json_list,$(MY_INCLUDES))], + "defines": [$(call json_list,$(DEFINES))], + "cStandard": "c99", + "intelliSenseMode": "$${default}", + "compilerPath":"$(subst \,\\,$(shell $(CC) -v 2>&1 | awk '/COLLECT_GCC=/ {sub(/[^=]+=/,"");print}'))" + } + ], + "version": 4 +} +endef + +VSCODE_DIR=$(PROJECT_DIR)/.vscode +VSCODE_CFG=$(VSCODE_DIR)/c_cpp_properties.json + +config_vscode: |$(VSCODE_DIR) + @echo "Creating or replacing $(VSCODE_CFG) $(file > $(VSCODE_CFG),$(subst $(TAB),$(SPACE)$(SPACE),$(vscode_c_config)))" + +$(VSCODE_DIR): + $(QUIET) mkdir -p $(VSCODE_DIR)