Commit | Line | Data |
---|---|---|
5f7a1a4d RW |
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net> | |
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-system ant) | |
20 | #:use-module (guix store) | |
21 | #:use-module (guix utils) | |
22 | #:use-module (guix packages) | |
23 | #:use-module (guix derivations) | |
24 | #:use-module (guix search-paths) | |
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 (%ant-build-system-modules | |
30 | ant-build | |
31 | ant-build-system)) | |
32 | ||
33 | ;; Commentary: | |
34 | ;; | |
35 | ;; Standard build procedure for Java packages using Ant. | |
36 | ;; | |
37 | ;; Code: | |
38 | ||
39 | (define %ant-build-system-modules | |
40 | ;; Build-side modules imported by default. | |
41 | `((guix build ant-build-system) | |
42 | (guix build syscalls) | |
43 | ,@%gnu-build-system-modules)) | |
44 | ||
45 | (define (default-jdk) | |
46 | "Return the default JDK package." | |
47 | ;; Lazily resolve the binding to avoid a circular dependency. | |
48 | (let ((jdk-mod (resolve-interface '(gnu packages java)))) | |
49 | (module-ref jdk-mod 'icedtea))) | |
50 | ||
51 | (define (default-ant) | |
52 | "Return the default Ant package." | |
53 | ;; Lazily resolve the binding to avoid a circular dependency. | |
54 | (let ((jdk-mod (resolve-interface '(gnu packages java)))) | |
55 | (module-ref jdk-mod 'ant))) | |
56 | ||
57 | (define* (lower name | |
58 | #:key source inputs native-inputs outputs system target | |
59 | (jdk (default-jdk)) | |
60 | (ant (default-ant)) | |
61 | #:allow-other-keys | |
62 | #:rest arguments) | |
63 | "Return a bag for NAME." | |
64 | (define private-keywords | |
65 | '(#:source #:target #:jdk #:ant #:inputs #:native-inputs)) | |
66 | ||
67 | (and (not target) ;XXX: no cross-compilation | |
68 | (bag | |
69 | (name name) | |
70 | (system system) | |
71 | (host-inputs `(,@(if source | |
72 | `(("source" ,source)) | |
73 | '()) | |
74 | ,@inputs | |
75 | ||
76 | ;; Keep the standard inputs of 'gnu-build-system'. | |
77 | ,@(standard-packages))) | |
78 | (build-inputs `(("jdk" ,jdk "jdk") | |
79 | ("ant" ,ant) | |
80 | ,@native-inputs)) | |
81 | (outputs outputs) | |
82 | (build ant-build) | |
83 | (arguments (strip-keyword-arguments private-keywords arguments))))) | |
84 | ||
85 | (define* (ant-build store name inputs | |
86 | #:key | |
87 | (tests? #t) | |
88 | (test-target "tests") | |
89 | (configure-flags ''()) | |
90 | (make-flags ''()) | |
91 | (build-target "jar") | |
92 | (jar-name #f) | |
93 | (phases '(@ (guix build ant-build-system) | |
94 | %standard-phases)) | |
95 | (outputs '("out")) | |
96 | (search-paths '()) | |
97 | (system (%current-system)) | |
98 | (guile #f)p | |
99 | (imported-modules %ant-build-system-modules) | |
100 | (modules '((guix build ant-build-system) | |
101 | (guix build utils)))) | |
102 | "Build SOURCE with INPUTS." | |
103 | (define builder | |
104 | `(begin | |
105 | (use-modules ,@modules) | |
106 | (ant-build #:name ,name | |
107 | #:source ,(match (assoc-ref inputs "source") | |
108 | (((? derivation? source)) | |
109 | (derivation->output-path source)) | |
110 | ((source) | |
111 | source) | |
112 | (source | |
113 | source)) | |
114 | #:make-flags ,make-flags | |
115 | #:configure-flags ,configure-flags | |
116 | #:system ,system | |
117 | #:tests? ,tests? | |
118 | #:test-target ,test-target | |
119 | #:build-target ,build-target | |
120 | #:jar-name ,jar-name | |
121 | #:phases ,phases | |
122 | #:outputs %outputs | |
123 | #:search-paths ',(map search-path-specification->sexp | |
124 | search-paths) | |
125 | #:inputs %build-inputs))) | |
126 | ||
127 | (define guile-for-build | |
128 | (match guile | |
129 | ((? package?) | |
130 | (package-derivation store guile system #:graft? #f)) | |
131 | (#f ; the default | |
132 | (let* ((distro (resolve-interface '(gnu packages commencement))) | |
133 | (guile (module-ref distro 'guile-final))) | |
134 | (package-derivation store guile system #:graft? #f))))) | |
135 | ||
136 | (build-expression->derivation store name builder | |
137 | #:inputs inputs | |
138 | #:system system | |
139 | #:modules imported-modules | |
140 | #:outputs outputs | |
141 | #:guile-for-build guile-for-build)) | |
142 | ||
143 | (define ant-build-system | |
144 | (build-system | |
145 | (name 'ant) | |
146 | (description "The standard Ant build system") | |
147 | (lower lower))) | |
148 | ||
149 | ;;; ant.scm ends here |