build: Use flock to serialize ar steps as workaround

Use flock to serialize ar steps to avoid parallel build break
sometimes.
This commit is contained in:
Xiang Xiao 2020-02-19 17:08:28 +08:00 committed by Gregory Nutt
parent 119f81f30a
commit f774e8ee72
4 changed files with 11 additions and 6 deletions

2
.gitignore vendored
View File

@ -15,8 +15,8 @@ cscope.out
/external
/.context
/.config
/.depend
/*.lib
/*.lock
/romfs.img
/boot_romfsimg.h
/symtab_apps.c

View File

@ -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 $@

View File

@ -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),)

View File

@ -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))