← board

Dynamic Include Paths, Configuration Files, and System Scanner

Motivation

Avoid hardcoding host system search paths in the compiler (parser.inc and cpreproc.inc). Provide command-line include flags, support configuration files for targets and libraries, and create a scanner tool to automatically discover and map SDKs/libraries (including ESP-IDF and host system libraries) without baking locations into the compiler.

Scope

Non-goals

Acceptance

Per-library scoped configuration (added 2026-06-19)

Beyond a global pxx.cfg, support per-directory library manifests so a library's compile settings (defines, undefs, dialect mode, include paths) apply only to units under that library's folder tree — never virally to the user's program or to sibling libraries. This is the general mechanism for compiling any third-party Pascal library that needs a different define/mode profile (Synapse, IDF, GTK, …) without CLI flags each time and without editing the library source.

Load-bearing primitive — per-unit define-scope save/restore keyed to the unit's source directory:

on begin-compiling unit U (path P):
    push define-state
    find nearest-ancestor manifest of P   (e.g. lib/synapse/pxxlib.cfg)
    apply its defines / undefs / mode / include paths
    ... compile U ...
    pop define-state

Because the scope follows the unit being compiled (its own directory), not the caller, cross-uses is automatically clean: a Synapse unit using our RTL and our code using Synapse each compile under their own directory's manifest. Sibling libraries never see each other's defines. The user's program (no manifest above it) keeps the base/command-line defines untouched.

Manifest = a small per-library build profile in the library root, e.g. lib/synapse/pxxlib.cfg:

define   POSIX
define   LINUX
define   UNIX
undef    FPC          # not-FPC selects Synapse's Delphi-Posix branch AND dodges
                      # the {$ifdef FPC}=real-FPC landmine — scoped, so it can't
                      # leak into our own code in the same build
mode     delphi       # the @-operator relax (see feature-mimic-fpc)
incpath  .

Relationship to feature-mimic-fpc: this supersedes the global --mimic define-profile idea. The Synapse define set becomes a scoped manifest, which is strictly better — the viral-leak / FPC-define-landmine worry disappears because undef FPC only applies under lib/synapse/.

Cost: (1) stackable define scope (push/pop), (2) resolver tracks the current unit's directory + nearest-ancestor manifest lookup, (3) a tiny manifest parser. Medium, but it is the general solution for ALL third-party libs, not a one-off.

Log