Improve platform and CPU detection, use the correct protoc binary for the running system.
Tested on OS X 10.10, Debian 8.1 (x86_64) and Debian 8.1 (i686).
--
MOS_MIGRATED_REVID=95819163
diff --git a/scripts/bootstrap/buildenv.sh b/scripts/bootstrap/buildenv.sh
index 2a64d8c..d59370d 100755
--- a/scripts/bootstrap/buildenv.sh
+++ b/scripts/bootstrap/buildenv.sh
@@ -1,3 +1,5 @@
+#!/bin/bash
+
# Copyright 2015 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,6 +25,12 @@
BAZELRC=${BAZELRC:-"/dev/null"}
PLATFORM="$(uname -s | tr 'A-Z' 'a-z')"
+MACHINE_TYPE="$(uname -m)"
+MACHINE_IS_64BIT='no'
+if [ "${MACHINE_TYPE}" = 'amd64' -o "${MACHINE_TYPE}" = 'x86_64' ]; then
+ MACHINE_IS_64BIT='yes'
+fi
+
ATEXIT_=""
function atexit() {
ATEXIT_="$1; ${ATEXIT_}"
diff --git a/scripts/bootstrap/compile.sh b/scripts/bootstrap/compile.sh
index 1bb3a62..f377f4a 100755
--- a/scripts/bootstrap/compile.sh
+++ b/scripts/bootstrap/compile.sh
@@ -78,7 +78,11 @@
MD5SUM="md5sum"
# JAVA_HOME must point to a Java installation.
JAVA_HOME="${JAVA_HOME:-$(readlink -f $(which javac) | sed 's_/bin/javac__')}"
- PROTOC=${PROTOC:-third_party/protobuf/protoc-linux-x86_32.exe}
+ if [ "${MACHINE_IS_64BIT}" = 'yes' ]; then
+ PROTOC=${PROTOC:-third_party/protobuf/protoc-linux-x86_64.exe}
+ else
+ PROTOC=${PROTOC:-third_party/protobuf/protoc-linux-x86_32.exe}
+ fi
;;
darwin)
@@ -89,7 +93,11 @@
JAVA_HOME="$(/usr/libexec/java_home -v ${JAVA_VERSION}+ 2> /dev/null)" \
|| fail "Could not find JAVA_HOME, please ensure a JDK (version ${JAVA_VERSION}+) is installed."
fi
- PROTOC=${PROTOC:-third_party/protobuf/protoc-osx-x86_32.exe}
+ if [ "${MACHINE_IS_64BIT}" = 'yes' ]; then
+ PROTOC=${PROTOC:-third_party/protobuf/protoc-osx-x86_64.exe}
+ else
+ PROTOC=${PROTOC:-third_party/protobuf/protoc-osx-x86_32.exe}
+ fi
;;
msys*|mingw*)