From: Mikko Rasa Date: Sat, 28 Aug 2021 13:00:12 +0000 (+0300) Subject: Move system-specific code to a separate file X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=1f694afd5fc5e282c3e814d4f3a96ff0f7c928cd;p=builder.git Move system-specific code to a separate file --- diff --git a/source/architecture.cpp b/source/architecture.cpp index 63ec6ba..8bdd1bf 100644 --- a/source/architecture.cpp +++ b/source/architecture.cpp @@ -1,11 +1,9 @@ #include -#ifndef _WIN32 -#include -#endif #include #include #include "architecture.h" #include "builder.h" +#include "sysutils.h" using namespace std; using namespace Msp; @@ -95,18 +93,9 @@ Architecture::Architecture(Builder &b, const string &spec): { if(spec.empty()) { -#ifdef _WIN32 - system = "windows"; -#else - utsname un; - if(uname(&un)==0) - { - system = tolower(un.sysname); - parse_specification(tolower(un.machine)); - // We really only want to set type for the default arch - cpu.clear(); - } -#endif + parse_specification(get_system_type()); + // We really only want to set type for the default arch + cpu.clear(); bits = sizeof(void *)*numeric_limits::digits; native = true; } diff --git a/source/sysutils.cpp b/source/sysutils.cpp new file mode 100644 index 0000000..6e1828c --- /dev/null +++ b/source/sysutils.cpp @@ -0,0 +1,22 @@ +#ifndef _WIN32 +#include +#endif +#include +#include +#include "sysutils.h" + +using namespace std; +using namespace Msp; + +string get_system_type() +{ +#ifdef _WIN32 + return "windows"; +#else + utsname un; + if(uname(&un)==0) + return tolower(format("%s-%s", un.sysname, un.machine)); +#endif + + return string(); +} diff --git a/source/sysutils.h b/source/sysutils.h new file mode 100644 index 0000000..c422b7f --- /dev/null +++ b/source/sysutils.h @@ -0,0 +1,8 @@ +#ifndef SYSUTILS_H_ +#define SYSUTILS_H_ + +#include + +std::string get_system_type(); + +#endif