From 3521edda975f52ccf5abf403fef8dfb6b0ca95d3 Mon Sep 17 00:00:00 2001 From: Jim McKeeth Date: Thu, 9 Apr 2026 23:32:00 -0600 Subject: [PATCH 1/2] LinuxMap support --- DelphiBuildDPROJ.ps1 | 29 +++++++++++++++++++++++++---- README.de.md | 23 +++++++++++++++++------ README.md | 24 ++++++++++++++++++------ 3 files changed, 60 insertions(+), 16 deletions(-) diff --git a/DelphiBuildDPROJ.ps1 b/DelphiBuildDPROJ.ps1 index 0ae8020..a637831 100644 --- a/DelphiBuildDPROJ.ps1 +++ b/DelphiBuildDPROJ.ps1 @@ -1,6 +1,9 @@ # ============================================================================= # DelphiBuildDPROJ.ps1 - Universal Delphi Project Builder # ============================================================================= +# Copyright (c) 2025 Olaf Monien - The MIT License (MIT) +# https://github.com/omonien/DelphiStandards +# ============================================================================= # Builds any Delphi project file (.dproj) with MSBuild # Can be used in any Delphi project - no dependencies to specific projects # @@ -33,9 +36,14 @@ param( [string]$Config = "", [string]$Platform = "", [string]$DelphiVersion = "", - [switch]$VerboseOutput + [switch]$VerboseOutput, + [switch]$LinuxMap ) +Write-Host "=============================================" +Write-Host "| Universal Delphi Project Builder - v1.1 |" +Write-Host "=============================================" + # ============================================================================= # CONFIGURATION - Edit these defaults as needed # ============================================================================= @@ -188,7 +196,8 @@ function Build-DPROJProject { [string]$Config, [string]$Platform, [string]$MSBuild, - [bool]$VerboseOutput + [bool]$VerboseOutput, + [bool]$LinuxMap ) if (-not (Test-Path $ProjectFile)) { @@ -209,7 +218,19 @@ function Build-DPROJProject { $ProjectPath, "/t:Build", "/p:Config=$Config", - "/p:Platform=$Platform", + "/p:Platform=$Platform" + ) + + if ($LinuxMap) { + $MSBuildArgs += "/p:DCC_MapFile=3" + $MSBuildArgs += "/p:DCC_DebugInfo=3" + $MSBuildArgs += "/p:DCC_LocalSymbols=true" + $MSBuildArgs += "/p:DCC_LocalDebugSymbols=true" + $MSBuildArgs += "/p:DCC_DebugInformation=2" + $MSBuildArgs += "/p:DCC_DebugInfoInExe=false" + } + + $MSBuildArgs += @( "/nologo", "/m" ) @@ -284,7 +305,7 @@ try { Write-Host "" # Build the project - $BuildSuccess = Build-DPROJProject -ProjectFile $ProjectFile -Config $Config -Platform $Platform -MSBuild $MSBuild -VerboseOutput $VerboseOutput + $BuildSuccess = Build-DPROJProject -ProjectFile $ProjectFile -Config $Config -Platform $Platform -MSBuild $MSBuild -VerboseOutput $VerboseOutput -LinuxMap $LinuxMap # Normalize boolean result $BuildResult = ($BuildSuccess -eq $true) diff --git a/README.de.md b/README.de.md index 26f3632..cdedb90 100644 --- a/README.de.md +++ b/README.de.md @@ -4,7 +4,6 @@ - # Delphi Standards [![Lang-DE](https://img.shields.io/badge/lang-DE-blue.svg)](README.de.md) [![Lang-EN](https://img.shields.io/badge/lang-EN-lightgrey.svg)](README.md) @@ -47,16 +46,19 @@ Hinweis: Der Style Guide wird synchron in Deutsch und Englisch gepflegt. Änderu ## Schnellstart -1) Style Guide lesen und im Team vereinbaren +1. Style Guide lesen und im Team vereinbaren + - Einrückung: 2 Leerzeichen; Zeilenlänge: 120 Zeichen (Formatter/Editor‑Guideline synchron halten) - Namenskonventionen (A-/L-/F‑Präfixe, Komponenten, Konstanten, Enums mit SCOPEDENUMS) - Moderne Features: Generics, anonyme Methoden, Inline‑Variablen (10.3+), Multiline‑Strings (12+) -2) .gitignore aktivieren +1. .gitignore aktivieren + - Datei „Delphi GitIgnore.txt“ ins Repo‑Root kopieren und in „.gitignore“ umbenennen - Projektspezifische Ergänzungen nach Bedarf vornehmen -3) Git Attributes hinzufügen +1. Git Attributes hinzufügen + - „Delphi GitAttributes.txt“ ins Repo‑Root kopieren und in „.gitattributes“ umbenennen. - Die Datei normalisiert Zeilenenden für Delphi‑Quellen (CRLF) und markiert Binärartefakte (.res, .ico, .dcu, .bpl, .dll, .exe) als binary. - Werden .dfm/.fmx im Projekt als Text gespeichert (Standard), die Text‑Regeln beibehalten. Bei Binärspeicherung die Binary‑Regeln aus dem Template aktivieren. @@ -69,9 +71,11 @@ Hinweis: Der Style Guide wird synchron in Deutsch und Englisch gepflegt. Änderu Das Repository enthält ein universelles PowerShell-Skript zum Bauen von Delphi-Projekten per Kommandozeile. Dies ist ideal für CI/CD-Pipelines, automatisierte Builds oder jedes Szenario, in dem Delphi-Projekte ohne IDE gebaut werden müssen. **Features:** + - Erkennt automatisch die neueste installierte Delphi-Version aus der Windows-Registry - Unterstützt alle Delphi-Projektdateien (.dproj) -- Konfigurierbare Build-Konfiguration (Debug/Release) und Plattform (Win32/Win64) +- Konfigurierbare Build-Konfiguration (Debug/Release) und Plattform (Win32/Win64/Linux64) +- Linux-Debug-Symbol- und Map-Datei-Unterstützung über `-LinuxMap` - Farbige Konsolenausgabe für bessere Lesbarkeit - Verbose-Modus für detaillierte Build-Informationen - Keine Abhängigkeiten von spezifischen Projekten - funktioniert mit jedem Delphi-Projekt @@ -79,6 +83,7 @@ Das Repository enthält ein universelles PowerShell-Skript zum Bauen von Delphi- - Robuste Fehlerbehandlung und saubere Exit-Codes für CI/CD-Integration **Verwendung:** + ```powershell # Einfache Verwendung (erkennt Delphi-Version automatisch, baut Debug/Win32) .\DelphiBuildDPROJ.ps1 -ProjectFile "MeinProjekt.dproj" @@ -88,16 +93,22 @@ Das Repository enthält ein universelles PowerShell-Skript zum Bauen von Delphi- # Spezifische Delphi-Version mit ausführlicher Ausgabe verwenden .\DelphiBuildDPROJ.ps1 -ProjectFile "MeinProjekt.dproj" -DelphiVersion "22.0" -VerboseOutput + +# Für Linux64 mit vollständigen Debug-Symbolen und Map-Datei bauen +.\DelphiBuildDPROJ.ps1 -ProjectFile "MeinProjekt.dproj" -Platform Linux64 -LinuxMap ``` **Parameter:** + - `-ProjectFile` (erforderlich): Pfad zur .dproj-Datei, die gebaut werden soll - `-Config`: Build-Konfiguration (Standard: "Debug") - `-Platform`: Zielplattform (Standard: "Win32") - `-DelphiVersion`: Zu verwendende Delphi-Version (Standard: automatische Erkennung der neuesten Version) - `-VerboseOutput`: Aktiviert ausführliche MSBuild-Ausgabe +- `-LinuxMap`: Aktiviert Linux-Debug-Symbole und Map-Datei-Generierung (setzt `DCC_MapFile=3`, `DCC_DebugInfo=3`, `DCC_LocalSymbols`, `DCC_LocalDebugSymbols`, `DCC_DebugInformation=2`, `DCC_DebugInfoInExe=false`) **Voraussetzungen:** + - Embarcadero Delphi installiert - MSBuild verfügbar (Visual Studio Build Tools oder vollständiges Visual Studio) @@ -106,6 +117,7 @@ Weitere Details finden Sie in der Skript-Dokumentation in [DelphiBuildDPROJ.ps1] ## Releases Offizielle Releases sind im Verzeichnis [release-assets/](release-assets/) verfügbar. Jedes Release enthält: + - PDF-Versionen der Style Guides (Deutsch und Englisch) - Git-Templates (.gitignore und .gitattributes) - Dokumentation @@ -125,4 +137,3 @@ Für die Erstellung neuer Releases siehe [release-tools/README.md](release-tools ## Lizenz MIT License – siehe Hinweise in den Dateien - diff --git a/README.md b/README.md index 55ae28d..5eab359 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ - # Delphi Standards [![Lang-EN](https://img.shields.io/badge/lang-EN-blue.svg)](README.md) [![Lang-DE](https://img.shields.io/badge/lang-DE-lightgrey.svg)](README.de.md) @@ -47,16 +46,19 @@ Note: The style guide is maintained in German and English. Please keep both docu ## Quick Start -1) Agree on the style guide in your team +1. Agree on the style guide in your team + - Indentation: 2 spaces; line length: 120 chars (keep formatter/editor guideline in sync) - Naming conventions (A-/L-/F‑prefixes, components, constants, enums with SCOPEDENUMS) - Modern features: generics, anonymous methods, inline variables (10.3+), multiline strings (12+) -2) Enable .gitignore +1. Enable .gitignore + - Copy "Delphi GitIgnore.txt" to the repo root and rename it to ".gitignore" - Add project-specific rules as needed -3) Add Git Attributes +1. Add Git Attributes + - Copy "Delphi GitAttributes.txt" to the repo root and rename it to ".gitattributes". - It normalizes EOLs for Delphi sources (CRLF) and marks binary artifacts (.res, .ico, .dcu, .bpl, .dll, .exe) as binary. - If your project stores .dfm/.fmx as text (default), keep the text rules. If stored as binary, switch to the binary rules in the template. @@ -69,9 +71,11 @@ Note: The style guide is maintained in German and English. Please keep both docu The repository includes a universal PowerShell script for building Delphi projects from the command line. This is ideal for CI/CD pipelines, automated builds, or any scenario where you need to build Delphi projects without the IDE. **Features:** + - Auto-detects the latest installed Delphi version from Windows Registry - Supports all Delphi project files (.dproj) -- Configurable build configuration (Debug/Release) and platform (Win32/Win64) +- Configurable build configuration (Debug/Release) and platform (Win32/Win64/Linux64) +- Linux debug symbol and map file support via `-LinuxMap` - Colored console output for better readability - Verbose mode for detailed build information - No dependencies on specific projects - works with any Delphi project @@ -79,6 +83,7 @@ The repository includes a universal PowerShell script for building Delphi projec - Robust error handling and clean exit codes for CI/CD integration **Usage:** + ```powershell # Basic usage (auto-detects Delphi version, builds Debug/Win32) .\DelphiBuildDPROJ.ps1 -ProjectFile "MyProject.dproj" @@ -88,16 +93,22 @@ The repository includes a universal PowerShell script for building Delphi projec # Use specific Delphi version with verbose output .\DelphiBuildDPROJ.ps1 -ProjectFile "MyProject.dproj" -DelphiVersion "22.0" -VerboseOutput + +# Build for Linux64 with full debug symbols and map file +.\DelphiBuildDPROJ.ps1 -ProjectFile "MyProject.dproj" -Platform Linux64 -LinuxMap ``` **Parameters:** + - `-ProjectFile` (required): Path to the .dproj file to build - `-Config`: Build configuration (default: "Debug") - `-Platform`: Target platform (default: "Win32") - `-DelphiVersion`: Delphi version to use (default: auto-detect latest) - `-VerboseOutput`: Enable verbose MSBuild output +- `-LinuxMap`: Enable Linux debug symbols and map file generation (sets `DCC_MapFile=3`, `DCC_DebugInfo=3`, `DCC_LocalSymbols`, `DCC_LocalDebugSymbols`, `DCC_DebugInformation=2`, `DCC_DebugInfoInExe=false`) **Requirements:** + - Embarcadero Delphi installed - MSBuild available (Visual Studio Build Tools or full Visual Studio) @@ -106,6 +117,7 @@ For more details, see the script documentation in [DelphiBuildDPROJ.ps1](DelphiB ## Releases Official releases are available in the [release-assets/](release-assets/) directory. Each release includes: + - PDF versions of the style guides (German and English) - Git templates (.gitignore and .gitattributes) - Documentation @@ -124,4 +136,4 @@ For creating new releases, see [release-tools/README.md](release-tools/README.md ## License -MIT License – see notices in the files \ No newline at end of file +MIT License – see notices in the files From ccf79659bbacffc89c700ef942600a3255552624 Mon Sep 17 00:00:00 2001 From: Jim McKeeth Date: Tue, 21 Apr 2026 19:58:28 -0600 Subject: [PATCH 2/2] Bash version that works from WSL --- .gitignore | 14 +--- CLAUDE.md | 87 +++++++++++++++++++++++ DelphiBuildDPROJ.ps1 | 8 ++- DelphiBuildDPROJ.sh | 160 +++++++++++++++++++++++++++++++++++++++++++ GEMINI.md | 72 +++++++++++++++++++ 5 files changed, 325 insertions(+), 16 deletions(-) create mode 100644 CLAUDE.md mode change 100644 => 100755 DelphiBuildDPROJ.ps1 create mode 100755 DelphiBuildDPROJ.sh create mode 100644 GEMINI.md diff --git a/.gitignore b/.gitignore index 04fbebd..65e3ba2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1 @@ -# Ignore release artifacts and local build outputs -release-assets/ - -# macOS -.DS_Store - -# VSCode workspace cache (keep recommended config files under version control) -.vscode/* -!.vscode/settings.json -!.vscode/extensions.json -!.vscode/tasks.json -!.vscode/launch.json - +test/ diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..8c7cc91 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,87 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## Repository Purpose + +This is a **documentation and tooling standards repository** for Delphi development — not a Delphi application itself. It contains: + +- Style guides in English and German (`Delphi Style Guide EN.md` / `Delphi Style Guide DE.md`) +- Git templates (`Delphi GitIgnore.txt`, `Delphi GitAttributes.txt`) +- A universal Delphi build script for CI/CD use (`DelphiBuildDPROJ.ps1`) +- A WSL bridge to that script (`DelphiBuildDPROJ.sh`) +- Release tooling that converts Markdown guides to PDFs (`release-tools/`) + +## Build Scripts + +### Windows (PowerShell) — `DelphiBuildDPROJ.ps1` + +```powershell +# Auto-detects latest Delphi from Windows Registry, builds Debug/Win32 +.\DelphiBuildDPROJ.ps1 -ProjectFile "MyProject.dproj" + +# Release build for Win64 +.\DelphiBuildDPROJ.ps1 -ProjectFile "MyProject.dproj" -Config Release -Platform Win64 + +# Linux64 with full debug symbols and map file +.\DelphiBuildDPROJ.ps1 -ProjectFile "MyProject.dproj" -Platform Linux64 -LinuxMap +``` + +The script loads the Delphi environment by executing `rsvars.bat` from the detected installation path and then invokes MSBuild. Auto-detection reads `HKLM:\SOFTWARE\Embarcadero\BDS` (and the Wow6432Node variant). + +### WSL — `DelphiBuildDPROJ.sh` + +```bash +# Basic build (defaults: Debug / Win32) +./DelphiBuildDPROJ.sh -ProjectFile ./test/Project38.dproj + +# Release build for Win64 +./DelphiBuildDPROJ.sh -ProjectFile "./MyProject.dproj" -Config Release -Platform Win64 + +# Linux64 with debug symbols and map file +./DelphiBuildDPROJ.sh -ProjectFile "./MyProject.dproj" -Platform Linux64 -LinuxMap +``` + +This is a pure bridge: it converts WSL paths to Windows UNC paths via `wslpath -w` and delegates to `DelphiBuildDPROJ.ps1` via `powershell.exe -Command "& 'unc-path'"`. Requires WSL with `powershell.exe` accessible on the host and Delphi installed on Windows. + +Parameters are identical to `DelphiBuildDPROJ.ps1` (minus `-IsWSL`, which is internal and no longer exists). Defaults (Debug / Win32) are applied by the PS1. + +## Release Process + +Releases bundle PDFs of the style guides with the git templates. Requires `pandoc` and `xelatex`. + +```bash +# From project root +./release-tools/create-release.sh +``` + +Before running: update the version in `release-tools/release-config.yaml` and update the version/date header in both style guide files. After running, create a git tag (`git tag -a vX.Y.Z -m "..."`) and push. + +## Bilingual Maintenance Rule + +The style guide exists in both German and English. **Both files must be kept in sync.** Single-language PRs are acceptable — the maintainer handles the other language post-merge — but if you are editing one, note which language was updated so the gap is visible. + +## Delphi Style Guide Conventions (Summary) + +When editing the style guides, preserve these conventions (they are the content being documented): + +| Element | Convention | +| ------------------- | ------------------------------------------------ | +| Local variables | `L` prefix — `LCustomer: TCustomer` | +| Parameters | `A` prefix — `const AValue: string` | +| Fields | `F` prefix — `FName: string` | +| Record fields | **No** `F` prefix (records differ from classes) | +| Loop counters | Lowercase, no prefix — `for var i := 0 to 10 do` | +| Classes / Records | `T` prefix | +| Interfaces | `I` prefix | +| Technical constants | `c` prefix — `cMaxRetries = 3` | +| String constants | `sc` prefix — `scErrorMessage = 'Error'` | + +Other key rules documented in the guide: + +- 2-space indentation, 120-char line limit +- `begin..end` always on separate lines +- `FreeAndNil(LObj)` instead of `LObj.Free` +- Inline variables (Delphi 10.3+), multiline strings (Delphi 12+) +- `TArray` for fixed-size, `TList` for dynamic, `TObjectList` for owned objects +- Unit names follow namespace hierarchy: `Main.Form`, `Customer.Details.DM` diff --git a/DelphiBuildDPROJ.ps1 b/DelphiBuildDPROJ.ps1 old mode 100644 new mode 100755 index a637831..9b46b7e --- a/DelphiBuildDPROJ.ps1 +++ b/DelphiBuildDPROJ.ps1 @@ -200,13 +200,15 @@ function Build-DPROJProject { [bool]$LinuxMap ) - if (-not (Test-Path $ProjectFile)) { + if (-not (Test-Path -LiteralPath $ProjectFile)) { Write-Err "Project file not found: $ProjectFile" exit 1 } - $ProjectPath = Resolve-Path $ProjectFile - $ProjectName = [System.IO.Path]::GetFileNameWithoutExtension($ProjectFile) + $ProjectItem = Get-Item -LiteralPath $ProjectFile + $ProjectPath = $ProjectItem.FullName + + $ProjectName = [System.IO.Path]::GetFileNameWithoutExtension($ProjectPath) Write-Warn "Building: $ProjectName" Write-Detail " File: $ProjectPath" diff --git a/DelphiBuildDPROJ.sh b/DelphiBuildDPROJ.sh new file mode 100755 index 0000000..fe8c12c --- /dev/null +++ b/DelphiBuildDPROJ.sh @@ -0,0 +1,160 @@ +#!/bin/bash + +# ============================================================================= +# DelphiBuildDPROJ.sh - Universal Delphi Project Builder for WSL +# ============================================================================= +# Copyright (c) 2025 Olaf Monien - The MIT License (MIT) +# https://github.com/omonien/DelphiStandards +# ============================================================================= +# Bridges WSL to the Windows Delphi environment via PowerShell. +# This script wraps DelphiBuildDPROJ.ps1 for use within WSL. +# ============================================================================= + +# Colors for output +CYAN='\033[0;36m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +RED='\033[0;31m' +NC='\033[0m' # No Color + +# Script directory +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PS_SCRIPT_PATH="${SCRIPT_DIR}/DelphiBuildDPROJ.ps1" + +function show_usage() { + echo -e "${CYAN}Usage:${NC}" + echo " $0 -ProjectFile [options]" + echo "" + echo -e "${CYAN}Options:${NC}" + echo " -Config Build configuration (default: Debug)" + echo " -Platform Target platform (default: Win32)" + echo " -DelphiVersion Specific Delphi version (e.g., 22.0)" + echo " -VerboseOutput Enable verbose MSBuild output" + echo " -LinuxMap Enable Linux debug symbols and map file" + echo " -h, --help Show this help message" + echo "" + echo -e "${CYAN}Example:${NC}" + echo " $0 -ProjectFile ./MyProject.dproj -Config Release -Platform Win64" +} + +# 1. WSL Check +if ! grep -qEi "(Microsoft|WSL)" /proc/version &> /dev/null; then + echo -e "${RED}Error: This script must be run from within WSL (Windows Subsystem for Linux).${NC}" + exit 1 +fi + +# 2. Check for powershell.exe +if ! command -v powershell.exe &> /dev/null; then + echo -e "${RED}Error: powershell.exe not found in PATH.${NC}" + echo "Ensure Windows PowerShell is accessible from your WSL environment." + exit 1 +fi + +# 3. Check for Delphi installation on the Windows host +# We perform a quick registry check for Embarcadero BDS keys +DELPHI_REG_CHECK=$(powershell.exe -NoProfile -Command "Get-Item -Path 'HKLM:\SOFTWARE\Embarcadero\BDS', 'HKLM:\SOFTWARE\WOW6432Node\Embarcadero\BDS' -ErrorAction SilentlyContinue | Measure-Object | Select-Object -ExpandProperty Count" 2>/dev/null | tr -d '\r\n') + +if [[ -z "$DELPHI_REG_CHECK" || "$DELPHI_REG_CHECK" -eq "0" ]]; then + echo -e "${RED}Error: Delphi installation not detected on the Windows host.${NC}" + echo "This script requires Embarcadero Delphi to be installed on Windows." + exit 1 +fi + +# 4. Check if the PowerShell script exists +if [[ ! -f "$PS_SCRIPT_PATH" ]]; then + echo -e "${RED}Error: Companion script not found: ${PS_SCRIPT_PATH}${NC}" + exit 1 +fi + +# 5. Parse Arguments +PROJECT_FILE="" +CONFIG="" +PLATFORM="" +DELPHI_VERSION="" +VERBOSE=false +LINUX_MAP=false + +while [[ $# -gt 0 ]]; do + case $1 in + -ProjectFile) + PROJECT_FILE="$2" + shift 2 + ;; + -Config) + CONFIG="$2" + shift 2 + ;; + -Platform) + PLATFORM="$2" + shift 2 + ;; + -DelphiVersion) + DELPHI_VERSION="$2" + shift 2 + ;; + -VerboseOutput) + VERBOSE=true + shift + ;; + -LinuxMap) + LINUX_MAP=true + shift + ;; + -h|--help) + show_usage + exit 0 + ;; + *) + echo -e "${RED}Unknown argument: $1${NC}" + show_usage + exit 1 + ;; + esac +done + +if [[ -z "$PROJECT_FILE" ]]; then + echo -e "${RED}Error: -ProjectFile is mandatory.${NC}" + show_usage + exit 1 +fi + +# 6. Convert Paths +# Check if project file exists in WSL +if [[ ! -f "$PROJECT_FILE" ]]; then + echo -e "${RED}Error: Project file not found at: ${PROJECT_FILE}${NC}" + exit 1 +fi + +# Convert WSL path to Windows path for the PowerShell script +WIN_PROJECT_FILE=$(wslpath -w "$PROJECT_FILE") +WIN_PS_SCRIPT_PATH=$(wslpath -w "$PS_SCRIPT_PATH") + +# 7. Construct and Run PowerShell command +# We use an array to handle arguments safely and avoid literal quote issues +# -InputFormat None prevents PowerShell from trying to read from stdin, which can cause hangs +PS_CMD_ARGS=("-NoProfile" "-NonInteractive" "-InputFormat" "None" "-ExecutionPolicy" "Bypass") + +# Using -Command with & is more robust for UNC paths from WSL than -File +# We wrap the call in a try/catch in PowerShell to ensure we see errors if initialization fails +COMMAND="try { & '$WIN_PS_SCRIPT_PATH' -ProjectFile '$WIN_PROJECT_FILE'" + +[[ -n "$CONFIG" ]] && COMMAND="$COMMAND -Config '$CONFIG'" +[[ -n "$PLATFORM" ]] && COMMAND="$COMMAND -Platform '$PLATFORM'" +[[ -n "$DELPHI_VERSION" ]] && COMMAND="$COMMAND -DelphiVersion '$DELPHI_VERSION'" +[[ "$VERBOSE" = true ]] && COMMAND="$COMMAND -VerboseOutput" +[[ "$LINUX_MAP" = true ]] && COMMAND="$COMMAND -LinuxMap" + +COMMAND="$COMMAND } catch { Write-Error \$_.Exception.Message; exit 1 }" + +echo -e "${CYAN}Bridging build to Windows host...${NC}" +# Note: we use -Command because it handles UNC paths better than -File in some PS versions +powershell.exe "${PS_CMD_ARGS[@]}" -Command "$COMMAND" +EXIT_CODE=$? + +if [[ $EXIT_CODE -eq 0 ]]; then + echo -e "${GREEN}WSL Bridge: Build finished successfully.${NC}" +else + echo -e "${RED}WSL Bridge: Build failed with exit code $EXIT_CODE.${NC}" +fi + +exit $EXIT_CODE diff --git a/GEMINI.md b/GEMINI.md new file mode 100644 index 0000000..8fffaa5 --- /dev/null +++ b/GEMINI.md @@ -0,0 +1,72 @@ +# Delphi Standards - Project Context + +This repository provides a battle-tested baseline for consistent Delphi code development, focusing on modern style guides, git templates, and build automation. + +## Project Overview + +* **Purpose:** Establish shared standards for Delphi teams to improve code readability, maintainability, and repository cleanliness. +* **Key Components:** + * **Style Guides:** Comprehensive guides in English (`Delphi Style Guide EN.md`) and German (`Delphi Style Guide DE.md`). + * **Git Templates:** Curated `.gitignore` and `.gitattributes` specifically tailored for Delphi projects to prevent IDE artifacts and binary bloat. + * **Build Automation:** A universal PowerShell script (`DelphiBuildDPROJ.ps1`) for CLI-based Delphi builds. + * **Release Tools:** Shell scripts and configurations (`release-tools/`) for generating PDF versions of the guides and packaging releases. + +## Building and Running + +### Build Automation (for Delphi Projects) +The `DelphiBuildDPROJ.ps1` script can be used to build any Delphi `.dproj` file via MSBuild on Windows. For WSL users, the `DelphiBuildDPROJ.sh` script provides a bridge to the Windows host. + +#### Windows (PowerShell) +```powershell +# Basic usage (auto-detects Delphi version, builds Debug/Win32) +.\DelphiBuildDPROJ.ps1 -ProjectFile "MyProject.dproj" + +# Build Release for Win64 +.\DelphiBuildDPROJ.ps1 -ProjectFile "MyProject.dproj" -Config Release -Platform Win64 +``` + +#### WSL (Bash) +```bash +# Basic usage (bridges to Windows host) +./DelphiBuildDPROJ.sh -ProjectFile "./MyProject.dproj" + +# Build Release for Win64 +./DelphiBuildDPROJ.sh -ProjectFile "./MyProject.dproj" -Config Release -Platform Win64 +``` + +### Release Generation (for this Repository) +To generate release assets (PDFs and ZIP archives), use the provided release script. This requires `pandoc` and `xelatex`. + +```bash +# Run from project root +./release-tools/create-release.sh +``` + +## Development Conventions + +### Formatting +* **Indentation:** 2 spaces. +* **Line Length:** 120 characters maximum. +* **Blocks:** `begin..end` always on separate lines. +* **Language Features:** Prefer modern features like generics, anonymous methods, inline variables (10.3+), and multiline strings (12+). + +### Naming Conventions +* **Locals:** `L` prefix (e.g., `LCustomer`). +* **Parameters:** `A` prefix (e.g., `const AValue: string`). +* **Fields:** `F` prefix (e.g., `FName`). +* **Types:** `T` prefix for classes/records, `I` prefix for interfaces. +* **Constants:** `c` prefix for technical constants, `sc` for string constants. +* **Unit Names:** Follow a namespace hierarchy, e.g., `Main.Form`, `Customer.Details.DM`. + +### Best Practices +* **Resource Management:** Always use `try..finally` blocks. Prefer `FreeAndNil(LObject)` over `.Free`. +* **Language Sync:** Both German and English style guides must be kept in sync. Maintainers handle synchronization post-merge if only one language is updated in a PR. +* **Git Hygiene:** Use the provided `Delphi GitIgnore.txt` and `Delphi GitAttributes.txt` in all Delphi repositories to ensure consistency. + +## Key Files +* `Delphi Style Guide EN.md`: The primary English style guide. +* `Delphi Style Guide DE.md`: The primary German style guide. +* `Delphi GitIgnore.txt`: Template for `.gitignore`. +* `Delphi GitAttributes.txt`: Template for `.gitattributes`. +* `DelphiBuildDPROJ.ps1`: Universal Delphi build script for Windows. +* `DelphiBuildDPROJ.sh`: WSL bridge for the Delphi build script.