blob: c8fa38bf900ba4c1fadef665c05b06c652a8f5ad [file] [log] [blame]
Zach Johnsonfacafb02019-04-22 16:34:49 -07001#! /bin/bash
Chris Manton0aba41d2019-06-19 10:54:04 -07002#
3# Script to setup environment to execute bluetooth certification stack
4#
Zach Johnsonfacafb02019-04-22 16:34:49 -07005# for more info, see go/acts
6
Chris Manton0aba41d2019-06-19 10:54:04 -07007## Android build main build setup script relative to top level android source root
8BUILD_SETUP=./build/envsetup.sh
9
10function UsageAndroidTree {
11 cat<<EOF
12Ensure invoked from within the android source tree
13EOF
14}
15
16function UsageSourcedNotExecuted {
17 cat<<EOF
18Ensure script is SOURCED and not executed to persist the build setup
19e.g.
20source $0
21EOF
22}
23
24function 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
35function 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
49function SetupPython3 {
50 echo "Setting up python3"
51 sudo apt-get install python3-dev
52}
53
54if [[ "${BASH_SOURCE[0]}" == "${0}" ]] ; then
55 UsageSourcedNotExecuted
56 exit 1
57fi
58
59if [[ -z "$ANDROID_BUILD_TOP" ]] ; then
60 SetUpAndroidBuild
61fi
62
63## Check python3 is installed properly
64dpkg -l python3-dev > /dev/null 2>&1
65if [[ $? -ne 0 ]] ; then
66 SetupPython3
67fi
68
69## All is good now so go ahead with the acts setup
70pushd .
Zach Johnsonfacafb02019-04-22 16:34:49 -070071cd $ANDROID_BUILD_TOP/tools/test/connectivity/acts/framework/
72sudo python3 setup.py develop
Chris Manton0aba41d2019-06-19 10:54:04 -070073if [[ $? -eq 0 ]] ; then
74 echo "cert setup complete"
75else
76 echo "cert setup failed"
77fi
78popd
79