Fork me on GitHub
#graalvm
<
2020-03-12
>
David Pham08:03:19

Does it mean we could target C++ using Clojure haha?

jeroenvandijk09:03:58

Graalvm protip: you can always shell out to the jar you are trying to run 🙈

jeroenvandijk10:03:29

(defn from-yaml-via-jar [jar-path s]
  (let [{:keys [exit out err]} (sh "java" "-jar" jar-path "generate" "--input-format" "yaml" :in (.StringReader. s))]
    (if (zero? exit)
      (cheshire/parse-string out)
      (throw (ex-info "" {:type :exit
                          :exit/code exit
                          :exit/message (str out err)})))))

(defn from-yaml [fallback-jar input]
  (let [s (slurp input)]
    (try
        (cfn/parse s)

        (catch org.yaml.snakeyaml.error.YAMLException e
          (if fallback-jar
            (from-yaml-via-jar fallback-jar s)
            (do
              (println "Did you consider using the --fallback-jar option to be able to read custom AWS tags?")
              (throw e)))))))

borkdude10:03:12

shelling out to java: that's also what the GraalVM compiled deps.clj does 🙂. it's kind of the entire of point of the tool, to create a classpath and then launch a JVM 🙂

jeroenvandijk10:03:52

yeah nice 🙂 I’m not doing the same though if that’s what you mean. I’m shelling out to the uberjar I’m trying to run via Graalvm in the first place. The yaml parsing fails in Graal, but succeeds in the jar ..

borkdude10:03:06

haha yeah, that's a nice fallback 😛

jeroenvandijk10:03:40

It’s really my last resort. I gave up this yaml parsing thing

borkdude10:03:59

it really is a rabbit hole, isn't it.

jeroenvandijk10:03:25

yeah and I only really wanted to use it for importing cloudformation templates. So it started as nice to have this yaml file importing part. Now time for some real features with Sci 😎

Nico14:03:55

can you use core.spec within something graalvm-compiled with clojure 1.9.0?

borkdude14:03:42

you can also use it again now with 1.10.2-alpha1

Nico15:03:16

oh, awesome!