1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016 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-system android-ndk)
20 #:use-module (guix search-paths)
21 #:use-module (guix store)
22 #:use-module (guix utils)
23 #:use-module (guix derivations)
24 #:use-module (guix packages)
25 #:use-module (guix build-system)
26 #:use-module (guix build-system gnu)
27 #:use-module (ice-9 match)
28 #:use-module (srfi srfi-26)
29 #:export (android-ndk-build-system))
31 (define %android-ndk-build-system-modules
32 ;; Build-side modules imported by default.
33 `((guix build android-ndk-build-system)
35 ,@%gnu-build-system-modules))
37 (define* (android-ndk-build store name inputs
41 (phases '(@ (guix build android-ndk-build-system)
46 (system (%current-system))
48 (imported-modules %android-ndk-build-system-modules)
49 (modules '((guix build android-ndk-build-system)
51 "Build SOURCE using Android NDK, and with INPUTS."
54 (use-modules ,@modules)
55 (android-ndk-build #:name ,name
56 #:source ,(match (assoc-ref inputs "source")
57 (((? derivation? source))
58 (derivation->output-path source))
64 #:test-target ,test-target
67 #:make-flags (cons* "-f"
69 (derivation->output-path
70 (car (assoc-ref inputs "android-build")))
71 "/share/android/build/core/main.mk")
74 #:search-paths ',(map search-path-specification->sexp
76 #:inputs %build-inputs)))
78 (define guile-for-build
81 (package-derivation store guile system #:graft? #f))
83 (let* ((distro (resolve-interface '(gnu packages commencement)))
84 (guile (module-ref distro 'guile-final)))
85 (package-derivation store guile system #:graft? #f)))))
87 (build-expression->derivation store name builder
90 #:modules imported-modules
92 #:guile-for-build guile-for-build))
95 #:key source inputs native-inputs outputs system target
98 "Return a bag for NAME."
100 (define private-keywords
101 '(#:source #:target #:inputs #:native-inputs #:outputs))
103 (and (not target) ;; TODO: support cross-compilation
108 (host-inputs `(,@(if source
109 `(("source" ,source))
113 ;; Keep the standard inputs of 'gnu-build-system'
114 ,@(standard-packages)))
115 (build-inputs `(("android-build" ,(module-ref (resolve-interface '(gnu packages android)) 'android-make-stub))
116 ("android-googletest" ,(module-ref (resolve-interface '(gnu packages android)) 'android-googletest))
119 (build android-ndk-build)
120 (arguments (strip-keyword-arguments private-keywords arguments)))))
122 (define android-ndk-build-system
126 "Android NDK build system, to build Android NDK packages")