From 7b925ccb4cb140b279db2ea89a3cd4767200ba7e Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 3 Feb 2015 08:24:24 -0600 Subject: [PATCH] apps/builtin: better fix for building with parallel make Build-server sometimes fails 'make -j24' with: In file included from builtin_list.c:62:0: builtin_list.h:1:46: error: 'ts_engine_main' undeclared here (not in a function) { "ts_engine", SCHED_PRIORITY_DEFAULT, 2048, ts_engine_main }, or sometimes silently succeeds but generates builds that contain a random subset of configured NuttX applications. There are two root causes for this: 1) Recipes for building builtin_list.h and builtin_proto.h are not linearizable. 2) Nothing ensures that 'make context' is run first for apps/builtin This patch addresses both issues. Signed-off-by: Juha Niskanen --- Makefile | 12 +++++++++--- builtin/Makefile | 24 +++++++++++++++--------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index fc04a8878..d580d2f10 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,7 @@ TOPDIR ?= $(APPDIR)/import # CONFIGURED_APPS is the list of all configured built-in directories/built # action. # SUBDIRS is the list of all directories containing Makefiles. It is used -# only for cleaning. builtin must always be the first in the list. +# only for cleaning. CONFIGURED_APPS = SUBDIRS = examples graphics interpreters modbus builtin import nshlib @@ -114,7 +114,7 @@ BIN = libapps$(LIBEXT) # Build targets all: $(BIN) -.PHONY: import install context .depdirs depend clean distclean +.PHONY: import install context context_serialize context_rest .depdirs depend clean distclean define SDIR_template $(1)_$(2): @@ -142,7 +142,13 @@ install: $(BIN_DIR) .install import: $(Q) $(MAKE) .import TOPDIR="$(APPDIR)$(DELIM)import" -context: $(foreach SDIR, $(INSTALLED_APPS), $(SDIR)_context) +context_rest: $(foreach SDIR, $(INSTALLED_APPS), $(SDIR)_context) + +context_serialize: + $(Q) $(MAKE) -C builtin context TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" + $(Q) $(MAKE) context_rest + +context: context_serialize .depdirs: $(foreach SDIR, $(INSTALLED_APPS), $(SDIR)_depend) diff --git a/builtin/Makefile b/builtin/Makefile index 57d7a432b..9fd170be5 100644 --- a/builtin/Makefile +++ b/builtin/Makefile @@ -74,35 +74,39 @@ $(COBJS): %$(OBJEXT): %.c registry$(DELIM).updated: $(Q) $(MAKE) -C registry .updated TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" +builtin_list$(OBJEXT): builtin_list.h builtin_proto.h + builtin_list.h: registry$(DELIM).updated - $(call DELFILE, builtin_list.h) - $(Q) touch builtin_list.h + $(call DELFILE, .xx_builtin_list.h) + $(Q) touch .xx_builtin_list.h ifeq ($(CONFIG_WINDOWS_NATIVE),y) - $(Q) (for /f %%G in ('dir /b registry\*.bdat') do ( type registry\%%G >> builtin_list.h )) || echo "" + $(Q) (for /f %%G in ('dir /b registry\*.bdat') do ( type registry\%%G >> .xx_builtin_list.h )) || echo "" else $(Q) ( \ filelist=`ls registry/*.bdat 2>/dev/null || echo ""`; \ for file in $$filelist; \ - do cat $$file >> builtin_list.h; \ + do cat $$file >> .xx_builtin_list.h; \ done; \ ) endif + $(Q) mv .xx_builtin_list.h builtin_list.h builtin_proto.h: registry$(DELIM).updated - $(call DELFILE, builtin_proto.h) - $(Q) touch builtin_proto.h + $(call DELFILE, .xx_builtin_proto.h) + $(Q) touch .xx_builtin_proto.h ifeq ($(CONFIG_WINDOWS_NATIVE),y) - $(Q) (for /f %%G in ('dir /b registry\*.pdat') do ( type registry\%%G >> builtin_proto.h )) || echo "" + $(Q) (for /f %%G in ('dir /b registry\*.pdat') do ( type registry\%%G >> .xx_builtin_proto.h )) || echo "" else $(Q) ( \ filelist=`ls registry/*.pdat 2>/dev/null || echo ""`; \ for file in $$filelist; \ - do cat $$file >> builtin_proto.h; \ + do cat $$file >> .xx_builtin_proto.h; \ done; \ ) endif + $(Q) mv .xx_builtin_proto.h builtin_proto.h -.built: builtin_list.h builtin_proto.h $(OBJS) +.built: $(OBJS) $(call ARCHIVE, $(BIN), $(OBJS)) $(Q) touch .built @@ -120,6 +124,8 @@ depend: .depend clean: $(Q) $(MAKE) -C registry clean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" $(call DELFILE, .built) + $(call DELFILE, .xx_builtin_list.h) + $(call DELFILE, .xx_builtin_proto.h) $(call CLEAN) distclean: clean