aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2022-06-29 18:23:54 +0200
committerDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2022-07-26 17:29:13 +0200
commit43983cdb532303224be896ec37e67fa515d87e3e (patch)
tree1363b7729fc30967f8e9fd56bbd48867bf7ecf66
parente4840993bbc77d640cb2d4c866e8e60e2deb27a9 (diff)
downloadhardware_replicant_libsamsung-ipc-43983cdb532303224be896ec37e67fa515d87e3e.tar.gz
hardware_replicant_libsamsung-ipc-43983cdb532303224be896ec37e67fa515d87e3e.tar.bz2
hardware_replicant_libsamsung-ipc-43983cdb532303224be896ec37e67fa515d87e3e.zip
Android.mk: fix missing files and build local-modules in guix.scm
In the commit 5f97bb60091a1c4d4335fd02eff2b01e27e7a881 ("tools: ipc-modem: Move log functions in their own file"), we added new files for ipc-modem. That commit was then tested with scripts/guix.scm, which at the time didn't build ipc-modem, so the issue slipped through the automatic tests. So in addition of adding back these missing files in Android.mk, this commit also makes guix.scm actually build all the local modules. This was not done before as it required some extensive work. That work consisted in adding code to retrieve the LOCAL_MODULEs from the Android.mk, and passing that to the package build and install procedures (which had to be converted into Guix's G-Expressions (gexp)[1] to be able to more cleanly get that data). In addition, making contributions to android-make-stub was needed as well. Having some of the parsing done in the guix.scm file instead of android-make-stub is needed because otherwise the android-make-stub design would probably need to be redone: android-make-stub consists of some Makefiles that are passed to make via -f, and that in turn these Makefiles include the Android.mk in the local directory. This doesn't make it possible to handle dependencies cleanly, as to do that, the Android.mk would need to first be parsed through another mean to understand the dependencies tree, and then to build the local modules in order. And that would need to be done in some compatible way not to break existing users of android-make-stub (like Guix that builds some Android packages with it). [1]https://guix.gnu.org/en/manual/devel/en/guix.html#G_002dExpressions Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
-rw-r--r--Android.mk8
-rw-r--r--scripts/guix.scm137
2 files changed, 112 insertions, 33 deletions
diff --git a/Android.mk b/Android.mk
index 663de28..b51f9ba 100644
--- a/Android.mk
+++ b/Android.mk
@@ -186,7 +186,9 @@ include $(LOCAL_PATH)/android_versions.mk
LOCAL_MODULE := ipc-modem
LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := tools/ipc-modem/ipc-modem.c
+LOCAL_SRC_FILES := \
+ tools/ipc-modem/ipc-modem.c \
+ tools/ipc-modem/ipc-modem-log.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include $(LOCAL_PATH)/tools/include/glibc
LOCAL_SHARED_LIBRARIES := libsamsung-ipc
@@ -202,7 +204,9 @@ include $(LOCAL_PATH)/android_versions.mk
LOCAL_MODULE := ipc-modem-static
LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := tools/ipc-modem/ipc-modem.c
+LOCAL_SRC_FILES := \
+ tools/ipc-modem/ipc-modem.c \
+ tools/ipc-modem/ipc-modem-log.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include $(LOCAL_PATH)/tools/include/glibc
LOCAL_STATIC_LIBRARIES := libsamsung-ipc
diff --git a/scripts/guix.scm b/scripts/guix.scm
index 19d6221..8d1c811 100644
--- a/scripts/guix.scm
+++ b/scripts/guix.scm
@@ -44,6 +44,8 @@
(use-modules
(ice-9 popen)
(ice-9 rdelim)
+ (ice-9 regex)
+ (ice-9 textual-ports)
(sxml ssax input-parse)
((guix licenses) #:prefix license:)
(guix build-system android-ndk)
@@ -51,8 +53,12 @@
(guix gexp)
(guix git-download)
(guix packages)
+ (guix profiles)
+ (guix transformations)
+ (gnu packages)
(gnu packages android)
(gnu packages autotools)
+ (gnu packages base)
(gnu packages commencement)
(gnu packages curl)
(gnu packages disk)
@@ -64,6 +70,43 @@
(gnu packages tls)
(gnu packages valgrind))
+;; We need a more recent version of android-make-stub as it now
+;; support passing LOCAL_MODULE= to make to build specific local
+;; modules. This is needed because android-make-stub doesn't handle
+;; dependencies, so we need to make sure that libsamsung-ipc is built
+;; first. In addition we need a fix to make the applications that
+;; depend on libsamsung-ipc find libsamsung-ipc's includes directory.
+(define with-fixed-android-make-stub
+ (options->transformation
+ '((with-commit
+ .
+ "android-make-stub=4bc0e068c32fe525741da00af064ddc079de7e4b"))))
+
+(define (parse-android.mk port modules-list)
+ (let* ((line (read-line port)))
+ (if (not (eof-object? line))
+ (let* ((line-parts (string-split line #\ )))
+ (if (string=? (car line-parts) "LOCAL_MODULE")
+ (if (not (string=? (list-ref line-parts 2) "libsamsung-ipc"))
+ (if (string=? modules-list "")
+ (parse-android.mk
+ port
+ (list-ref line-parts 2))
+ (parse-android.mk
+ port
+ (string-append modules-list
+ " " (list-ref line-parts 2))))
+ (parse-android.mk port modules-list))
+ (parse-android.mk port modules-list)))
+ modules-list)))
+
+(define android-local-modules-list
+ (let* ((port (open-input-file
+ "./Android.mk"))
+ (local-modules (parse-android.mk port "")))
+ (close-input-port port)
+ (string-split local-modules #\ )))
+
(define %common-strict-cflags
(let* ((port (open-input-pipe
"./strict-cflags.sh"))
@@ -87,6 +130,56 @@
(dirname (dirname (current-filename)))
#:recursive? #t))
+(define android-make
+ #~(lambda (target android-local-modules)
+ (lambda*
+ (#:key inputs
+ make-flags
+ native-inputs
+ outputs
+ #:allow-other-keys)
+ (substitute*
+ "Android.mk"
+ (("BUILD_SHARED_LIBRARY")
+ "BUILD_HOST_SHARED_LIBRARY")
+ (("BUILD_EXECUTABLE") "BUILD_HOST_EXECUTABLE"))
+ ((assoc-ref %standard-phases target)
+ #:inputs inputs
+ #:outputs outputs
+ ;; TODO: use pkg-config for -lssl -lcrypto
+ #:make-flags
+ (append
+ make-flags
+ '("LDFLAGS=-lssl -lcrypto"
+ "LOCAL_MODULE=libsamsung-ipc"
+ "SO=libsamsung-ipc.so")))
+ (map-in-order
+ (lambda (local-module)
+ ((assoc-ref %standard-phases target)
+ #:inputs inputs
+ #:outputs outputs
+ ;; TODO: use pkg-config for -lssl -lcrypto
+ #:make-flags
+ (append
+ make-flags
+ (list
+ (string-append
+ "LDFLAGS=-Wl,-rpath="
+ #$output
+ "/lib -lssl -lcrypto -L .")
+ (string-append "LOCAL_MODULE="
+ local-module)))))
+ android-local-modules))))
+
+(define android-phases
+ #~(modify-phases
+ %standard-phases
+ (delete 'bootstrap)
+ (replace 'build
+ (#$android-make 'build '#$android-local-modules-list))
+ (replace 'install
+ (#$android-make 'install '#$android-local-modules-list))))
+
(define-public libsamsung-ipc
(package
(name "libsamsung-ipc")
@@ -140,20 +233,13 @@ found in many Samsung smartphones and tablets.")
(build-system android-ndk-build-system)
(inputs
`(("android-libutils" ,android-libutils)
- ("libcrypto" ,openssl)))
+ ("libcrypto" ,openssl)
+ ("libcurl" ,curl)))
(native-inputs '())
(arguments
- `(#:phases
- (modify-phases %standard-phases
- (delete 'bootstrap)
- (add-before 'build 'patch-host
- (lambda _
- (substitute* "Android.mk"
- (("BUILD_SHARED_LIBRARY") "BUILD_HOST_SHARED_LIBRARY")
- (("BUILD_STATIC_LIBRARY") "BUILD_HOST_STATIC_LIBRARY")
- (("BUILD_STATIC_EXECUTABLE") "BUILD_HOST_STATIC_EXECUTABLE"))
- #t)))
- #:make-flags (list ,%common-strict-cflags)))))
+ (list
+ #:make-flags #~(list #$%common-strict-cflags #$%clang-strict-cflags)
+ #:phases android-phases))))
(define-public libsamsung-ipc-gcc-autotools
(package
@@ -205,24 +291,13 @@ found in many Samsung smartphones and tablets.")
(inputs
`(("android-libutils" ,android-libutils)
("libcrypto" ,openssl)
+ ("libcurl" ,curl)
("clang" ,clang)))
(native-inputs '())
(arguments
- `(#:phases
- (modify-phases %standard-phases
- (delete 'bootstrap)
- (add-before 'build 'patch-host
- (lambda _
- (substitute* "Android.mk"
- (("BUILD_SHARED_LIBRARY") "BUILD_HOST_SHARED_LIBRARY")
- (("BUILD_STATIC_LIBRARY") "BUILD_HOST_STATIC_LIBRARY")
- (("BUILD_STATIC_EXECUTABLE") "BUILD_HOST_STATIC_EXECUTABLE"))
- #t))
- (add-after 'patch-host 'prepare-build-environment
- (lambda* (#:key inputs #:allow-other-keys)
- (setenv "CC" "clang")
- #t)))
- #:make-flags (list ,%common-strict-cflags ,%clang-strict-cflags)))))
+ (list
+ #:make-flags #~(list #$%common-strict-cflags #$%clang-strict-cflags)
+ #:phases android-phases))))
;; Combinaisons:
;; +--------------------------------+----------+----------+--------------+--------------+
@@ -241,7 +316,7 @@ found in many Samsung smartphones and tablets.")
;; +--------------------------------+----------+----------+--------------+--------------+
(list libsamsung-ipc
- libsamsung-ipc-gcc-android
- libsamsung-ipc-gcc-autotools
- libsamsung-ipc-clang-android
- libsamsung-ipc-clang-autotools)
+ (with-fixed-android-make-stub libsamsung-ipc-clang-android)
+ (with-fixed-android-make-stub libsamsung-ipc-gcc-android)
+ libsamsung-ipc-clang-autotools
+ libsamsung-ipc-gcc-autotools)