-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
196 lines (172 loc) · 5.91 KB
/
configure
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
#!/usr/bin/env bash
# Copyright (C) 2019-2020 Arm Limited.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This script selects the build configuration to use for Gralloc.
# The Arm Reference Gralloc supports multiple versions of Android and Gralloc APIs.
# This script must be used before the build stage to select what to build, consistently with the target Android system.
#
# The Arm Reference Gralloc supports the following combinations:
# - Gralloc 4 APIs on Android 11
# This uses Blueprint as a build system.
# - Gralloc 3 APIs on Android 10
# This uses Makefiles as a build system.
# The privatebuffer interface is enabled by default, but can be disabled (not recommended.)
#
# The script determines automatically what to do from the environment, which requires a previous "lunch".
#
# When not in a "lunched" shell, the Android version can be set to 'n' by specifying:
# ANDROID_n=y
# The Android version affects whether the private buffer interface build is enabled or not.
# It will be enabled on Android version 10 unless overriden with the PRIVATE_BUFFER_INTERFACE option.
#
# The Android version also affects the Gralloc version which is then used to decide
# whether the Blueprint build files are enabled.
# Defaults are:
# Android 9 : Gralloc 2, use makefiles.
# Android 10: Gralloc 3, use makefiles.
# Android 11: Gralloc 4, use Blueprint.
#
# To override the default Gralloc version to n use:
# GRALLOC_n=y
# Note that this does not mean that that version of Gralloc will be built, it only controls
# whether makefiles or Blueprint files are enabled.
#
# The script does not check that the combination of options specified is valid.
set -e
PLATFORM_VERSION=0
GRALLOC_VERSION=0
# In a lunched shell auto detect the Android version.
if [ ! -z $ANDROID_BUILD_TOP ]; then
PLATFORM_VERSION=$(${ANDROID_BUILD_TOP}/build/soong/soong_ui.bash --dumpvar-mode PLATFORM_VERSION 2>/dev/null)
# Adjust for early access versions that use a capital letter eg. Q -> 10
if [[ $PLATFORM_VERSION == [A-Z] ]]; then
PLATFORM_VERSION=$(printf "%d" "'$PLATFORM_VERSION")
PLATFORM_VERSION=$(($PLATFORM_VERSION - 71))
fi
fi
SELECTED_PLATFORM=0
for arg in "$@"; do
case $arg in
ANDROID_9=y)
SELECTED_PLATFORM=9
;;
ANDROID_10=y)
SELECTED_PLATFORM=10
;;
ANDROID_11=y)
SELECTED_PLATFORM=11
;;
PRIVATEBUFFER_INTERFACE=y)
PRIVATE_BUFFER=1
;;
PRIVATEBUFFER_INTERFACE=n)
PRIVATE_BUFFER=0
;;
GRALLOC_2=y)
GRALLOC_VERSION=2
;;
GRALLOC_3=y)
GRALLOC_VERSION=3
;;
GRALLOC_4=y)
GRALLOC_VERSION=4
;;
*)
echo "$arg ignored"
;;
esac
done
if [ $PLATFORM_VERSION != 0 ] && [ $SELECTED_PLATFORM != 0 ] && [ $PLATFORM_VERSION != $SELECTED_PLATFORM ]; then
echo "ANDROID_${SELECTED_PLATFORM} ignored. Using detected Android version of ${PLATFORM_VERSION}"
elif [ $SELECTED_PLATFORM != 0 ]; then
PLATFORM_VERSION=$SELECTED_PLATFORM
fi
if [ $PLATFORM_VERSION = 0 ] && [ $GRALLOC_VERSION = 0 ] && [ -z $PRIVATE_BUFFER ]; then
echo "Error: no Android version detected or specified. It is recommended to run from a lunched shell."
exit 1
fi
if [ -z $PRIVATE_BUFFER ] && [ $PLATFORM_VERSION = 10 ]; then
PRIVATE_BUFFER=1
fi
if [ -z $PRIVATE_BUFFER ]; then
PRIVATE_BUFFER=0
fi
if [ $GRALLOC_VERSION = 0 ]; then
case $PLATFORM_VERSION in
9)
GRALLOC_VERSION=2
;;
10)
GRALLOC_VERSION=3
;;
11)
GRALLOC_VERSION=4
;;
esac
fi
if [ $PRIVATE_BUFFER = 1 ]; then
echo "Private buffer interface build enabled."
fi
# command pushd `dirname $0` > /dev/null
command pushd $(pwd) > /dev/null
# Clean all build files
find . \( -name "Android.bp" ! -wholename "*src/Android.bp" \) -delete
if [ -f Android.mk ]; then
mv Android.mk Android.mk.disabled
fi
if [ $PRIVATE_BUFFER = 1 ]; then
cp interfaces/Android.bp.disabled interfaces/Android.bp
for path in `find interfaces/graphics -name Android.bp.disabled`; do
dir=`dirname $path`
cp $dir/Android.bp.disabled $dir/Android.bp
done
cp interfaces/libs/drmutils/Android.bp.disabled interfaces/libs/drmutils/Android.bp
fi
if [ $GRALLOC_VERSION = 0 ]; then
echo "Warning: no Gralloc version selected. No build files enabled."
exit
else
echo "Enabling build files for Gralloc version ${GRALLOC_VERSION}"
fi
if [ $GRALLOC_VERSION = 2 ] || [ $GRALLOC_VERSION = 3 ]; then
cp Android.mk.disabled Android.mk
fi
# Stable AIDL and DRM utils interfaces
AIDL_FILES="interfaces/aidl/Android.bp.disabled
interfaces/libs/drmutils/Android.bp.disabled"
# Blueprint files for all modules common to all Gralloc versions
COMMON_FILES="Android.bp.disabled
src/core/Android.bp.disabled
src/capabilities/Android.bp.disabled
src/allocator/Android.bp.disabled
src/hidl_common/Android.bp.disabled"
# Blueprint files for tests
if [ -d tests ]; then
TEST_FILES=`find tests -name Android.bp.disabled`
else
TEST_FILES=
fi
if [ $GRALLOC_VERSION = 4 ]; then
GRALLOC4_FILES="${AIDL_FILES}
${COMMON_FILES}
${TEST_FILES}
service/4.x/Android.bp.disabled
src/4.x/Android.bp.disabled"
for FILE in $GRALLOC4_FILES; do
cp "${FILE}" "${FILE%.disabled}"
done
fi
command popd > /dev/null