Skip to content

Commit

Permalink
try detect rosetta environment
Browse files Browse the repository at this point in the history
  • Loading branch information
snmsts committed Jan 17, 2024
1 parent 573fcee commit eac8e53
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
1 change: 1 addition & 0 deletions bin/main.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
(sb-posix:unsetenv "P")
(setf *stage1-commit* (uiop:read-file-line "lib/commit"))
(lib-init)
(strip-run-cmd nil) ;; clear all cache
(uname-s)
(uname-m))

Expand Down
11 changes: 9 additions & 2 deletions bin/uname.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@

(defun uname-m ()
(let ((m (strip-run-cmd "uname -m" :cache t)))
(cond ((equal m "i86pc")
(cond ((equal m "x86_64")
(or
#+darwin
(when (equal (strip-run-cmd "sysctl -in sysctl.proc_translated" :cache t)
"1")
"arm64") ;;rosetta
"x86-64"))
((equal m "i86pc")
;; solaris
(if (equal (strip-run-cmd "isainfo -k" :cache t)
"amd64")
Expand Down Expand Up @@ -54,7 +61,7 @@

(defun core-path (base-path)
(merge-pathnames (format nil "core/~A/~A/roswell~A"
(uname-m)
(uname-m)
(uname-s)
(exeext)) base-path))

Expand Down
21 changes: 12 additions & 9 deletions bin/util.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,18 @@
(defvar *strip-run-cmd-hash* (make-hash-table :test 'equal))

(defun strip-run-cmd (cmd &key cache)
(unless cache
(remhash cmd *strip-run-cmd-hash*))
(if (eql (gethash cmd *strip-run-cmd-hash* t) t)
(setf (gethash cmd *strip-run-cmd-hash*)
(uiop:run-program
cmd
:output '(:string :stripped t)
:ignore-error-status t))
(gethash cmd *strip-run-cmd-hash*)))
(cond (cmd
(unless cache
(remhash cmd *strip-run-cmd-hash*))
(if (eql (gethash cmd *strip-run-cmd-hash* t) t)
(setf (gethash cmd *strip-run-cmd-hash*)
(uiop:run-program
cmd
:output '(:string :stripped t)
:ignore-error-status t))
(gethash cmd *strip-run-cmd-hash*)))
(t
(setf *strip-run-cmd-hash* (make-hash-table :test 'equal)))))

(defun which (cmd)
"find out command's full path."
Expand Down

0 comments on commit eac8e53

Please sign in to comment.