Commit 5edf83527134f4cac0ccf9bb6dc94d5d11aa89d7

Added functions for reading a list of libraries from a file in the sketch folder
README
(25 / 0)
  
2929 ``lib'' in the sketch directory which is where the
3030 ``preferences.txt'' file will reside. Sym-linking also works.
3131
32=== Using Processing Libraries ===
33
34Processing allows developers to extend its functionality with
35libraries. These are collections of JAR (Java ARchive) files that can
36be included with a sketch.
37
38processing-mode handles the inclusion of libraries by opening up a
39file named ``libraries_required.txt'' in the sketch folder. On each
40line of that file will be the name of the library's folder.
41
42As an example, let's say we have a sketch that uses the JavaScript
43library. To include it with the sketch, our ``libraries_required.txt''
44would look like:
45
46 javascript
47
48Just a single line :D processing-mode will do some magic and use the
49following path when including the library with the sketch compilation:
50
51 <processing_path>/libraries/javascript/library/
52
53In the ``library'' sub-folder of all libraries there will be a set of
54JAR files. They will be added to the classpath when the sketch is
55compiled or run.
56
3257== Fixed Bugs ==
3358
3459* Compilation errors...The regular expression used to detect
  
99;; Licensed under the GNU GPL version 3 or later
1010
1111(require 'compile)
12(require 'cl)
1213
1314(define-derived-mode processing-mode
1415 java-mode "Processing"
4343
4444(defun make-java-classpath (&rest args)
4545 (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
51required for their use. Each element looks like (library-name
52&REST jar-files) where library-name is a SYMBOL and jar-files are
53strings.")
54
55(defun processing-import-library (library-name)
56 "Generates a STRING that is a Java classpath, delimited by
57colons (\":\"). The paths are constructed from the REST of the
58library found in the alist ``processing-import-libraries''. The
59suffix \".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
68libraries. This list if stored in the \"libraries_required.txt\"
69file found in the Processing sketch directory ``sketch-dir''.
70
71If the file does not exist, it is assumed that there are no
72libraries required and NIL is returned.
73
74A general error is signalled if the library is not supported.
75Check the variable ``processing-import-libraries'' to see which
76libraries 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)))
4692
4793(defun processing-commander (sketch-dir output-dir cmd &optional platform)
4894 "Runs the Processing compiler targetting the sketch files found