added detect_arch function and ARCH global variable

This commit is contained in:
Timerix 2025-04-25 19:23:41 +05:00
parent fa15e15758
commit 4d06f57758
2 changed files with 26 additions and 4 deletions

View File

@ -19,6 +19,7 @@ function load_config {
fi fi
OS=$(detect_os) OS=$(detect_os)
ARCH=$(detect_arch)
myprint_quiet $quiet "${GREEN}detected OS: $OS" myprint_quiet $quiet "${GREEN}detected OS: $OS"
# getting version of cbuild installation # getting version of cbuild installation

View File

@ -3,9 +3,9 @@
include "cbuild/myprint.sh" include "cbuild/myprint.sh"
function detect_os { function detect_os {
local uname_rezult="$(uname -o)" local uname_result="$(uname -o)"
# myprint "uname rezult: '$uname_rezult'" # myprint "uname result: '$uname_result'"
case "$uname_rezult" in case "$uname_result" in
Msys | Cygwin | MS/Windows) Msys | Cygwin | MS/Windows)
safeprint WINDOWS safeprint WINDOWS
;; ;;
@ -19,7 +19,28 @@ function detect_os {
safeprint MACOS 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 esac
} }