From 4d06f57758853d8c731cbcce9f20db6d15ea6556 Mon Sep 17 00:00:00 2001 From: Timerix Date: Fri, 25 Apr 2025 19:23:41 +0500 Subject: [PATCH] added detect_arch function and ARCH global variable --- config.sh | 1 + detect_os.sh | 29 +++++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/config.sh b/config.sh index bf3cc6a..29f9497 100644 --- a/config.sh +++ b/config.sh @@ -19,6 +19,7 @@ function load_config { fi OS=$(detect_os) + ARCH=$(detect_arch) myprint_quiet $quiet "${GREEN}detected OS: $OS" # getting version of cbuild installation diff --git a/detect_os.sh b/detect_os.sh index b69e5d4..dea5728 100644 --- a/detect_os.sh +++ b/detect_os.sh @@ -3,9 +3,9 @@ include "cbuild/myprint.sh" function detect_os { - local uname_rezult="$(uname -o)" - # myprint "uname rezult: '$uname_rezult'" - case "$uname_rezult" in + local uname_result="$(uname -o)" + # myprint "uname result: '$uname_result'" + case "$uname_result" in Msys | Cygwin | MS/Windows) safeprint WINDOWS ;; @@ -19,7 +19,28 @@ function detect_os { safeprint MACOS ;; *) - error "unknown operating system: $uname_rezult" + error "unknown operating system: $uname_result" + ;; + esac +} + +function detect_arch { + local uname_result="$(uname -m)" + case "$uname_result" in + arm | arm32 | armhf | aarch32) + safeprint arm32 + ;; + arm64 | aarch64 | aarch64_be | armv8b | armv8l) + safeprint arm64 + ;; + x86 | i386 | i486 | i686) + safeprint x86 + ;; + x64 | x86_64 | amd64) + safeprint x64 + ;; + *) + error "unknown CPU architecture: $uname_result" ;; esac }