platformio_pre.py

This commit is contained in:
Andrey
2022-01-14 18:15:56 +03:00
parent 0504fa187e
commit a7df53fbfe
34 changed files with 200 additions and 117 deletions

View File

@@ -25,7 +25,7 @@
#include "pisysteminfo.h"
#include "piresourcesstorage.h"
#include "pidir.h"
#ifndef FREERTOS
#ifndef MICRO_PIP
# include "piprocess.h"
#endif
#ifdef ESP_PLATFORM
@@ -49,7 +49,7 @@ void __PISetTimerResolution() {
}
#else
# include <pwd.h>
# ifndef FREERTOS
# ifndef MICRO_PIP
# include <sys/utsname.h>
# endif
# include <pthread.h>
@@ -84,7 +84,7 @@ ULONG prev_res;
bool delete_locs;
PRIVATE_DEFINITION_END(PIInit)
#ifndef FREERTOS
#ifndef MICRO_PIP
void __sighandler__(PISignals::Signal s) {
//piCout << Hex << int(s);
if (s == PISignals::StopTTYInput || s == PISignals::StopTTYOutput)
@@ -106,12 +106,12 @@ PIInit::PIInit() {
file_charset = 0;
PISystemInfo * sinfo = PISystemInfo::instance();
sinfo->execDateTime = PIDateTime::current();
#ifndef MICRO_PIP
setFileCharset("UTF-8");
#ifndef FREERTOS
#ifndef ANDROID
# ifndef ANDROID
PISignals::setSlot(__sighandler__);
PISignals::grabSignals(PISignals::UserDefined1);
# ifndef WINDOWS
# ifndef WINDOWS
PISignals::grabSignals(PISignals::StopTTYInput | PISignals::StopTTYOutput);
sigset_t ss;
sigemptyset(&ss);
@@ -128,7 +128,7 @@ PIInit::PIInit() {
break;
}
}
# else
# else //WINDOWS
// OS version
DWORD dwVersion = GetVersion();
DWORD dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
@@ -154,33 +154,33 @@ PIInit::PIInit() {
setTimerResolutionAddr = (PINtSetTimerResolution)GetProcAddress(PRIVATE->ntlib, "NtSetTimerResolution");
__PISetTimerResolution();
}
# endif
# ifdef HAS_LOCALE
# endif //WINDOWS
# ifdef HAS_LOCALE
//cout << "has locale" << endl;
if (currentLocale_t != 0) {
freelocale(currentLocale_t);
currentLocale_t = 0;
}
currentLocale_t = newlocale(LC_ALL, setlocale(LC_ALL, ""), 0);
# else
# else //HAS_LOCALE
setlocale(LC_ALL, "");
setlocale(LC_NUMERIC, "C");
# endif
#else
# endif //HAS_LOCALE
# else //ANDROID
struct sigaction actions;
memset(&actions, 0, sizeof(actions));
sigemptyset(&actions.sa_mask);
actions.sa_flags = 0;
actions.sa_handler = android_thread_exit_handler;
sigaction(SIGTERM, &actions, 0);
#endif
# endif //ANDROID
PRIVATE->delete_locs = false;
__syslocname__ = __sysoemname__ = 0;
__utf8name__ = const_cast<char*>("UTF-8");
#ifdef PIP_ICU
# ifdef PIP_ICU
UErrorCode e((UErrorCode)0);
u_init(&e);
# ifdef WINDOWS
# ifdef WINDOWS
PRIVATE->delete_locs = true;
CPINFOEX cpinfo;
int l = 0;
@@ -192,30 +192,30 @@ PIInit::PIInit() {
memset(__sysoemname__, 0, 256);
memcpy(__sysoemname__, "ibm-", 4);
memcpy(&(__sysoemname__[4]), cpinfo.CodePageName, l);
# else
# else
/*PIString en(getenv("LANG"));
if (!en.isEmpty())
en = en.mid(en.find(".") + 1);
PIByteArray enba = en.toByteArray();
memcpy(__syslocname__, enba.data(), enba.size_s());*/
# endif
# endif
//piCout << __syslocname__;
//piCout << __sysoemname__;
#else
# ifdef WINDOWS
# else //PIP_ICU
# ifdef WINDOWS
__syslocname__ = (char *)CP_ACP;
__sysoemname__ = (char *)CP_OEMCP;
__utf8name__ = (char *)CP_UTF8;
# endif
#endif
#ifdef MAC_OS
# endif
# endif //PIP_ICU
# ifdef MAC_OS
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &__pi_mac_clock);
#endif
# endif
char cbuff[1024];
memset(cbuff, 0, 1024);
if (gethostname(cbuff, 1023) == 0)
sinfo->hostname = cbuff;
#ifdef WINDOWS
# ifdef WINDOWS
SYSTEM_INFO sysinfo;
GetSystemInfo(&sysinfo);
sinfo->processorsCount = sysinfo.dwNumberOfProcessors;
@@ -236,7 +236,7 @@ PIInit::PIInit() {
ulong unlen = 1023;
if (GetUserName(cbuff, &unlen) != 0)
sinfo->user = cbuff;
#else
# else //WINDOWS
sinfo->processorsCount = piMaxi(1, int(sysconf(_SC_NPROCESSORS_ONLN)));
passwd * ps = getpwuid(getuid());
if (ps)
@@ -252,8 +252,9 @@ PIInit::PIInit() {
sinfo->OS_version = uns.release;
sinfo->architecture = uns.machine;
}
# endif
#endif
# endif //WINDOWS
#endif // MICRO_PIP
#ifdef ESP_PLATFORM
esp_chip_info_t chip_info;
esp_chip_info(&chip_info);
@@ -265,19 +266,21 @@ PIInit::PIInit() {
sinfo->OS_name =
#ifdef WINDOWS
PIStringAscii("Windows");
#elif defined(QNX)
# elif defined(QNX)
PIStringAscii("QNX");
#elif defined(MAC_OS)
# elif defined(MAC_OS)
PIStringAscii("MacOS");
#elif defined(ANDROID)
# elif defined(ANDROID)
PIStringAscii("Android");
#elif defined(FREE_BSD)
# elif defined(FREE_BSD)
PIStringAscii("FreeBSD");
#elif defined(FREERTOS)
# elif defined(FREERTOS)
PIStringAscii("FreeRTOS");
#else
# elif defined(MICRO_PIP)
PIStringAscii("MicroPIP");
# else
uns.sysname;
#endif
# endif
}