all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Android.mk build system limitations
@ 2022-07-06 15:20 Denis 'GNUtoo' Carikli
  2022-07-09 12:57 ` Denis 'GNUtoo' Carikli
  0 siblings, 1 reply; 4+ messages in thread
From: Denis 'GNUtoo' Carikli @ 2022-07-06 15:20 UTC (permalink / raw)
  To: help-guix, Julien Lepiller

[-- Attachment #1: Type: text/plain, Size: 4346 bytes --]

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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-07-11  7:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-06 15:20 Android.mk build system limitations Denis 'GNUtoo' Carikli
2022-07-09 12:57 ` Denis 'GNUtoo' Carikli
2022-07-09 19:17   ` Denis 'GNUtoo' Carikli
2022-07-11  7:22     ` Denis 'GNUtoo' Carikli

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.