diff --git a/.gitignore b/.gitignore index 668630512c9..7ff6bb2f442 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -.arlock .depend Make.dep *.o @@ -14,6 +13,7 @@ cscope.out /Kconfig /bin /external +/.arlock /.context /.config /.depend diff --git a/Application.mk b/Application.mk index 641e89b85e2..25af1926e42 100644 --- a/Application.mk +++ b/Application.mk @@ -130,9 +130,9 @@ $(CXXOBJS): %$(SUFFIX)$(OBJEXT): %$(CXXEXT) .built: $(OBJS) ifeq ($(WINTOOL),y) - $(call ARLOCK, "${shell cygpath -w $(BIN)}", $(OBJS)) + $(call ARCHIVE, "${shell cygpath -w $(BIN)}", $(OBJS)) else - $(call ARLOCK, $(BIN), $(OBJS)) + $(call ARCHIVE, $(BIN), $(OBJS)) endif $(Q) touch $@ diff --git a/Make.defs b/Make.defs index 89a649b39c0..3d58155d4be 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,9 +99,13 @@ define REGISTER endef endif -define ARLOCK - $(Q) flock .arlock $(call ARCHIVE, $1, $(2)) -endef +# Workaround for concurrent execution to the same library (libapps) +ifeq ($(CONFIG_HOST_MACOS),y) +# macOS doesn't have flock. Use shlock instead. +AR := $(APPDIR)/tools/flock.sh $(APPDIR)/.arlock $(AR) +else +AR := flock $(APPDIR)/.arlock $(AR) +endif # Tools diff --git a/Makefile b/Makefile index dfb9da882df..e0ad31f1cfb 100644 --- a/Makefile +++ b/Makefile @@ -117,9 +117,9 @@ $(SYMTABOBJ): %$(OBJEXT): %.c $(BIN): $(SYMTABOBJ) ifeq ($(WINTOOL),y) - $(call ARLOCK, "${shell cygpath -w $(BIN)}", $^) + $(call ARCHIVE, "${shell cygpath -w $(BIN)}", $^) else - $(call ARLOCK, $(BIN), $^) + $(call ARCHIVE, $(BIN), $^) endif endif # !CONFIG_BUILD_LOADABLE @@ -198,7 +198,6 @@ else fi; \ ) endif - $(call DELFILE, .arlock) $(call DELFILE, .depend) $(call DELFILE, $(SYMTABSRC)) $(call DELFILE, $(SYMTABOBJ)) diff --git a/tools/flock.sh b/tools/flock.sh new file mode 100755 index 00000000000..e20c1050cfd --- /dev/null +++ b/tools/flock.sh @@ -0,0 +1,36 @@ +#! /bin/sh + +# apps/tools/flock.sh +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +# This script tries to mimic flock using shlock +# +# NOTE: It just aims to be enough for our usage in libapps build. +# Not intended to be a full replacement of flock. + +LOCKFILE=$1 +shift + +while ! shlock -f ${LOCKFILE} -p $$; do + sleep 1 +done + +set -e +$@ +STATUS=$? +rm -f ${LOCKFILE} || : +exit ${STATUS}