-
Notifications
You must be signed in to change notification settings - Fork 21
/
configure_hacks
84 lines (78 loc) · 1.96 KB
/
configure_hacks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
## ------------------------------- ##
## Android cross-compilation hacks ##
## ------------------------------- ##
# as_android_send SRC DST
# -----------------------
# copy SRC to DST on android phone
as_android_send ()
{
adb push "$1" "$2" &>/dev/null
return $?
}
# as_android_get SRC DST
# -----------------------
# copy SRC from android phone to DST
as_android_get ()
{
for f in $(adb shell ls "$1" | tr -d '\r'); do
adb pull "$f" "$2" &>/dev/null
done
return $?
}
# as_android_exec CMD
# ---------------
# execute CMD on android phone
as_android_exec ()
{
local exitcode;
local wd=".";
test ${1:0:1} = '/' && wd=$(dirname "$1")
adb shell "\$SHELL cd $wd; $1; echo -ne \"\\tEXITCODE=\$?\"" &>adb.raw
exitcode=$?
#check if adb failed
if test $exitcode -ne 0; then
return $exitcode;
fi
exitcode=$(( $(grep "EXITCODE=" adb.raw | grep -oE "[0-9]+") + 0 ))
sed -E 's/\tEXITCODE=[0-9]+//' < adb.raw
$as_echo "adb shell \"\$SHELL cd $wd; $1; echo -ne \"\\tEXITCODE=\$?\" => $exitcode" >&5
return $exitcode
}
# as_android_rm FILE
# ---------------
# remove FILE from android phone
as_android_rm ()
{
for f in $(adb shell ls "$1" | tr -d '\r'); do
adb rm "$f" &>/dev/null
done
return $?
}
# as_android_run FILE
# -------------------
# run FILE on android phone
as_android_run()
{
local fname=$(basename "$1")
local remote_path="/data/local/tmp/$fname"
local exitcode;
as_android_send $1 $remote_path || as_fn_error "cannot upload \`$1' to \`$remote_path'"
as_android_exec $remote_path
exitcode=$?
as_android_get "/data/local/tmp/conf*" ./
as_android_rm $remote_path
as_android_rm "/data/local/tmp/conf*"
return $exitcode
}
# in ac_fn_c_try_run ()
# substitute (eval "$ac_try") with:
case $android in
yes)
eval ac_try="$ac_try"
as_android_run $ac_try 2>&5;;
*) (eval "$ac_try") 2>&5;;
esac
# set cross_compile=no and android=yes before project checks an AFTER libtool initialization.
# usually after `case "$host:$CC" in' case statement
cross_compiling=no
android=yes