File: cfg-android-abi

package info (click to toggle)
brltty 6.9-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 44,844 kB
  • sloc: ansic: 154,246; java: 13,514; sh: 9,934; xml: 5,672; tcl: 2,679; makefile: 2,346; awk: 713; lisp: 366; python: 321; ml: 301
file content (240 lines) | stat: -rwxr-xr-x 6,553 bytes parent folder | download
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
#!/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-2025 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 <dave@mielke.cc>.
###############################################################################

. "`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,al,at,bm,bn,ce,cn,dp,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"]}" ] || {
      logTask "installing tool chain for ABI: ${abiName}"

      if [ -d "${properties["NDK"]}/platforms" ]
      then
         VERBOSE=no "${properties["NDK"]}/build/tools/make-standalone-toolchain.sh" \
            --platform="${properties["PLATFORM"]}" \
            --arch="${properties["ARCH"]}" \
            --install-dir="${properties["TOOLCHAIN"]}" || exit "${?}"
      else
         ln -s "${properties["NDK"]}/toolchains/llvm/prebuilt/linux-x86_64" "${properties["TOOLCHAIN"]}"
      fi
   }
}

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}"
   shift 1
   local toolNames=( "${@}" )

   local toolPrefixPatterns=(
      "${properties["SYSTEM"]}-"
      "${properties["SYSTEM"]}[1-9][0-9]-"
      "llvm-"
      ""
   )

   logDetail "finding tool: ${variable}: ${toolNames[*]}"
   local toolName

   for toolName in "${toolNames[@]}"
   do
      local toolPrefixPattern

      for toolPrefixPattern in "${toolPrefixPatterns[@]}"
      do
         local toolPaths=( "${toolsDirectory}/"${toolPrefixPattern}"${toolName}" )
         local toolCount="${#toolPaths[*]}"
         [ "${toolCount}" -gt 0 ] || continue

         local toolPath="${toolPaths[toolCount - 1]}"
         logDetail "checking for tool: ${toolPath}"

         [ -f "${toolPath}" ] && {
            setVariable "${variable}" "${toolPath}"
            export "${variable}"

            logNote "tool found: ${variable}: ${toolPath}"
            return 0
         }
      done
   done

   setVariable "${variable}" "TOOL_NOT_FOUND_${variable}"
   logWarning "tool not found: ${variable}: ${toolNames[*]}"
}

addProgramOption f flag forceReconfigure "force a reconfigure"
addProgramParameter ABI abiName "name of ABI to configure" "the source tree"
parseProgramArguments "${@}"

set -e
shopt -s nullglob

abiRoot="${programDirectory}/Android/ABI/${abiName}"
abiPropertiesFile="${abiRoot}/build.properties"
[ -f "${abiPropertiesFile}" ] || syntaxError "unrecognized ABI: ${abiName}"
. "${abiPropertiesFile}"
setProperties

makeToolChain
linkMissingHeaders

[ -L "${properties["TOOLCHAIN"]}" ] && {
   declare -n systemTriplet="properties["SYSTEM"]"
   systemTriplet="${systemTriplet/arm-/armv7a-}"
}

buildDirectory="$(pwd)"
buildMakeFile="${buildDirectory}/Makefile"

if [ -f "${buildMakeFile}" ]
then
   if "${forceReconfigure}"
   then
      logNotice "reconfiguring build: ${buildDirectory}"
   else
      logNote "build already configured: ${buildDirectory}"
      exit 0
   fi
else
   logTask "configuring build: ${buildDirectory}"
fi

toolsDirectory="${properties["TOOLCHAIN"]}/bin"
export PATH="${toolsDirectory}:${PATH}"
findTool CC gcc clang
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