help-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Android.mk build system limitations


From: Denis 'GNUtoo' Carikli
Subject: Android.mk build system limitations
Date: Wed, 6 Jul 2022 17:20:27 +0200

Hi,

I'm maintaining a library that can be used in both Android and
GNU/Linux. To do quick build tests in various configurations before
pushing commits, I use a guix.scm[1] file.

With that I'm also testing the build with the Android.mk to find
potential issues.

There are several limitations with the Android.mk build system in Guix.
A well known one is the inability to handle cross compilation, so
people using that build system typically work around that with
something like that[2]:
>        (modify-phases %standard-phases
>          (add-before 'build 'patch-host
>            (lambda _
>              ;; TODO: Cross-compile.
>              (substitute* "Android.mk"
>               (("BUILD_STATIC_LIBRARY") "BUILD_HOST_STATIC_LIBRARY"))
>              #t)))

However I found an issue that is more problematic: this build system
expects an Android.mk with a single target (which is defined
with "LOCAL_MODULE :=" in the Android.mk). 

Until now I didn't implement that in my guix.scm and only built the
library and not the associated utilities.

But then recently I found that the build broke in Android because I
forgot to add some source code files for one of the utilities in the
Android.mk file, so I now really want to build the utilities too in
that guix.scm with the Android.mk build system.

With some help on #guix on liberachat, I managed to run the make
multiple times, and to pass it a list of local-modules to build.

The new build function looks like that[3]:
> (replace 'build
>  (lambda*
>   (#:key inputs make-flags native-inputs outputs #:allow-other-keys)
>    (for-each
>     (lambda (arg)
>      (substitute* "Android.mk"
>       (("BUILD_EXECUTABLE")
>         "BUILD_HOST_EXECUTABLE"))
>       ((assoc-ref %standard-phases 'build)
>        #:make-flags (append make-flags
>                      (list (string-append "LOCAL_MODULE=" arg)))))
>                      ,local-modules)
>   #t))

And the new installation function looks really similar:
> (replace 'install
>  (lambda*
>   (#:key inputs make-flags native-inputs outputs #:allow-other-keys)
>          (for-each
>            (lambda (arg)
>              ((assoc-ref %standard-phases 'install)
>               #:inputs inputs
>               #:outputs outputs
>               #:make-flags
>               (append make-flags
>                       (list (string-append "LOCAL_MODULE=" arg)))))
>            ,local-modules)
>           #t))

But it then ends up building the first local-module in the local-modules
list, many times, and install it with different names.

After building, we can see that https-send-sms was built correctly:
> $ 
> /gnu/store/[...]-libsamsung-ipc-gcc-android-0.0-HEAD.c4d664a/bin/https-send-sms
>  
> Usage:
> /gnu/store/[...]-libsamsung-ipc-gcc-android-0.0-HEAD.c4d664a/bin/https-send-sms
> free-mobile <username> <token> <message>
> 
> Example:
>       
> /gnu/store/[...]-libsamsung-ipc-gcc-android-0.0-HEAD.c4d664a/bin/https-send-sms
> free-mobile "12345678" "1234abcdEFGH" "hello world!"
> $ /gnu/store/[...]-libsamsung-ipc-gcc-android-0.0-HEAD.c4d664a/bin/ipc-test

But the same source code was also used to build ipc-test
> Usage: 
> /gnu/store/[...]-libsamsung-ipc-gcc-android-0.0-HEAD.c4d664a/bin/ipc-test 
> free-mobile <username> <token> <message>
> 
> Example:
>       
> /gnu/store/[...]-libsamsung-ipc-gcc-android-0.0-HEAD.c4d664a/bin/ipc-test 
> free-mobile "12345678" "1234abcdEFGH" "hello world!"

And if ipc-test source code was used we would end up with something
like that instead:
> $ ipc-test
> Creating client failed

So I'm a bit confused on how to solve this issue. I'm also not sure if
it needs to be solved in Guix or in the underlying Makefiles that
makes it possible to use Android.mk files under GNU/Linux.

I'm writing that mail in the hope that people who knows better the
implementation of the Android.mk build system in Guix would have
pointers to help me solve that issue.

References:
-----------
[1]https://git.replicant.us/replicant/hardware_replicant_libsamsung-ipc/plain/scripts/guix.scm
[2]from android-safe-iop from gnu/packages/android.scm in Guix
[3]https://git.replicant.us/contrib/GNUtoo/replicant/hardware_replicant_libsamsung-ipc/plain/scripts/guix.scm?h=c4d664ae71eb65415d799ada8018cfa49f6fb7fb

Denis.

Attachment: pgpcDvCvTLjJh.pgp
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]