diff options
Diffstat (limited to 'platform_tools/android/bin')
17 files changed, 87 insertions, 998 deletions
diff --git a/platform_tools/android/bin/adb_list_devices.py b/platform_tools/android/bin/adb_list_devices.py deleted file mode 100755 index f140484f4b..0000000000 --- a/platform_tools/android/bin/adb_list_devices.py +++ /dev/null @@ -1,153 +0,0 @@ -#!/usr/bin/python -# -# Copyright (c) 2012 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -""" adb_list_devices: list information about attached Android devices. """ - - -import os -import re -import shlex -import subprocess -import sys - -# This file, which resides on every Android device, contains a great deal of -# information about the device. -INFO_FILE = '/system/build.prop' - -# Default set of properties to query about a device. -DEFAULT_PROPS_TO_GET = ['ro.product.device', 'ro.build.version.release', - 'ro.build.type'] - - -def GetDeviceInfo(adb, serial, props_to_get): - """ Return a list of values (or "<Unknown>" if no value can be found) for the - given set of properties for the device with the given serial number. - - adb: path to the ADB program. - serial: serial number of the target device. - props_to_get: list of strings indicating which properties to determine. - """ - device_proc = subprocess.Popen([adb, '-s', serial, 'shell', 'cat', - INFO_FILE], stdout=subprocess.PIPE) - code = device_proc.wait() - if code != 0: - raise Exception('Could not query device with serial number %s.' % serial) - output = device_proc.stdout.read() - device_info = [] - for prop in props_to_get: - # Find the property in the outputs - search_str = r'%s=(\S+)' % prop - match = re.search(search_str, output) - if not match: - value = '<Unknown>' - else: - value = match.group(1) - device_info.append(value) - return device_info - - -def PrintPrettyTable(data, file=None): - """ Print out the given data in a nicely-spaced format. This function scans - the list multiple times and uses extra memory, so don't use it for big data - sets. - - data: list of lists of strings, where each list represents a row of data. - This table is assumed to be rectangular; if the length of any list differs - some of the output may not get printed. - file: file-like object into which the table should be written. If none is - provided, the table is written to stdout. - """ - if not file: - file = sys.stdout - column_widths = [0 for length in data[0]] - for line in data: - column_widths = [max(longest_len, len(prop)) for \ - longest_len, prop in zip(column_widths, line)] - for line in data: - for prop, width in zip(line, column_widths): - file.write(prop.ljust(width + 1)) - file.write('\n') - - -def FindADB(hint=None): - """ Attempt to find the ADB program using the following sequence of steps. - Returns the path to ADB if it can be found, or None otherwise. - 1. If a hint was provided, is it a valid path to ADB? - 2. Is ADB in PATH? - 3. Is there an environment variable for ADB? - 4. If the ANDROID_SDK_ROOT variable is set, try to find ADB in the SDK - directory. - - hint: string indicating a possible path to ADB. - """ - # 1. If a hint was provided, does it point to ADB? - if hint: - if os.path.basename(hint) == 'adb': - adb = hint - else: - adb = os.path.join(hint, 'adb') - if subprocess.Popen([adb, 'version'], stdout=subprocess.PIPE).wait() == 0: - return adb - - # 2. Is 'adb' in our PATH? - adb = 'adb' - if subprocess.Popen([adb, 'version'], stdout=subprocess.PIPE).wait() == 0: - return adb - - # 3. Is there an environment variable for ADB? - try: - adb = os.environ.get('ADB') - if subprocess.Popen([adb, 'version'], stdout=subprocess.PIPE).wait() == 0: - return adb - except: - pass - - # 4. If ANDROID_SDK_ROOT is set, try to find ADB in the SDK directory. - try: - sdk_dir = os.environ.get('ANDROID_SDK_ROOT') - adb = os.path.join(sdk_dir, 'platform-tools', 'adb') - if subprocess.Popen([adb, 'version'], stdout=subprocess.PIPE).wait() == 0: - return adb - except: - pass - return None - - -def main(argv): - """ Print out information about connected Android devices. By default, print - the serial number, status, device name, OS version, and build type of each - device. If any arguments are supplied on the command line, print the serial - number and status for each device along with values for those arguments - interpreted as properties. - """ - if len(argv) > 1: - props_to_get = argv[1:] - else: - props_to_get = DEFAULT_PROPS_TO_GET - adb = FindADB() - if not adb: - raise Exception('Could not find ADB!') - proc = subprocess.Popen([adb, 'devices'], stdout=subprocess.PIPE) - code = proc.wait() - if code != 0: - raise Exception('Failure in ADB: could not find attached devices.') - header = ['Serial', 'Status'] - header.extend(props_to_get) - output_lines = [header] - for line in proc.stdout: - line = line.rstrip() - if line != 'List of devices attached' and line != '': - line_list = shlex.split(line) - serial = line_list[0] - status = line_list[1] - device_info = [serial, status] - device_info.extend(GetDeviceInfo(adb, serial, props_to_get)) - output_lines.append(device_info) - PrintPrettyTable(output_lines) - - -if __name__ == '__main__': - sys.exit(main(sys.argv))
\ No newline at end of file diff --git a/platform_tools/android/bin/adb_print_path b/platform_tools/android/bin/adb_print_path deleted file mode 100755 index 4067f04c0e..0000000000 --- a/platform_tools/android/bin/adb_print_path +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -# -# adb_print_path: prints the path to the copy of adb that will be used by Skia's -# android scripts. This is used by Skia's build infrastructure to ensure that -# we use the same adb revision (and instance). - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source $SCRIPT_DIR/android_setup.sh -source $SCRIPT_DIR/utils/setup_adb.sh - -echo $ADB -exit 0 diff --git a/platform_tools/android/bin/adb_pull_if_needed b/platform_tools/android/bin/adb_pull_if_needed index 6a35902bdd..36a178bdc7 100755 --- a/platform_tools/android/bin/adb_pull_if_needed +++ b/platform_tools/android/bin/adb_pull_if_needed @@ -3,8 +3,7 @@ # Copy the contents of a directory from a device to the host. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -SKIP_TOOLCHAIN_SETUP="true" -source $SCRIPT_DIR/android_setup.sh +source $SCRIPT_DIR/utils/android_setup.sh source $SCRIPT_DIR/utils/setup_adb.sh adb_pull_if_needed ${APP_ARGS[@]} diff --git a/platform_tools/android/bin/adb_push_if_needed b/platform_tools/android/bin/adb_push_if_needed index efe6bb8a1f..2f8958e027 100755 --- a/platform_tools/android/bin/adb_push_if_needed +++ b/platform_tools/android/bin/adb_push_if_needed @@ -3,8 +3,7 @@ # Copy the contents of a directory from the host to a device. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -SKIP_TOOLCHAIN_SETUP="true" -source $SCRIPT_DIR/android_setup.sh +source $SCRIPT_DIR/utils/android_setup.sh source $SCRIPT_DIR/utils/setup_adb.sh adb_push_if_needed ${APP_ARGS[@]} diff --git a/platform_tools/android/bin/adb_wait_for_charge b/platform_tools/android/bin/adb_wait_for_charge deleted file mode 100755 index f05c44f455..0000000000 --- a/platform_tools/android/bin/adb_wait_for_charge +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/bash -# -# Wait for the device to be charged enough for testing. - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -SKIP_TOOLCHAIN_SETUP="true" -source $SCRIPT_DIR/android_setup.sh -source $SCRIPT_DIR/utils/setup_adb.sh - -# Helper function used by get_battery_level. Parses the battery level from -# dumpsys output. -function _parse_battery_level { - SPLIT=( $@ ) - - HAS_BATTERY=1 - LEVEL="" - - for i in "${!SPLIT[@]}"; do - if [ "${SPLIT[$i]}" = "level:" ]; then - LEVEL="${SPLIT[$i+1]}" - fi - if [ "${SPLIT[$i]}" = "present:" ]; then - PRESENT="$(echo "${SPLIT[$i+1]}" | tr -d '\r')" - if [ "$PRESENT" = "0" ]; then - HAS_BATTERY=0 - fi - if [ "$PRESENT" = "false" ]; then - HAS_BATTERY=0 - fi - fi - done - - if [ "$HAS_BATTERY" = "1" ]; then - echo "$LEVEL" | tr -d '\r' - return - fi - # If there's no battery, report a full battery. - echo "Device has no battery." 1>&2 - echo "100" -} - -# Echo the battery level percentage of the attached Android device. -function get_battery_level { - STATS="$($ADB $DEVICE_SERIAL shell dumpsys batteryproperties)" - SPLIT=( $STATS ) - RV="$(_parse_battery_level ${SPLIT[@]})" - if [ -n "$RV" ]; then - echo "$RV" - return - fi - - echo "Battery level fallback..." 1>&2 - - STATS="$($ADB $DEVICE_SERIAL shell dumpsys battery)" - SPLIT=( $STATS ) - RV="$(_parse_battery_level ${SPLIT[@]})" - if [ -n "$RV" ] && [ "$RV" != "-1" ]; then - echo "$RV" - return - fi - - echo "Could not determine battery level!" 1>&2 - # Just exit to prevent hanging forever or failing the build. - echo "0" -} - -# Wait for battery charge. -DESIRED_BATTERY_LEVEL=80 -CURRENT_BATTERY_LEVEL="$(get_battery_level)" -while [ "${CURRENT_BATTERY_LEVEL}" -lt "${DESIRED_BATTERY_LEVEL}" ]; do - echo "Battery level is ${CURRENT_BATTERY_LEVEL}; waiting to charge to ${DESIRED_BATTERY_LEVEL}" - sleep 5 - CURRENT_BATTERY_LEVEL="$(get_battery_level)" -done - -echo "Charged!" diff --git a/platform_tools/android/bin/adb_wait_for_device b/platform_tools/android/bin/adb_wait_for_device deleted file mode 100755 index 45ed4b2a78..0000000000 --- a/platform_tools/android/bin/adb_wait_for_device +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -# -# Wait for the device to be connected. - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -SKIP_TOOLCHAIN_SETUP="true" -source $SCRIPT_DIR/android_setup.sh -source $SCRIPT_DIR/utils/setup_adb.sh - -set -e - -# Wait for the device to be connected and fully booted. -while [ "$($ADB $DEVICE_SERIAL shell getprop sys.boot_completed | tr -d '\r')" != "1" ]; do - echo "Waiting for the device to be connected and ready." - sleep 5 -done - -echo "Connected!" diff --git a/platform_tools/android/bin/android_gdb_native b/platform_tools/android/bin/android_gdb_native index c114a3d309..da513cbf79 100755 --- a/platform_tools/android/bin/android_gdb_native +++ b/platform_tools/android/bin/android_gdb_native @@ -4,10 +4,9 @@ # and enters command line debugging environment. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source $SCRIPT_DIR/android_setup.sh +source $SCRIPT_DIR/utils/android_setup.sh # setup the gdbserver -export BUILDTYPE # from android_setup.sh $SCRIPT_DIR/android_gdbserver -d ${DEVICE_ID} ${APP_ARGS[@]} # quit if gdbserver setup failed @@ -27,25 +26,29 @@ PORT=5039 # Set up gdb commands GDBSETUP=$GDB_TMP_DIR/gdb.setup { - echo "file ${GDB_TMP_DIR}/skia_launcher" + echo "file ${GDB_TMP_DIR}/${APP_NAME}" echo "target remote :${PORT}" echo "set solib-absolute-prefix ${GDB_TMP_DIR}" echo "set solib-search-path ${GDB_TMP_DIR}" - # The apps shared library symbols are not loaded by default so we - # load them here. - echo "break launch_app" + echo "break main" echo "continue" - echo "sharedLibrary ${APP_NAME}" - - # Load libskia_android.so here. - echo "sharedLibrary skia_android" } > $GDBSETUP # Launch gdb client +HOST=`uname | tr '[A-Z]' '[a-z]'` +if [ $HOST == "darwin" ]; then + GDB_HOST=$ANDROID_NDK_ROOT/prebuilt/darwin-x86_64/bin/gdb +elif [ $HOST == "linux" ]; then + GDB_HOST=$ANDROID_NDK_ROOT/prebuilt/linux-x86_64/bin/gdb +else + echo "Could not automatically determine OS!" + exit 1; +fi + echo "Entering gdb client shell" -$ANDROID_TOOLCHAIN/host_prebuilt/bin/gdb -x $GDBSETUP +$GDB_HOST -x $GDBSETUP # Clean up: # We could 'rm -rf $GDB_TMP_DIR', but doing so would cause subsequent debugging diff --git a/platform_tools/android/bin/android_gdbserver b/platform_tools/android/bin/android_gdbserver index 8e4a6f00a9..432ab7c82b 100755 --- a/platform_tools/android/bin/android_gdbserver +++ b/platform_tools/android/bin/android_gdbserver @@ -3,17 +3,15 @@ # android_gdbserver: Pushes gdbserver. Starts debugging environment. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source $SCRIPT_DIR/android_setup.sh +source $SCRIPT_DIR/utils/android_setup.sh source $SCRIPT_DIR/utils/setup_adb.sh APP_NAME=${APP_ARGS[0]} -PORT=5039 -BUILD_DIR="${SKIA_OUT}/${BUILDTYPE}" -TARGET_LIBRARY="${BUILD_DIR}/lib/lib${APP_NAME}.so" -if [ ! -f "$TARGET_LIBRARY" ] +TARGET_EXE="${SKIA_OUT}/${APP_NAME}" +if [ ! -f "$TARGET_EXE" ] then - echo "Unable to find the ${APP_NAME} library at ${TARGET_LIBRARY}." + echo "Unable to find ${TARGET_EXE}." exit 1 fi @@ -22,8 +20,9 @@ GDB_TMP_DIR=$SKIA_OUT/android_gdb_tmp mkdir -p $GDB_TMP_DIR echo "Copying symbol files" -if [[ $ANDROID_ARCH == *64* ]]; then +if [[ $IS_64_BIT == "true" ]]; then SYSTEM_LIBRARY_PATH=/system/lib64 + echo "64 bit!" else SYSTEM_LIBRARY_PATH=/system/lib fi @@ -55,17 +54,11 @@ else fi echo "Pushing app..." -for file in \ - "${BUILD_DIR}/skia_launcher" \ - "${BUILD_DIR}/lib/libskia_android.so" \ - "${BUILD_DIR}/lib/lib${APP_NAME}.so" \ - ; do - cp "$file" $GDB_TMP_DIR - adb_push_if_needed "$file" /data/local/tmp -done +cp "$TARGET_EXE" $GDB_TMP_DIR +adb_push_if_needed "${TARGET_EXE}" /data/local/tmp echo "Pushing gdbserver..." -adb_push_if_needed $ANDROID_TOOLCHAIN/gdbserver /data/local/tmp +adb_push_if_needed $GDBSERVER_DIR/gdbserver/gdbserver /data/local/tmp echo "Setting up port forward" $ADB forward "tcp:5039" "tcp:5039" @@ -79,4 +72,4 @@ set -e # Starting up gdbserver in android shell echo "Starting gdbserver with command: ${APP_ARGS[@]}" -$ADB shell LD_LIBRARY_PATH=/data/local/tmp:\$LD_LIBRARY_PATH /data/local/tmp/gdbserver :5039 /data/local/tmp/skia_launcher ${APP_ARGS[@]} & +$ADB shell /data/local/tmp/gdbserver :5039 /data/local/tmp/${APP_ARGS[@]} & diff --git a/platform_tools/android/bin/android_kill_skia b/platform_tools/android/bin/android_kill_skia deleted file mode 100755 index 3c4a757349..0000000000 --- a/platform_tools/android/bin/android_kill_skia +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -# -# android_kill_skia: kills any skia processes on the device. - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -SKIP_TOOLCHAIN_SETUP="true" -source $SCRIPT_DIR/android_setup.sh -source $SCRIPT_DIR/utils/setup_adb.sh - -if [ $(uname) == "Linux" ]; then - $ADB $DEVICE_SERIAL shell ps | grep skia | awk '{print $2}' | xargs -r $ADB $DEVICE_SERIAL shell kill -elif [ $(uname) == "Darwin" ]; then - $ADB $DEVICE_SERIAL shell ps | grep skia | awk '{print $2}' | xargs $ADB $DEVICE_SERIAL shell kill -else - echo "Could not automatically determine OS!" - exit 1; -fi diff --git a/platform_tools/android/bin/android_make b/platform_tools/android/bin/android_make index 9601db9b17..cac0cc93c6 100755 --- a/platform_tools/android/bin/android_make +++ b/platform_tools/android/bin/android_make @@ -9,11 +9,12 @@ set -e rm -f .android_config SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}") -source $SCRIPT_DIR/android_setup.sh +source $SCRIPT_DIR/utils/android_setup.sh SKIA_SRC_DIR=$(cd "${SCRIPT_DIR}/../../.."; pwd) -GYP_GENERATORS=ninja-android "${SKIA_SRC_DIR}/gyp_skia" -ninja -C $SKIA_OUT/$BUILDTYPE ${APP_ARGS[@]} +echo $GN_ARGS +gn gen $SKIA_OUT --args="${GN_ARGS}" +ninja -C $SKIA_OUT ${APP_ARGS[@]} # Write the device id into the .android_config file. This tells # android_run_skia the last build we completed. diff --git a/platform_tools/android/bin/android_perf b/platform_tools/android/bin/android_perf index 3754013ef3..cf51074788 100755 --- a/platform_tools/android/bin/android_perf +++ b/platform_tools/android/bin/android_perf @@ -9,7 +9,7 @@ # SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source $SCRIPT_DIR/android_setup.sh +source $SCRIPT_DIR/utils/android_setup.sh source $SCRIPT_DIR/utils/setup_adb.sh if [ $(uname) == "Linux" ]; then @@ -49,37 +49,30 @@ perf_setup() { adb_pull_if_needed /system/lib/libz.so $TMP_SYS_LIB # BUILDTYPE variable is set by android_setup.sh - BUILDDIR="${SKIA_OUT}/${BUILDTYPE}" - if [ ! -f "${BUILDDIR}/lib/lib${runVars[0]}.so" ]; + if [ ! -f "${SKIA_OUT}/${runVars[0]}" ]; then - echo "Unable to find the ${runVars[0]} library in ${BUILDDIR}/lib." + echo "Unable to find the ${runVars[0]} executable" exit 1 fi echo "Pushing app..." - for lib_file in \ - "${BUILDDIR}/skia_launcher" \ - "${BUILDDIR}/lib/libskia_android.so" \ - "${BUILDDIR}/lib/lib${runVars[0]}.so" \ - ; do - adb_push_if_needed "$lib_file" /data/local/tmp - cp "$lib_file" $TMP_APP_LOC - done + adb_push_if_needed "${SKIA_OUT}/${runVars[0]}" /data/local/tmp + cp "${SKIA_OUT}/${runVars[0]}" $TMP_APP_LOC } perf_record() { echo "Killing any running Skia processes." - $ADB shell ps | grep skia_launcher | awk '{print $2}' | xargs $ADB shell kill + $ADB shell ps | grep ${runVars[0]} | awk '{print $2}' | xargs $ADB shell kill echo "Starting application" - $ADB shell /data/local/tmp/skia_launcher ${runVars[@]} & + $ADB shell /data/local/tmp/${runVars[@]} & # WE REALLY REALLY WANT TO BE ABLE TO PASS THE SKIA_LAUNCHER APP DIRECTLY TO # PERF, BUT AT THIS POINT THE DATA FILE WE GET WHEN GOING THAT ROUTE IS UNABLE # TO BE READ BY THE REPORTING TOOL echo "Starting profiler" - APP_PID=$($ADB shell ps | grep skia_launcher | awk '{print $2}') + APP_PID=$($ADB shell ps | grep ${runVars[0]} | awk '{print $2}') $ADB shell perf record -p ${APP_PID} sleep 70 $ADB pull /data/perf.data $PERF_TMP_DIR/perf.data diff --git a/platform_tools/android/bin/android_run_skia b/platform_tools/android/bin/android_run_skia index c4e9056d7e..659b690e2e 100755 --- a/platform_tools/android/bin/android_run_skia +++ b/platform_tools/android/bin/android_run_skia @@ -4,23 +4,17 @@ # output, and kills the app if interrupted. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -SKIP_TOOLCHAIN_SETUP="true" -source $SCRIPT_DIR/android_setup.sh +source $SCRIPT_DIR/utils/android_setup.sh source $SCRIPT_DIR/utils/setup_adb.sh -if [ ! -f "${SKIA_OUT}/$BUILDTYPE/lib/lib${APP_ARGS[0]}.so" ]; +if [ ! -f "${SKIA_OUT}/${APP_ARGS[0]}" ]; then - echo "Unable to find $BUILDTYPE ${APP_ARGS[0]} library" + echo "Unable to find ${APP_ARGS[0]} executable" exit 1 fi verbose "pushing binaries onto the device..." -adb_push_if_needed "${SKIA_OUT}/$BUILDTYPE/skia_launcher" /data/local/tmp -if [ -f "${SKIA_OUT}/$BUILDTYPE/lib/libskia_android.so" ]; then - # Does not exist for builds with static skia. - adb_push_if_needed "${SKIA_OUT}/$BUILDTYPE/lib/libskia_android.so" /data/local/tmp -fi -adb_push_if_needed "${SKIA_OUT}/$BUILDTYPE/lib/lib${APP_ARGS[0]}.so" /data/local/tmp +adb_push_if_needed "${SKIA_OUT}/${APP_ARGS[0]}" /data/local/tmp if [[ -n $RESOURCE_PATH ]]; then verbose "pushing resources onto the device..." adb_push_if_needed "${SKIA_SRC_DIR}/resources" $RESOURCE_PATH @@ -32,8 +26,7 @@ if [ $LOGCAT ]; then fi STATUS_FILENAME="/data/local/tmp/.skia_tmp_$(date +%s%N)" CMD_FILENAME=".skia_cmd_tmp_$(date +%s%N)" -echo "LD_LIBRARY_PATH=/data/local/tmp:$LD_LIBRARY_PATH \ - /data/local/tmp/skia_launcher ${APP_ARGS[*]}; \ +echo "/data/local/tmp/${APP_ARGS[*]}; \ echo \$? > ${STATUS_FILENAME}" > ${CMD_FILENAME} chmod +x ${CMD_FILENAME} verbose "======== To reproduce this run: ========" diff --git a/platform_tools/android/bin/download_utils.py b/platform_tools/android/bin/download_utils.py deleted file mode 100755 index 298ba9a863..0000000000 --- a/platform_tools/android/bin/download_utils.py +++ /dev/null @@ -1,323 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2012 The Native Client Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""A library to assist automatically downloading files. - -This library is used by scripts that download tarballs, zipfiles, etc. as part -of the build process. -""" - -import hashlib -import http_download -import os.path -import re -import shutil -import sys -import time -import urllib2 - -SOURCE_STAMP = 'SOURCE_URL' -HASH_STAMP = 'SOURCE_SHA1' - - -# Designed to handle more general inputs than sys.platform because the platform -# name may come from the command line. -PLATFORM_COLLAPSE = { - 'windows': 'windows', - 'win32': 'windows', - 'cygwin': 'windows', - 'linux': 'linux', - 'linux2': 'linux', - 'linux3': 'linux', - 'darwin': 'mac', - 'mac': 'mac', -} - -ARCH_COLLAPSE = { - 'i386' : 'x86', - 'i686' : 'x86', - 'x86_64': 'x86', - 'armv7l': 'arm', -} - - -class HashError(Exception): - def __init__(self, download_url, expected_hash, actual_hash): - self.download_url = download_url - self.expected_hash = expected_hash - self.actual_hash = actual_hash - - def __str__(self): - return 'Got hash "%s" but expected hash "%s" for "%s"' % ( - self.actual_hash, self.expected_hash, self.download_url) - - -def PlatformName(name=None): - if name is None: - name = sys.platform - return PLATFORM_COLLAPSE[name] - -def ArchName(name=None): - if name is None: - if PlatformName() == 'windows': - # TODO(pdox): Figure out how to auto-detect 32-bit vs 64-bit Windows. - name = 'i386' - else: - import platform - name = platform.machine() - return ARCH_COLLAPSE[name] - -def EnsureFileCanBeWritten(filename): - directory = os.path.dirname(filename) - if not os.path.exists(directory): - os.makedirs(directory) - - -def WriteData(filename, data): - EnsureFileCanBeWritten(filename) - f = open(filename, 'wb') - f.write(data) - f.close() - - -def WriteDataFromStream(filename, stream, chunk_size, verbose=True): - EnsureFileCanBeWritten(filename) - dst = open(filename, 'wb') - try: - while True: - data = stream.read(chunk_size) - if len(data) == 0: - break - dst.write(data) - if verbose: - # Indicate that we're still writing. - sys.stdout.write('.') - sys.stdout.flush() - finally: - if verbose: - sys.stdout.write('\n') - dst.close() - - -def DoesStampMatch(stampfile, expected, index): - try: - f = open(stampfile, 'r') - stamp = f.read() - f.close() - if stamp.split('\n')[index] == expected: - return "already up-to-date." - elif stamp.startswith('manual'): - return "manual override." - return False - except IOError: - return False - - -def WriteStamp(stampfile, data): - EnsureFileCanBeWritten(stampfile) - f = open(stampfile, 'w') - f.write(data) - f.close() - - -def StampIsCurrent(path, stamp_name, stamp_contents, min_time=None, index=0): - stampfile = os.path.join(path, stamp_name) - - # Check if the stampfile is older than the minimum last mod time - if min_time: - try: - stamp_time = os.stat(stampfile).st_mtime - if stamp_time <= min_time: - return False - except OSError: - return False - - return DoesStampMatch(stampfile, stamp_contents, index) - - -def WriteSourceStamp(path, url): - stampfile = os.path.join(path, SOURCE_STAMP) - WriteStamp(stampfile, url) - -def WriteHashStamp(path, hash_val): - hash_stampfile = os.path.join(path, HASH_STAMP) - WriteStamp(hash_stampfile, hash_val) - - -def Retry(op, *args): - # Windows seems to be prone to having commands that delete files or - # directories fail. We currently do not have a complete understanding why, - # and as a workaround we simply retry the command a few times. - # It appears that file locks are hanging around longer than they should. This - # may be a secondary effect of processes hanging around longer than they - # should. This may be because when we kill a browser sel_ldr does not exit - # immediately, etc. - # Virus checkers can also accidently prevent files from being deleted, but - # that shouldn't be a problem on the bots. - if sys.platform in ('win32', 'cygwin'): - count = 0 - while True: - try: - op(*args) - break - except Exception: - sys.stdout.write("FAILED: %s %s\n" % (op.__name__, repr(args))) - count += 1 - if count < 5: - sys.stdout.write("RETRY: %s %s\n" % (op.__name__, repr(args))) - time.sleep(pow(2, count)) - else: - # Don't mask the exception. - raise - else: - op(*args) - - -def MoveDirCleanly(src, dst): - RemoveDir(dst) - MoveDir(src, dst) - - -def MoveDir(src, dst): - Retry(shutil.move, src, dst) - - -def RemoveDir(path): - if os.path.exists(path): - Retry(shutil.rmtree, path) - - -def RemoveFile(path): - if os.path.exists(path): - Retry(os.unlink, path) - - -def _HashFileHandle(fh): - """sha1 of a file like object. - - Arguments: - fh: file handle like object to hash. - Returns: - sha1 as a string. - """ - hasher = hashlib.sha1() - try: - while True: - data = fh.read(4096) - if not data: - break - hasher.update(data) - finally: - fh.close() - return hasher.hexdigest() - - -def HashFile(filename): - """sha1 a file on disk. - - Arguments: - filename: filename to hash. - Returns: - sha1 as a string. - """ - fh = open(filename, 'rb') - return _HashFileHandle(fh) - - -def HashUrlByDownloading(url): - """sha1 the data at an url. - - Arguments: - url: url to download from. - Returns: - sha1 of the data at the url. - """ - try: - fh = urllib2.urlopen(url) - except: - sys.stderr.write("Failed fetching URL: %s\n" % url) - raise - return _HashFileHandle(fh) - - -# Attempts to get the SHA1 hash of a file given a URL by looking for -# an adjacent file with a ".sha1hash" suffix. This saves having to -# download a large tarball just to get its hash. Otherwise, we fall -# back to downloading the main file. -def HashUrl(url): - hash_url = '%s.sha1hash' % url - try: - fh = urllib2.urlopen(hash_url) - data = fh.read(100) - fh.close() - except urllib2.HTTPError, exn: - if exn.code == 404: - return HashUrlByDownloading(url) - raise - else: - if not re.match('[0-9a-f]{40}\n?$', data): - raise AssertionError('Bad SHA1 hash file: %r' % data) - return data.strip() - - -def SyncURL(url, filename=None, stamp_dir=None, min_time=None, - hash_val=None, keep=False, verbose=False, stamp_index=0): - """Synchronize a destination file with a URL - - if the URL does not match the URL stamp, then we must re-download it. - - Arugments: - url: the url which will to compare against and download - filename: the file to create on download - path: the download path - stamp_dir: the filename containing the URL stamp to check against - hash_val: if set, the expected hash which must be matched - verbose: prints out status as it runs - stamp_index: index within the stamp file to check. - Returns: - True if the file is replaced - False if the file is not replaced - Exception: - HashError: if the hash does not match - """ - - assert url and filename - - # If we are not keeping the tarball, or we already have it, we can - # skip downloading it for this reason. If we are keeping it, - # it must exist. - if keep: - tarball_ok = os.path.isfile(filename) - else: - tarball_ok = True - - # If we don't need the tarball and the stamp_file matches the url, then - # we must be up to date. If the URL differs but the recorded hash matches - # the one we'll insist the tarball has, then that's good enough too. - # TODO(mcgrathr): Download the .sha1sum file first to compare with - # the cached hash, in case --file-hash options weren't used. - if tarball_ok and stamp_dir is not None: - if StampIsCurrent(stamp_dir, SOURCE_STAMP, url, min_time): - if verbose: - print '%s is already up to date.' % filename - return False - if (hash_val is not None and - StampIsCurrent(stamp_dir, HASH_STAMP, hash_val, min_time, stamp_index)): - if verbose: - print '%s is identical to the up to date file.' % filename - return False - - if verbose: - print 'Updating %s\n\tfrom %s.' % (filename, url) - EnsureFileCanBeWritten(filename) - http_download.HttpDownload(url, filename) - - if hash_val: - tar_hash = HashFile(filename) - if hash_val != tar_hash: - raise HashError(actual_hash=tar_hash, expected_hash=hash_val, - download_url=url) - - return True diff --git a/platform_tools/android/bin/http_download.py b/platform_tools/android/bin/http_download.py deleted file mode 100755 index 15f7983b77..0000000000 --- a/platform_tools/android/bin/http_download.py +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2012 The Native Client Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Download a file from a URL to a file on disk. - -This module supports username and password with basic authentication. -""" - -import base64 -import os -import os.path -import sys -import urllib2 - -import download_utils - - -def _CreateDirectory(path): - """Create a directory tree, ignore if it's already there.""" - try: - os.makedirs(path) - return True - except os.error: - return False - - -def HttpDownload(url, target, username=None, password=None, verbose=True, - logger=None): - """Download a file from a remote server. - - Args: - url: A URL to download from. - target: Filename to write download to. - username: Optional username for download. - password: Optional password for download (ignored if no username). - logger: Function to log events to. - """ - - # Log to stdout by default. - if logger is None: - logger = sys.stdout.write - headers = [('Accept', '*/*')] - if username: - if password: - auth_code = base64.b64encode(username + ':' + password) - else: - auth_code = base64.b64encode(username) - headers.append(('Authorization', 'Basic ' + auth_code)) - if os.environ.get('http_proxy'): - proxy = os.environ.get('http_proxy') - proxy_handler = urllib2.ProxyHandler({ - 'http': proxy, - 'https': proxy}) - opener = urllib2.build_opener(proxy_handler) - else: - opener = urllib2.build_opener() - opener.addheaders = headers - urllib2.install_opener(opener) - _CreateDirectory(os.path.split(target)[0]) - # Retry up to 10 times (appengine logger is flaky). - for i in xrange(10): - if i: - logger('Download failed on %s, retrying... (%d)\n' % (url, i)) - try: - # 30 second timeout to ensure we fail and retry on stalled connections. - src = urllib2.urlopen(url, timeout=30) - try: - download_utils.WriteDataFromStream(target, src, chunk_size=2**20, - verbose=verbose) - content_len = src.headers.get('Content-Length') - if content_len: - content_len = int(content_len) - file_size = os.path.getsize(target) - if content_len != file_size: - logger('Filesize:%d does not match Content-Length:%d' % ( - file_size, content_len)) - continue - finally: - src.close() - break - except urllib2.HTTPError, e: - if e.code == 404: - logger('Resource does not exist.\n') - raise - logger('Failed to open.\n') - except urllib2.URLError: - logger('Failed mid stream.\n') - else: - logger('Download failed on %s, giving up.\n' % url) - raise diff --git a/platform_tools/android/bin/android_setup.sh b/platform_tools/android/bin/utils/android_setup.sh index d092922416..a50819efa7 100755 --- a/platform_tools/android/bin/android_setup.sh +++ b/platform_tools/android/bin/utils/android_setup.sh @@ -11,8 +11,7 @@ # Fail-fast if anything in the script fails. set -e -BUILDTYPE=${BUILDTYPE-Release_Developer} -USE_CLANG="true" +IS_DEBUG="false" while (( "$#" )); do if [[ "$1" == "-d" ]]; then @@ -25,17 +24,8 @@ while (( "$#" )); do elif [[ "$1" == "-s" ]]; then DEVICE_SERIAL="-s $2" shift - elif [[ "$1" == "-t" ]]; then - BUILDTYPE=$2 - shift elif [[ "$1" == "--debug" ]]; then - BUILDTYPE=Debug - elif [[ "$1" == "--release" ]]; then - BUILDTYPE=Release - elif [[ "$1" == "--gcc" ]]; then - USE_CLANG="false" - elif [[ "$1" == "--clang" ]]; then - USE_CLANG="true" + IS_DEBUG="true" elif [[ "$1" == "--logcat" ]]; then LOGCAT=1 elif [[ "$1" == "--verbose" ]]; then @@ -48,10 +38,6 @@ while (( "$#" )); do shift done -if [ "$USE_CLANG" == "true" ]; then - export GYP_DEFINES="skia_clang_build=1 $GYP_DEFINES" -fi - function verbose { if [[ -n $VERBOSE ]]; then echo $@ @@ -69,7 +55,7 @@ function absPath { (cd $1; pwd) } -SCRIPT_DIR=$(absPath "$(dirname "$BASH_SOURCE[0]}")") +UTIL_DIR=$(absPath "$(dirname "$BASH_SOURCE[0]}")") if [ -z "$ANDROID_SDK_ROOT" ]; then if ANDROID_SDK_ROOT="$(dirname $(which android))/.."; then @@ -85,19 +71,22 @@ if [ -z "$ANDROID_HOME" ]; then exportVar ANDROID_HOME $ANDROID_SDK_ROOT fi -if [ "$SKIA_VULKAN" == "true" ]; then - export GYP_DEFINES="skia_vulkan=1 $GYP_DEFINES" +if [ -z "$ANDROID_NDK_ROOT" ]; then + if [ -d "${ANDROID_SDK_ROOT}/ndk-bundle" ]; then + exportVar ANDROID_NDK_ROOT ${ANDROID_SDK_ROOT}/ndk-bundle + else + echo "No ANDROID_NDK_ROOT set and can't auto detect it from location of SDK." + exit 1 + fi fi -# Helper function to configure the GYP defines to the appropriate values +# Helper function to configure the GN defines to the appropriate values # based on the target device. setup_device() { - DEFINES="OS=android" - DEFINES="${DEFINES} host_os=$(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/')" - DEFINES="${DEFINES} skia_os=android" - DEFINES="${DEFINES} android_base=$(absPath ${SCRIPT_DIR}/..)" - if [[ "$GYP_DEFINES" != *skia_shared_lib=* ]]; then - DEFINES="${DEFINES} skia_shared_lib=1" + DEFINES="ndk=\"${ANDROID_NDK_ROOT}\" is_debug=${IS_DEBUG}" + + if [ $SKIA_VULKAN == "true" ]; then + DEFINES="${DEFINES} ndk_api=24" fi # Setup the build variation depending on the target device @@ -108,79 +97,57 @@ setup_device() { TARGET_DEVICE=$(cat .android_config) verbose "no target device (-d), using ${TARGET_DEVICE} from most recent build" else - TARGET_DEVICE="arm_v7_neon" + TARGET_DEVICE="arm_v7" verbose "no target device (-d), using ${TARGET_DEVICE}" fi fi case $TARGET_DEVICE in - arm) - DEFINES="${DEFINES} skia_arch_type=arm arm_neon=0" - ANDROID_ARCH="arm" + arm_v7 | nexus_4 | nexus_5 | nexus_6 | nexus_7 | nexus_10) + DEFINES="${DEFINES} target_cpu=\"arm\"" + GDBSERVER_DIR="${ANDROID_NDK_ROOT}/prebuilt/android-arm" + IS_64_BIT=false ;; - arm_v7 | xoom) - DEFINES="${DEFINES} skia_arch_type=arm arm_neon=0 arm_version=7" - ANDROID_ARCH="arm" - ;; - arm_v7_neon | nexus_4 | nexus_5 | nexus_6 | nexus_7 | nexus_10) - DEFINES="${DEFINES} skia_arch_type=arm arm_neon=1 arm_version=7" - ANDROID_ARCH="arm" - ;; - arm64 | nexus_9) - DEFINES="${DEFINES} skia_arch_type=arm64 arm_version=8" - ANDROID_ARCH="arm64" + arm64 | nexus_9 | nexus_5x | nexus_6p | pixel) + DEFINES="${DEFINES} target_cpu=\"arm64\"" + GDBSERVER_DIR="${ANDROID_NDK_ROOT}/prebuilt/android-arm64" + IS_64_BIT=true ;; x86) - DEFINES="${DEFINES} skia_arch_type=x86" - ANDROID_ARCH="x86" + DEFINES="${DEFINES} target_cpu=\"x86\"" + GDBSERVER_DIR="${ANDROID_NDK_ROOT}/prebuilt/android-x86" + IS_64_BIT=false ;; x86_64 | x64) - DEFINES="${DEFINES} skia_arch_type=x86_64" - ANDROID_ARCH="x86_64" + DEFINES="${DEFINES} target_cpu=\"x64\"" + GDBSERVER_DIR="${ANDROID_NDK_ROOT}/prebuilt/android-x86_64" + IS_64_BIT=true ;; mips) - DEFINES="${DEFINES} skia_arch_type=mips32" - DEFINES="${DEFINES} skia_resource_cache_mb_limit=32" - ANDROID_ARCH="mips" - ;; - mips_dsp2) - DEFINES="${DEFINES} skia_arch_type=mips32" - DEFINES="${DEFINES} mips_arch_variant=mips32r2 mips_dsp=2" - ANDROID_ARCH="mips" + DEFINES="${DEFINES} target_cpu=\"mipsel\"" + GDBSERVER_DIR="${ANDROID_NDK_ROOT}/prebuilt/android-mips" + IS_64_BIT=false + #DEFINES="${DEFINES} skia_resource_cache_mb_limit=32" ;; mips64) - DEFINES="${DEFINES} skia_arch_type=mips64" - ANDROID_ARCH="mips64" + DEFINES="${DEFINES} target_cpu=\"mips64el\"" + GDBSERVER_DIR="${ANDROID_NDK_ROOT}/prebuilt/android-mips64" + IS_64_BIT=true ;; *) - if [ -z "$ANDROID_IGNORE_UNKNOWN_DEVICE" ]; then - echo "ERROR: unknown device $TARGET_DEVICE" - exit 1 - fi - # If ANDROID_IGNORE_UNKNOWN_DEVICE is set, then ANDROID_TOOLCHAIN - # or ANDROID_ARCH should be set; Otherwise, ANDROID_ARCH - # defaults to 'arm' and the default ARM toolchain is used. - DEFINES="${DEFINES} skia_arch_type=${ANDROID_ARCH-arm}" - # If ANDROID_IGNORE_UNKNOWN_DEVICE is set, extra gyp defines can be - # added via ANDROID_GYP_DEFINES - DEFINES="${DEFINES} ${ANDROID_GYP_DEFINES}" + echo "ERROR: unknown device $TARGET_DEVICE" + exit 1 ;; esac verbose "The build is targeting the device: $TARGET_DEVICE" exportVar DEVICE_ID $TARGET_DEVICE + exportVar GN_ARGS "$DEFINES" + exportVar GDBSERVER_DIR $GDBSERVER_DIR + exportVar IS_64_BIT $IS_64_BIT - if [ -z "$SKIP_TOOLCHAIN_SETUP" ]; then - # setup the appropriate cross compiling toolchains - source $SCRIPT_DIR/utils/setup_toolchain.sh - fi - - DEFINES="${DEFINES} android_toolchain=${ANDROID_TOOLCHAIN}" - DEFINES="${DEFINES} android_buildtype=${BUILDTYPE}" - exportVar GYP_DEFINES "$DEFINES $GYP_DEFINES" - - SKIA_SRC_DIR=$(cd "${SCRIPT_DIR}/../../.."; pwd) - DEFAULT_SKIA_OUT="${SKIA_SRC_DIR}/out/config/android-${TARGET_DEVICE}" + SKIA_SRC_DIR=$(cd "${UTIL_DIR}/../../../.."; pwd) + DEFAULT_SKIA_OUT="${SKIA_SRC_DIR}/out/android-${TARGET_DEVICE}" exportVar SKIA_OUT "${SKIA_OUT:-${DEFAULT_SKIA_OUT}}" } diff --git a/platform_tools/android/bin/utils/setup_adb.sh b/platform_tools/android/bin/utils/setup_adb.sh index 81e4851cef..94c4e8eb2a 100644 --- a/platform_tools/android/bin/utils/setup_adb.sh +++ b/platform_tools/android/bin/utils/setup_adb.sh @@ -3,8 +3,6 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -UTIL_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - if [ $PYADB ] && [ -a "$PYADB" ]; then echo "Python ADB detected, going to use that" ADB="python ${PYADB}" diff --git a/platform_tools/android/bin/utils/setup_toolchain.sh b/platform_tools/android/bin/utils/setup_toolchain.sh deleted file mode 100755 index c341c2e341..0000000000 --- a/platform_tools/android/bin/utils/setup_toolchain.sh +++ /dev/null @@ -1,165 +0,0 @@ -# Copyright 2015 Google Inc. -# -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -#!/bin/bash -# -# setup_toolchain.sh: Sets toolchain environment variables used by other scripts. - -# Fail-fast if anything in the script fails. -set -e - -# check that the preconditions for this script are met -if [ $(type -t verbose) != 'function' ]; then - echo "ERROR: The verbose function is expected to be defined" - return 1 -fi - -if [ $(type -t exportVar) != 'function' ]; then - echo "ERROR: The exportVar function is expected to be defined" - return 1 -fi - -if [ $(type -t absPath) != 'function' ]; then - echo "ERROR: The absPath function is expected to be defined" - return 1 -fi - -if [ -z "$SCRIPT_DIR" ]; then - echo "ERROR: The SCRIPT_DIR variable is expected to be defined" - return 1 -fi - -function default_toolchain() { - TOOLCHAINS=${SCRIPT_DIR}/../toolchains - - ANDROID_ARCH=${ANDROID_ARCH-arm} - NDK=r12b - - if [[ $ANDROID_ARCH == *64* ]]; then - API=21 # Android 5.0 - else - API=14 # Android 4.0 - fi - - if [ "$SKIA_VULKAN" == "true" ]; then - API=24 # Android N Preview - fi - - TOOLCHAIN=$ANDROID_ARCH-$NDK-$API - HOST=`uname | tr '[A-Z]' '[a-z]'` - - exportVar ANDROID_TOOLCHAIN "${TOOLCHAINS}/${TOOLCHAIN}" - - if [ ! -d "$ANDROID_TOOLCHAIN" ]; then - mkdir -p $TOOLCHAINS - pushd $TOOLCHAINS - curl -o $NDK.zip https://dl.google.com/android/repository/android-ndk-$NDK-$HOST-x86_64.zip - unzip $NDK.zip - UNZIPPED=android-ndk-$NDK - ./$UNZIPPED/build/tools/make-standalone-toolchain.sh \ - --use-llvm \ - --arch=$ANDROID_ARCH \ - --platform=android-$API \ - --install_dir=$TOOLCHAIN - cp $UNZIPPED/prebuilt/android-$ANDROID_ARCH/gdbserver/gdbserver $TOOLCHAIN - cp -r $UNZIPPED/prebuilt/${HOST}-x86_64 $TOOLCHAIN/host_prebuilt - rm $NDK.zip - rm -rf $UNZIPPED - popd - fi - - verbose "Targeting NDK API $API (NDK Revision $NDK)" -} - -#check to see if the toolchain has been defined and if not setup the default toolchain -if [ -z "$ANDROID_TOOLCHAIN" ]; then - default_toolchain - if [ ! -d "$ANDROID_TOOLCHAIN" ]; then - echo "ERROR: unable to download/setup the required toolchain (${ANDROID_TOOLCHAIN})" - return 1; - fi -fi - -GCC=$(command ls $ANDROID_TOOLCHAIN/bin/*-gcc | head -n1) -if [ -z "$GCC" ]; then - echo "ERROR: Could not find Android cross-compiler in: ${ANDROID_TOOLCHAIN}/bin" - return 1 -fi - -# Remove the '-gcc' at the end to get the full toolchain prefix -ANDROID_TOOLCHAIN_PREFIX=${GCC%%-gcc} - -CCACHE=${ANDROID_MAKE_CCACHE-$(which ccache || true)} - -# Cross compiling Android on Mac is not currently supported by gyp. -# It doesn't appear to be supported on Windows either. -# As of now, we will only support cross compiling on Linux. -# libjpeg-turbo assembly code for x86 and x86-64 Android devices -# must be disabled for Android on non-Linux platforms because -# of this issue. We still support compiling on Mac and other -# variants for local development, but shipping versions of Skia -# should be compiled on Linux for performance reasons. -# TODO (msarett): Collect more information about this. -if [ $HOST == "linux" ]; then - if [ "$USE_CLANG" != "true" ]; then - exportVar CC_target "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc" - exportVar CXX_target "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-g++" - exportVar LINK_target "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc" - exportVar CC_host "$CCACHE cc" - exportVar CXX_host "$CCACHE c++" - exportVar LINK_host "$CCACHE cc" - else - exportVar CC_target "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang" - exportVar CXX_target "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang++" - exportVar LINK_target "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang" - exportVar CC_host "$CCACHE clang" - exportVar CXX_host "$CCACHE clang++" - exportVar LINK_host "$CCACHE clang" - fi - - exportVar AR_target "$ANDROID_TOOLCHAIN_PREFIX-ar" - exportVar RANLIB_target "$ANDROID_TOOLCHAIN_PREFIX-ranlib" - exportVar OBJCOPY_target "$ANDROID_TOOLCHAIN_PREFIX-objcopy" - exportVar STRIP_target "$ANDROID_TOOLCHAIN_PREFIX-strip" - exportVar AR_host "ar" - exportVar RANLIB_host "ranlib" - exportVar OBJCOPY_host "objcopy" - exportVar STRIP_host "strip" -else - if [ "$USE_CLANG" != "true" ]; then - exportVar CC "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc" - exportVar CXX "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-g++" - exportVar LINK "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc" - else - exportVar CC "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang" - exportVar CXX "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang++" - exportVar LINK "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang" - fi - - exportVar AR "$ANDROID_TOOLCHAIN_PREFIX-ar" - exportVar RANLIB "$ANDROID_TOOLCHAIN_PREFIX-ranlib" - exportVar OBJCOPY "$ANDROID_TOOLCHAIN_PREFIX-objcopy" - exportVar STRIP "$ANDROID_TOOLCHAIN_PREFIX-strip" -fi - -# GCC doesn't seem to put this on its include path when setting -march=mips32r2. -# Oddly, it does for mips32, mips32r3, and mips32r5, but it's gone again for mips32r6. -# Clang's fine. -if [ "$USE_CLANG" != "true" ]; then - if [ "$ANDROID_ARCH" == "mips" ]; then - exportVar CXX_target "$CXX_target -isystem $ANDROID_TOOLCHAIN/include/c++/4.9.x/mipsel-linux-android" - fi -fi - -# Create symlinks for nm & readelf and add them to the path so that the ninja -# build uses them instead of attempting to use the one on the system. -# This is required to build using ninja on a Mac. -if [ $HOST == "darwin" ]; then - ln -sf $ANDROID_TOOLCHAIN_PREFIX-nm $ANDROID_TOOLCHAIN/bin/nm - ln -sf $ANDROID_TOOLCHAIN_PREFIX-readelf $ANDROID_TOOLCHAIN/bin/readelf - ln -sf $ANDROID_TOOLCHAIN_PREFIX-as $ANDROID_TOOLCHAIN/bin/as -fi - -exportVar PATH ${ANDROID_TOOLCHAIN}/bin:${PATH} |