# Platform Entry Support

`platform.h`/`platform.cpp` define `Platform`, a class of nothing but `static` members that centralizes program identity (name, version, copyright, homepage), filesystem locations (library path, home directory, the three candidate config file paths), terminal introspection, and the configurable paths to external tools (OpenVAF compiler, Python interpreter). Where [Platform Specifics](libplatform.md) provides low-level, reusable `#ifdef`-guarded primitives, `Platform` is the simulator-specific layer built on top of them (and on [File Access](filesystem.md) and [Process Utilities](processutils.md)) that the rest of `simulator/` and `lib/` actually calls.

## Setup and configurable tool paths

`Platform::setup()` must be called once, early in `main()`, before anything else on `Platform` is used: it seeds `openVaf_` from `defaultOpenVafBinaryName()` and `pythonExecutable_` from `findPythonExecutable()` (both from [Platform Specifics](libplatform.md)). `setOpenVaf()`/`setOpenVafArgs()`/`setPythonExecutable()` let later steps override these defaults - `main()` checks the `SIM_OPENVAF` environment variable, and [`readConfig()`](config.md) applies `[Binaries]` settings from a `vacaskrc.toml` file - and the corresponding getters (`openVaf()`, `openVafArgs()`, `pythonExecutable()`) are what `CommandInterpreter` ([Command Interpreter](cmd.md)) and the OpenVAF compiler wrapper read back.

## Filesystem locations

- **`libraryPath()`** - the simulator's installed library directory, derived from the running executable's own path (`executableFile()` two levels up, plus `lib/<programName>` on non-Windows; see [Process Utilities](processutils.md)), cached in a function-local static.
- **`pythonPath()`** - `libraryPath()/python`, the directory added to a postprocessing script's `PYTHONPATH` so it can `import` simulator-supplied helper modules (see [Process Utilities](processutils.md)'s `runProcess()`).
- **`homeDir()`** - the user's home directory: `$HOME` on Linux, `%USERPROFILE%` (falling back to `%HOMEDRIVE%`+`%HOMEPATH%`) on Windows.
- **`systemConfig()`/`userConfig()`/`localConfig()`** - the three fixed candidate `vacaskrc.toml` locations `main()` checks, in order: a system-wide path (`/etc/vacask/vacaskrc.toml`, or `libraryPath()/vacaskrc.toml` on Windows), `homeDir()/.vacaskrc.toml`, and `.vacaskrc.toml` resolved from the current directory (`std::filesystem::weakly_canonical`). Each is a function-local static, computed once.

## Terminal introspection

`isTty(os)` and `ttyColumns(os)` answer "is this stream a terminal" and "how wide is it," dispatching on whether `os` is `std::cout`, `std::cerr`/`std::clog`, or something else (in which case `isTty()` is `false` and `ttyColumns()` is `0`) - implemented via `isatty()`/`ioctl(TIOCGWINSZ)` on POSIX and `GetConsoleMode()`/`GetConsoleScreenBufferInfo()` on Windows. [`AnalysisProgress`](progressbar.md) is the sole consumer: it uses these at construction to decide whether a progress bar can be drawn at all, and how wide to make it.

## Program identity

`programName`, `programVersion`, `programCopyright`, and `programHomepage` are `const std::string` statics built from preprocessor definitions (`PROGRAM_NAME`, `PROGRAM_VERSION`, `PROGRAM_COPYRIGHT`, `PROGRAM_HOMEPAGE`, supplied by the build system) via the `str_expand`/`to_str` stringizing macro pair. `main()` prints these in the simulator's startup banner.

## Fitting into the run

`Platform::setup()` and the derived paths it feeds ([Command Interpreter](cmd.md)'s `clearVariables()`, [`readConfig()`](config.md), the OpenVAF compiler wrapper) are among the first things [`main()`](main.md) touches, before any netlist file is even opened.
