refactor: migrate MICRO_PIP to fine-grained feature flags
Replace monolithic MICRO_PIP/PIP_MICRO with granular flags: Feature flags (CMake options + platform auto-detection): - PIP_NO_FILESYSTEM, PIP_NO_THREADS, PIP_NO_SOCKET - PIP_NO_PROCESS, PIP_NO_DYNLIB, PIP_NO_FFT, PIP_NO_SERIAL Embedded optimization flag: - PIP_EMBEDDED (auto-set for Pico SDK and FreeRTOS) Controls buffer sizes, time stubs, terminal fallback, init stubs Platform blocks in CMakeLists.txt: - Pico SDK: auto-disables FS, PROCESS, DYNLIB, FFT, SERIAL; conditionally disables THREADS (no FreeRTOS) and SOCKET (no LWIP) - FreeRTOS: auto-disables FS, PROCESS, DYNLIB, FFT, SERIAL; conditionally disables SOCKET (no LWIP) - Android: auto-disables PROCESS, DYNLIB, FFT Updated 96 files across libs/, utils/, tests/, and CMakeLists.txt. Builds verified for Linux (547 tests pass) and Pico SDK (100%). Removed all MICRO_PIP and PIP_MICRO references (0 remaining).
This commit is contained in:
+55
-50
@@ -22,9 +22,11 @@
|
||||
#include "piliterals_time.h"
|
||||
// clang-format off
|
||||
#ifndef WINDOWS
|
||||
#ifndef PICO_SDK
|
||||
# include <fcntl.h>
|
||||
# include <sys/ioctl.h>
|
||||
# include <termios.h>
|
||||
#endif // PICO_SDK
|
||||
#else
|
||||
# include <wingdi.h>
|
||||
# include <wincon.h>
|
||||
@@ -35,11 +37,12 @@
|
||||
// clang-format on
|
||||
|
||||
|
||||
#if !defined(PICO_SDK)
|
||||
using namespace PIScreenTypes;
|
||||
|
||||
|
||||
PRIVATE_DEFINITION_START(PIScreen::SystemConsole)
|
||||
#ifdef WINDOWS
|
||||
# ifdef WINDOWS
|
||||
void * hOut;
|
||||
CONSOLE_SCREEN_BUFFER_INFO sbi, csbi;
|
||||
CONSOLE_CURSOR_INFO curinfo;
|
||||
@@ -48,7 +51,7 @@ PRIVATE_DEFINITION_START(PIScreen::SystemConsole)
|
||||
WORD dattr;
|
||||
DWORD smode, written;
|
||||
PIVector<CHAR_INFO> chars;
|
||||
#endif
|
||||
# endif
|
||||
PRIVATE_DEFINITION_END(PIScreen::SystemConsole)
|
||||
|
||||
|
||||
@@ -59,16 +62,16 @@ PIScreen::SystemConsole::SystemConsole() {
|
||||
|
||||
|
||||
PIScreen::SystemConsole::~SystemConsole() {
|
||||
#ifdef WINDOWS
|
||||
# ifdef WINDOWS
|
||||
SetConsoleMode(PRIVATE->hOut, PRIVATE->smode);
|
||||
SetConsoleTextAttribute(PRIVATE->hOut, PRIVATE->dattr);
|
||||
#endif
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
void PIScreen::SystemConsole::begin() {
|
||||
int w, h;
|
||||
#ifdef WINDOWS
|
||||
# ifdef WINDOWS
|
||||
PRIVATE->ulcoord.X = 0;
|
||||
PRIVATE->hOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
GetConsoleScreenBufferInfo(PRIVATE->hOut, &PRIVATE->sbi);
|
||||
@@ -78,24 +81,24 @@ void PIScreen::SystemConsole::begin() {
|
||||
PRIVATE->ulcoord.Y = PRIVATE->sbi.srWindow.Top;
|
||||
GetConsoleMode(PRIVATE->hOut, &PRIVATE->smode);
|
||||
GetConsoleCursorInfo(PRIVATE->hOut, &PRIVATE->curinfo);
|
||||
#else
|
||||
# ifdef MICRO_PIP
|
||||
# else
|
||||
# ifdef PIP_EMBEDDED
|
||||
w = 80;
|
||||
h = 24;
|
||||
# else
|
||||
# else
|
||||
winsize ws;
|
||||
ioctl(0, TIOCGWINSZ, &ws);
|
||||
w = ws.ws_col;
|
||||
h = ws.ws_row;
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
resize(w, h);
|
||||
#ifdef WINDOWS
|
||||
# ifdef WINDOWS
|
||||
SetConsoleMode(PRIVATE->hOut, ENABLE_WRAP_AT_EOL_OUTPUT);
|
||||
GetConsoleScreenBufferInfo(PRIVATE->hOut, &PRIVATE->sbi);
|
||||
PRIVATE->bc.X = 0;
|
||||
PRIVATE->bc.Y = 0;
|
||||
#endif
|
||||
# endif
|
||||
clear();
|
||||
clearScreen();
|
||||
hideCursor();
|
||||
@@ -103,11 +106,11 @@ void PIScreen::SystemConsole::begin() {
|
||||
|
||||
|
||||
void PIScreen::SystemConsole::end() {
|
||||
#ifdef WINDOWS
|
||||
# ifdef WINDOWS
|
||||
SetConsoleTextAttribute(PRIVATE->hOut, PRIVATE->dattr);
|
||||
#else
|
||||
# else
|
||||
printf("\e[0m");
|
||||
#endif
|
||||
# endif
|
||||
moveTo(0, height);
|
||||
showCursor();
|
||||
}
|
||||
@@ -115,18 +118,18 @@ void PIScreen::SystemConsole::end() {
|
||||
|
||||
void PIScreen::SystemConsole::prepare() {
|
||||
int w = 80, h = 24;
|
||||
#ifdef WINDOWS
|
||||
# ifdef WINDOWS
|
||||
GetConsoleScreenBufferInfo(PRIVATE->hOut, &PRIVATE->csbi);
|
||||
w = PRIVATE->csbi.srWindow.Right - PRIVATE->csbi.srWindow.Left + 1;
|
||||
h = PRIVATE->csbi.srWindow.Bottom - PRIVATE->csbi.srWindow.Top + 1;
|
||||
#else
|
||||
# ifndef MICRO_PIP
|
||||
# else
|
||||
# ifndef PIP_EMBEDDED
|
||||
winsize ws;
|
||||
ioctl(0, TIOCGWINSZ, &ws);
|
||||
w = ws.ws_col;
|
||||
h = ws.ws_row;
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
resize(w, h);
|
||||
}
|
||||
|
||||
@@ -149,10 +152,10 @@ void PIScreen::SystemConsole::resize(int w, int h) {
|
||||
cells[i].resize(width);
|
||||
pcells[i].resize(width, Cell(PIChar()));
|
||||
}
|
||||
#ifdef WINDOWS
|
||||
# ifdef WINDOWS
|
||||
PRIVATE->sbi.srWindow = PRIVATE->csbi.srWindow;
|
||||
PRIVATE->chars.resize(width * height);
|
||||
#endif
|
||||
# endif
|
||||
for (int i = 0; i < pcells.size_s(); ++i)
|
||||
pcells[i].fill(Cell());
|
||||
clear();
|
||||
@@ -164,7 +167,7 @@ void PIScreen::SystemConsole::print() {
|
||||
if (mouse_x >= 0 && mouse_x < width && mouse_y >= 0 && mouse_y < height) {
|
||||
/// cells[mouse_y][mouse_x].format.flags ^= Inverse;
|
||||
}
|
||||
#ifdef WINDOWS
|
||||
# ifdef WINDOWS
|
||||
PRIVATE->srect = PRIVATE->sbi.srWindow;
|
||||
int dx0 = -1, dx1 = -1, dy0 = -1, dy1 = -1;
|
||||
for (int j = 0; j < height; ++j) {
|
||||
@@ -201,7 +204,7 @@ void PIScreen::SystemConsole::print() {
|
||||
PRIVATE->srect.Right -= width - dx1 - 1;
|
||||
PRIVATE->srect.Bottom -= height - dy1 - 1;
|
||||
WriteConsoleOutputW(PRIVATE->hOut, PRIVATE->chars.data(), PRIVATE->bs, PRIVATE->bc, &PRIVATE->srect);
|
||||
#else
|
||||
# else
|
||||
PIString s;
|
||||
int si = 0, sj = 0;
|
||||
CellFormat prf(0xFFFF);
|
||||
@@ -238,14 +241,14 @@ void PIScreen::SystemConsole::print() {
|
||||
}
|
||||
printf("\e[0m");
|
||||
fflush(0);
|
||||
#endif
|
||||
# endif
|
||||
pcells = cells;
|
||||
}
|
||||
|
||||
|
||||
#ifdef WINDOWS
|
||||
# define FOREGROUND_MASK (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE)
|
||||
# define BACKGROUND_MASK (BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE)
|
||||
# ifdef WINDOWS
|
||||
# define FOREGROUND_MASK (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE)
|
||||
# define BACKGROUND_MASK (BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE)
|
||||
ushort PIScreen::SystemConsole::attributes(const PIScreenTypes::Cell & c) {
|
||||
WORD attr = PRIVATE->dattr;
|
||||
if (c.format.flags & Bold)
|
||||
@@ -284,8 +287,8 @@ ushort PIScreen::SystemConsole::attributes(const PIScreenTypes::Cell & c) {
|
||||
}
|
||||
return attr;
|
||||
}
|
||||
# undef FOREGROUND_MASK
|
||||
# undef BACKGROUND_MASK
|
||||
# undef FOREGROUND_MASK
|
||||
# undef BACKGROUND_MASK
|
||||
|
||||
void PIScreen::SystemConsole::getWinCurCoord() {
|
||||
GetConsoleScreenBufferInfo(PRIVATE->hOut, &PRIVATE->csbi);
|
||||
@@ -304,7 +307,7 @@ void PIScreen::SystemConsole::newLine() {
|
||||
PRIVATE->ccoord.Y++;
|
||||
SetConsoleCursorPosition(PRIVATE->hOut, PRIVATE->ccoord);
|
||||
}
|
||||
#else // WINDOWS
|
||||
# else // WINDOWS
|
||||
PIString PIScreen::SystemConsole::formatString(const PIScreenTypes::Cell & c) {
|
||||
PIString ts = PIStringAscii("\e[0");
|
||||
switch (c.format.color_char) {
|
||||
@@ -333,39 +336,39 @@ PIString PIScreen::SystemConsole::formatString(const PIScreenTypes::Cell & c) {
|
||||
if ((c.format.flags & Inverse) == Inverse) ts += PIStringAscii(";7");
|
||||
return ts + 'm';
|
||||
}
|
||||
#endif // WINDOWS
|
||||
# endif // WINDOWS
|
||||
|
||||
|
||||
void PIScreen::SystemConsole::toUpperLeft() {
|
||||
#ifdef WINDOWS
|
||||
# ifdef WINDOWS
|
||||
SetConsoleCursorPosition(PRIVATE->hOut, PRIVATE->ulcoord);
|
||||
#else
|
||||
# else
|
||||
printf("\e[H");
|
||||
#endif
|
||||
# endif
|
||||
}
|
||||
|
||||
void PIScreen::SystemConsole::moveTo(int x, int y) {
|
||||
#ifdef WINDOWS
|
||||
# ifdef WINDOWS
|
||||
PRIVATE->ccoord.X = x;
|
||||
PRIVATE->ccoord.Y = PRIVATE->ulcoord.Y + y;
|
||||
SetConsoleCursorPosition(PRIVATE->hOut, PRIVATE->ccoord);
|
||||
#else
|
||||
# else
|
||||
printf("\e[%d;%dH", y + 1, x + 1);
|
||||
#endif
|
||||
# endif
|
||||
}
|
||||
|
||||
void PIScreen::SystemConsole::clearScreen() {
|
||||
#ifdef WINDOWS
|
||||
# ifdef WINDOWS
|
||||
toUpperLeft();
|
||||
FillConsoleOutputAttribute(PRIVATE->hOut, PRIVATE->dattr, width * (height + 1), PRIVATE->ulcoord, &PRIVATE->written);
|
||||
FillConsoleOutputCharacter(PRIVATE->hOut, ' ', width * (height + 1), PRIVATE->ulcoord, &PRIVATE->written);
|
||||
#else
|
||||
# else
|
||||
printf("\e[0m\e[H\e[J");
|
||||
#endif
|
||||
# endif
|
||||
}
|
||||
|
||||
void PIScreen::SystemConsole::clearScreenLower() {
|
||||
#ifdef WINDOWS
|
||||
# ifdef WINDOWS
|
||||
getWinCurCoord();
|
||||
FillConsoleOutputAttribute(PRIVATE->hOut,
|
||||
PRIVATE->dattr,
|
||||
@@ -377,27 +380,27 @@ void PIScreen::SystemConsole::clearScreenLower() {
|
||||
width * height - width * PRIVATE->ccoord.Y + PRIVATE->ccoord.X,
|
||||
PRIVATE->ccoord,
|
||||
&PRIVATE->written);
|
||||
#else
|
||||
# else
|
||||
printf("\e[0m\e[J");
|
||||
#endif
|
||||
# endif
|
||||
}
|
||||
|
||||
void PIScreen::SystemConsole::hideCursor() {
|
||||
#ifdef WINDOWS
|
||||
# ifdef WINDOWS
|
||||
PRIVATE->curinfo.bVisible = false;
|
||||
SetConsoleCursorInfo(PRIVATE->hOut, &PRIVATE->curinfo);
|
||||
#else
|
||||
# else
|
||||
printf("\e[?25l");
|
||||
#endif
|
||||
# endif
|
||||
}
|
||||
|
||||
void PIScreen::SystemConsole::showCursor() {
|
||||
#ifdef WINDOWS
|
||||
# ifdef WINDOWS
|
||||
PRIVATE->curinfo.bVisible = true;
|
||||
SetConsoleCursorInfo(PRIVATE->hOut, &PRIVATE->curinfo);
|
||||
#else
|
||||
# else
|
||||
printf("\e[?25h");
|
||||
#endif
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
@@ -602,9 +605,9 @@ void PIScreen::start(bool wait) {
|
||||
void PIScreen::stop(bool clear) {
|
||||
PIThread::stopAndWait();
|
||||
if (clear) console.clearScreen();
|
||||
#ifndef WINDOWS
|
||||
# ifndef WINDOWS
|
||||
fflush(0);
|
||||
#endif
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
@@ -657,3 +660,5 @@ PIScreenTile * PIScreen::tileByName(const PIString & name) {
|
||||
if (t->name() == name) return t;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // !PICO_SDK
|
||||
|
||||
Reference in New Issue
Block a user