Skip to content

Commit

Permalink
Restructure mbed SDK makefiles.
Browse files Browse the repository at this point in the history
No longer deploy common headers to drop subdirectory from the device
specific makefiles.  This caused contention during some parallel build
runs.  Now the common headers are deployed to drop from the main
makefile in the mbed/src directory.  This should not only remove the
parallel build race condition but even improve the performance of
since the common header deployment can now occur in parallel with
the device specific builds.
  • Loading branch information
adamgreen committed Mar 30, 2013
1 parent af5e8cc commit 24bab28
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 22 deletions.
2 changes: 1 addition & 1 deletion mbed/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ $(DIRSCLEAN): %.clean:
@echo Cleaning $*
@ $(MAKE) -C $* clean

.PHONY: all $(DIRS) $(DIRSCLEAN)
.PHONY: all clean $(DIRS) $(DIRSCLEAN)
82 changes: 77 additions & 5 deletions mbed/src/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,72 @@
#!/usr/bin/make

DEVICES = mbed-lpc1768.mk mbed-lpc11u24.mk
DEVICESCLEAN = $(addsuffix .clean,$(DEVICES))
DEVICES =mbed-lpc1768.mk mbed-lpc11u24.mk
DEVICESCLEAN =$(addsuffix .clean,$(DEVICES))

all: $(DEVICES)

clean: $(DEVICESCLEAN)
# Set VERBOSE make variable to 1 to output all tool commands.
VERBOSE?=0
ifeq "$(VERBOSE)" "0"
Q=@
else
Q=
endif


# Directories where source files are found and output files should be placed.
ROOT_DIR =..
SRC_DIR =.
DROP_DIR =$(ROOT_DIR)/drop
MBED_CAPI_SRC =$(SRC_DIR)/capi
MBED_CPP_SRC =$(SRC_DIR)/cpp


# Copy headers to drop directory.
COMMON_HEADER_SRCS =$(notdir $(wildcard $(MBED_CPP_SRC)/*.h))
COMMON_HEADER_SRCS+=$(notdir $(wildcard $(MBED_CAPI_SRC)/*.h))
COMMON_HEADERS =$(patsubst %.h,$(DROP_DIR)/%.h,$(COMMON_HEADER_SRCS))


# Command line tools that are different between *nix and Windows.
ifeq "$(OS)" "Windows_NT"
REMOVE =del /q
REMOVE_DIR =rd /s /q
COPY =copy
CAT =type
MKDIR =mkdir
QUIET =>nul 2>nul & exit 0
NOSTDOUT =>nul
else
REMOVE =rm
REMOVE_DIR =rm -r -f
COPY =cp
CAT =cat
MKDIR =mkdir -p
QUIET => /dev/null 2>&1 ; exit 0
NOSTDOUT => /dev/null
endif


# Macro which will convert / to \ on Windows.
ifeq "$(OS)" "Windows_NT"
define convert-slash
$(subst /,\,$1)
endef
else
define convert-slash
$1
endef
endif


# Make rules.
all: $(COMMON_HEADERS) $(DEVICES)

clean: $(DEVICESCLEAN) clean_drop

clean_drop:
@echo Cleaning $(DROP_DIR)
$(Q) $(REMOVE_DIR) $(call convert-slash,$(DROP_DIR)) $(QUIET)

$(DEVICES):
@echo Building $@
Expand All @@ -15,4 +76,15 @@ $(DEVICESCLEAN): %.clean:
@echo Cleaning $*
@ $(MAKE) -f $* clean

.PHONY: all $(DEVICES) $(DEVICESCLEAN)
$(DROP_DIR)/%.h : $(MBED_CPP_SRC)/%.h
@echo Deploying $? to drop
$(Q) $(MKDIR) $(call convert-slash,$(dir $@)) $(QUIET)
$(Q) $(COPY) $(call convert-slash,$?) $(call convert-slash,$@) $(NOSTDOUT)

$(DROP_DIR)/%.h : $(MBED_CAPI_SRC)/%.h
@echo Deploying $? to drop
$(Q) $(MKDIR) $(call convert-slash,$(dir $@)) $(QUIET)
$(Q) $(COPY) $(call convert-slash,$?) $(call convert-slash,$@) $(NOSTDOUT)


.PHONY: all clean clean_drop $(DEVICES) $(DEVICESCLEAN)
23 changes: 7 additions & 16 deletions mbed/src/arm-common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ LD_DEST=$(RELEASE_DROP)/$(LD_FILE)


# Copy headers to device drop directory.
COMMON_HEADER_SRCS =$(notdir $(wildcard $(MBED_CPP_SRC)/*.h))
COMMON_HEADER_SRCS+=$(notdir $(wildcard $(MBED_CAPI_SRC)/*.h))
COMMON_HEADERS =$(patsubst %.h,$(DROP_DIR)/%.h,$(COMMON_HEADER_SRCS))
DEVICE_HEADER_SRCS =$(notdir $(wildcard $(VENDOR_CAPI_DEVICE_SRC)/*.h))
DEVICE_HEADER_SRCS+=$(notdir $(wildcard $(VENDOR_CMSIS_SRC)/*.h))
DEVICE_HEADERS =$(patsubst %.h,$(DEVICE_DROP)/%.h,$(DEVICE_HEADER_SRCS))
Expand Down Expand Up @@ -160,13 +157,15 @@ COPY =copy
CAT =type
MKDIR =mkdir
QUIET =>nul 2>nul & exit 0
NOSTDOUT =>nul
else
REMOVE =rm
REMOVE_DIR =rm -r -f
COPY =cp
CAT =cat
MKDIR =mkdir -p
QUIET => /dev/null 2>&1 ; exit 0
NOSTDOUT => /dev/null
endif


Expand All @@ -187,7 +186,7 @@ endif
#########################################################################
.PHONY: all clean

all: $(RELEASE_MBED) $(DEBUG_MBED) $(COMMON_HEADERS) $(DEVICE_HEADERS) $(LD_DEST)
all: $(RELEASE_MBED) $(DEBUG_MBED) $(DEVICE_HEADERS) $(LD_DEST)

$(RELEASE_MBED): $(RELEASE_OBJECTS)
@echo Linking release library $@
Expand All @@ -205,10 +204,8 @@ $(LD_DEST): $(LD_SRC)
$(Q) $(COPY) $(call convert-slash,$?) $(call convert-slash,$@)

clean:
@echo Cleaning up all build generated files
$(Q) $(REMOVE_DIR) $(call convert-slash,$(DEBUG_OBJDIR)) $(QUIET)
$(Q) $(REMOVE_DIR) $(call convert-slash,$(RELEASE_OBJDIR)) $(QUIET)
$(Q) $(REMOVE_DIR) $(call convert-slash,$(DROP_DIR)) $(QUIET)

-include $(DEBUG_DEPFILES)
-include $(RELEASE_DEPFILES)
Expand Down Expand Up @@ -247,18 +244,12 @@ $(RELEASE_OBJDIR)/%.o : %.s
$(Q) $(MKDIR) $(call convert-slash,$(dir $@)) $(QUIET)
$(Q) $(GCC) $(AS_FLAGS) -c $< -o $@

$(DROP_DIR)/%.h : $(MBED_CPP_SRC)/%.h
$(Q) $(MKDIR) $(call convert-slash,$(dir $@)) $(QUIET)
$(Q) $(COPY) $(call convert-slash,$?) $(call convert-slash,$@)

$(DROP_DIR)/%.h : $(MBED_CAPI_SRC)/%.h
$(Q) $(MKDIR) $(call convert-slash,$(dir $@)) $(QUIET)
$(Q) $(COPY) $(call convert-slash,$?) $(call convert-slash,$@)

$(DEVICE_DROP)/%.h : $(VENDOR_CAPI_DEVICE_SRC)/%.h
@echo Deploying $? to drop
$(Q) $(MKDIR) $(call convert-slash,$(dir $@)) $(QUIET)
$(Q) $(COPY) $(call convert-slash,$?) $(call convert-slash,$@)
$(Q) $(COPY) $(call convert-slash,$?) $(call convert-slash,$@) $(NOSTDOUT)

$(DEVICE_DROP)/%.h : $(VENDOR_CMSIS_SRC)/%.h
@echo Deploying $? to drop
$(Q) $(MKDIR) $(call convert-slash,$(dir $@)) $(QUIET)
$(Q) $(COPY) $(call convert-slash,$?) $(call convert-slash,$@)
$(Q) $(COPY) $(call convert-slash,$?) $(call convert-slash,$@) $(NOSTDOUT)

0 comments on commit 24bab28

Please sign in to comment.