Restore standalone Windows and Linux build and debug support

This commit is contained in:
maxwes08
2026-10-23 12:58:35 +02:00
parent 85d4fb828a
commit 4c435fdd76
8 changed files with 205 additions and 55 deletions

View File

@@ -17,48 +17,71 @@ a claim about all current models. Validation must include conservation of
mass, momentum and energy, analytic acoustic modes, boundary reflection and
radiation, thermodynamics and convergence under time/space refinement.
## Build (Windows / Visual Studio)
## Build and run (Windows and Linux)
Open a Visual Studio Developer PowerShell (or initialize the MSVC environment
with `VsDevCmd.bat`), then run from this directory:
Both platforms use CMake 3.28 or newer, Git, and a C++20 compiler. The presets
build with optimizations and debugging symbols (`RelWithDebInfo`). The first
desktop configure fetches SFML 3.0.2 if it is not installed and needs network
access. Visual Studio is not required.
### Windows
Install CMake and Git and ensure both are on PATH. Then run from this folder
in a regular PowerShell terminal:
```powershell
cmake -S . -B build -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release
cmake --build build
ctest --test-dir build --output-on-failure
powershell -NoProfile -ExecutionPolicy Bypass -File .\tools\Setup-Windows.ps1
cmake --preset windows
cmake --build --preset windows
ctest --preset windows
.\out\build\windows-gcc\fluidsim_desktop.exe
```
## Build (Linux / Windows presets)
The setup script installs the portable [WinLibs](https://winlibs.com/) x64 UCRT
GCC bundle, including GDB and Ninja, in
`%LOCALAPPDATA%/FluidSimTools/mingw64`. It verifies the download's SHA-256
checksum, removes the downloaded archive, and reuses an existing installation.
It needs no administrator access and does not change your system PATH.
Each built executable gets its GCC runtime DLLs copied beside it so it also
runs directly from a terminal or Explorer.
The repository includes CMake presets and VS Code tasks for the desktop app.
Install CMake 3.28 or newer, a C++20 compiler, and Make on Linux. On Windows,
install Visual Studio 2022 with the C++ desktop workload and CMake. Configure
and build from the project root with:
### Linux
Install CMake 3.28 or newer, GCC with C++20 support, Make, GDB, and the SFML
development dependencies. For Ubuntu 24.04 / Debian with a suitable CMake:
```sh
sudo apt-get update
sudo apt-get install build-essential cmake git gdb pkg-config \
libx11-dev libxrandr-dev libxcursor-dev libxi-dev libudev-dev \
libgl1-mesa-dev libfreetype6-dev libflac-dev libogg-dev libvorbis-dev \
fonts-dejavu-core
cmake --preset linux
cmake --build --preset linux --target fluidsim_desktop
cmake --build --preset linux
ctest --preset linux
./build-desktop/fluidsim_desktop
```
On Windows, use the `windows` preset in place of `linux`. CMake fetches SFML
3.0.2 if it is not installed, so the first desktop configure needs network
access. In VS Code, choose **FluidSim desktop** in Run and Debug; the
same configuration selects the Windows executable on Windows. The `.vscode`
build task configures and builds the desktop target before launching it.
Other distributions need equivalent packages; see
[SFML's source-build dependencies](https://www.sfml-dev.org/tutorials/3.0/getting-started/build-from-source/).
Running the desktop app requires a graphical session and an audio device.
The UI uses the optional Fira Code Nerd Font file from `../fonts` when present.
Without it, the simulation still runs but text labels are hidden. To bundle a
font from another location, configure with `-DFLUIDSIM_FONT_FILE=/path/to/font.ttf`.
### VS Code
The first configure fetches SFML 3.0.2 with CMake FetchContent for the desktop
window and audio stream. `-DFLUIDSIM_BUILD_DESKTOP=OFF` builds only the headless
runner and physics tests.
Install the recommended **C/C++** and **CMake Tools** extensions and open this
folder. Select the `windows` or `linux` CMake preset for your platform. Choose
**FluidSim desktop**, **FluidSim two-stroke**, or **FluidSim Saab B205** in
**Run and Debug**, then press F5 or the green Run button. The launch
configurations select the platform's executable and GDB automatically; the
build task configures and builds the desktop target before launch.
Ctrl+F5 runs without debugging; Ctrl+Shift+B builds the desktop target only.
The command-line builds above also build the CLI, benchmarks, and tests.
Run the interactive simulator with:
```powershell
.\build\fluidsim_desktop.exe
```
The UI uses `../fonts/FiraCodeNerdFont-Medium.ttf` when available, then tries
installed Windows or Linux system fonts. To bundle another font, add
`-DFLUIDSIM_FONT_FILE=/path/to/font.ttf` to the configure command. For a
headless build, add `-DFLUIDSIM_BUILD_DESKTOP=OFF`; this skips SFML and the
desktop's graphics/audio dependencies.
Controls: hold `W` for throttle, `C` for clutch, `A` / `D` to shift, `Z` for
neutral, up/down to adjust throttle target, left/right to adjust engine load,
@@ -68,12 +91,14 @@ speed, and Space toggles real time.
The command-line runner is useful for repeatable checks:
```powershell
.\build\fluidsim_cpp.exe --seconds 1 --throttle 0.35
.\build\fluidsim_cpp.exe --scenario two-stroke --seconds 1 --throttle 0.3
.\build\fluidsim_cpp.exe --scenario helmholtz --seconds 1
.\build\fluidsim_cpp.exe --scenario pulse --seconds 1
.\out\build\windows-gcc\fluidsim_cpp.exe --seconds 1 --throttle 0.35
.\out\build\windows-gcc\fluidsim_cpp.exe --scenario two-stroke --seconds 1 --throttle 0.3
.\out\build\windows-gcc\fluidsim_cpp.exe --scenario helmholtz --seconds 1
.\out\build\windows-gcc\fluidsim_cpp.exe --scenario pulse --seconds 1
```
On Linux, use `./build-desktop/fluidsim_cpp` with the same arguments.
To compare deterministic checkpoints from the active C# twin scenario against
the C++ port (energy variation is disabled for repeatability), build the C++
trace runner and execute the PowerShell comparison script: