emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/emacsql be9c46c274 259/427: Change the way tuples are comp


From: ELPA Syncer
Subject: [nongnu] elpa/emacsql be9c46c274 259/427: Change the way tuples are computed.
Date: Tue, 13 Dec 2022 02:59:49 -0500 (EST)

branch: elpa/emacsql
commit be9c46c2746a7e27d06a294547edfcf480f011ed
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>

    Change the way tuples are computed.
---
 emacsql-sqlite.el |  2 +-
 emacsql-system.el | 48 +++++++++++++++++++-----------------------------
 2 files changed, 20 insertions(+), 30 deletions(-)

diff --git a/emacsql-sqlite.el b/emacsql-sqlite.el
index a8afc23cdd..5a60eec670 100644
--- a/emacsql-sqlite.el
+++ b/emacsql-sqlite.el
@@ -8,7 +8,7 @@
 (require 'emacsql-system)
 
 (defvar emacsql-sqlite-executable
-  (expand-file-name (emacsql-system-binary "bin/emacsql-sqlite")
+  (expand-file-name (concat "bin/emacsql-sqlite-" (emacsql-system-tuple))
                     (file-name-directory load-file-name))
   "Path to the Emacsql backend (this is not the sqlite3 shell).")
 
diff --git a/emacsql-system.el b/emacsql-system.el
index 8bca22b24a..38a8618f23 100644
--- a/emacsql-system.el
+++ b/emacsql-system.el
@@ -8,40 +8,30 @@
 
 (defun emacsql-system-normalize-arch (arch)
   "Normalize the name of string ARCH."
-  (cl-case (intern arch)
-    ((x86 i386 i486 i586 i686) 'x86)
-    ((x86_64 amd64) 'x86_64)
-    (otherwise (intern arch))))
-
-(defun emacsql-system-architecture ()
-  "Determine this system's architecture."
-  (emacsql-system-normalize-arch
-    (if (executable-find "uname")
-        (with-temp-buffer
-          (call-process "uname" nil (current-buffer) nil "-m")
-          (replace-regexp-in-string "\\s " "" (buffer-string)))
-      (getenv "PROCESSOR_ARCHITECTURE"))))
+  (cond ((string-match-p "^i[0-9]\\{3\\}" arch) "x86")
+        ((string-match-p "^amd64" arch) "x86_64")
+        (arch)))
+
+(defun emacsql-system-normalize-os (os)
+  "Normalize OS into a simple canonical name.
+Unfortunately config.guess has lots of names for Windows."
+  (cond ((string-match-p "^nt" os) "windows")
+        ((string-match-p "^ming" os) "windows")
+        ((string-match-p "^cygwin" os) "windows")
+        ((string-match-p "^linux" os) "linux")
+        (os)))
 
 (defun emacsql-system-tuple ()
-  "Return a tuple (kernel architecture) for the current system."
-  (list
-   (emacsql-system-architecture)
-   (cl-ecase system-type
-     (gnu 'hurd)
-     (gnu/linux 'linux)
-     ((gnu/kfreebsd berkeley-unix) 'bsd)
-     (darwin 'darwin)
-     (ms-dos 'dos)
-     (windows-nt 'windows)
-     (cygwin 'windows))))
-
-(defun emacsql-system-binary (prefix)
-  "Determine an executable name for PREFIX."
-  (concat prefix "-" (mapconcat #'symbol-name (emacsql-system-tuple) "-")))
+  "Determine the architecture-system tuple for Emacs' host system."
+  (cl-destructuring-bind (arch _vendor . os-parts)
+      (split-string system-configuration "-")
+    (let ((os (mapconcat #'identity os-parts "-")))
+      (format "%s-%s" (emacsql-system-normalize-arch arch)
+              (emacsql-system-normalize-os os)))))
 
 (defun emacsql-system-print-tuple ()
   "This is for calling from a Makefile."
-  (princ (mapconcat #'symbol-name (emacsql-system-tuple) "-"))
+  (emacsql-system-tuple)
   (princ "\n"))
 
 (provide 'emacsql-system)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]