Zach Johnson | facafb0 | 2019-04-22 16:34:49 -0700 | [diff] [blame] | 1 | #! /bin/bash |
Chris Manton | 0aba41d | 2019-06-19 10:54:04 -0700 | [diff] [blame] | 2 | # |
| 3 | # Script to setup environment to execute bluetooth certification stack |
| 4 | # |
Zach Johnson | facafb0 | 2019-04-22 16:34:49 -0700 | [diff] [blame] | 5 | # for more info, see go/acts |
| 6 | |
Chris Manton | 0aba41d | 2019-06-19 10:54:04 -0700 | [diff] [blame] | 7 | ## Android build main build setup script relative to top level android source root |
| 8 | BUILD_SETUP=./build/envsetup.sh |
| 9 | |
| 10 | function UsageAndroidTree { |
| 11 | cat<<EOF |
| 12 | Ensure invoked from within the android source tree |
| 13 | EOF |
| 14 | } |
| 15 | |
| 16 | function UsageSourcedNotExecuted { |
| 17 | cat<<EOF |
| 18 | Ensure script is SOURCED and not executed to persist the build setup |
| 19 | e.g. |
| 20 | source $0 |
| 21 | EOF |
| 22 | } |
| 23 | |
| 24 | function UpFind { |
| 25 | while [[ $PWD != / ]] ; do |
| 26 | rc=$(find "$PWD" -maxdepth 1 "$@") |
| 27 | if [ -n "$rc" ]; then |
| 28 | echo $(dirname "$rc") |
| 29 | return |
| 30 | fi |
| 31 | cd .. |
| 32 | done |
| 33 | } |
| 34 | |
| 35 | function SetUpAndroidBuild { |
| 36 | pushd . |
| 37 | android_root=$(UpFind -name out -type d) |
| 38 | if [[ -z $android_root ]] ; then |
| 39 | UsageAndroidTree |
| 40 | return |
| 41 | fi |
| 42 | echo "Found android root $android_root" |
| 43 | cd $android_root && . $BUILD_SETUP |
| 44 | echo "Sourced build setup rules" |
| 45 | cd $android_root && lunch |
| 46 | popd |
| 47 | } |
| 48 | |
| 49 | function SetupPython3 { |
| 50 | echo "Setting up python3" |
| 51 | sudo apt-get install python3-dev |
| 52 | } |
| 53 | |
| 54 | if [[ "${BASH_SOURCE[0]}" == "${0}" ]] ; then |
| 55 | UsageSourcedNotExecuted |
| 56 | exit 1 |
| 57 | fi |
| 58 | |
| 59 | if [[ -z "$ANDROID_BUILD_TOP" ]] ; then |
| 60 | SetUpAndroidBuild |
| 61 | fi |
| 62 | |
| 63 | ## Check python3 is installed properly |
| 64 | dpkg -l python3-dev > /dev/null 2>&1 |
| 65 | if [[ $? -ne 0 ]] ; then |
| 66 | SetupPython3 |
| 67 | fi |
| 68 | |
| 69 | ## All is good now so go ahead with the acts setup |
| 70 | pushd . |
Zach Johnson | facafb0 | 2019-04-22 16:34:49 -0700 | [diff] [blame] | 71 | cd $ANDROID_BUILD_TOP/tools/test/connectivity/acts/framework/ |
| 72 | sudo python3 setup.py develop |
Chris Manton | 0aba41d | 2019-06-19 10:54:04 -0700 | [diff] [blame] | 73 | if [[ $? -eq 0 ]] ; then |
| 74 | echo "cert setup complete" |
| 75 | else |
| 76 | echo "cert setup failed" |
| 77 | fi |
| 78 | popd |
| 79 | |