Closed sogaiu closed 5 years ago
How is something like this?
diff --git a/src/clj/native_image.clj b/src/clj/native_image.clj
index 76766be..6cc8097 100644
--- a/src/clj/native_image.clj
+++ b/src/clj/native_image.clj
@@ -59,11 +59,17 @@
(.mkdir compile-path)))
(defn native-image-bin-path []
- (-> (io/file (System/getenv "GRAALVM_HOME")
- (if windows?
- "bin/native-image.cmd"
- "bin/native-image"))
- (.getAbsolutePath)))
+ (let [path (->> (clojure.string/split (System/getenv "PATH") #":")
+ (map #(str % "/native-image"))
+ (filter #(.isFile (java.io.File. %)))
+ first)]
+ (if (string? path)
+ path
+ (-> (io/file (System/getenv "GRAALVM_HOME")
+ (if windows?
+ "bin/native-image.cmd"
+ "bin/native-image"))
+ (.getAbsolutePath)))))
(defn- munge-class-name [class-name]
(cs/replace class-name "-" "_"))
@sogaiu let me know if latest commit works for you. Thanks!
It appears to work fine!
Thanks a lot :)
I have native-image in my PATH but it isn't used. (As the documentation mentions, setting GRAALVM_HOME or having the bin subdirectory of my project contain a symlink to native-image works.)
https://github.com/taylorwood/clj.native-image/blob/567176ddb0f7507c8b0969e0a10f60f848afaf7d/src/clj/native_image.clj#L57-L59
Does it sound reasonable for clj.native-image to make use of a native-image binary that's on one's PATH?