Minor fixes to build script, including:
- Get # of cpus for darwin.
- When cross-building, require a sysroot.
Change-Id: Ice3ed3b7b2e646ccc58e67dbbb8b16b58407c52e
diff --git a/do-build b/do-build
index 63c66d9..3ddc23f 100755
--- a/do-build
+++ b/do-build
@@ -42,7 +42,7 @@
CONFIG_BINUTILS_x86_64_fuchsia="--enable-gold=default"
CONFIG_BINUTILS_aarch64_fuchsia="--enable-gold"
CONFIG_BINUTILS_fuchsia="--enable-plugins: \
- --enable-relro:"
+ --enable-relro"
CONFIG_BINUTILS_x86_64_none="--enable-targets=x86_64-pep"
# GDB
@@ -104,11 +104,15 @@
BUILD_OS="$(uname | tr '[:upper:]' '[:lower:]')"
BUILD="$BUILD_ARCH-$BUILD_OS"
- if [ "$BUILD_OS" == "linux" ]
- then
- local num_cpus=$(grep processor /proc/cpuinfo | wc -l)
- PARALLEL_BUILDS="$num_cpus"
- fi
+ case "$BUILD_OS" in
+ linux)
+ PARALLEL_BUILDS="$(grep processor /proc/cpuinfo | wc -l)"
+ ;;
+ darwin)
+ PARALLEL_BUILDS="$(sysctl -n hw.ncpu)"
+ ;;
+ # No fallback case needed - we'll just build with "-j".
+ esac
if cc --version | grep -q "LLVM"
then
@@ -201,7 +205,7 @@
{
if echo "$1" | grep -q "="
then
- RESULT=$(echo "$1" | sed -E -e 's/^[^=]+*=//')
+ RESULT=$(echo "$1" | sed -E -e 's/^[^=]+.*=//')
else
if [ -z "$2" ]
then
@@ -284,6 +288,11 @@
die "Configuration not supported. Use --force to try anyway."
fi
+ if [ "$BUILD" != "$HOST" ] && [ -z "$SYSROOT" ] && [ -z "$force" ]
+ then
+ die "Sysroot expected when host differs from build system. Use --force to try anyway."
+ fi
+
ARCHIVE_DIR="$OUT_DIR/archives"
}
@@ -658,4 +667,5 @@
TARGET="$ORIG_TARGET"
fi
build_components
+exit 0