Commit 5edf83527134f4cac0ccf9bb6dc94d5d11aa89d7
- Diff rendering mode:
- inline
- side by side
README
(25 / 0)
|   | |||
| 29 | 29 | ``lib'' in the sketch directory which is where the | |
| 30 | 30 | ``preferences.txt'' file will reside. Sym-linking also works. | |
| 31 | 31 | ||
| 32 | === Using Processing Libraries === | ||
| 33 | |||
| 34 | Processing allows developers to extend its functionality with | ||
| 35 | libraries. These are collections of JAR (Java ARchive) files that can | ||
| 36 | be included with a sketch. | ||
| 37 | |||
| 38 | processing-mode handles the inclusion of libraries by opening up a | ||
| 39 | file named ``libraries_required.txt'' in the sketch folder. On each | ||
| 40 | line of that file will be the name of the library's folder. | ||
| 41 | |||
| 42 | As an example, let's say we have a sketch that uses the JavaScript | ||
| 43 | library. To include it with the sketch, our ``libraries_required.txt'' | ||
| 44 | would look like: | ||
| 45 | |||
| 46 | javascript | ||
| 47 | |||
| 48 | Just a single line :D processing-mode will do some magic and use the | ||
| 49 | following path when including the library with the sketch compilation: | ||
| 50 | |||
| 51 | <processing_path>/libraries/javascript/library/ | ||
| 52 | |||
| 53 | In the ``library'' sub-folder of all libraries there will be a set of | ||
| 54 | JAR files. They will be added to the classpath when the sketch is | ||
| 55 | compiled or run. | ||
| 56 | |||
| 32 | 57 | == Fixed Bugs == | |
| 33 | 58 | ||
| 34 | 59 | * Compilation errors...The regular expression used to detect |
processing-mode.el
(47 / 0)
|   | |||
| 9 | 9 | ;; Licensed under the GNU GPL version 3 or later | |
| 10 | 10 | ||
| 11 | 11 | (require 'compile) | |
| 12 | (require 'cl) | ||
| 12 | 13 | ||
| 13 | 14 | (define-derived-mode processing-mode | |
| 14 | 15 | java-mode "Processing" | |
| … | … | ||
| 43 | 43 | ||
| 44 | 44 | (defun make-java-classpath (&rest args) | |
| 45 | 45 | (apply 'concat-with-delim ":" args)) | |
| 46 | |||
| 47 | (defvar processing-import-libraries | ||
| 48 | '((minim "jl1.0" "mp3spi1.9.4" "tritonus_share" "tritonus_aos" | ||
| 49 | "minim-spi" "minim" "jsminim")) | ||
| 50 | "An alist of library names and the JAR (Java ARchive) files | ||
| 51 | required for their use. Each element looks like (library-name | ||
| 52 | &REST jar-files) where library-name is a SYMBOL and jar-files are | ||
| 53 | strings.") | ||
| 54 | |||
| 55 | (defun processing-import-library (library-name) | ||
| 56 | "Generates a STRING that is a Java classpath, delimited by | ||
| 57 | colons (\":\"). The paths are constructed from the REST of the | ||
| 58 | library found in the alist ``processing-import-libraries''. The | ||
| 59 | suffix \".jar\" is added to each string." | ||
| 60 | (make-java-classpath (mapcar (lambda (x) (expand-file-name (concat processing-location | ||
| 61 | "libraries/" | ||
| 62 | (symbol-name library-name) | ||
| 63 | "/library/" x ".jar"))) | ||
| 64 | (rest (assoc library-name processing-import-libraries))))) | ||
| 65 | |||
| 66 | (defun processing-read-libraries (sketch-dir) | ||
| 67 | "Returns a LIST of SYMBOLS that are the names of Processing | ||
| 68 | libraries. This list if stored in the \"libraries_required.txt\" | ||
| 69 | file found in the Processing sketch directory ``sketch-dir''. | ||
| 70 | |||
| 71 | If the file does not exist, it is assumed that there are no | ||
| 72 | libraries required and NIL is returned. | ||
| 73 | |||
| 74 | A general error is signalled if the library is not supported. | ||
| 75 | Check the variable ``processing-import-libraries'' to see which | ||
| 76 | libraries are supported." | ||
| 77 | (let ((file-name (expand-file-name (concat sketch-dir "libraries_required.txt")))) | ||
| 78 | (if (and (file-exists-p file-name) (file-readable-p file-name)) | ||
| 79 | (let ((temp-buf (generate-new-buffer "libraries-required-by-sketch"))) | ||
| 80 | (set-buffer temp-buf) | ||
| 81 | (insert-file-contents file-name) | ||
| 82 | (unwind-protect | ||
| 83 | (loop while (< (point) (buffer-size)) | ||
| 84 | for library-name = (read temp-buf) then (read-temp-buf) | ||
| 85 | if (assoc library-name processing-import-libraries) | ||
| 86 | collect library-name | ||
| 87 | else do (error "Processing-mode does not know how to handle the library %s" | ||
| 88 | library-name) | ||
| 89 | do (forward-line)) | ||
| 90 | (kill-buffer temp-buf))) | ||
| 91 | nil))) | ||
| 46 | 92 | ||
| 47 | 93 | (defun processing-commander (sketch-dir output-dir cmd &optional platform) | |
| 48 | 94 | "Runs the Processing compiler targetting the sketch files found |

