forked from brltty/brltty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cfg-android-abi
executable file
·203 lines (168 loc) · 5.33 KB
/
cfg-android-abi
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#!/bin/bash
###############################################################################
# BRLTTY - A background process providing access to the console screen (when in
# text mode) for a blind person using a refreshable braille display.
#
# Copyright (C) 1995-2024 by The BRLTTY Developers.
#
# BRLTTY comes with ABSOLUTELY NO WARRANTY.
#
# This is free software, placed under the terms of the
# GNU Lesser General Public License, as published by the Free Software
# Foundation; either version 2.1 of the License, or (at your option) any
# later version. Please see the file LICENSE-LGPL for details.
#
# Web Page: http://brltty.app/
#
# This software is maintained by Dave Mielke <[email protected]>.
###############################################################################
. "`dirname "${0}"`/brltty-prologue.sh"
showProgramUsagePurpose() {
cat <<END_OF_PROGRAM_USAGE_PURPOSE
Configure a BRLTTY build for a specific ABI (application binary interface) of the Android platform.
END_OF_PROGRAM_USAGE_PURPOSE
}
showProgramUsageNotes() {
cat <<END_OF_PROGRAM_USAGE_NOTES
This script is used by cfg-android, and is for internal use only.
END_OF_PROGRAM_USAGE_NOTES
}
# Braille drivers already disabled:
# lb (by --without-libbraille)
# xw (by --disable-x)
readonly configureOptions=(
--disable-expat
--disable-gpm
--disable-iconv
--disable-icu
--disable-liblouis
--disable-polkit
--disable-x
--without-libbraille
--with-braille-driver=-ba,-bg,-tt,-vr,al,at,bm,bn,ce,eu,fs,hm,ht,hw,ic,ir,md,mm,mt,np,pg,pm,sk,vo
--without-espeak
--without-espeak-ng
--without-flite
--without-mikropuhe
--without-speechd
--without-swift
--without-theta
--with-speech-driver=an,-all
--with-screen-driver=an,-all
--without-pgmpath-package
--without-pgmprivs-package
--without-service-package
--without-params-package
--without-charset-package
--without-rgx-package
--without-hostcmd-package
--without-mntpt-package
--without-mntfs-package
--without-bell-package
--without-leds-package
--without-beep-package
--without-midi-package
--without-fm-package
--without-hid-package
--without-ports-package
--disable-emacs-bindings
--disable-lua-bindings
)
setProperties() {
declare -g -A properties
local ok=true
local property
for property in ARCH -CFLAGS -LDFLAGS NDK PLATFORM SOURCE SYSTEM TOOLCHAIN
do
local optional=false
[ "${property:0:1}" != "-" ] || {
optional=true
property="${property:1}"
}
local variable="BRLTTY_ANDROID_${property}"
local value="${!variable}"
"${optional}" || {
[ -n "${value}" ] || {
logError "property not set: ${property}"
ok=false
}
}
properties["${property}"]="${value}"
done
"${ok}" || exit 9
}
makeToolChain() {
[ -d "${properties[TOOLCHAIN]}" ] || {
logMessage task "installing tool chain for ABI: ${abiName}"
VERBOSE=no "${properties[NDK]}/build/tools/make-standalone-toolchain.sh" \
--platform="${properties[PLATFORM]}" \
--arch="${properties[ARCH]}" \
--install-dir="${properties[TOOLCHAIN]}" || exit "${?}"
}
}
linkMissingHeaders() {
local buildInclude="/usr/include"
local hostInclude="${properties[TOOLCHAIN]}/sysroot${buildInclude}"
local header
for header in bluetooth
do
local hostHeader="${hostInclude}/${header}"
[ ! -e "${hostHeader}" ] || continue
local buildHeader="${buildInclude}/${header}"
[ -e "${buildHeader}" ] || continue
logNote "adding symbolic link for header: ${abiName}: ${header}"
ln -s "${buildHeader}" "${hostHeader}" || exit "${?}"
done
}
findTool() {
local variable="${1}"
local name="${2}"
logDetail "finding tool: ${name}"
local path="${toolsDirectory}/${properties["SYSTEM"]}-${name}"
[ -f "${path}" ] || {
logError "tool not found: ${path}"
exit 8
}
logNote "tool found: ${path}"
setVariable "${variable}" "${path}"
export "${variable}"
}
addProgramOption f flag forceReconfigure "force a reconfigure"
addProgramParameter ABI abiName "name of ABI to configure" "the source tree"
parseProgramArguments "${@}"
set -e
abiRoot="${programDirectory}/Android/ABI/${abiName}"
abiPropertiesFile="${abiRoot}/build.properties"
[ -f "${abiPropertiesFile}" ] || syntaxError "unrecognized ABI: ${abiName}"
. "${abiPropertiesFile}"
setProperties
makeToolChain
linkMissingHeaders
buildDirectory="$(pwd)"
buildMakeFile="${buildDirectory}/Makefile"
if [ -f "${buildMakeFile}" ]
then
if "${forceReconfigure}"
then
logWarning "reconfiguring build: ${buildDirectory}"
else
logNote "build already configured: ${buildDirectory}"
exit 0
fi
else
logMessage task "configuring build: ${buildDirectory}"
fi
toolsDirectory="${properties[TOOLCHAIN]}/bin"
export PATH="${toolsDirectory}:${PATH}"
findTool CC gcc
findTool LD ld
findTool STRIP strip
findTool RANLIB ranlib
sysrootDirectory="${properties[TOOLCHAIN]}/sysroot"
export PKG_CONFIG_SYSROOT_DIR="${sysrootDirectory}"
export PKG_CONFIG_LIBDIR="${sysrootDirectory}/usr/lib/pkgconfig:${sysrootDirectory}/usr/share/pkgconfig"
export PKG_CONFIG_PATH=""
export CFLAGS="${properties[CFLAGS]}"
export LDFLAGS="${properties[LDFLAGS]}"
"${properties[SOURCE]}/configure" --quiet --host="${properties[SYSTEM]}" "${configureOptions[@]}"
exit 0