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 1/2] 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) From 955572e2835a855b78a8540d91c5939239f27cb9 Mon Sep 17 00:00:00 2001 From: Esteban Volentini Date: Wed, 18 Jun 2025 09:12:13 -0300 Subject: [PATCH 2/2] Fixed to run in MacOS and Linux --- module/base/makefile | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/module/base/makefile b/module/base/makefile index bb8897c..de1a623 100644 --- a/module/base/makefile +++ b/module/base/makefile @@ -348,26 +348,34 @@ info: ################################################################################################## # +define NEWLINE + + +endef COMMA := , EMPTY := SPACE := $(EMPTY) $(EMPTY) -TAB := $(EMPTY) $(EMPTY) -json_list = $(subst $(SPACE),$(COMMA)$(SPACE),$(strip $(foreach w,$1,"$w"))) +TAB := $(SPACE)$(SPACE)$(SPACE)$(SPACE) +INDENT := $(COMMA)\n$(TAB)$(TAB)$(TAB)$(TAB) + +define json_list +$(subst $(SPACE),$(INDENT),$(strip $(foreach w,$1,"$w"))) +endef -MY_INCLUDES = $(strip $(foreach p,$(PROJECT_INC),$(subst $(abspath $(PROJECT_DIR)),$(PROJECT_DIR),$(call full_path,$(p))))) +VSCODE_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}'))" - } - ], + "configurations": [ + { + "name": "MUJU", + "includePath": [$(call json_list,$(VSCODE_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 @@ -375,8 +383,9 @@ 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: |$(VSCODE_DIR) + @echo "Creating or replacing $(VSCODE_CFG)" + @echo '$(subst $(NEWLINE),\n,${vscode_c_config})' > $(VSCODE_CFG) $(VSCODE_DIR): - $(QUIET) mkdir -p $(VSCODE_DIR) + -@mkdir -p $(VSCODE_DIR)