Wiki » History » Version 2
Liam H, 09/24/2024 09:52 AM
1 | 1 | Liam H | **WIP Report: FOSS Android SDK Build** |
---|---|---|---|
2 | |||
3 | **Current Status:** |
||
4 | |||
5 | We have successfully created a pkgbuild/APKBUILD for the android-sdk based on the Rebuild-SDK, which builds without errors. However, upon further investigation, we discovered that the Android repository includes over 187 binary dependencies, such as Go and Rust, in the prebuilt repository. Patching these dependencies manually is a tedious task. |
||
6 | |||
7 | **New Approach:** |
||
8 | |||
9 | We have found an unofficial CMake-based build system for Android command line utilities, which is already used in many Linux distributions. Our next step is to evaluate the possibility of creating a merge request to build the Android SDK using CMake. |
||
10 | |||
11 | **Call for Help:** |
||
12 | |||
13 | We are seeking assistance in writing the necessary CMake files to support this new build system. Specifically, we are looking for help with: |
||
14 | |||
15 | * Creating CMake files for the Android SDK build process |
||
16 | * Integrating the CMake build system with the existing Android repository |
||
17 | |||
18 | h3. APKBUILD for alpine linux |
||
19 | 2 | Liam H | |
20 | |||
21 | 1 | Liam H | <pre><code class="shell"> |
22 | pkgname=android-sdk |
||
23 | pkgver=14.0.0 |
||
24 | _pkgrev=r74 |
||
25 | pkgrel=0 |
||
26 | pkgdesc="android sdk without google binaries" |
||
27 | url="https://git.replicant.us/contrib/wizzard/Android/SDK-Rebuild" |
||
28 | arch="all" |
||
29 | license="APACHE" |
||
30 | makedepends=" |
||
31 | bison |
||
32 | flex |
||
33 | git |
||
34 | gnupg |
||
35 | gperf |
||
36 | libx11-static |
||
37 | libxml2 |
||
38 | libxslt |
||
39 | mesa-dev |
||
40 | ncurses-static |
||
41 | python3 |
||
42 | repo |
||
43 | rsync |
||
44 | unzip |
||
45 | openssh |
||
46 | bash |
||
47 | " |
||
48 | source="" |
||
49 | builddir="$srcdir/" |
||
50 | options="!check net" |
||
51 | |||
52 | prepare() { |
||
53 | git config --global user.email "you@example.com" r |
||
54 | git config --global user.name "Your Name" |
||
55 | sdkver="${pkgver}_${_pkgrev}" |
||
56 | echo $sdkver |
||
57 | # TODO maybe make init fast using this: https://android.googlesource.com/platform/sdk/+/refs/tags/android-14.0.0_r74/README.txt |
||
58 | repo init -u https://android.googlesource.com/platform/manifest -b android-$sdkver --depth=1 </dev/null |
||
59 | sed -i '/prebuilt/d' "$builddir"/.repo/manifests/default.xml |
||
60 | while ! repo sync --current-branch -j"$(nproc)"; do |
||
61 | echo "repo sync failed, retrying..." |
||
62 | done |
||
63 | } |
||
64 | |||
65 | build() { |
||
66 | export TARGET_RELEASE=trunk |
||
67 | BUILD_VARIANT='eng' |
||
68 | export BUILD_NUMBER=${BUILD_VARIANT}."${sdkver}" |
||
69 | # needed, because otherwise conscrypt build will fail. ART and some other |
||
70 | # dependencies need to be built from source. |
||
71 | export ART_MODULE_BUILD_FROM_SOURCE=true |
||
72 | export MODULE_BUILD_FROM_SOURCE=true |
||
73 | echo "$BUILD_NUMBER" |
||
74 | |||
75 | cd src |
||
76 | . build/envsetup.sh |
||
77 | |||
78 | lunch sdk-$TARGET_RELEASE-$BUILD_VARIANT |
||
79 | make -j"$(nproc)" sdk dist sdk_repo |
||
80 | } |
||
81 | |||
82 | package() { |
||
83 | install -Dm755 "$srcdir"/build/dist/android-sdk_linux-x86-"$BUILD_VARIANT".zip "$pkgdir"/opt/android-sdk |
||
84 | } |
||
85 | </code></pre> |
||
86 | |||
87 | The build script has been tested on trisquel using this script |
||
88 | <pre><code class="shell"> |
||
89 | #!/bin/env bash |
||
90 | |||
91 | # Source the PKGBUILD file |
||
92 | . APKBUILD |
||
93 | |||
94 | # Set environment variables |
||
95 | if [ -z "$pkgver" ] || [ -z "$_pkgrev" ]; then |
||
96 | echo "Error: pkgver and/or _pkgrev not set in PKGBUILD" |
||
97 | exit 1 |
||
98 | fi |
||
99 | |||
100 | # Check if required Ubuntu packages are available, install them if not |
||
101 | sudo apt-get update |
||
102 | for pkg in bison flex git gnupg gperf libx11-dev libxml2 libxslt1-dev libgl1-mesa-dev libncurses5-dev python3 repo rsync unzip openssh-client; do |
||
103 | if ! dpkg -s $pkg &>/dev/null; then |
||
104 | echo "Installing $pkg..." |
||
105 | sudo apt-get install -y $pkg |
||
106 | fi |
||
107 | done |
||
108 | |||
109 | # Run the prepare, build, and package functions |
||
110 | prepare |
||
111 | build |
||
112 | package |
||
113 | |||
114 | # Save the SHA256 of the zip |
||
115 | sha256sum=$(sha256sum "$pkgdir"/opt/android-sdk/android-sdk_linux-x86-"$BUILD_VARIANT".zip | cut -d' ' -f1) |
||
116 | echo "SHA256 of android-sdk: $sha256sum" |
||
117 | echo "$sha256sum" >android-sdk.sha256 |
||
118 | |||
119 | </code></pre> |
||
120 | |||
121 | |||
122 | |||
123 | **Tooling:** |
||
124 | |||
125 | We either write the cmake files by hand or to utilize Bear, a tool that generates a compilation database for clang tooling, to aid in the creation of the CMake files. Bear can generate a JSON compilation database during the build process when make is called, which will help us to port the build process to cmake, as the JSON complilation database will contain all the files, that where required for building the sdk |
||
126 | |||
127 | **Next Steps:** |
||
128 | |||
129 | * Evaluate the feasibility of building the Android SDK with CMake |
||
130 | * Create a merge request to integrate the CMake build system into the Android repository |
||
131 | * Collaborate with the community to write the necessary CMake files |
||
132 | |||
133 | **Help Wanted:** |
||
134 | |||
135 | If you have experience with CMake and Android build systems, we would appreciate your help in writing the CMake files and integrating the new build system. Your contributions will be invaluable in helping us create a FOSS version of the Android SDK. |
||
136 | |||
137 | [[https://github.com/nmeum/android-tools]] |
||
138 | [[https://github.com/rizsotto/Bear]] |