Skip to content

Build Script Simplification

Executive Summary

The run subcommand in build.py previously delegated executable launch to a CMake script (run-executable.cmake) via cmake -P. This indirection was originally necessary to inject CMake preset variables and environment into the execution context. However, since CMake 4.x removed --preset support in script mode, all variables were already being passed manually via -D flags — making the CMake script an unnecessary intermediate layer. The entire execution path was consolidated into Python, eliminating the CMake script, removing the --exec flag, and replacing hardcoded Qt bin subdirectory mapping with a preset-driven configuration variable (SF_QT_BIN_SUBDIR).


Technical Details & Changes

  1. Removed CMake Script Path: The else branch in SubCommandRun.handle() (which invoked cmake -P run-executable.cmake) was entirely removed. The Python execution path, previously gated behind the --exec flag, is now the default and only behavior.

  2. Removed --exec / -e Flag: With only one execution path remaining, the flag distinguishing between the CMake script and Python paths became redundant and was removed from the argument parser.

  3. Preset-Driven Qt Bin Subdirectory: The hardcoded compiler-to-Qt-subdirectory mapping in Python, qt_subdir = "mingw_64" if compiler_type == "gw" else "gcc_64", was replaced by reading SF_QT_BIN_SUBDIR from the CMake preset's cacheVariables. This variable was added to all five toolchain presets (.tc-gnu, .tc-ga, .tc-gw, .tc-mingw, .tc-msvc).

  4. Removed cmake_encode() Method: The static method that URL-encoded arguments for CMake list syntax is no longer needed and was deleted.

  5. Configuration Cleanup: Obsolete entries (cmake-run-file and qt-bin-* fields) were removed from build.ini [config] section.

  6. Deleted run-executable.cmake: The CMake script file was removed from cmake/lib/.


Benefits

1. Console Input Fixed

The previous nested process chain (build.py → cmake -P → execute_process() → command) broke TTY settings, causing interactive commands like cmd to not echo or register typed characters. The direct Python path (build.py → subprocess.run() → command) preserves proper TTY inheritance.

2. Simpler Codebase

  • No CMake script to maintain alongside Python logic
  • No dual execution paths to keep in sync
  • No argument encoding/decoding between Python and CMake

3. Configuration Centralization

The Qt bin subdirectory is now defined in the toolchain presets alongside SF_COMPILER, making the mapping explicit and discoverable without reading code.

4. No Behavior Change for Non-Qt Projects

All Qt-related environment setup is properly guarded: if SF_QT_BIN_SUBDIR is absent from the preset or RUN_QT_VER_DIR is not in the environment, the Qt PATH/WINEPATH prefixing is silently skipped.


Files Modified

File Change
build.py Removed --exec flag, CMake script path, cmake_encode() method, and hardcoded Qt mapping; reads SF_QT_BIN_SUBDIR from preset
CMakePresets.json Added SF_QT_BIN_SUBDIR cache variable to 5 toolchain presets
build.ini Removed cmake-run-file and qt-bin-* fields from [config]
cmake/lib/run-executable.cmake Deleted

Verification

The changes were verified by confirming:

  • Zero remaining references to cmake-run-file, run-executable, cmake_encode, args.exec, or qt-bin- in build.py and build.ini.
  • The run-executable.cmake file was deleted from disk.
  • The Python execution path correctly handles all three platform/compiler combinations: Linux/gw with Wine, Windows with mingw/msvc, and Linux native with gnu/ga.