Configuring CrabPascal with crabpascal.toml | Configurando com crabpascal.toml
Bilingual post · Post bilíngue Jump to: English · Português English {#english} Configuring CrabPascal with crabpascal.toml Every serious compiler needs project-level configuration. CrabPascal v2.22.0 reads crabpascal.toml from your project root — search paths, preprocessor symbols, Delphi vs FPC mode, output format, and runtime defaults. Where the file lives The compiler searches in order: crabpascal.toml (project root) .crabpascal.toml (hidden) config/crabpascal.toml If none exist, sensible defaults apply. Add the file when your project grows beyond a single .dpr . Starter configuration [compiler] version = "2.22.0" search_paths = [ "rtl/" , "lib/" , "examples/" ] defines = [ "CRABPASCAL" , "RELEASE" , "MSWINDOWS" ] mode = "DELPHI" # or "OBJFPC" strict = false warnings = true [preprocessor] enabled = true process_includes = true symbols = [] [output] error_format = "vscode" # or "gcc", "delphi" colors = true [runtime] default_http_port = 9000 [paths] rtl_path = "rtl/" output_path = "output/" Place this beside your .dpr file. All CLI commands ( check , run , build-exe ) pick it up automatically. Common use cases Delphi vs Free Pascal mode [compiler] mode = "DELPHI" defines = [ "CRABPASCAL" , "MSWINDOWS" ] Switch to FPC compatibility: [compiler] mode = "OBJFPC" defines = [ "FPC" , "UNIX" ] Mode affects parsing rules and RTL resolution under rtl/ . Custom unit search paths Large projects split units across folders: [compiler] search_paths = [ "rtl/" , "src/units/" , "src/services/" , "third_party/" ] This replaces hardcoded -U flags in scripts. Preprocessor symbols Match Delphi conditional compilation: [preprocessor] enabled = true symbols = [ "DEBUG" , "TESTING" ] Your Pascal code can use: {$IFDEF DEBUG} WriteLn ( 'Debug build' ); {$ENDIF} Run crab-pascal preproc MyApp.dpr to inspect expanded source. CI-friendly error output [output] error_format = "gcc" colors = false show_stacktrace = false GitHub Actions parsers often prefer gcc-style lines. Local development can