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