Skip to content

Commit

Permalink
vscode: fixed copy of debug.elf
Browse files Browse the repository at this point in the history
  • Loading branch information
tridge committed Jul 20, 2024
1 parent a6dc28b commit d0ce737
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
21 changes: 14 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

QUIET = @

# update version numbers here
Expand Down Expand Up @@ -50,14 +51,16 @@ SRC_COMMON := $(foreach dir,$(SRC_DIRS_COMMON),$(wildcard $(dir)/*.[cs]))

FIRMWARE_VERSION := $(VERSION_MAJOR).$(VERSION_MINOR)

TARGET_BASENAME = $(BIN_DIR)/$(IDENTIFIER)_$(TARGET)_$(FIRMWARE_VERSION)
TARGET_FNAME = $(IDENTIFIER)_$(TARGET)_$(FIRMWARE_VERSION)
TARGET_BASENAME = $(BIN_DIR)/$(TARGET_FNAME)

# Build tools, so we all share the same versions
# import macros common to all supported build systems
# include $(ROOT)/make/system-id.mk

# configure some directories that are relative to wherever ROOT_DIR is located
BIN_DIR := $(ROOT)/obj
OBJ := obj
BIN_DIR := $(ROOT)/$(OBJ)

TOOLS_DIR ?= $(ROOT)/tools
DL_DIR := $(ROOT)/downloads
Expand All @@ -71,10 +74,16 @@ e230 : $(TARGETS_E230)
f421 : $(TARGETS_F421)
f415 : $(TARGETS_F415)

$(OBJ):
@$(MKDIR) $(OBJ) > $(NUL)

clean :
rm -rf $(BIN_DIR)/*

binary : $(TARGET_BASENAME).bin
# we copy debug.elf to give us a constant debug target for vscode
# this means the debug button will always debug the last target built
@$(COPY) $(OBJ)$(DSEP)$(TARGET_FNAME).elf $(OBJ)$(DSEP)debug.elf > $(NUL)
@$(ECHO) done $(TARGET)

$(TARGETS_F051) :
Expand All @@ -98,11 +107,9 @@ $(TARGETS_F415) :
# Compile target
$(TARGET_BASENAME).elf: CFLAGS := $(MCU_$(MCU_TYPE)) $(CFLAGS_$(MCU_TYPE)) $(CFLAGS_COMMON)
$(TARGET_BASENAME).elf: LDFLAGS := $(LDFLAGS_COMMON) $(LDFLAGS_$(MCU_TYPE)) -T$(LDSCRIPT_$(MCU_TYPE))
$(TARGET_BASENAME).elf: $(SRC_COMMON) $(SRC_$(MCU_TYPE))
$(TARGET_BASENAME).elf: $(SRC_COMMON) $(SRC_$(MCU_TYPE)) $(OBJ)
@$(ECHO) Compiling $(notdir $@)
if not exist obj (mkdir obj)
$(QUIET)$(CC) $(CFLAGS) $(LDFLAGS) -MMD -MP -MF $(@:.elf=.d) -o $(@) $(SRC_COMMON) $(SRC_$(MCU_TYPE))
$(QUIET)echo $(COPY) $(patsubst /,\\,$(TARGET_BASENAME).elf) $(patsubst /,\\,obj/debug.elf)

# Generate bin and hex files
$(TARGET_BASENAME).bin: $(TARGET_BASENAME).elf
Expand All @@ -112,10 +119,10 @@ $(TARGET_BASENAME).bin: $(TARGET_BASENAME).elf

# mkdirs
$(DL_DIR):
$(QUIET)mkdir -p $@
$(QUIET)$(MKDIR) $@

$(TOOLS_DIR):
$(QUIET)mkdir -p $@
$(QUIET)$(MKDIR) $@

# include the tools makefile
include $(ROOT)/make/tools.mk
Expand Down
10 changes: 7 additions & 3 deletions make/tools.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@

ifeq ($(OS),Windows_NT)
ARM_SDK_PREFIX := "tools/windows/xpack-arm-none-eabi-gcc-10.3.1-2.3/bin/arm-none-eabi-"
MKDIR:=mkdir
SHELL:=cmd.exe
COPY:=copy
COPY:=copy /Y
DSEP:=\\
NUL:=NUL
MKDIR:=mkdir
else
ARM_SDK_PREFIX := "tools/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-"
MKDIR:=mkdir -p
COPY:=cp
DSEP:=/
NUL:=/dev/null
MKDIR:=mkdir -p
endif

0 comments on commit d0ce737

Please sign in to comment.