Skip to content

Commit

Permalink
fix(Build): Allow Users to Give Absolute Paths to SRCS (#666)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake-Carter authored Jul 17, 2023
1 parent 31f54fe commit 54dd724
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion Libraries/CMSIS/Device/Maxim/GCC/gcc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ ifeq "$(BUILD_DIR)" ""
BUILD_DIR=$(CURDIR)/build
endif

# Make sure VPATH has the location of any absolute paths given to SRCS
# This allows users to specify SRCS += /absolute/path/to/file.c to add a single file to the build
# without also having to add VPATH += /absolute/path/to
# This is necessary because we create our object file definitions with OBJS_NOPATH.
VPATH += $(sort $(abspath $(dir $(SRCS))))

# Create output object file names
SRCS_NOPATH := $(foreach NAME,$(SRCS),$(basename $(notdir $(NAME))).c)
BINS_NOPATH := $(foreach NAME,$(BINS),$(basename $(notdir $(NAME))).bin)
Expand Down Expand Up @@ -507,4 +513,4 @@ $(BUILD_DIR)/project_defines.h: mkbuildir
@echo "// This is a generated file that's used to detect definitions that have been set by the compiler and build system." > $@
@$(CC) -E -P -dD $(BUILD_DIR)/_empty_tmp_file.c $(CFLAGS) >> $@
@rm $(BUILD_DIR)/_empty_tmp_file.c
@rm _empty_tmp_file.d
@rm _empty_tmp_file.d
8 changes: 7 additions & 1 deletion Libraries/CMSIS/Device/Maxim/GCC/gcc_riscv.mk
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ ifeq "$(BUILD_DIR)" ""
BUILD_DIR=$(CURDIR)/buildrv
endif

# Make sure VPATH has the location of any absolute paths given to SRCS
# This allows users to specify SRCS += /absolute/path/to/file.c to add a single file to the build
# without also having to add VPATH += /absolute/path/to
# This is necessary because we create our object file definitions with OBJS_NOPATH.
VPATH += $(sort $(abspath $(dir $(SRCS))))

# Create output object file names
SRCS_NOPATH := $(foreach NAME,$(SRCS),$(basename $(notdir $(NAME))).c)
OBJS_NOPATH := $(SRCS_NOPATH:.c=.o)
Expand Down Expand Up @@ -464,4 +470,4 @@ $(BUILD_DIR)/project_defines.h: mkbuildir
@echo "// This is a generated file that's used to detect definitions that have been set by the compiler and build system." > $@
@$(CC) -E -P -dD $(BUILD_DIR)/_empty_tmp_file.c $(CFLAGS) >> $@
@rm $(BUILD_DIR)/_empty_tmp_file.c
@rm _empty_tmp_file.d
@rm _empty_tmp_file.d

0 comments on commit 54dd724

Please sign in to comment.