From e306ce2451c9aff4f99c773a2549ecfc06eb03ed Mon Sep 17 00:00:00 2001 From: Jort Band Date: Mon, 9 Sep 2024 00:16:37 +0200 Subject: [PATCH 1/5] fix: iisue ##206 did not build anything else than elf files. was an issue in the all build target --- src/CreateMakefile.ts | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/src/CreateMakefile.ts b/src/CreateMakefile.ts index 600f894..1aba08b 100644 --- a/src/CreateMakefile.ts +++ b/src/CreateMakefile.ts @@ -246,6 +246,16 @@ HEX = $(CP) -O ihex BIN = $(CP) -O binary -S LSS = $(DP) -h -S + +REMOVE_DIRECTORY_COMMAND = rm -fR +mkdir_function = mkdir -p $(1) +ifeq ($(OS),Windows_NT) + convert_to_windows_path = $(strip $(subst /,\\,$(patsubst %/,%,$(1)))) + REMOVE_DIRECTORY_COMMAND = cmd /c rd /s /q + mkdir_function = cmd /e:on /c md $(call convert_to_windows_path,$(1)) +endif + + # Flash and debug tools # Default is openocd however will be gotten from the env file when existing OPENOCD ?= openocd @@ -328,15 +338,7 @@ LDFLAGS = $(MCU) $(ADDITIONALLDFLAGS) -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$ ####################################### # build the application ####################################### -add_release_directory = $(sort $(addprefix $(RELEASE_DIRECTORY)/,$(addsuffix .$(2),$(basename $(subst ../,parent,$(1)))))) - -REMOVE_DIRECTORY_COMMAND = rm -fR -mkdir_function = mkdir -p $(1) -ifeq ($(OS),Windows_NT) - convert_to_windows_path = $(strip $(subst /,\\,$(patsubst %/,%,$(1)))) - REMOVE_DIRECTORY_COMMAND = cmd /c rd /s /q - mkdir_function = cmd /e:on /c md $(call convert_to_windows_path,$(1)) -endif +add_release_directory = $(sort $(addprefix $(RELEASE_DIRECTORY)/,$(addsuffix .$(2),$(basename $(subst ../,/parent,$(1)))))) @@ -357,6 +359,14 @@ vpath %.S $(sort $(dir $(ASM_SOURCES))) # the tree of folders which needs to be present based on the object files BUILD_TREE = $(sort $(dir $(OBJECTS))) + +####################################### +# all +####################################### +# note needs to be located as the first rule to be the default build rule +# default action: build all +all: $(BUILD_DIRECTORY)/$(TARGET).elf $(BUILD_DIRECTORY)/$(TARGET).hex $(BUILD_DIRECTORY)/$(TARGET).bin $(BUILD_DIRECTORY)/$(TARGET).lss + # C build $(RELEASE_DIRECTORY)/%.o: %.c ${makefileName} | $(BUILD_TREE) \t$(CC) -c $(CFLAGS) $< -o $@ @@ -412,24 +422,17 @@ $(BUILD_DIRECTORY): $(BUILD_TREE): \t$(call mkdir_function, $@) + ####################################### -# all +# flash ####################################### -# default action: build all -all: -\t$(BUILD_DIRECTORY)/$(TARGET).elf -\t$(BUILD_DIRECTORY)/$(TARGET).hex -\t$(BUILD_DIRECTORY)/$(TARGET).bin -\t$(BUILD_DIRECTORY)/$(TARGET).lss - - -flash: $(BUILD_DIRECTORY)/$(TARGET).elf +flash: all \t"$(OPENOCD)" -f ./openocd.cfg -c "program $(BUILD_DIRECTORY)/$(TARGET).elf verify reset exit" ####################################### # erase ####################################### -erase: $(BUILD_DIRECTORY)/$(TARGET).elf +erase: all \t"$(OPENOCD)" -f ./openocd.cfg -c "init; reset halt; ${makeInfo.targetMCU} mass_erase 0; exit" ####################################### From 5b412170e4a86851fb5e0874e8b8cafd5d4af443 Mon Sep 17 00:00:00 2001 From: Jort Date: Fri, 27 Sep 2024 10:30:49 +0200 Subject: [PATCH 2/5] chore: version bump for new minor patch release. fix: issue #212 Used fix proposed by qwertym88 --- CHANGELOG.md | 5 +++++ package.json | 2 +- src/CreateMakefile.ts | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f317a8..f1171e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ - Full support for CubeIDE imports. - Add option to select installation location for the tooling. +## [3.2.9] - 2024-09-27 +### Added + - Issue #206: Did not build anything else than elf files due to the all recipe not being correct. + - Issue #212: On Windows threw an error because the build folder was already there. Now checks before using the md command. Thanks to: qwertym88 + ## [3.2.8] - 2024-09-05 ### Added - Issue #197: Added CONTRIBUTING.md files thanks to DeflateAwning diff --git a/package.json b/package.json index 4e388e0..b6f96ce 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "stm32-for-vscode", "displayName": "stm32-for-vscode", "description": "An extension for: setting up, compiling, uploading and debugging STM32 applications", - "version": "3.2.8", + "version": "3.2.9", "engines": { "vscode": "^1.44.0" }, diff --git a/src/CreateMakefile.ts b/src/CreateMakefile.ts index 1aba08b..bffe2ac 100644 --- a/src/CreateMakefile.ts +++ b/src/CreateMakefile.ts @@ -48,7 +48,7 @@ export function createStringList(arr: string[], prefix?: string): string { // Replace '#' with '\#' (for escaping in Makefile). // Backslash replacement is because CodeQL complained about incomplete escaping. const escapedEntry = entry.replace(/\\/g, '\\\\').replace(/#/g, '\\#'); - + if (prefix) { output += prefix; } @@ -252,7 +252,7 @@ mkdir_function = mkdir -p $(1) ifeq ($(OS),Windows_NT) convert_to_windows_path = $(strip $(subst /,\\,$(patsubst %/,%,$(1)))) REMOVE_DIRECTORY_COMMAND = cmd /c rd /s /q - mkdir_function = cmd /e:on /c md $(call convert_to_windows_path,$(1)) + mkdir_function = cmd /e:on /c if not exist $(call convert_to_windows_path,$(1)) md $(call convert_to_windows_path,$(1)) endif From d91fa6044cac10894f32e19cde55bc601d509ad2 Mon Sep 17 00:00:00 2001 From: Jort Band Date: Thu, 31 Oct 2024 22:07:38 +0100 Subject: [PATCH 3/5] fix: reverted to non build tree, build as it was giving issue for both build on windows (max size for command in terminal) and out of parent build files build --- src/CreateMakefile.ts | 48 ++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/src/CreateMakefile.ts b/src/CreateMakefile.ts index bffe2ac..bddc7a0 100644 --- a/src/CreateMakefile.ts +++ b/src/CreateMakefile.ts @@ -338,7 +338,7 @@ LDFLAGS = $(MCU) $(ADDITIONALLDFLAGS) -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$ ####################################### # build the application ####################################### -add_release_directory = $(sort $(addprefix $(RELEASE_DIRECTORY)/,$(addsuffix .$(2),$(basename $(subst ../,/parent,$(1)))))) +add_release_directory = $(sort $(addprefix $(RELEASE_DIRECTORY)/,$(addsuffix .$(2),$(basename $(notdir $(1)))))) @@ -356,70 +356,66 @@ vpath %.CPP $(sort $(dir $(CXX_SOURCES))) vpath %.s $(sort $(dir $(ASM_SOURCES))) vpath %.S $(sort $(dir $(ASM_SOURCES))) -# the tree of folders which needs to be present based on the object files -BUILD_TREE = $(sort $(dir $(OBJECTS))) - - ####################################### # all ####################################### # note needs to be located as the first rule to be the default build rule # default action: build all -all: $(BUILD_DIRECTORY)/$(TARGET).elf $(BUILD_DIRECTORY)/$(TARGET).hex $(BUILD_DIRECTORY)/$(TARGET).bin $(BUILD_DIRECTORY)/$(TARGET).lss +all: $(RELEASE_DIRECTORY)/$(TARGET).elf $(RELEASE_DIRECTORY)/$(TARGET).hex $(RELEASE_DIRECTORY)/$(TARGET).bin $(RELEASE_DIRECTORY)/$(TARGET).lss # C build -$(RELEASE_DIRECTORY)/%.o: %.c ${makefileName} | $(BUILD_TREE) +$(RELEASE_DIRECTORY)/%.o: %.c ${makefileName} | $(RELEASE_DIRECTORY) \t$(CC) -c $(CFLAGS) $< -o $@ # C++ build -$(RELEASE_DIRECTORY)/%.o: %.cc ${makefileName} | $(BUILD_TREE) +$(RELEASE_DIRECTORY)/%.o: %.cc ${makefileName} | $(RELEASE_DIRECTORY) \t$(CXX) -c $(CXXFLAGS) $< -o $@ -$(RELEASE_DIRECTORY)/%.o: %.cp ${makefileName} | $(BUILD_TREE) +$(RELEASE_DIRECTORY)/%.o: %.cp ${makefileName} | $(RELEASE_DIRECTORY) \t$(CXX) -c $(CXXFLAGS) $< -o $@ -$(RELEASE_DIRECTORY)/%.o: %.cxx ${makefileName} | $(BUILD_TREE) +$(RELEASE_DIRECTORY)/%.o: %.cxx ${makefileName} | $(RELEASE_DIRECTORY) \t$(CXX) -c $(CXXFLAGS) $< -o $@ -$(RELEASE_DIRECTORY)/%.o: %.cpp ${makefileName} | $(BUILD_TREE) +$(RELEASE_DIRECTORY)/%.o: %.cpp ${makefileName} | $(RELEASE_DIRECTORY) \t$(CXX) -c $(CXXFLAGS) $< -o $@ -$(RELEASE_DIRECTORY)/%.o: %.c++ ${makefileName} | $(BUILD_TREE) +$(RELEASE_DIRECTORY)/%.o: %.c++ ${makefileName} | $(RELEASE_DIRECTORY) \t$(CXX) -c $(CXXFLAGS) $< -o $@ -$(RELEASE_DIRECTORY)/%.o: %.C ${makefileName} | $(BUILD_TREE) +$(RELEASE_DIRECTORY)/%.o: %.C ${makefileName} | $(RELEASE_DIRECTORY) \t$(CXX) -c $(CXXFLAGS) $< -o $@ -$(RELEASE_DIRECTORY)/%.o: %.CPP ${makefileName} | $(BUILD_TREE) +$(RELEASE_DIRECTORY)/%.o: %.CPP ${makefileName} | $(RELEASE_DIRECTORY) \t$(CXX) -c $(CXXFLAGS) $< -o $@ #Assembly build -$(RELEASE_DIRECTORY)/%.o: %.s ${makefileName} | $(BUILD_TREE) +$(RELEASE_DIRECTORY)/%.o: %.s ${makefileName} | $(RELEASE_DIRECTORY) \t$(AS) -c $(ASFLAGS) $< -o $@ -$(RELEASE_DIRECTORY)/%.o: %.S ${makefileName} | $(BUILD_TREE) +$(RELEASE_DIRECTORY)/%.o: %.S ${makefileName} | $(RELEASE_DIRECTORY) \t$(AS) -c $(ASFLAGS) $< -o $@ -$(RELEASE_DIRECTORY)/%.o: %.sx ${makefileName} | $(BUILD_TREE) +$(RELEASE_DIRECTORY)/%.o: %.sx ${makefileName} | $(RELEASE_DIRECTORY) \t$(AS) -c $(ASFLAGS) $< -o $@ -$(BUILD_DIRECTORY)/$(TARGET).elf: $(OBJECTS) ${makefileName} | $(BUILD_DIRECTORY) +$(RELEASE_DIRECTORY)/$(TARGET).elf: $(OBJECTS) ${makefileName} | $(RELEASE_DIRECTORY) \t$(${makeInfo.language === 'C' ? 'CC' : 'CXX'}) $(OBJECTS) $(LDFLAGS) -o $@ \t$(SZ) $@ -$(BUILD_DIRECTORY)/%.hex: $(BUILD_DIRECTORY)/%.elf | $(BUILD_DIRECTORY) +$(RELEASE_DIRECTORY)/%.hex: $(RELEASE_DIRECTORY)/%.elf | $(RELEASE_DIRECTORY) \t$(HEX) $< $@ -$(BUILD_DIRECTORY)/%.bin: $(BUILD_DIRECTORY)/%.elf | $(BUILD_DIRECTORY) +$(RELEASE_DIRECTORY)/%.bin: $(RELEASE_DIRECTORY)/%.elf | $(RELEASE_DIRECTORY) \t$(BIN) $< $@ -$(BUILD_DIRECTORY)/%.lss: $(BUILD_DIRECTORY)/%.elf | $(BUILD_DIRECTORY) +$(RELEASE_DIRECTORY)/%.lss: $(RELEASE_DIRECTORY)/%.elf | $(RELEASE_DIRECTORY) \t$(LSS) $< > $@ -$(BUILD_DIRECTORY): +$(RELEASE_DIRECTORY): \t$(call mkdir_function, $@) -$(BUILD_TREE): +$(BUILD_DIRECTORY): | $(RELEASE_DIRECTORY) \t$(call mkdir_function, $@) @@ -427,7 +423,7 @@ $(BUILD_TREE): # flash ####################################### flash: all -\t"$(OPENOCD)" -f ./openocd.cfg -c "program $(BUILD_DIRECTORY)/$(TARGET).elf verify reset exit" +\t"$(OPENOCD)" -f ./openocd.cfg -c "program $(RELEASE_DIRECTORY)/$(TARGET).elf verify reset exit" ####################################### # erase @@ -439,7 +435,7 @@ erase: all # clean up ####################################### clean: -\t$(REMOVE_DIRECTORY_COMMAND) $(BUILD_DIRECTORY) +\t$(REMOVE_DIRECTORY_COMMAND) $(RELEASE_DIRECTORY) ####################################### # custom makefile rules @@ -449,7 +445,7 @@ ${customMakefileRules(makeInfo)} ####################################### # dependencies ####################################### --include $(wildcard $(BUILD_DIRECTORY)/*.d) +-include $(wildcard $(RELEASE_DIRECTORY)/*.d) # *** EOF ***`; } From d4bcf0e17bae2a5913fe26cde3665573931a9e53 Mon Sep 17 00:00:00 2001 From: Jort Band Date: Sun, 17 Nov 2024 20:06:59 +0100 Subject: [PATCH 4/5] fix: fixed issue with windows maximum command line string length by using a file top pass the objects for linking --- src/CreateMakefile.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/CreateMakefile.ts b/src/CreateMakefile.ts index 37b34ae..ff5ba05 100644 --- a/src/CreateMakefile.ts +++ b/src/CreateMakefile.ts @@ -401,7 +401,8 @@ $(RELEASE_DIRECTORY)/%.o: %.sx ${makefileName} | $(RELEASE_DIRECTORY) \t$(AS) -c $(ASFLAGS) $< -o $@ $(RELEASE_DIRECTORY)/$(TARGET).elf: $(OBJECTS) ${makefileName} | $(RELEASE_DIRECTORY) -\t$(${makeInfo.language === 'C' ? 'CC' : 'CXX'}) $(OBJECTS) $(LDFLAGS) -o $@ +\t$(file >$@.in,$(OBJECTS)) +\t$(${makeInfo.language === 'C' ? 'CC' : 'CXX'}) @$@.in $(LDFLAGS) -o $@ \t$(SZ) $@ $(RELEASE_DIRECTORY)/%.hex: $(RELEASE_DIRECTORY)/%.elf | $(RELEASE_DIRECTORY) From 6fd9da3811215889c268fc9e29cb494797a6a7f3 Mon Sep 17 00:00:00 2001 From: Jort Band Date: Sun, 17 Nov 2024 20:19:09 +0100 Subject: [PATCH 5/5] doc: updated changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1171e0..2b79182 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ - Issue #206: Did not build anything else than elf files due to the all recipe not being correct. - Issue #212: On Windows threw an error because the build folder was already there. Now checks before using the md command. Thanks to: qwertym88 +### Fix + - Reverted to single name build instead of a file tree based build output. + - Linkerscript now uses a file for the objects it needs to link to prevent Windows based command line length issues. + ## [3.2.8] - 2024-09-05 ### Added - Issue #197: Added CONTRIBUTING.md files thanks to DeflateAwning