blob: cb9152bfea74ad810217b1bbc457b886bbced632 [file] [log] [blame]
gfanc351bd02018-06-11 11:25:36 -07001#!/bin/bash
2
3# assumption:
4# - pwd must be inside the repo's homed directory (android-ndk)
5# - upon completion, we are still in the same directory ( no change )
6
7TMP_SETUP_FILENAME=versions_.txt
8
9# parse all build.gradle to find the specified tokens' version
10# usage:
11# retrive_versions token version_file
12# where
13# token: the token to search for inside build.grade
14# version string is right after the token string
15# version_file: file to hold the given versions
16# one version at a line
17retrieve_versions() {
18# $1: token; $2 version_file
19 if [[ -z $1 ]] || [[ -z $2 ]]; then
20 echo "input string(s) may be empty: token: $1; version_file: $2"
21 return 1
22 fi
23
24 find . -type f -name 'build.gradle' -exec grep $1 {} + | \
25 sed "s/^.*$1//" | sed 's/[=+]//g' | \
26 sed 's/"//g' | sed "s/'//g" | \
27 sed 's/[[:space:]]//g' | \
28 awk '!seen[$0]++' > $2
29
30 return 0
31}
32
33## Retrieve all necessary Android Platforms and install them all
34retrieve_versions compileSdkVersion $TMP_SETUP_FILENAME
35
36# fixups
37sed -i '/COMPILE_SDK_VERSION/d' $TMP_SETUP_FILENAME
38# Install platforms
39while read -r version_; do
40 echo y | $ANDROID_HOME/tools/bin/sdkmanager "platforms;android-$version_";
41done < $TMP_SETUP_FILENAME
42#echo "Android platforms:"; cat $TMP_SETUP_FILENAME;rm -f $TMP_SETUP_FILENAME
43
44## Retrieve constraint-layout versions
45retrieve_versions "constraint-layout:" $TMP_SETUP_FILENAME
46while read -r version_; do
47 echo y | $ANDROID_HOME/tools/bin/sdkmanager \
48 "extras;m2repository;com;android;support;constraint;constraint-layout;$version_"
49done < $TMP_SETUP_FILENAME
50#echo "constraint-layout versions:"; cat $TMP_SETUP_FILENAME;
51rm -f $TMP_SETUP_FILENAME