unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Marius Bakke <mbakke@fastmail.com>
To: Julien Lepiller <julien@lepiller.eu>, 26522@debbugs.gnu.org
Subject: bug#26522: gnu: Add adb
Date: Sat, 15 Apr 2017 20:02:52 +0200	[thread overview]
Message-ID: <87a87hmtv7.fsf@fastmail.com> (raw)
In-Reply-To: <20170415183146.45f95eda@lepiller.eu>

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

Julien Lepiller <julien@lepiller.eu> writes:

> Hi guix,
>
> here is an updated version of Marius' patch mixed with my own. It
> updates our patches to the latest 7_1_2.rc6, adapts to some changes
> since last version, and fixes the build of adb.

Wahoo! :)

I was *just* thinking yesterday that I should fix up this package ASAP.
Thanks a lot for beating me to it!

[...]

> +(define liblog
> +  (package
> +    (name "liblog")
> +    (version (android-platform-version))
> +    (source (android-platform-system-core version))
> +    (build-system gnu-build-system)
> +    (arguments
> +     `(#:tests? #f ; TODO.
> +       #:make-flags '("CC=gcc")
> +       #:phases
> +       (modify-phases %standard-phases
> +         (add-after 'unpack 'enter-source
> +           (lambda _ (chdir "liblog") #t))
> +         (add-after 'enter-source 'create-Makefile
> +           (lambda _
> +             ;; No useful makefile is shipped, so we create one.
> +             (with-output-to-file "Makefile"
> +               (lambda _
> +                 (display
> +                  (string-append
> +                   "NAME = liblog\n"
> +                   "SOURCES = log_event_list.c log_event_write.c"
> +                   " logger_write.c config_write.c logger_name.c"
> +                   " logger_lock.c fake_log_device.c fake_writer.c"
> +                   " event_tag_map.c\n"
> +
> +                   "CFLAGS += -fvisibility=hidden -fPIC\n"
> +                   "CPPFLAGS += -I../include -DFAKE_LOG_DEVICE=1"
> +                   ;; Keep these two in sync with "liblog/Android.bp".
> +                   " -DLIBLOG_LOG_TAG=1005"
> +                   " -DSNET_EVENT_LOG_TAG=1397638484\n"
> +                   "LDFLAGS += -shared -Wl,-soname,$(NAME).so.0 -lpthread\n"
> +
> +                   "build: $(SOURCES)\n"
> +                   "	$(CC) $^ -o $(NAME).so.0 $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)\n"))))))

I'm actually not sure what the return value of "display" is and the
Guile manual does not mention. I'd end this on a #t just to be "safe".

> +         (delete 'configure)
> +         (replace 'install
> +           (lambda* (#:key outputs #:allow-other-keys)
> +             (let* ((out (assoc-ref outputs "out"))
> +                    (lib (string-append out "/lib")))
> +               (install-file "liblog.so.0" lib)
> +               (with-directory-excursion lib
> +                 (symlink "liblog.so.0" "liblog.so"))
> +               #t))))))
> +    (home-page "https://developer.android.com/")
> +    (synopsis "Logging library from the Android platform.")
> +    (description "@code{liblog} represents an interface to the volatile Android
> +Logging system for NDK (Native) applications and libraries and contain
> +interfaces for either writing or reading logs.  The log buffers are divided up
> +in Main, System, Radio and Events sub-logs.")
> +    (license license:asl2.0)))
> +
> +(define libbase
> +  (package
> +    (name "libbase")
> +    (version (android-platform-version))
> +    (source (origin
> +              (inherit (android-platform-system-core version))
> +              (patches
> +               (search-patches "libbase-use-own-logging.patch"
> +                               "libbase-fix-includes.patch"))))
> +    (build-system gnu-build-system)
> +    (arguments
> +     `(#:tests? #f ; TODO.
> +       #:phases
> +       (modify-phases %standard-phases
> +         (add-after 'unpack 'enter-source
> +           (lambda _ (chdir "base") #t))
> +         (add-after 'enter-source 'create-Makefile
> +           (lambda _
> +             ;; No useful makefile is shipped, so we create one.
> +             (with-output-to-file "Makefile"
> +               (lambda _
> +                 (display
> +                  (string-append
> +                   "NAME = libbase\n"
> +                   "SOURCES = file.cpp logging.cpp parsenetaddress.cpp"
> +                   " stringprintf.cpp strings.cpp errors_unix.cpp\n"
> +
> +                   "CXXFLAGS += -std=gnu++11 -fPIC\n"
> +                   "CPPFLAGS += -Iinclude -I../include\n"
> +                   "LDFLAGS += -shared -Wl,-soname,$(NAME).so.0"
> +                   " -L.. -llog\n"
> +
> +                   "build: $(SOURCES)\n"
> +                   "	$(CXX) $^ -o $(NAME).so.0 $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS)\n"
> +                   ))))))

Same here, and also move the parens to the previous line. Possibly also
break it into two lines :)

> +         (delete 'configure)
> +         (replace 'install
> +           (lambda* (#:key outputs #:allow-other-keys)
> +             (let* ((out (assoc-ref outputs "out"))
> +                    (lib (string-append out "/lib")))
> +               (install-file "libbase.so.0" lib)
> +               (with-directory-excursion lib
> +                 (symlink "libbase.so.0" "libbase.so"))
> +               (copy-recursively "include" out)
> +               #t))))))
> +    (inputs `(("liblog" ,liblog)))
> +    (home-page "https://developer.android.com/")
> +    (synopsis "Android platform base library")
> +    (description "@code{libbase} is a library in common use by the
> +various Android core host applications.")
> +    (license license:asl2.0)))
> +
> +(define libcutils
> +  (package
> +    (name "libcutils")
> +    (version (android-platform-version))
> +    (source (android-platform-system-core version))
> +    (build-system gnu-build-system)
> +    (arguments
> +     `(#:tests? #f ; TODO.
> +       #:phases
> +       (modify-phases %standard-phases
> +         (add-after 'unpack 'enter-source
> +           (lambda _ (chdir "libcutils") #t))
> +         (add-after 'enter-source 'create-Makefile
> +           (lambda _
> +             ;; No useful makefile is shipped, so we create one.
> +             (with-output-to-file "Makefile"
> +               (lambda _
> +                 (display
> +                  (string-append
> +                   "NAME = libcutils\n"
> +                   "SOURCES = load_file.o socket_local_client_unix.o"
> +                   " socket_loopback_client_unix.o socket_network_client_unix.o"
> +                   " socket_loopback_server_unix.o socket_local_server_unix.o"
> +                   " sockets_unix.o socket_inaddr_any_server_unix.o"
> +                   " sockets.o\n"
> +                   "CC = gcc\n"
> +
> +                   "CFLAGS += -fPIC\n"
> +                   "CXXFLAGS += -std=gnu++11 -fPIC\n"
> +                   "CPPFLAGS += -Iinclude -I../include\n"
> +                   "LDFLAGS += -shared -Wl,-soname,$(NAME).so.0\n"
> +
> +                   "build: $(SOURCES)\n"
> +                   "	$(CXX) $^ -o $(NAME).so.0 $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS)\n"
> +                   ))))))

...and here.

> +         (delete 'configure)
> +         (replace 'install
> +           (lambda* (#:key outputs #:allow-other-keys)
> +             (let* ((out (assoc-ref outputs "out"))
> +                    (lib (string-append out "/lib")))
> +               (install-file "libcutils.so.0" lib)
> +               (with-directory-excursion lib
> +                 (symlink "libcutils.so.0" "libcutils.so"))
> +               #t))))))
> +    (home-page "https://developer.android.com/")
> +    (synopsis "Android platform c utils library")
> +    (description "@code{libcutils} is a library in common use by the
> +various Android core host applications.")
> +    (license license:asl2.0)))
> +
> +(define-public adb
> +  (package
> +    (name "adb")
> +    (version (android-platform-version))
> +    (source (origin
> +              (inherit (android-platform-system-core version))
> +              (patches
> +               (search-patches "libbase-use-own-logging.patch"
> +                               "libbase-fix-includes.patch"))))
> +    (build-system gnu-build-system)
> +    (arguments
> +     `(#:phases
> +       (modify-phases %standard-phases
> +         (add-after 'unpack 'enter-source
> +           (lambda _ (chdir "adb") #t))
> +         (add-before 'build 'fix-clang
> +           (lambda _
> +             (substitute* "adb_client.h"
> +                   (("_Nonnull") "")
> +                   (("_Nullable") ""))))

Can you add a comment explaining what this does? From the phase name,
I'd guess it removes a clang dependency, but it's not clear how or why.
Also check indentation here and end with an explicit #t.

> +         (add-before 'build 'fix-main
> +           (lambda _
> +             (copy-file "client/main.cpp" "adb_main.cpp")))

This should also end on a #t. A comment would be nice too if you know
why it's needed, what an odd build step.

> +         (add-after 'enter-source 'create-Makefile
> +           (lambda* (#:key outputs #:allow-other-keys)
> +             ;; No useful makefile is shipped, so we create one.
> +             (with-output-to-file "Makefile"
> +               (lambda _
> +                 (display
> +                  (string-append
> +                   ;; Common for all components.
> +                   "CXXFLAGS += -std=gnu++14 -fpermissive\n"
> +                   "CPPFLAGS += -I../include -I../base/include -I. -DADB_HOST=1 "
> +                   "-DADB_REVISION='\"" ,version "\"' -fPIC\n"
> +                   "LDFLAGS += -lcrypto -lpthread -lbase -lcutils -L. -ladb\n"
> +
> +                   ;; Libadb specifics.
> +                   "LIBADB_SOURCES = adb.cpp adb_auth.cpp adb_io.cpp "
> +                   "adb_listeners.cpp adb_trace.cpp adb_utils.cpp fdevent.cpp "
> +                   "sockets.cpp transport.cpp transport_local.cpp transport_usb.cpp "
> +                   "get_my_path_linux.cpp sysdeps_unix.cpp usb_linux.cpp "
> +                   "adb_auth_host.cpp diagnose_usb.cpp services.cpp "
> +                   "shell_service_protocol.cpp bugreport.cpp line_printer.cpp\n"
> +
> +                   "LIBADB_LDFLAGS += -shared -Wl,-soname,libadb.so.0 "
> +                   "-lcrypto -lpthread -lbase\n"
> +
> +                   ;; Adb specifics.
> +                   "ADB_SOURCES = adb_main.cpp console.cpp commandline.cpp "
> +                   "adb_client.cpp file_sync_client.cpp\n"
> +                   "ADB_LDFLAGS += -Wl,-rpath=" (assoc-ref outputs "out") "/lib\n"
> +
> +                   "build: libadb $(ADB_SOURCES)\n"
> +                   "	$(CXX) $(ADB_SOURCES) -o adb $(CXXFLAGS) $(CPPFLAGS) "
> +                   "$(ADB_LDFLAGS) $(LDFLAGS)\n"
> +
> +                   "libadb: $(LIBADB_SOURCES)\n"
> +                   "	$(CXX) $^ -o libadb.so.0 $(CXXFLAGS) $(CPPFLAGS) "
> +                   "$(LIBADB_LDFLAGS)\n"
> +                   "	ln -sv libadb.so.0 libadb.so\n"
> +                   ))))))

...lonely parens here too (`lint` should complain about this) :)

LGTM with these fixes! Thank you!

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

  reply	other threads:[~2017-04-15 18:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-15 16:31 bug#26522: gnu: Add adb Julien Lepiller
2017-04-15 18:02 ` Marius Bakke [this message]
2017-04-16  9:22   ` Julien Lepiller
2017-04-16 21:54     ` Marius Bakke
2017-04-17  8:40       ` Julien Lepiller
2017-04-17 15:09         ` Marius Bakke
2017-04-18  8:21           ` Ludovic Courtès
2017-04-20  8:33 ` bug#26522: julien lepiller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a87hmtv7.fsf@fastmail.com \
    --to=mbakke@fastmail.com \
    --cc=26522@debbugs.gnu.org \
    --cc=julien@lepiller.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).