2016-12-14 01:07:13 +00:00
|
|
|
#!/bin/bash
|
2018-09-11 22:27:47 +00:00
|
|
|
# Copyright (c) Facebook, Inc. and its affiliates.
|
2018-09-07 20:08:05 +00:00
|
|
|
#
|
|
|
|
# This source code is licensed under the MIT license found in the
|
|
|
|
# LICENSE file in the root directory of this source tree.
|
|
|
|
#
|
2016-12-14 01:07:13 +00:00
|
|
|
# This script validates that Android is set up correctly for the
|
|
|
|
# testing environment.
|
|
|
|
#
|
|
|
|
# In particular, the config in ReactAndroid/build.gradle must match
|
|
|
|
# the android sdk that is actually installed. Also, we must have the
|
|
|
|
# right version of Java.
|
|
|
|
|
|
|
|
# Check that Buck is working.
|
|
|
|
if [ -z "$(which buck)" ]; then
|
|
|
|
echo "You need to install Buck."
|
2018-06-27 18:55:26 +00:00
|
|
|
echo "See https://buckbuild.com/setup/getting_started.html for instructions."
|
2016-12-14 01:07:13 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-03-11 00:03:27 +00:00
|
|
|
if [ -z "$(buck --version)" ]; then
|
2016-12-14 01:07:13 +00:00
|
|
|
echo "Your Buck install is broken."
|
|
|
|
|
|
|
|
if [ -d "/opt/facebook" ]; then
|
2018-03-10 01:06:51 +00:00
|
|
|
BUCK_SUGGESTED_COMMIT_FB="b9b76a3a5a086eb440a26d1db9b0731875975099"
|
2016-12-14 01:07:13 +00:00
|
|
|
echo "FB laptops ship with a Buck config that is not compatible with open "
|
|
|
|
echo "source. FB Buck requires the environment to set a buck version, but "
|
|
|
|
echo "the open source version of Buck forbids that."
|
|
|
|
echo
|
|
|
|
echo "You can try setting:"
|
|
|
|
echo
|
2018-03-10 01:06:51 +00:00
|
|
|
echo "export BUCKVERSION=${BUCK_SUGGESTED_COMMIT_FB}"
|
2016-12-14 01:07:13 +00:00
|
|
|
echo
|
|
|
|
echo "in your .bashrc or .bash_profile to fix this."
|
|
|
|
echo
|
|
|
|
echo "If you don't want to alter BUCKVERSION for other things running on"
|
|
|
|
echo "your machine, you can just scope it to a single script, for example"
|
|
|
|
echo "by running something like:"
|
|
|
|
echo
|
2018-03-10 01:06:51 +00:00
|
|
|
echo "BUCKVERSION=${BUCK_SUGGESTED_COMMIT_FB} $0"
|
2016-12-14 01:07:13 +00:00
|
|
|
echo
|
|
|
|
else
|
|
|
|
echo "I don't know what's wrong, but calling 'buck --version' should work."
|
|
|
|
fi
|
|
|
|
exit 1
|
2018-03-10 01:06:51 +00:00
|
|
|
else
|
2018-03-11 00:03:27 +00:00
|
|
|
BUCK_EXPECTED_VERSION="buck version d743d2d0229852ce7c029ec257532d8916f6b2b7"
|
|
|
|
if [ "$(buck --version)" != "$BUCK_EXPECTED_VERSION" ]; then
|
|
|
|
if [ ! -d "/opt/facebook" ]; then
|
|
|
|
echo "Warning: The test suite expects ${BUCK_EXPECTED_VERSION} to be installed"
|
|
|
|
fi
|
2018-03-10 01:06:51 +00:00
|
|
|
fi
|
2016-12-14 01:07:13 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# BUILD_TOOLS_VERSION is in a format like "23.0.1"
|
|
|
|
BUILD_TOOLS_VERSION=`grep buildToolsVersion $(dirname $0)/../ReactAndroid/build.gradle | sed 's/^[^"]*\"//' | sed 's/"//'`
|
|
|
|
|
|
|
|
# MAJOR is something like "23"
|
|
|
|
MAJOR=`echo $BUILD_TOOLS_VERSION | sed 's/\..*//'`
|
|
|
|
|
|
|
|
# Check that we have the right major version of the Android SDK.
|
|
|
|
PLATFORM_DIR="$ANDROID_HOME/platforms/android-$MAJOR"
|
|
|
|
if [ ! -e "$PLATFORM_DIR" ]; then
|
|
|
|
echo "Error: could not find version $ANDROID_VERSION of the Android SDK."
|
|
|
|
echo "Specifically, the directory $PLATFORM_DIR does not exist."
|
|
|
|
echo "You probably need to specify the right version using the SDK Manager from within Android Studio."
|
|
|
|
echo "See https://facebook.github.io/react-native/docs/getting-started.html for details."
|
2017-10-12 22:28:25 +00:00
|
|
|
echo "If you are using Android SDK Tools from the command line, you may need to run:"
|
|
|
|
echo
|
|
|
|
echo " sdkmanager \"platform-tools\" \"platform-tools;android-$MAJOR\""
|
|
|
|
echo
|
|
|
|
echo "Check out https://developer.android.com/studio/command-line/sdkmanager.html for details."
|
2016-12-14 01:07:13 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check that we have the right version of the build tools.
|
|
|
|
BT_DIR="$ANDROID_HOME/build-tools/$BUILD_TOOLS_VERSION"
|
|
|
|
if [ ! -e "$BT_DIR" ]; then
|
|
|
|
echo "Error: could not find version $BUILD_TOOLS_VERSION of the Android build tools."
|
|
|
|
echo "Specifically, the directory $BT_DIR does not exist."
|
|
|
|
echo "You probably need to explicitly install the correct version of the Android SDK Build Tools from within Android Studio."
|
|
|
|
echo "See https://facebook.github.io/react-native/docs/getting-started.html for details."
|
2017-10-12 22:28:25 +00:00
|
|
|
echo "If you are using Android SDK Tools from the command line, you may need to run:"
|
|
|
|
echo
|
|
|
|
echo " sdkmanager \"platform-tools\" \"build-tools;android-$BUILD_TOOLS_VERSION\""
|
|
|
|
echo
|
|
|
|
echo "Check out https://developer.android.com/studio/command-line/sdkmanager.html for details."
|
2016-12-14 01:07:13 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$(which csrutil)" ]; then
|
|
|
|
# This is a SIP-protected machine (recent OSX).
|
|
|
|
# Check that we are not using SIP-protected Java.
|
|
|
|
JAVA=`which java`
|
|
|
|
if [ "$JAVA" = "/usr/bin/java" ]; then
|
|
|
|
echo "Error: we can't use this Java version."
|
|
|
|
echo "Currently, Java runs from $JAVA."
|
|
|
|
echo "The operating-system-provided Java doesn't work with React Native because of SIP protection."
|
|
|
|
echo "Please install the Oracle Java Development Kit 8."
|
|
|
|
if [ -d "/opt/facebook" ]; then
|
|
|
|
echo "See https://our.intern.facebook.com/intern/dex/installing-java-8/ for instructions on installing Java 8 on FB laptops."
|
|
|
|
else
|
|
|
|
echo "Check out http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html ."
|
2017-10-12 22:28:25 +00:00
|
|
|
echo "Be sure that you set JAVA_HOME and PATH correctly in your .bashrc or equivalent. Example:"
|
|
|
|
echo
|
|
|
|
echo " export JAVA_HOME=path/to/java"
|
|
|
|
echo " export PATH=\$PATH:\$JAVA_HOME/bin"
|
|
|
|
echo
|
2016-12-14 01:07:13 +00:00
|
|
|
fi
|
|
|
|
echo "After installing Java, run 'buck kill' and 'buck clean'."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
2018-09-07 20:08:05 +00:00
|
|
|
|
2016-12-14 01:07:13 +00:00
|
|
|
if [ -z "$JAVA_HOME" ]; then
|
|
|
|
echo "Error: \$JAVA_HOME is not configured."
|
|
|
|
echo "Try adding export JAVA_HOME=\$(/usr/libexec/java_home) to your .bashrc or equivalent."
|
|
|
|
echo "You will also want to add \$JAVA_HOME/bin to your path."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
|