boot-clj / boot

Build tooling for Clojure.
https://boot-clj.github.io/
Eclipse Public License 1.0
1.75k stars 180 forks source link

scripts with quil? #594

Closed jtoy closed 6 years ago

jtoy commented 7 years ago

I have boot scripts working with other examples, but im trying to use it with quil/Processing. I wrote this simple script and tried to run it, but all it does is launches a Java Applet window then immediately closes. There are no error logs for me to debug. is there something special to get it running with quil?

#!/usr/bin/env boot
(set-env! :dependencies '[[quil "2.6.0"]])
(require '[quil.core :as q])
(defn setup []
  (q/background 111 111 111 )  )
(defn -main  [& args]
  (q/defsketch my-art
  :size [800 800]
  :setup setup))
arichiardi commented 7 years ago

I don't know how quil works but maybe there is no non-daemon thread in the spawned JVM that keeps it up? If I remember correctly boot does not do it for you (that is why there is a wait task) so this might be the issue.

martinklepsch commented 6 years ago

@jtoy Hey :wave: So I think the issue here is that defsketch won't block the main thread causing the process to exit once it evaluated all of your forms. A working version would be:

#!/usr/bin/env boot
(set-env! :dependencies '[[quil "2.6.0"]])

(require '[quil.core :as q])

(defn setup []
  (q/background 111 111 111))

(q/defsketch my-art
  :size [800 800]
  :setup setup
  :features [:exit-on-close])

(deref (promise))

The (deref (promise)) at the end ensures that the process keeps running. And the :exit-on-close feature causes the JVM process to terminate once you close the Sketch window.

I'll close this issue but let us know if you run into other problems! ✨