Skip to content

Commit

Permalink
get OS and CPU info via Qt (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
da-liii authored May 4, 2022
1 parent df96c4d commit 834d524
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 43 deletions.
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,6 @@ option (USE_JEAIII "Use JEAIII itoa" ON)

set (CONFIG_STD_SETENV "#define STD_SETENV")
set (tm_orig ${TEXMACS_SOURCE_DIR})
set (CONFIG_HOST_OS ${CMAKE_HOST_SYSTEM_NAME})
set (CONFIG_HOST_VENDOR "pc") # TODO: should not be hard-coded
set (CONFIG_HOST_CPU ${CMAKE_SYSTEM_PROCESSOR})
set (CONFIG_USER $ENV{USER})
string (TIMESTAMP CONFIG_DATE)
set (tm_devel TeXmacs-${DEVEL_VERSION})
Expand Down
11 changes: 11 additions & 0 deletions src/Plugins/Qt/qt_sys_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,22 @@
******************************************************************************/

#include "qt_sys_utils.hpp"
#include "qt_utilities.hpp"
#include "basic.hpp"
#include "string.hpp"

#include <QProcess>
#include <QString>
#include <QSysInfo>


string qt_get_current_cpu_arch () {
return from_qstring (QSysInfo::currentCpuArchitecture ());
}

string qt_get_pretty_os_name () {
return from_qstring (QSysInfo::prettyProductName ());
}

static void
ReadOutputs(QProcess& p, string& o, string& e) {
Expand Down
4 changes: 4 additions & 0 deletions src/Plugins/Qt/qt_sys_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

#include "string.hpp"


string qt_get_current_cpu_arch ();
string qt_get_pretty_os_name ();

/* exitcode= qt_system (command, result);
*
* Execute /command/ in the local command interpreter. Return all
Expand Down
22 changes: 21 additions & 1 deletion src/System/Misc/sys_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,35 @@
#include "parse_string.hpp"

#ifdef OS_MINGW
#include "Qt/qt_sys_utils.hpp"
#include "Windows/mingw_sys_utils.hpp"
#include "Windows/win-utf8-compat.hpp"
#else
#include "Unix/unix_sys_utils.hpp"
#endif

#ifdef QTTEXMACS
#include "Qt/qt_sys_utils.hpp"
#endif

int script_status = 1;


string get_current_cpu_arch () {
#ifdef QTTEXMACS
return qt_get_current_cpu_arch ();
#else
return "unknown";
#endif
}

string get_pretty_os_name () {
#ifdef QTTEXMACS
return qt_get_pretty_os_name ();
#else
return "unknown";
#endif
}

/******************************************************************************
* System functions
******************************************************************************/
Expand Down
4 changes: 3 additions & 1 deletion src/System/Misc/sys_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@

extern int script_status; // 0: never accept, 1: prompt, 2: always accept

string get_current_cpu_arch ();
string get_pretty_os_name ();

int system (string s);
int system (string s, string &r);
int system (string s, string &r, string& e);
string eval_system (string s);
string var_eval_system (string s);
string get_env (string var);
void set_env (string var, string with);
int os_version ();
string get_stacktrace (unsigned int max_frames= 127);

url get_texmacs_path ();
Expand Down
3 changes: 0 additions & 3 deletions src/System/tm_configure.hpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
#define WORD_MASK @CONFIG_WORD_MASK@
#define MAX_FAST @CONFIG_MAX_FAST@

#define HOST_OS "@CONFIG_HOST_OS@"
#define HOST_VENDOR "@CONFIG_HOST_VENDOR@"
#define HOST_CPU "@CONFIG_HOST_CPU@"
#define BUILD_USER "@CONFIG_USER@"
#define BUILD_DATE "@CONFIG_DATE@"

Expand Down
31 changes: 0 additions & 31 deletions src/System/tm_configure.in

This file was deleted.

6 changes: 2 additions & 4 deletions src/Texmacs/Server/tm_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@ get_system_information () {
r << " Building date : "
<< BUILD_DATE << "\n";
r << " Operating system : "
<< HOST_OS << "\n";
r << " Vendor : "
<< HOST_VENDOR << "\n";
<< get_pretty_os_name () << "\n";
r << " Processor : "
<< HOST_CPU << "\n";
<< get_current_cpu_arch () << "\n";
r << " Crash date : "
<< var_eval_system ("date") << "\n";
return r;
Expand Down

0 comments on commit 834d524

Please sign in to comment.