Commit | Line | Data |
---|---|---|
d991b056 | 1 | ;;; GNU Guix --- Functional package management for GNU |
1ae04a2a | 2 | ;;; Copyright © 2016, 2017, 2019 Ricardo Wurmus <rekado@elephly.net> |
07c1a10e | 3 | ;;; Copyright © 2019 Tobias Geerinckx-Rice <me@tobias.gr> |
d991b056 RW |
4 | ;;; |
5 | ;;; This file is part of GNU Guix. | |
6 | ;;; | |
7 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
8 | ;;; under the terms of the GNU General Public License as published by | |
9 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
10 | ;;; your option) any later version. | |
11 | ;;; | |
12 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
13 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | ;;; GNU General Public License for more details. | |
16 | ;;; | |
17 | ;;; You should have received a copy of the GNU General Public License | |
18 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
19 | ||
20 | (define-module (gnu packages axoloti) | |
21 | #:use-module (guix utils) | |
22 | #:use-module (guix packages) | |
23 | #:use-module (guix download) | |
07c1a10e | 24 | #:use-module (guix git-download) |
d991b056 RW |
25 | #:use-module ((guix licenses) #:prefix license:) |
26 | #:use-module (guix build-system gnu) | |
27 | #:use-module (guix build-system ant) | |
28 | #:use-module (gnu packages) | |
29 | #:use-module (gnu packages base) | |
30 | #:use-module (gnu packages compression) | |
31 | #:use-module (gnu packages cross-base) | |
32 | #:use-module (gnu packages embedded) | |
33 | #:use-module (gnu packages flashing-tools) | |
34 | #:use-module (gnu packages java) | |
5261553a | 35 | #:use-module (gnu packages java-graphics) |
d991b056 RW |
36 | #:use-module (gnu packages libusb) |
37 | #:use-module (gnu packages pkg-config) | |
38 | #:use-module (gnu packages textutils) | |
39 | #:use-module (gnu packages version-control) | |
40 | #:use-module (gnu packages xml)) | |
41 | ||
42 | (define libusb-for-axoloti | |
43 | (package (inherit libusb) | |
44 | (name "axoloti-libusb") | |
45 | (version (package-version libusb)) | |
46 | (source | |
47 | (origin | |
48 | (inherit (package-source libusb)) | |
49 | (patches (list (search-patch "libusb-for-axoloti.patch"))))))) | |
50 | ||
51 | (define dfu-util-for-axoloti | |
52 | (package (inherit dfu-util) | |
53 | (name "axoloti-dfu-util") | |
54 | (version "0.8") | |
55 | (source | |
56 | (origin | |
57 | (method url-fetch) | |
58 | (uri (string-append "http://dfu-util.sourceforge.net/releases/" | |
59 | "dfu-util-" version ".tar.gz")) | |
60 | (sha256 | |
61 | (base32 | |
62 | "0n7h08avlzin04j93m6hkq9id6hxjiiix7ff9gc2n89aw6dxxjsm")))) | |
63 | (inputs | |
64 | `(("libusb" ,libusb-for-axoloti))))) | |
65 | ||
66 | (define-public axoloti-runtime | |
67 | (package | |
68 | (name "axoloti-runtime") | |
ea38d2ee | 69 | (version "1.0.12-2") |
07c1a10e TGR |
70 | (source |
71 | (origin | |
72 | (method git-fetch) | |
73 | (uri (git-reference | |
b0e7b699 | 74 | (url "https://github.com/axoloti/axoloti") |
07c1a10e TGR |
75 | (commit version))) |
76 | (file-name (git-file-name name version)) | |
77 | (sha256 | |
ea38d2ee | 78 | (base32 "1qffis277wshldr3i939b0r2x3a2mlr53samxqmr2nk1sfm2b4w9")) |
07c1a10e TGR |
79 | (modules '((guix build utils))) |
80 | (snippet | |
81 | '(begin | |
82 | ;; Remove pre-built Java binaries. | |
83 | (delete-file-recursively "lib/") | |
84 | #t)))) | |
d991b056 RW |
85 | (build-system gnu-build-system) |
86 | (arguments | |
87 | `(#:tests? #f ; no check target | |
88 | #:modules ((guix build gnu-build-system) | |
89 | (guix build utils) | |
90 | (srfi srfi-1) | |
91 | (srfi srfi-26) | |
92 | (ice-9 match) | |
93 | (ice-9 regex)) | |
94 | #:imported-modules ((guix build syscalls) | |
95 | ,@%gnu-build-system-modules) | |
96 | #:phases | |
97 | (modify-phases %standard-phases | |
98 | (add-after 'unpack 'patch-paths | |
99 | (lambda* (#:key inputs #:allow-other-keys) | |
100 | ;; prepare ChibiOS | |
1ae04a2a RW |
101 | (invoke "unzip" "-o" (assoc-ref inputs "chibios")) |
102 | (invoke "mv" "ChibiOS_2.6.9" "chibios") | |
103 | (with-directory-excursion "chibios/ext" | |
104 | (invoke "unzip" "-o" "fatfs-0.9-patched.zip")) | |
d991b056 RW |
105 | |
106 | ;; Remove source of non-determinism in ChibiOS | |
107 | (substitute* "chibios/os/various/shell.c" | |
108 | (("#ifdef __DATE__") "#if 0")) | |
109 | ||
110 | ;; Patch shell paths | |
111 | (substitute* '("src/main/java/qcmds/QCmdCompileFirmware.java" | |
112 | "src/main/java/qcmds/QCmdCompilePatch.java" | |
113 | "src/main/java/qcmds/QCmdFlashDFU.java") | |
114 | (("/bin/sh") (which "sh"))) | |
115 | ||
116 | ;; Override cross compiler base name | |
117 | (substitute* "firmware/Makefile.patch" | |
118 | (("arm-none-eabi-(gcc|g\\+\\+|objcopy|objdump)" tool) | |
119 | (which tool))) | |
120 | ||
121 | ;; Hardcode full path to compiler tools | |
122 | (substitute* '("firmware/Makefile" | |
123 | "firmware/flasher/Makefile" | |
124 | "firmware/mounter/Makefile") | |
125 | (("TRGT =.*") | |
126 | (string-append "TRGT = " | |
127 | (assoc-ref inputs "cross-toolchain") | |
128 | "/bin/arm-none-eabi-\n"))) | |
129 | ||
130 | ;; Hardcode path to "make" | |
131 | (substitute* '("firmware/compile_firmware_linux.sh" | |
132 | "firmware/compile_patch_linux.sh") | |
133 | (("make") (which "make"))) | |
134 | ||
135 | ;; Hardcode path to "dfu-util" | |
136 | (substitute* "platform_linux/upload_fw_dfu.sh" | |
137 | (("-f \"\\$\\{platformdir\\}/bin/dfu-util\"") "-z \"\"") | |
138 | (("\\./dfu-util") (which "dfu-util"))) | |
139 | #t)) | |
140 | (delete 'configure) | |
141 | (replace 'build | |
142 | ;; Build Axoloti firmware with cross-compiler | |
143 | (lambda* (#:key inputs #:allow-other-keys) | |
144 | (let* ((toolchain (assoc-ref inputs "cross-toolchain")) | |
145 | (headers (string-append | |
146 | toolchain | |
147 | "/arm-none-eabi/include:" | |
148 | toolchain | |
149 | "/arm-none-eabi/include/arm-none-eabi/armv7e-m"))) | |
150 | (setenv "CROSS_CPATH" headers) | |
151 | (setenv "CROSS_CPLUS_INCLUDE_PATH" headers) | |
152 | (setenv "CROSS_LIBRARY_PATH" | |
153 | (string-append toolchain | |
154 | "/arm-none-eabi/lib"))) | |
155 | (with-directory-excursion "platform_linux" | |
1ae04a2a | 156 | (invoke "sh" "compile_firmware.sh")))) |
d991b056 RW |
157 | (replace 'install |
158 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
159 | (let* ((out (assoc-ref outputs "out")) | |
160 | (share (string-append out "/share/axoloti/")) | |
161 | (doc (string-append share "doc")) | |
162 | (dir (getcwd)) | |
163 | (pats '("/doc/[^/]+$" | |
164 | "/patches/[^/]+/[^/]+$" | |
165 | "/objects/[^/]+/[^/]+$" | |
166 | "/firmware/.+" | |
167 | "/chibios/[^/]+$" | |
168 | "/chibios/boards/ST_STM32F4_DISCOVERY/[^/]+$" | |
169 | "/chibios/(ext|os|docs)/.+" | |
170 | "/CMSIS/[^/]+/[^/]+$" | |
171 | "/patch/[^/]+/[^/]+$" | |
172 | "/[^/]+\\.txt$")) | |
173 | (pattern (string-append | |
174 | "(" (string-join | |
175 | (map (cut string-append dir <>) | |
176 | pats) | |
177 | "|") ")")) | |
178 | (files (find-files dir | |
179 | (lambda (file stat) | |
180 | (and (eq? 'regular (stat:type stat)) | |
181 | (string-match pattern file)))))) | |
182 | (for-each (lambda (file) | |
183 | (install-file file | |
184 | (string-append | |
185 | share | |
186 | (regexp-substitute | |
187 | #f | |
188 | (string-match dir (dirname file)) | |
189 | 'pre 'post)))) | |
190 | files) | |
191 | #t)))))) | |
192 | (inputs | |
193 | `(("chibios" | |
194 | ,(origin | |
195 | (method url-fetch) | |
341bddb3 | 196 | (uri "mirror://sourceforge/chibios/ChibiOS%20GPL3/Version%202.6.9/ChibiOS_2.6.9.zip") |
d991b056 RW |
197 | (sha256 |
198 | (base32 | |
199 | "0lb5s8pkj80mqhsy47mmq0lqk34s2a2m3xagzihalvabwd0frhlj")))) | |
200 | ;; for compiling patches | |
201 | ("make" ,gnu-make) | |
202 | ;; for compiling firmware | |
203 | ("cross-toolchain" ,arm-none-eabi-nano-toolchain-4.9) | |
204 | ;; for uploading compiled patches and firmware | |
205 | ("dfu-util" ,dfu-util-for-axoloti))) | |
206 | (native-inputs | |
207 | `(("unzip" ,unzip))) | |
94b55ace | 208 | (home-page "http://www.axoloti.com/") |
d991b056 RW |
209 | (synopsis "Audio development environment for the Axoloti core board") |
210 | (description | |
211 | "The Axoloti patcher offers a “patcher” environment similar to Pure Data | |
212 | for sketching digital audio algorithms. The patches run on a standalone | |
213 | powerful microcontroller board: Axoloti Core. This package provides the | |
214 | runtime.") | |
215 | (license license:gpl3+))) | |
216 | ||
217 | (define-public axoloti-patcher | |
218 | (package (inherit axoloti-runtime) | |
219 | (name "axoloti-patcher") | |
220 | (version (package-version axoloti-runtime)) | |
221 | (arguments | |
222 | `(#:tests? #f ; no check target | |
223 | #:modules ((guix build gnu-build-system) | |
224 | ((guix build ant-build-system) #:prefix ant:) | |
225 | (guix build utils) | |
226 | (srfi srfi-1) | |
227 | (srfi srfi-26) | |
228 | (ice-9 match) | |
229 | (ice-9 regex) | |
230 | (sxml simple) | |
231 | (sxml xpath) | |
232 | (sxml transform)) | |
233 | #:imported-modules ((guix build ant-build-system) | |
234 | (guix build syscalls) | |
235 | ,@%gnu-build-system-modules) | |
236 | #:phases | |
237 | (modify-phases %standard-phases | |
07c1a10e TGR |
238 | (add-after 'unpack 'make-git-checkout-writable |
239 | (lambda _ | |
240 | (for-each make-file-writable (find-files ".")) | |
241 | #t)) | |
d991b056 RW |
242 | (delete 'configure) |
243 | (replace 'build | |
244 | (lambda* (#:key inputs #:allow-other-keys) | |
245 | (setenv "JAVA_HOME" (assoc-ref inputs "icedtea")) | |
246 | ;; We want to use our own jar files instead of the pre-built | |
247 | ;; stuff in lib. So we replace the zipfileset tags in the | |
248 | ;; build.xml with new ones that reference our jars. | |
249 | (let* ((build.xml (with-input-from-file "build.xml" | |
250 | (lambda _ | |
251 | (xml->sxml #:trim-whitespace? #t)))) | |
252 | (jars (append-map (match-lambda | |
253 | (((? (cut string-prefix? "java-" <>) | |
254 | label) . directory) | |
255 | (find-files directory "\\.jar$")) | |
256 | (_ '())) | |
257 | inputs)) | |
258 | (classpath (string-join jars ":")) | |
259 | (fileset (map (lambda (jar) | |
260 | `(zipfileset (@ (excludes "META-INF/*.SF") | |
261 | (src ,jar)))) | |
262 | jars))) | |
263 | (call-with-output-file "build.xml" | |
264 | (lambda (port) | |
265 | (sxml->xml | |
266 | (pre-post-order | |
267 | build.xml | |
268 | `(;; Remove all zipfileset tags from the "jar" tree and | |
269 | ;; inject our own tags. | |
270 | (jar . ,(lambda (tag . kids) | |
271 | `(jar ,@(append-map | |
272 | (filter (lambda (e) | |
273 | (not (eq? 'zipfileset (car e))))) | |
274 | kids) | |
275 | ,@fileset))) | |
276 | ;; Skip the "bundle" target (and the "-post-jar" target | |
277 | ;; that depends on it), because we don't need it and it | |
278 | ;; confuses sxml->xml. | |
279 | (target . ,(lambda (tag . kids) | |
280 | (let ((name ((sxpath '(name *text*)) | |
281 | (car kids)))) | |
282 | (if (or (member "bundle" name) | |
283 | (member "-post-jar" name)) | |
284 | '() ; skip | |
285 | `(,tag ,@kids))))) | |
286 | (*default* . ,(lambda (tag . kids) `(,tag ,@kids))) | |
287 | (*text* . ,(lambda (_ txt) | |
288 | (match txt | |
289 | ;; Remove timestamp. | |
290 | ("${TODAY}" "(unknown)") | |
291 | (_ txt)))))) | |
292 | port))) | |
293 | ||
294 | ;; Build it! | |
c28bf42f RW |
295 | (invoke "ant" |
296 | (string-append "-Djavac.classpath=" classpath) | |
297 | "-Dbuild.runtime=true" | |
298 | "-Dbuild.time=01/01/1970 00:00:00" | |
299 | "-Djavac.source=1.7" | |
300 | "-Djavac.target=1.7" | |
301 | (string-append "-Dtag.short.version=" | |
302 | ,version))))) | |
d991b056 RW |
303 | (replace 'install |
304 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
305 | (let* ((out (assoc-ref outputs "out")) | |
306 | (share (string-append out "/share/axoloti/"))) | |
307 | (install-file "dist/Axoloti.jar" share) | |
308 | ||
309 | ;; We do this to ensure that this package retains references to | |
310 | ;; other Java packages' jar files. | |
311 | (install-file "build.xml" share) | |
312 | ||
313 | ;; Create a launcher script | |
314 | (mkdir (string-append out "/bin")) | |
315 | (let ((target (string-append out "/bin/Axoloti"))) | |
316 | (with-output-to-file target | |
317 | (lambda () | |
318 | (let* ((dir (string-append (assoc-ref outputs "out") | |
319 | "/share/axoloti")) | |
320 | (runtime (string-append (assoc-ref inputs "axoloti-runtime") | |
321 | "/share/axoloti")) | |
322 | (toolchain (assoc-ref inputs "cross-toolchain")) | |
323 | (includes (string-append | |
324 | toolchain | |
325 | "/arm-none-eabi/include:" | |
326 | toolchain | |
327 | "/arm-none-eabi/include/arm-none-eabi/armv7e-m"))) | |
328 | (display | |
329 | (string-append "#!" (which "sh") "\n" | |
330 | "export CROSS_CPATH=" includes "\n" | |
331 | "export CROSS_CPLUS_INCLUDE_PATH=" includes "\n" | |
332 | "export CROSS_LIBRARY_PATH=" | |
333 | toolchain "/arm-none-eabi/lib" "\n" | |
334 | (which "java") | |
335 | " -Daxoloti_release=" runtime | |
336 | " -Daxoloti_runtime=" runtime | |
337 | " -jar " dir "/Axoloti.jar"))))) | |
338 | (chmod target #o555)) | |
339 | #t))) | |
340 | (add-after 'install 'strip-jar-timestamps | |
341 | (assoc-ref ant:%standard-phases 'strip-jar-timestamps))))) | |
342 | (inputs | |
343 | `(("icedtea" ,icedtea "jdk") | |
344 | ("cross-toolchain" ,arm-none-eabi-nano-toolchain-4.9) | |
345 | ("java-simple-xml" ,java-simple-xml) | |
346 | ("java-rsyntaxtextarea" ,java-rsyntaxtextarea) | |
347 | ("java-usb4java" ,java-usb4java) | |
348 | ("java-jsch" ,java-jsch) | |
349 | ("java-slf4j-api" ,java-slf4j-api) | |
350 | ("java-jgit" ,java-jgit-4.2) | |
351 | ("axoloti-runtime" ,axoloti-runtime))) | |
352 | (native-inputs | |
353 | `(("ant" ,ant) | |
354 | ("zip" ,zip) ; for repacking the jar | |
355 | ("unzip" ,unzip))) | |
356 | (description | |
357 | "The Axoloti patcher offers a “patcher” environment similar to Pure Data | |
358 | for sketching digital audio algorithms. The patches run on a standalone | |
359 | powerful microcontroller board: Axoloti Core. This package provides the | |
360 | patcher application."))) | |
5261553a RW |
361 | |
362 | (define-public axoloti-patcher-next | |
363 | (package | |
364 | (name "axoloti-patcher-next") | |
365 | (version "2.0.0") | |
366 | (source | |
367 | (origin | |
368 | (method git-fetch) | |
369 | (uri (git-reference | |
b0e7b699 | 370 | (url "https://github.com/axoloti/axoloti") |
5261553a RW |
371 | (commit version))) |
372 | (file-name (git-file-name name version)) | |
373 | (sha256 | |
374 | (base32 "022p993wf9l9mp6vg94x592vfqd1k1sjrq5f6x45h5r16qy6bdzh")) | |
375 | (modules '((guix build utils))) | |
376 | (snippet | |
377 | '(begin | |
378 | ;; Remove pre-built Java binaries. | |
379 | (delete-file-recursively "lib/") | |
380 | #t)))) | |
381 | (build-system gnu-build-system) | |
382 | (arguments | |
383 | `(#:tests? #f ; there's a Java test which is run as part of the Java build. | |
384 | #:modules ((guix build gnu-build-system) | |
385 | ((guix build ant-build-system) #:prefix ant:) | |
386 | (guix build utils) | |
387 | (srfi srfi-1) | |
388 | (srfi srfi-26) | |
389 | (ice-9 match) | |
390 | (ice-9 regex) | |
391 | (sxml simple) | |
392 | (sxml xpath) | |
393 | (sxml transform)) | |
394 | #:imported-modules ((guix build ant-build-system) | |
395 | (guix build syscalls) | |
396 | ,@%gnu-build-system-modules) | |
397 | #:phases | |
398 | (modify-phases %standard-phases | |
399 | (add-after 'unpack 'make-git-checkout-writable | |
400 | (lambda* (#:key inputs #:allow-other-keys) | |
401 | (copy-recursively (assoc-ref inputs "elfloader") | |
402 | "firmware/elfloader") | |
403 | (for-each make-file-writable (find-files ".")) | |
404 | #t)) | |
405 | (add-after 'unpack 'patch-paths | |
406 | (lambda* (#:key inputs #:allow-other-keys) | |
407 | ;; prepare ChibiOS | |
408 | (invoke "7z" "x" (assoc-ref inputs "chibios")) | |
409 | (with-directory-excursion "ChibiOS_19.1.3/ext" | |
410 | (invoke "7z" "x" "fatfs-0.13_patched.7z")) | |
5261553a RW |
411 | |
412 | ;; Hardcode full path to compiler tools | |
413 | (substitute* | |
414 | '("ChibiOS_19.1.3/os/common/startup/ARMCMx/compilers/GCC/mk/arm-none-eabi.mk" | |
415 | "env/arm-none-eabi.mk") | |
416 | (("TRGT =.*") | |
417 | (string-append "TRGT = " | |
418 | (assoc-ref inputs "cross-toolchain") | |
419 | "/bin/arm-none-eabi-\n"))) | |
420 | ||
421 | ;; Hardcode path to "make" | |
422 | (substitute* "src/main/java/axoloti/shell/ShellTask.java" | |
423 | (("return \"make\"") | |
424 | (string-append "return \"" (which "make") "\""))) | |
425 | ||
426 | ;; Hardcode path to "dfu-util" | |
427 | (substitute* "src/main/java/axoloti/shell/UploadFirmwareDFU.java" | |
428 | (("Axoloti.getReleaseDir\\(\\) \\+ \"/platform_.+/bin/dfu-util\"") | |
429 | (string-append "\"" (which "dfu-util") "\""))) | |
430 | #t)) | |
431 | (delete 'configure) | |
432 | (replace 'build | |
433 | ;; Build Axoloti firmware with cross-compiler | |
434 | (lambda* (#:key inputs #:allow-other-keys) | |
435 | (let* ((toolchain (assoc-ref inputs "cross-toolchain")) | |
436 | (headers (string-append | |
437 | toolchain | |
438 | "/arm-none-eabi/include:" | |
439 | toolchain | |
440 | "/arm-none-eabi/include/arm-none-eabi/armv7e-m"))) | |
441 | (setenv "CROSS_CPATH" headers) | |
442 | (setenv "CROSS_CPLUS_INCLUDE_PATH" headers) | |
443 | (setenv "CROSS_LIBRARY_PATH" | |
444 | (string-append toolchain | |
445 | "/arm-none-eabi/lib"))) | |
446 | (with-directory-excursion "platform_linux" | |
447 | (invoke "sh" "compile_firmware.sh")))) | |
448 | (add-after 'build 'build-patcher | |
449 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
450 | (setenv "JAVA_HOME" (assoc-ref inputs "jdk")) | |
451 | ;; We want to use our own jar files instead of the pre-built | |
452 | ;; stuff in lib. So we replace the zipfileset tags in the | |
453 | ;; build.xml with new ones that reference our jars. | |
454 | (let* ((build.xml (with-input-from-file "build.xml" | |
455 | (lambda _ | |
456 | (xml->sxml #:trim-whitespace? #t)))) | |
457 | (jars (append-map (match-lambda | |
458 | (((? (cut string-prefix? "java-" <>) | |
459 | label) . directory) | |
460 | (find-files directory "\\.jar$")) | |
461 | (_ '())) | |
462 | inputs)) | |
463 | (classpath (string-join jars ":")) | |
464 | (fileset (map (lambda (jar) | |
465 | `(zipfileset (@ (excludes "META-INF/*.SF") | |
466 | (src ,jar)))) | |
467 | jars))) | |
468 | (call-with-output-file "build.xml" | |
469 | (lambda (port) | |
470 | (sxml->xml | |
471 | (pre-post-order | |
472 | build.xml | |
473 | `( ;; Remove all zipfileset tags from the "jar" tree and | |
474 | ;; inject our own tags. | |
475 | (jar . ,(lambda (tag . kids) | |
476 | `(jar ,@(append-map | |
477 | (filter (lambda (e) | |
478 | (not (eq? 'zipfileset (car e))))) | |
479 | kids) | |
480 | ,@fileset))) | |
481 | ;; Skip the "bundle" target (and the "-post-jar" target | |
482 | ;; that depends on it), because we don't need it and it | |
483 | ;; confuses sxml->xml. | |
484 | (target . ,(lambda (tag . kids) | |
485 | (let ((name ((sxpath '(name *text*)) | |
486 | (car kids)))) | |
487 | (if (or (member "bundle" name) | |
488 | (member "-post-jar" name)) | |
489 | '() ; skip | |
490 | `(,tag ,@kids))))) | |
491 | (*default* . ,(lambda (tag . kids) `(,tag ,@kids))) | |
492 | (*text* . ,(lambda (_ txt) | |
493 | (match txt | |
494 | ;; Remove timestamp. | |
495 | ("${TODAY}" "(unknown)") | |
496 | (_ txt)))))) | |
497 | port))) | |
498 | ||
499 | ;; Build it! | |
500 | (invoke "ant" | |
501 | (string-append "-Djavac.classpath=" classpath) | |
502 | "-Dbuilt_by=guix" | |
503 | "-Dbuild.time=01/01/1970 00:00:00" | |
504 | "-Djavac.source=1.8" | |
505 | "-Djavac.target=1.8" | |
506 | (string-append "-Dshort.version=" | |
507 | ,version) | |
508 | ;; TODO: this is the output of: | |
509 | ;; git describe --long --tags --dirty --always | |
510 | (string-append "-Dbuild.version=" | |
511 | ,version "-0-g88b60feb"))))) | |
512 | (replace 'install | |
513 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
514 | (let* ((out (assoc-ref outputs "out")) | |
515 | (share (string-append out "/share/axoloti/"))) | |
516 | ||
517 | ;; TODO: don't copy *everything* from these directories. | |
518 | (for-each (lambda (dir) | |
519 | (copy-recursively dir (string-append share "/" dir))) | |
520 | '("api" | |
521 | "archive" | |
522 | "doc" | |
523 | "env" | |
524 | "firmware" | |
525 | "nbproject" | |
526 | "platform_linux")) | |
527 | (install-file "dist/Axoloti.jar" share) | |
528 | ||
529 | ;; Install old firmware | |
530 | (let ((target (string-append share "/old_firmware/")) | |
531 | (old-firmware | |
532 | (string-append (assoc-ref inputs "axoloti-runtime") | |
533 | "/share/axoloti/firmware/"))) | |
534 | (mkdir-p target) | |
535 | (install-file (string-append old-firmware | |
536 | "flasher/flasher_build/flasher.bin") | |
537 | target) | |
538 | ;; TODO: the old file differs from the file that is included | |
539 | ;; in this repository as the old firmware. | |
540 | (install-file (string-append old-firmware | |
541 | "build/axoloti.bin") | |
542 | target)) | |
543 | ||
544 | ;; We do this to ensure that this package retains references to | |
545 | ;; other Java packages' jar files. | |
546 | (install-file "build.xml" share) | |
547 | ||
548 | ;; Create a launcher script | |
549 | (mkdir (string-append out "/bin")) | |
550 | (let ((target (string-append out "/bin/Axoloti"))) | |
551 | (with-output-to-file target | |
552 | (lambda () | |
553 | (let* ((dir (string-append (assoc-ref outputs "out") | |
554 | "/share/axoloti")) | |
555 | (toolchain (assoc-ref inputs "cross-toolchain")) | |
556 | (includes (string-append | |
557 | toolchain | |
558 | "/arm-none-eabi/include:" | |
559 | toolchain | |
560 | "/arm-none-eabi/include/arm-none-eabi/armv7e-m"))) | |
561 | (display | |
562 | (string-append "#!" (which "sh") "\n" | |
563 | "export CROSS_CPATH=" includes "\n" | |
564 | "export CROSS_CPLUS_INCLUDE_PATH=" includes "\n" | |
565 | "export CROSS_LIBRARY_PATH=" | |
566 | toolchain "/arm-none-eabi/lib" "\n" | |
567 | (which "java") | |
568 | ||
569 | ;; Renderer arguments | |
570 | " -Xbootclasspath/a:" | |
571 | (assoc-ref inputs "java-marlin-renderer") | |
572 | "/lib/marlin.jar" | |
573 | " -Dsun.java2d.renderer=org.marlin.pisces.MarlinRenderingEngine" | |
574 | " -Daxoloti_release=" share | |
575 | " -jar " dir "/Axoloti.jar"))))) | |
576 | (chmod target #o555)) | |
577 | #t))) | |
578 | (add-after 'install 'strip-jar-timestamps | |
579 | (assoc-ref ant:%standard-phases 'strip-jar-timestamps))))) | |
580 | (inputs | |
581 | `(("jdk" ,icedtea "jdk") | |
582 | ("cross-toolchain" ,arm-none-eabi-nano-toolchain-7-2018-q2-update) | |
583 | ;; for compiling patches | |
584 | ("make" ,gnu-make) | |
585 | ;; for uploading compiled patches and firmware | |
586 | ("dfu-util" ,dfu-util-for-axoloti) | |
587 | ;; for org/apache/commons/lang3/tuple/ImmutablePair | |
588 | ("java-commons-lang3" ,java-commons-lang3) | |
589 | ("java-jgit" ,java-jgit-4.2) | |
590 | ("java-jsch" ,java-jsch) | |
591 | ("java-marlin-renderer" ,java-marlin-renderer) | |
592 | ("java-piccolo2d-core" ,java-piccolo2d-core) | |
593 | ("java-piccolo2d-extras" ,java-piccolo2d-extras) | |
594 | ("java-rsyntaxtextarea" ,java-rsyntaxtextarea) | |
595 | ("java-simple-xml" ,java-simple-xml) | |
596 | ("java-slf4j-api" ,java-slf4j-api) | |
597 | ("java-usb4java" ,java-usb4java))) | |
598 | (native-inputs | |
599 | `(("ant" ,ant) | |
600 | ("axoloti-runtime" ,axoloti-runtime) ; for old firmware | |
601 | ("java-junit" ,java-junit) | |
602 | ("java-hamcrest-core" ,java-hamcrest-core) | |
603 | ("p7zip" ,p7zip) | |
604 | ("zip" ,zip) ; for repacking the jar | |
605 | ("elfloader" | |
606 | ,(let ((commit "d0f93acac6577a069b8739bf42c9500e9a862988")) | |
607 | (origin | |
608 | (method git-fetch) | |
609 | (uri (git-reference | |
b0e7b699 | 610 | (url "https://github.com/JohannesTaelman/elfloader") |
5261553a RW |
611 | (commit commit))) |
612 | (file-name (git-file-name "elfloader" commit)) | |
613 | (sha256 | |
614 | (base32 | |
615 | "0zsy6w784amfq4vr1qnx8xvy70v33gvffz1vljllwppdc8s3khmn"))))) | |
616 | ("chibios" | |
617 | ,(origin | |
618 | (method url-fetch) | |
619 | (uri "http://rwthaachen.dl.osdn.jp/chibios/70739/ChibiOS_19.1.3.7z") | |
620 | (sha256 | |
621 | (base32 | |
622 | "1090alqp1z1bhj1z8ls04a350kbs8hsjcpkfddbprds73zbnnpk9")))))) | |
623 | (home-page "http://www.axoloti.com/") | |
624 | (synopsis "Audio development environment for the Axoloti core board") | |
625 | (description | |
626 | "The Axoloti patcher offers a “patcher” environment similar to Pure Data | |
627 | for sketching digital audio algorithms. The patches run on a standalone | |
628 | powerful microcontroller board: Axoloti Core.") | |
629 | (license (list license:gpl3+ ; the whole project and GUI | |
630 | license:bsd-3)))) ; the elfloader |