Commit | Line | Data |
---|---|---|
436515cd DM |
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2018 Danny Milosavljevic <dannym@scratchpost.org> | |
3 | ;;; | |
4 | ;;; This file is part of GNU Guix. | |
5 | ;;; | |
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. | |
10 | ;;; | |
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. | |
15 | ;;; | |
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/>. | |
18 | ||
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 | |
32 | android-ndk-build)) | |
33 | ||
34 | ;; Commentary: | |
35 | ;; | |
36 | ;; Builder-side code of the Android NDK build system. | |
37 | ;; | |
38 | ;; Code: | |
39 | ||
40 | (define* (configure #:key inputs outputs #:allow-other-keys) | |
41 | (let ((library-directories (filter-map (match-lambda | |
42 | ((name . path) | |
43 | (if (eq? 'directory (stat:type (stat path))) | |
44 | path | |
45 | #f))) | |
46 | inputs))) | |
47 | (setenv "CC" "gcc") | |
48 | (setenv "CXX" "g++") | |
49 | (setenv "CPPFLAGS" | |
50 | (string-join | |
51 | (map (cut string-append "-I " <> "/include") library-directories) | |
52 | " ")) | |
53 | (setenv "LDFLAGS" | |
54 | (string-append "-L . " | |
55 | (string-join | |
56 | (map (lambda (x) | |
57 | (string-append "-L " x "/lib" " -Wl,-rpath=" x "/lib")) | |
58 | library-directories) | |
59 | " "))) | |
60 | #t)) | |
61 | ||
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) | |
66 | make-flags) | |
436515cd DM |
67 | #t)) |
68 | ||
9ed36cd3 DM |
69 | (define* (check #:key target inputs outputs (tests? (not target)) (make-flags '()) #:allow-other-keys) |
70 | (if tests? | |
71 | (begin | |
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~%")) | |
77 | #t) | |
436515cd DM |
78 | |
79 | (define %standard-phases | |
80 | (modify-phases gnu:%standard-phases | |
81 | (replace 'configure configure) | |
82 | (replace 'install install) | |
83 | (replace 'check check))) | |
84 | ||
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)) |