Skip to content

Commit

Permalink
Build system: handle source dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ReservedField committed Oct 26, 2016
1 parent a4d0d9e commit b5f8447
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ CLEAN_PATH_TMPL += clean-sdkdir-tmpl
# Enable secondary expansion.
.SECONDEXPANSION:

# Include source dependency files.
-include $(call get-deps,$(objs-all))

# Rule to archive prerequisite objects into a library.
$(lib-all): | $$(@D)
$(call info-cmd,LIB)
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ source tree is replicated in there, to avoid conflicts between files with the sa
you wanted to compile the file `src/foo/bar.c` for an eVic VTC Mini, debug flavor, you could
issue `make obj/dbg/evic/src/foo/bar.o`.

#### Source dependency files

Source dependency files live in the same directory as object files. They have a `.d` extension
and are generated automatically when objects are built.

#### SDK builds

SDK output files live in the `lib/FLAVOR/DEVICE` directory. Debug builds enable debug info
Expand Down
3 changes: 3 additions & 0 deletions make/Base.mk
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ CLEAN_PATH_TMPL += clean-bindir-tmpl
# Enable secondary expansion.
.SECONDEXPANSION:

# Include source dependency files.
-include $(call get-deps,$(objs-all))

# Set BUILD_* for all our targets.
$(call build-vars-rules,elf-tmpl)
$(call build-vars-rules,bin-dec-tmpl)
Expand Down
7 changes: 6 additions & 1 deletion make/Common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,12 @@ get-incflags = $(foreach d,$(call fixpath-cc,$1),-I$d)
# CXXFLAGS: C++ compiler flags.
# ASFLAGS: assembler flags.
# Note that those are NOT inclusive of CPU flags.
# The -MMD flag generates source dependency files. Those files
# are never specified as targets to avoid a remake on include.
__CC_FLAGS := \
$(call get-incflags,$(INCDIRS)) \
-Os -fdata-sections -ffunction-sections \
$(if $(CC_IS_CLANG),-nostdinc)
$(if $(CC_IS_CLANG),-nostdinc) -MMD
ifndef EVICSDK_FPU_DISABLE
__CC_FLAGS += -DEVICSDK_FPU_SUPPORT
ASFLAGS += -DEVICSDK_FPU_SUPPORT
Expand Down Expand Up @@ -253,6 +255,9 @@ clean-devfla-tmpl = clean$(if $1,-$1)$(if $2,-$2)
# Gets the paths to all possible sources for the given objects.
# Argument 1: object list.
get-srcs = $(foreach e,c cpp s,$(patsubst %.o,%.$e,$1))
# Gets the paths to all source dependency files for the given objects.
# Argument 1: object list.
get-deps = $(addsuffix .d,$(basename $1))

# Gets object and source paths to cache for fixpath.
# Argument 1: object list.
Expand Down

0 comments on commit b5f8447

Please sign in to comment.