Remove Unix-specific classes (#227)

This commit is contained in:
Michiel Borkent 2020-01-08 11:48:40 +01:00 committed by GitHub
parent 6633d8b674
commit 2b0cb6fb1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 174 additions and 172 deletions

View file

@ -52,7 +52,7 @@ jobs:
mkdir -p /tmp/release mkdir -p /tmp/release
lein do clean, uberjar lein do clean, uberjar
VERSION=$(cat resources/BABASHKA_VERSION) VERSION=$(cat resources/BABASHKA_VERSION)
cp target/babashka-$VERSION-standalone.jar /tmp/release/babashka-$VERSION-linux-standalone.jar cp target/babashka-$VERSION-standalone.jar /tmp/release/babashka-$VERSION-standalone.jar
- store_artifacts: - store_artifacts:
path: /tmp/release path: /tmp/release
destination: release destination: release

2
sci

@ -1 +1 @@
Subproject commit d9e6d7396374631731a9cc7b11dedb41281e867d Subproject commit 1374d2a37b64e3d2216349345ff930b1154e39b3

View file

@ -2,18 +2,17 @@
{:no-doc true} {:no-doc true}
(:require (:require
[cheshire.core :as json] [cheshire.core :as json]
[clojure.string :as str])) #_[clojure.string :as str]))
(def os-name (str/lower-case (System/getProperty "os.name"))) ;; (def os-name (str/lower-case (System/getProperty "os.name")))
(def os (cond (str/includes? os-name "mac") :mac ;; (def os (cond (str/includes? os-name "mac") :mac
(or (str/includes? os-name "nix") ;; (or (str/includes? os-name "nix")
(str/includes? os-name "nux")) :linux ;; (str/includes? os-name "nux")) :linux
(str/includes? os-name "win") :windows)) ;; (str/includes? os-name "win") :windows))
(def unix-like? (or (identical? os :linux) ;; (def unix-like? (or (identical? os :linux)
(identical? os :mac))) ;; (identical? os :mac)))
(def classes (def classes
(cond->
'{:all [java.io.BufferedReader '{:all [java.io.BufferedReader
java.io.BufferedWriter java.io.BufferedWriter
java.io.ByteArrayInputStream java.io.ByteArrayInputStream
@ -162,12 +161,7 @@
;; not supported: {:name "setURLStreamHandlerFactory"} ;; not supported: {:name "setURLStreamHandlerFactory"}
{:name "toExternalForm"} {:name "toExternalForm"}
{:name "toString"} {:name "toString"}
{:name "toURI"}]}}} {:name "toURI"}]}}})
unix-like? (->
(update :methods conj 'sun.nio.fs.UnixPath)
(update :all conj
'java.lang.UNIXProcess
'java.lang.UNIXProcess$ProcessPipeOutputStream))))
(defmacro gen-class-map [] (defmacro gen-class-map []
(let [classes (concat (:all classes) (let [classes (concat (:all classes)
@ -175,11 +169,17 @@
(:constructors classes) (:constructors classes)
(:methods classes) (:methods classes)
(:fields classes) (:fields classes)
(:instance-checks classes))] (:instance-checks classes))
(apply hash-map m (apply hash-map
(for [c classes (for [c classes
c [(list 'quote c) c]] c [(list 'quote c) c]]
c)))) c))]
(assoc m :public-class
(fn [v]
(cond (instance? java.nio.file.Path v)
java.nio.file.Path
(instance? java.lang.Process v)
java.lang.Process)))))
(def class-map (gen-class-map)) (def class-map (gen-class-map))

View file

@ -169,6 +169,8 @@
(deftest process-builder-test (deftest process-builder-test
(is (str/includes? (bb nil " (is (str/includes? (bb nil "
(def ls (-> (ProcessBuilder. [\"ls\"]) (.start))) (def ls (-> (ProcessBuilder. [\"ls\"]) (.start)))
(def input (.getOutputStream ls))
(.write (io/writer input) \"hello\") ;; dummy test just to see if this works
(def output (.getInputStream ls)) (def output (.getInputStream ls))
(assert (int? (.waitFor ls))) (assert (int? (.waitFor ls)))
(slurp output)") (slurp output)")