This is an automated email from the ASF dual-hosted git repository.

gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new f774e8e  build: Use flock to serialize ar steps as workaround
f774e8e is described below

commit f774e8ee7202a61bcf64a93b2f3ddfd240288cf1
Author: Xiang Xiao <[email protected]>
AuthorDate: Wed Feb 19 17:08:28 2020 +0800

    build: Use flock to serialize ar steps as workaround
    
    Use flock to serialize ar steps to avoid parallel build break
    sometimes.
---
 .gitignore     | 2 +-
 Application.mk | 4 ++--
 Make.defs      | 6 +++++-
 Makefile       | 5 +++--
 4 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/.gitignore b/.gitignore
index 722303b..59148ed 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,8 +15,8 @@ cscope.out
 /external
 /.context
 /.config
-/.depend
 /*.lib
+/*.lock
 /romfs.img
 /boot_romfsimg.h
 /symtab_apps.c
diff --git a/Application.mk b/Application.mk
index 25af192..641e89b 100644
--- a/Application.mk
+++ b/Application.mk
@@ -130,9 +130,9 @@ $(CXXOBJS): %$(SUFFIX)$(OBJEXT): %$(CXXEXT)
 
 .built: $(OBJS)
 ifeq ($(WINTOOL),y)
-       $(call ARCHIVE, "${shell cygpath -w $(BIN)}", $(OBJS))
+       $(call ARLOCK, "${shell cygpath -w $(BIN)}", $(OBJS))
 else
-       $(call ARCHIVE, $(BIN), $(OBJS))
+       $(call ARLOCK, $(BIN), $(OBJS))
 endif
        $(Q) touch $@
 
diff --git a/Make.defs b/Make.defs
index d48fa38..dcc6402 100644
--- a/Make.defs
+++ b/Make.defs
@@ -52,7 +52,7 @@ CLEANDIRS := $(dir $(wildcard 
$(APPDIR)$(DELIM)*$(DELIM)Makefile))
 CONFIGURED_APPS :=
 
 define Add_Application
-  include $(1)Make.defs
+       include $(1)Make.defs
 endef
 
 $(foreach BDIR, $(BUILDIRS), $(eval $(call Add_Application,$(BDIR))))
@@ -99,6 +99,10 @@ define REGISTER
 endef
 endif
 
+define ARLOCK
+       $(Q) flock $1.lock $(call ARCHIVE, $1, $(2))
+endef
+
 # Tools
 
 ifeq ($(DIRLINK),)
diff --git a/Makefile b/Makefile
index e0ad31f..6744ef7 100644
--- a/Makefile
+++ b/Makefile
@@ -117,9 +117,9 @@ $(SYMTABOBJ): %$(OBJEXT): %.c
 
 $(BIN): $(SYMTABOBJ)
 ifeq ($(WINTOOL),y)
-       $(call ARCHIVE, "${shell cygpath -w $(BIN)}", $^)
+       $(call ARLOCK, "${shell cygpath -w $(BIN)}", $^)
 else
-       $(call ARCHIVE, $(BIN), $^)
+       $(call ARLOCK, $(BIN), $^)
 endif
 
 endif # !CONFIG_BUILD_LOADABLE
@@ -198,6 +198,7 @@ else
                fi; \
        )
 endif
+       $(call DELFILE, *.lock)
        $(call DELFILE, .depend)
        $(call DELFILE, $(SYMTABSRC))
        $(call DELFILE, $(SYMTABOBJ))

Reply via email to