aboutsummaryrefslogtreecommitdiff
path: root/src/cljcc/util.clj
diff options
context:
space:
mode:
Diffstat (limited to 'src/cljcc/util.clj')
-rw-r--r--src/cljcc/util.clj19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/cljcc/util.clj b/src/cljcc/util.clj
new file mode 100644
index 0000000..1087029
--- /dev/null
+++ b/src/cljcc/util.clj
@@ -0,0 +1,19 @@
+(ns cljcc.util
+ (:require [clojure.java.shell :refer [sh]]))
+
+(defn get-os []
+ (let [os-name (.toLowerCase (System/getProperty "os.name"))]
+ (cond
+ (.contains os-name "mac") :mac
+ (.contains os-name "linux") :linux
+ :else :unsupported)))
+
+(defn mac-aarch64? []
+ (and (= :mac (get-os)) (= (System/getProperty "os.arch" "aarch64"))))
+
+(defn handle-sh
+ "Preprends arch -x86_64 if running under Mac M chips."
+ [command & args]
+ (if (mac-aarch64?)
+ (apply sh "arch" "-x86_64" command args)
+ (apply sh command args)))