1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2018 Danny Milosavljevic <dannym@scratchpost.org>
4 ;;; This file is part of GNU Guix.
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19 (define-module (guix build android-ndk-build-system)
20 #:use-module ((guix build gnu-build-system) #:prefix gnu:)
21 #:use-module (guix build syscalls)
22 #:use-module (guix build utils)
23 #:use-module (ice-9 popen)
24 #:use-module (ice-9 rdelim)
25 #:use-module (ice-9 ftw)
26 #:use-module (ice-9 format)
27 #:use-module (ice-9 match)
28 #:use-module (rnrs io ports)
29 #:use-module (srfi srfi-1)
30 #:use-module (srfi srfi-26)
31 #:export (%standard-phases
36 ;; Builder-side code of the Android NDK build system.
40 (define* (configure #:key inputs outputs #:allow-other-keys)
41 (let ((library-directories (filter-map (match-lambda
43 (if (eq? 'directory (stat:type (stat path)))
51 (map (cut string-append "-I " <> "/include") library-directories)
54 (string-append "-L . "
57 (string-append "-L " x "/lib" " -Wl,-rpath=" x "/lib"))
62 (define* (install #:key inputs outputs (make-flags '()) #:allow-other-keys)
63 (let ((out (assoc-ref outputs "out")))
64 (apply invoke "make" "install"
65 (string-append "prefix=" out)
69 (define* (check #:key target inputs outputs (tests? (not target)) (make-flags '()) #:allow-other-keys)
72 (apply invoke "make" "check" make-flags)
73 (when (and (file-exists? "tests") tests?)
74 (with-directory-excursion "tests"
75 (apply invoke "make" "check" make-flags))))
76 (format #t "test suite not run~%"))
79 (define %standard-phases
80 (modify-phases gnu:%standard-phases
81 (replace 'configure configure)
82 (replace 'install install)
83 (replace 'check check)))
85 (define* (android-ndk-build #:key inputs (phases %standard-phases)
86 #:allow-other-keys #:rest args)
87 "Build the given Android NDK package, applying all of PHASES in order."
88 (apply gnu:gnu-build #:inputs inputs #:phases phases args))