Skip to content

Commit

Permalink
Xcode: fix race condition when invoking ninja
Browse files Browse the repository at this point in the history
Don't create temp ninja files for invocation from Xcode in deps/
Instead create then in build directory and in a way that prevents race
conditions when multiple targets are launched in parallel.
  • Loading branch information
vslavik committed Mar 25, 2024
1 parent 89375d6 commit 2ba1a57
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ macosx/dsa_priv.pem
/x64/

/deps/tarballs
/deps/build.vars.local.ninja
/deps/.ninja_deps
/deps/.ninja_log
/deps/gettext/build-aux/test-driver
Expand Down
2 changes: 0 additions & 2 deletions deps/build.arm64.ninja

This file was deleted.

3 changes: 0 additions & 3 deletions deps/build.vars.ninja
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Local settings (regenerated by Xcode):
include build.vars.local.ninja

# Compiler etc. variables:
ncpu = `sysctl -n hw.ncpu`
Expand All @@ -12,4 +10,3 @@ cflags = $cflags_sdk $cflags_config -w
cxxflags = $cflags_sdk $cflags_config -stdlib=libc++ -w
ldflags = $ldflags_sdk $ldflags_config


2 changes: 0 additions & 2 deletions deps/build.x86_64.ninja

This file was deleted.

26 changes: 19 additions & 7 deletions deps/build_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

set -e

mkdir -p "$DEPS_BUILD_DIR"
if [ ! -d "$DEPS_BUILD_DIR" ] ; then
echo "build directory '$DEPS_BUILD_DIR' doesn't exist"
exit 1
fi

if [ "$2" = clean ] ; then
if [ ! -z "$DEPS_BUILD_DIR" ] ; then
rm -rf "$DEPS_BUILD_DIR"/*
Expand Down Expand Up @@ -57,8 +63,16 @@ else
ldflags_config=""
fi

cat <<EOT >build.vars.local.ninja
# don't produce error if the build is stopped for other reasons
trap "exit 0" INT

xcode_ninja_file="$DEPS_BUILD_DIR/xcode-$$.ninja"
trap "rm -f $xcode_ninja_file" EXIT

for ARCH in $ARCHS; do
cat <<EOT >$xcode_ninja_file
# Generated by Xcode on `date`
SDKROOT = $SDKROOT
MACOSX_DEPLOYMENT_TARGET = $MACOSX_DEPLOYMENT_TARGET
CONFIGURATION = $CONFIGURATION
Expand All @@ -67,6 +81,7 @@ sed = $GSED
yacc = $YACC
curl = $CURL
arch = $ARCH
top_srcdir = `pwd`
builddir = $DEPS_BUILD_DIR
Expand All @@ -75,13 +90,10 @@ cxx = $CXX
cflags_config = $cflags_config
ldflags_config = $ldflags_config
EOT

# don't produce error if the build is stopped for other reasons
trap 'exit 0' INT
for ARCH in $ARCHS; do
ninja -f build.$ARCH.ninja $1
include build.ninja
EOT
ninja -f $xcode_ninja_file $1
done

../macos/merge-archs.sh "$DEPS_BUILD_DIR/$1"

0 comments on commit 2ba1a57

Please sign in to comment.