From ab32a441a6aafb29cf615e14dcd284e9f62786ef Mon Sep 17 00:00:00 2001 From: Shagun Agrawal Date: Wed, 24 Jul 2024 18:51:24 +0530 Subject: Add initial compiler implementation --- src/cljcc/util.clj | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/cljcc/util.clj (limited to 'src/cljcc/util.clj') 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))) -- cgit v1.2.3