GuixBuildSystem » History » Version 1
  Denis 'GNUtoo'  Carikli, 07/27/2020 04:52 PM 
  Initial import
| 1 | 1 | Denis 'GNUtoo' Carikli | h1. GuixBuildSystem | 
|---|---|---|---|
| 2 | |||
| 3 | Guix currently uses "android-make-stub":https://github.com/daym/android-make-stub.git to build Android software using Android.mk. | ||
| 4 | |||
| 5 | There are some comments in Guix source code that cross compilation isn't supported for the android-ndk build system. | ||
| 6 | |||
| 7 | Practically speaking it means that Guix won't be able to build any BUILD_SHARED_LIBRARY, BUILD_SHARED_LIBRARY or BUILD_STATIC_EXECUTABLE, however building the HOST_* counterpart works fine. | ||
| 8 | |||
| 9 | To workaround that they simply do replace them in the Android.mk during the build procedude: | ||
| 10 | * BUILD_SHARED_LIBRARY becomes BUILD_HOST_SHARED_LIBRARY | ||
| 11 | * BUILD_SHARED_LIBRARY becomes BUILD_HOST_STATIC_LIBRARY | ||
| 12 | * BUILD_STATIC_EXECUTABLE becomes BUILD_HOST_STATIC_EXECUTABLE | ||
| 13 | |||
| 14 | For instance we have: | ||
| 15 | <pre> | ||
| 16 | (arguments | ||
| 17 | `(#:phases | ||
| 18 | (modify-phases %standard-phases | ||
| 19 | (delete 'bootstrap) | ||
| 20 | (add-before 'build 'patch-host | ||
| 21 | (lambda _ | ||
| 22 | ;; TODO: Cross-compile. | ||
| 23 | (substitute* "Android.mk" | ||
| 24 | 						(("BUILD_SHARED_LIBRARY") "BUILD_HOST_SHARED_LIBRARY") | ||
| 25 | 						;; (("BUILD_STATIC_LIBRARY") "BUILD_HOST_STATIC_LIBRARY") | ||
| 26 | 						;; (("BUILD_STATIC_EXECUTABLE") "BUILD_HOST_STATIC_EXECUTABLE") | ||
| 27 | ) | ||
| 28 | #t)) | ||
| 29 | ))) | ||
| 30 | </pre> | ||
| 31 | |||
| 32 | Here the (delete 'bootstrap) is because the build is done in several phases, and here the bootstrap phase wasn't overriden by the android-ndk build system yet. As a result it tried to run autogen.sh. That might be because in libsamsung-ipc there is both an android build system and an autotools based one. | ||
| 33 | |||
| 34 | h2. Example | ||
| 35 | |||
| 36 | <pre> | ||
| 37 | ;;; Copyright © 2020 Denis Carikli <GNUtoo@cyberdimension.org> | ||
| 38 | ;;; | ||
| 39 | ;;; This file is not part of GNU Guix (yet). | ||
| 40 | ;;; | ||
| 41 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | ||
| 42 | ;;; under the terms of the GNU General Public License as published by | ||
| 43 | ;;; the Free Software Foundation; either version 3 of the License, or (at | ||
| 44 | ;;; your option) any later version. | ||
| 45 | ;;; | ||
| 46 | ;;; GNU Guix is distributed in the hope that it will be useful, but | ||
| 47 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 48 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 49 | ;;; GNU General Public License for more details. | ||
| 50 | ;;; | ||
| 51 | ;;; You should have received a copy of the GNU General Public License | ||
| 52 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | ||
| 53 | |||
| 54 | (define-module (replicant) | ||
| 55 | #:use-module ((guix licenses) #:prefix license:) | ||
| 56 | #:use-module (guix packages) | ||
| 57 | #:use-module (guix git-download) | ||
| 58 | #:use-module (guix build-system android-ndk) | ||
| 59 | #:use-module (guix build-system gnu) | ||
| 60 | #:use-module (gnu packages android) | ||
| 61 | #:use-module (gnu packages autotools) | ||
| 62 | #:use-module (gnu packages pkg-config) | ||
| 63 | #:use-module (gnu packages tls) | ||
| 64 | ) | ||
| 65 | |||
| 66 | (define-public libsamsung-ipc | ||
| 67 | (package | ||
| 68 | (name "libsamsung-ipc") | ||
| 69 | (version "0.1") | ||
| 70 | (source | ||
| 71 | (origin | ||
| 72 | (method git-fetch) | ||
| 73 | (uri (git-reference | ||
| 74 | (url "https://git.replicant.us/replicant/hardware_replicant_libsamsung-ipc.git") | ||
| 75 | (commit "73aa86f31bb004c48c5250ea43cca9ed9d51cb17"))) | ||
| 76 | (file-name (git-file-name name version)) | ||
| 77 | (sha256 (base32 "1wkvkgbckb7cif6lrd8rivh6s4886qa4dw2s433l28h2lh3zmqkb")) | ||
| 78 | ) | ||
| 79 | ) | ||
| 80 | (build-system gnu-build-system) | ||
| 81 | |||
| 82 | (native-inputs | ||
| 83 |     `(("autoreconf" ,autoconf) | ||
| 84 |       ("aclocal" ,automake) | ||
| 85 |       ("libtool" ,libtool) | ||
| 86 |       ("pkgconfig" ,pkg-config) | ||
| 87 | )) | ||
| 88 | |||
| 89 | (inputs | ||
| 90 |     `(("openssl" ,openssl))) | ||
| 91 | |||
| 92 | (synopsis "libsamsung-ipc is a free software implementation of the Samsung IPC modem protocol") | ||
| 93 | (description | ||
| 94 | "libsamsung-ipc is a free software implementation of the Samsung IPC modem protocol, | ||
| 95 | found in many Samsung smartphones and tablets.") | ||
| 96 | (home-page "https://www.replicant.us") | ||
| 97 | (license license:gpl2+) | ||
| 98 | ) | ||
| 99 | ) | ||
| 100 | |||
| 101 | (define-public libsamsung-ipc-android | ||
| 102 | (package | ||
| 103 | (name "libsamsung-ipc-android") | ||
| 104 | (version "0.1") | ||
| 105 | (source | ||
| 106 | (origin | ||
| 107 | (method git-fetch) | ||
| 108 | (uri (git-reference | ||
| 109 | (url "https://git.replicant.us/replicant/hardware_replicant_libsamsung-ipc.git") | ||
| 110 | (commit "73aa86f31bb004c48c5250ea43cca9ed9d51cb17"))) | ||
| 111 | (file-name (git-file-name name version)) | ||
| 112 | (sha256 (base32 "1wkvkgbckb7cif6lrd8rivh6s4886qa4dw2s433l28h2lh3zmqkb")) | ||
| 113 | ) | ||
| 114 | ) | ||
| 115 | (build-system android-ndk-build-system) | ||
| 116 | |||
| 117 | (inputs | ||
| 118 |     `(("android-libutils" ,android-libutils) | ||
| 119 |       ("libcrypto" ,openssl))) | ||
| 120 | |||
| 121 | (arguments | ||
| 122 | `(#:phases | ||
| 123 | (modify-phases %standard-phases | ||
| 124 | (delete 'bootstrap) | ||
| 125 | (add-before 'build 'patch-host | ||
| 126 | (lambda _ | ||
| 127 | ;; TODO: Cross-compile. | ||
| 128 | (substitute* "Android.mk" | ||
| 129 | 						(("BUILD_SHARED_LIBRARY") "BUILD_HOST_SHARED_LIBRARY") | ||
| 130 | 						;; (("BUILD_STATIC_LIBRARY") "BUILD_HOST_STATIC_LIBRARY") | ||
| 131 | 						;; (("BUILD_STATIC_EXECUTABLE") "BUILD_HOST_STATIC_EXECUTABLE") | ||
| 132 | ) | ||
| 133 | #t)) | ||
| 134 | ))) | ||
| 135 | |||
| 136 | (synopsis "libsamsung-ipc is a free software implementation of the Samsung IPC modem protocol") | ||
| 137 | (description | ||
| 138 | "libsamsung-ipc is a free software implementation of the Samsung IPC modem protocol, | ||
| 139 | found in many Samsung smartphones and tablets.") | ||
| 140 | (home-page "https://www.replicant.us") | ||
| 141 | (license license:gpl2+) | ||
| 142 | ) | ||
| 143 | ) | ||
| 144 | |||
| 145 | ;; TODO: This package doesn't compile yet. | ||
| 146 | ;; To make it compile, we would need to: | ||
| 147 | ;; - patch Guix to change (define android-libcutils to | ||
| 148 | ;; (define-public android-libcutils and also do the same for android-liblog. | ||
| 149 | ;; When this is done we can use the following in inputs: | ||
| 150 | ;;   ("android-libcutils" ,android-libcutils) | ||
| 151 | ;;   ("android-liblog" ,android-liblog) | ||
| 152 | ;; - to package libnetutils and libpower | ||
| 153 | ;; - find a way to use headers that are not in LOCAL_SHARED_LIBRARIES like | ||
| 154 | ;; hardware/libhardware_legacy/include and system/core/include | ||
| 155 | |||
| 156 | (define-public libsamsung-ril | ||
| 157 | (package | ||
| 158 | (name "libsamsung-ril") | ||
| 159 | (version "0.1") | ||
| 160 | (source | ||
| 161 | (origin | ||
| 162 | (method git-fetch) | ||
| 163 | (uri (git-reference | ||
| 164 | (url "https://git.replicant.us/replicant/hardware_replicant_libsamsung-ril.git") | ||
| 165 | (commit "181d3e2a85dff24552a29a0cecbca9ac78cba5b7"))) | ||
| 166 | (file-name (git-file-name name version)) | ||
| 167 | (sha256 (base32 "0sjiw7kp9hipkc9smphbzzbmhyf30y0vni94w15vliry381g5ma8")) | ||
| 168 | ) | ||
| 169 | ) | ||
| 170 | (build-system android-ndk-build-system) | ||
| 171 | |||
| 172 | (inputs | ||
| 173 |     `(("android-libutils" ,android-libutils) | ||
| 174 |       ("libsamsung-ipc", libsamsung-ipc) | ||
| 175 |       ("libcrypto" ,openssl))) | ||
| 176 | |||
| 177 | (arguments | ||
| 178 | `(#:phases | ||
| 179 | (modify-phases %standard-phases | ||
| 180 | (delete 'bootstrap) | ||
| 181 | (add-before 'build 'patch-host | ||
| 182 | (lambda _ | ||
| 183 | ;; TODO: Cross-compile. | ||
| 184 | (substitute* "Android.mk" | ||
| 185 | 						(("BUILD_SHARED_LIBRARY") "BUILD_HOST_SHARED_LIBRARY")) | ||
| 186 | #t)) | ||
| 187 | ))) | ||
| 188 | |||
| 189 | (synopsis "libsamsung-ipc is a free software implementation of the Samsung IPC modem protocol") | ||
| 190 | (description | ||
| 191 | "libril implementation for the Samsung IPC modem protocol, found in many Samsung smartphones and tablets.") | ||
| 192 | (home-page "https://www.replicant.us") | ||
| 193 | (license license:gpl2+) | ||
| 194 | ) | ||
| 195 | ) | ||
| 196 | </pre> |