Skip to content

Commit 4e82da2

Browse files
committed
More fixes.
1 parent 06ca77f commit 4e82da2

14 files changed

+538
-41
lines changed

docker/Dockerfile.aarch64-linux-android

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@ ARG ANDROID_NDK=r21d
1717
ARG ANDROID_SDK=28
1818
ARG ANDROID_VERSION=9.0.0_r1
1919
ARG ANDROID_SYSTEM_COMPLETE=0
20+
ARG PYTHON_TMPDIR=/tmp/android
2021

2122
COPY android-ndk.sh /
2223
RUN /android-ndk.sh arm64
2324
ENV PATH=$PATH:/android-ndk/bin
2425

2526
# TODO(ahuszagh) Restore...
26-
COPY android-system.sh remove_android_tests.py /
27+
COPY android-system.sh /
28+
RUN mkdir -p $PYTHON_TMPDIR
29+
COPY android $PYTHON_TMPDIR
2730
#RUN /android-system.sh arm64
2831
#
2932
#COPY android-symlink.sh /

docker/android-system.sh

Lines changed: 83 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ main() {
6464
python \
6565
python3 \
6666
xz-utils
67-
purge_list+=(default-jre)
6867

6968
curl --retry 3 -sSfL https://storage.googleapis.com/git-repo-downloads/repo -O
7069
chmod +x repo
@@ -128,30 +127,40 @@ main() {
128127
popd
129128

130129
rm -rf "${td}"
130+
rm -rf "${PYTHON_TMPDIR}"
131131
rm "${0}"
132132
}
133133

134+
# java isn't required for the build, but the build expects to
135+
# find a java compiler. the supported android versions are:
136+
# https://source.android.com/docs/setup/start/older-versions
137+
# Android 7: OpenJDK-8
134138
fake_java() {
139+
local java_type=
135140
local java_version=
136-
local icedtea_version=
141+
local jre_info=
142+
local build_info=
143+
137144
case "${MAJOR_VERSION}" in
138145
5|6)
146+
java_type=java
139147
java_version=1.7.0
140-
icedtea_version=2.6.9
148+
jre_info="IcedTea 2.6.9"
149+
build_info="build 24.131-b00, mixed mode"
141150
;;
142151
*)
143-
java_version=1.8.0
144-
icedtea_version=2.6.9
152+
java_type=openjdk
153+
java_version=1.8.0_342
154+
jre_info="build 1.8.0_342-8u342-b07-0ubuntu1~20.04-b07"
155+
build_info="build 25.342-b07, mixed mode"
145156
;;
146157
esac
147158

148-
# fake java and javac, it is not necessary for what we build, but the build
149-
# script asks for it
150159
cat << EOF > /usr/bin/java
151160
#!/usr/bin/env bash
152-
echo "java version \"${java_version}\""
153-
echo "OpenJDK Runtime Environment (IcedTea ${icedtea_version})"
154-
echo "OpenJDK 64-Bit Server VM (build 24.131-b00, mixed mode)"
161+
echo "${java_type} version \"${java_version}\""
162+
echo "OpenJDK Runtime Environment (${jre_info})"
163+
echo "OpenJDK 64-Bit Server VM (${build_info})"
155164
EOF
156165

157166
cat << EOF > /usr/bin/javac
@@ -164,7 +173,7 @@ EOF
164173

165174
# more faking
166175
export ANDROID_JAVA_HOME=/tmp
167-
mkdir /tmp/lib/
176+
mkdir -p /tmp/lib/
168177
touch /tmp/lib/tools.jar
169178
}
170179

@@ -225,6 +234,7 @@ android_repo_v5() {
225234
sync external/libselinux
226235
sync external/mksh
227236
sync external/openssl
237+
sync external/pcre
228238
sync external/stlport
229239
sync prebuilts/clang/linux-x86/host/3.5
230240
sync system/core
@@ -262,9 +272,11 @@ android_repo_v6() {
262272
sync external/compiler-rt
263273
sync external/libcxx
264274
sync external/libcxxabi
275+
sync external/libselinux
265276
sync external/elfutils
266277
sync external/jemalloc
267278
sync external/mksh
279+
sync external/pcre
268280
sync external/safe-iop
269281
sync external/zlib
270282
sync libnativehelper
@@ -300,6 +312,7 @@ android_repo_v6() {
300312

301313
# tested on 7.0.0_r36 (SDK 24)
302314
# tested on 7.1.2_r39 (SDK 25, not supported)
315+
# API level 25, requires for Android 7.1, is not provided in NDKs
303316
android_repo_v7() {
304317
sync bionic
305318
sync build
@@ -321,6 +334,7 @@ android_repo_v7() {
321334
sync prebuilts/clang/host/linux-x86
322335
sync prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8
323336
sync prebuilts/misc
337+
sync prebuilts/ndk
324338
sync prebuilts/ninja/linux-x86
325339
sync system/core
326340

@@ -349,12 +363,26 @@ android_repo_v7() {
349363
# the unittests from it is a bit of work.
350364
rm bionic/tools/relocation_packer/Android.mk
351365

352-
ANDROID_MAJOR=7 python3 /remove_android_tests.py
366+
remove_tests
353367
}
354368

355369
# TODO: tested on 8.0.0_r51 (SDK 26)
356-
# TODO: tested on 8.1.0_r81 (SDK 2278.0.0_r516)
370+
# Currently failing due to libLLVM/libclang issues
371+
# TODO: tested on 8.1.0_r81 (SDK 27)
357372
android_repo_v8() {
373+
# external/compiler-rt/lib/sanitizer_common/tests/Android.bp:37:1
374+
# name: "san_test-Nolibc"
375+
#
376+
# libnativehelper/Android.bp
377+
# subdirs = ["tests"]
378+
#
379+
# system/core/bootstat/Android.bp
380+
# whole_static_libs: ["libgtest_prod"],
381+
#
382+
# external/compiler-rt/lib/asan/Android.bp
383+
# name: "libasan_noinst_test",
384+
#
385+
358386
sync bionic
359387
sync build
360388
sync build/make
@@ -363,34 +391,42 @@ android_repo_v8() {
363391
sync external/boringssl
364392
sync external/clang
365393
sync external/compiler-rt
394+
sync external/elfutils
366395
sync external/jemalloc
367396
sync external/libcxx
368397
sync external/libcxxabi
369-
sync external/libnl
398+
# TODO(ahuszagh) Remove?
399+
#sync external/libnl
400+
sync external/libevent
370401
sync external/libunwind
371402
sync external/libunwind_llvm
372403
sync external/llvm
373404
sync external/lzma
374405
sync external/mksh
375406
sync external/pcre
407+
sync external/safe-iop
376408
sync external/selinux
377409
sync external/zlib
378-
sync hardware/interfaces
379-
sync hardware/libhardware
380-
sync frameworks/native
410+
# TODO(ahuszagh) Remove?
411+
#sync hardware/interfaces
412+
#sync hardware/libhardware
413+
#sync frameworks/native
381414
sync libnativehelper
382415
sync prebuilts/build-tools
383416
sync prebuilts/clang/host/linux-x86
417+
# TODO(ahuszagh) clang-tools isn't available till 9.0
384418
sync prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8
385419
sync prebuilts/go/linux-x86
386-
# needed for libnativehelper_compat_libc++
387420
sync prebuilts/ndk
388421
sync system/core
389-
sync system/libfmq
390-
sync system/libhidl
391-
sync system/libhwbinder
392-
sync system/media
393-
sync system/tools/hidl
422+
sync toolchain/binutils
423+
424+
# TODO(ahuszagh) See if I can remove all of these
425+
#sync system/libfmq
426+
#sync system/libhidl
427+
#sync system/libhwbinder
428+
#sync system/media
429+
#sync system/tools/hidl
394430
# TODO(ahuszagh) Android 8 is a mess
395431

396432
# avoid build tests
@@ -399,26 +435,21 @@ android_repo_v8() {
399435
rm bionic/tests/Android.bp
400436
rm bionic/benchmarks/Android.bp
401437
rm bionic/tests/libs/Android.bp
402-
rm hardware/interfaces/tests/Android.bp
403-
rm system/tools/hidl/test/Android.bp
438+
# TODO(ahuszagh) Can probably remove this
439+
# rm hardware/interfaces/tests/Android.bp
440+
# rm system/tools/hidl/test/Android.bp
404441
# we don't need the relocation packer, and removing
405442
# the unittests from it is a bit of work.
406443
rm bionic/tools/relocation_packer/Android.bp
407444
rm bionic/tools/relocation_packer/Android.mk
445+
rm system/core/libgrallocusage/Android.bp
446+
rm system/core/libmemtrack/Android.bp
447+
rm system/core/libsysutils/Android.bp
448+
449+
# avoid java dependencies
450+
rm external/lzma/Java/Tukaani/Android.mk
408451

409-
# extra utilities we don't need
410-
rm frameworks/native/libs/vr/Android.bp
411-
rm frameworks/native/services/Android.bp
412-
rm frameworks/native/services/*/Android.bp
413-
rm hardware/interfaces/automotive/Android.bp
414-
rm hardware/interfaces/camera/Android.bp
415-
rm system/libhidl/transport/Android.bp
416-
rm system/media/alsa_utils/Android.bp
417-
rm system/media/audio_route/Android.bp
418-
rm system/media/audio_utils/tests/Android.bp
419-
# TODO(ahuszagh) Need to remove the tests here
420-
421-
ANDROID_MAJOR=8 python3 /remove_android_tests.py
452+
remove_tests
422453
}
423454

424455
# tested on 9.0.0_r1 (SDK 28)
@@ -482,7 +513,7 @@ android_repo_v9() {
482513
rm bionic/tests/headers/Android.bp
483514
rm bionic/tests/headers/posix/Android.bp
484515

485-
ANDROID_MAJOR=9 python3 /remove_android_tests.py
516+
remove_tests
486517
}
487518

488519
# tested on 10.0.0_r47 (SDK 29)
@@ -553,7 +584,19 @@ android_repo_v10() {
553584
rm bionic/tests/headers/Android.bp
554585
rm bionic/tests/headers/posix/Android.bp
555586

556-
ANDROID_MAJOR=10 python3 /remove_android_tests.py
587+
remove_tests
588+
}
589+
590+
remove_tests() {
591+
install_packages python3-pip
592+
593+
export PYTHONPATH="${PYTHON_TMPDIR}/lib/python3.8/site-packages/":"${PYTHONPATH}"
594+
mkdir -p "${PYTHON_TMPDIR}"
595+
python3 -m pip install sly==0.4.0 --prefix "${PYTHON_TMPDIR}"
596+
597+
# TODO(ahuszagh) Need to change this
598+
# Need a custom entrypoint
599+
ANDROID_MAJOR="${MAJOR_VERSION}" python3 "${PYTHON_TMPDIR}/remove_tests.py"
557600
}
558601

559602
sync() {

docker/android/android/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import sys
2+
3+
# we run this script once every build, and we'd rather
4+
# have much smaller image sizes, so copying without
5+
# any bytecode is a better idea.
6+
sys.dont_write_bytecode = True
7+
8+
__all__ = [
9+
"make",
10+
"soong",
11+
]
Binary file not shown.

docker/android/android/make.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
'''
2+
make
3+
====
4+
5+
utilities to process makefiles
6+
'''
7+
8+
import re
9+
10+
from . import util
11+
12+
class Section:
13+
def __init__(self, title, contents):
14+
self.title = title
15+
self.contents = contents
16+
17+
def is_test(self):
18+
return self.title is not None and 'test' in self.title.lower()
19+
20+
def is_benchmark(self):
21+
return self.title is not None and 'benchmark' in self.title.lower()
22+
23+
def is_dev(self):
24+
return self.is_test() or self.is_benchmark()
25+
26+
def __repr__(self):
27+
return self.contents
28+
29+
class Makefile:
30+
def __init__(self, sections):
31+
self.sections = sections
32+
33+
@staticmethod
34+
def parse(path):
35+
with open(path, 'r') as f:
36+
contents = f.read()
37+
38+
sep1 = r'#\s+=+'
39+
sep2 = r'#\s+-+'
40+
comment = r'[A-Za-z0-9._ -]+'
41+
pat1 = fr'(?:{sep1}\n)?#\s+({comment})\n{sep1}'
42+
pat2 = fr'(?:{sep2}\n)?#\s+({comment})\n{sep2}'
43+
pattern = fr'(?:{pat1})|(?:{pat2})'
44+
45+
sections = []
46+
matches = list(re.finditer(pattern, contents))
47+
if len(matches) == 0:
48+
sections.append(Section(None, contents))
49+
else:
50+
first = matches[0]
51+
last = matches[-1]
52+
if first.start() != 0:
53+
sections.append(Section(None, contents[:first.start()]))
54+
for (prev, nxt) in util.windows(matches, 2):
55+
title = prev.group(1) or prev.group(2)
56+
sections.append(Section(title, contents[prev.start():nxt.start()]))
57+
title = last.group(1) or prev.group(2)
58+
sections.append(Section(title, contents[last.start():]))
59+
60+
return Makefile(sections)
61+
62+
def filter_dev(self):
63+
return Makefile([i for i in self.sections if not i.is_dev()])
64+
65+
def __repr__(self):
66+
return ''.join([str(i) for i in self.sections])

0 commit comments

Comments
 (0)