====== Build Pipeline ====== Description of the build process for WvdS FPC RAD Studio. ===== Overview ===== ┌─────────────────────────────────────────────────────────────┐ │ BUILD PIPELINE │ ├─────────────────────────────────────────────────────────────┤ │ │ │ 1. PRE-BUILD │ │ ├── Policy-Check (wvds-lint) │ │ ├── Dependency Resolution │ │ └── Asset Preparation │ │ │ │ 2. COMPILE │ │ ├── pas2js / FPC invocation │ │ ├── Unit Resolution │ │ └── Code Generation │ │ │ │ 3. POST-BUILD │ │ ├── Bundle Assets │ │ ├── Generate Source Maps │ │ └── Copy to dist/ │ │ │ │ 4. PACKAGE (optional) │ │ ├── VSIX Creation │ │ └── Version Stamping │ │ │ └─────────────────────────────────────────────────────────────┘ ===== Pre-Build ===== ==== Policy-Check ==== wvds-lint policy --path sources/ Checks: * P0: No duplicates in Extensions * P1: No .ts or handwritten .js * P2: Wrappers only in common/ * P3: Self-contained Output ==== Dependency Resolution ==== Dependencies are resolved from ''build.cfg'' and ''package.json'': # build.cfg [build] compiler=pas2js entry=extension_main.pas [dependencies] core=../../common/core vscode=../../common/web/vscode ===== Compile ===== ==== pas2js Compilation ==== pas2js \ -Jc \ # Compact output -Jirtl.js \ # RTL as external module -Jm \ # Generate Source Maps -Tbrowser \ # Target: Browser -Fu../../common \ # Unit paths -FE./dist \ # Output directory pas/extension_main.pas # Entry Point ==== FPC Compilation ==== fpc \ -Mobjfpc \ # Object Pascal Mode -Sh \ # Ansi Strings -O3 \ # Optimization Level 3 -Fu../../common \ # Unit paths -FE./bin \ # Output directory project.lpr # Project file ==== Compiler Options ==== ^ Option ^ pas2js ^ FPC ^ Description ^ | Debug | -Jc -Jm | -g -O0 | Debug symbols, no optimization | | Release | -Jc -O3 | -O3 -Xs | Optimized, no symbols | | Profile | -Jc -Jm | -g -O2 -pg | Profiling instrumentation | ===== Post-Build ===== ==== Asset Bundling ==== Resources are copied to ''dist/'': dist/ ├── extension_main.js # Compiled code ├── extension_main.js.map # Source Map └── assets/ # Copied resources ├── templates/*.html └── images/*.png ==== Source Maps ==== Source Maps enable debugging of Pascal code: // extension_main.js.map { "version": 3, "sources": ["../pas/extension_main.pas"], "mappings": "..." } ===== Package ===== ==== VSIX Creation ==== vsce package --out binaries/dist/ Produces: ''wvds-vscode-{name}-{version}.vsix'' ==== Version Stamping ==== The version is read from ''package.json'' and embedded in the build: const VERSION = {$I version.inc}; // Generated from package.json ===== Build Modes ===== ^ Mode ^ Usage ^ Optimization ^ Symbols ^ | debug | Development | None | Yes | | release | Production | Maximum | No | | profile | Performance analysis | Medium | Yes + Profiling | ===== Incremental Build ===== The build uses caching for faster compilation: * ''binaries/cache/'' contains compiled units (.ppu, .o) * Only changed units are recompiled * ''wvds-build clean'' clears the cache ===== Toolchain CLI ===== The build toolchain consists of two main tools: ==== pxamlc (PXAML Compiler) ==== Compiles PXAML files for a specific target: pxamlc compile \ --target \ --pxaml \ --packs ~/packs \ --out ~/binaries/out// ^ Option ^ Description ^ | ''%%--%%target'' | Target platform: tui, desktop, web | | ''%%--%%pxaml'' | Input PXAML file | | ''%%--%%packs'' | Path to pack registry | | ''%%--%%out'' | Output directory | ==== wvds-build ==== Orchestrates the entire build process: wvds-build build \ --app ~/sources/applications/ \ --config ~/.wvds/wvds-build.json \ --out ~/binaries/out ^ Option ^ Description ^ | ''%%--%%app'' | Application directory | | ''%%--%%config'' | Configuration file | | ''%%--%%out'' | Output directory | === Additional Commands === # Delete all build artifacts wvds-build clean # Install pack wvds-build pack install --from --to ~/vendor-packs --enable tui,web # Uninstall pack wvds-build pack uninstall --vendor --pack # List installed packs wvds-build pack list ==== Configuration File ==== **Path:** ''~/.wvds/wvds-build.json'' { "compilers": { "fpc": "%LAZARUS%/fpc/3.3.1/bin/fpc.exe", "pas2js": "%LAZARUS%/fpc/3.3.1/bin/pas2js.exe" }, "paths": { "packs": "~/packs", "common": "~/sources/common", "output": "~/binaries/out" }, "defaults": { "target": "web", "mode": "debug" }, "targets": { "tui": { "compiler": "fpc", "enabled": true }, "desktop": { "compiler": "fpc", "enabled": true }, "web": { "compiler": "pas2js", "enabled": true } } } ==== VS Code Tasks ==== Tasks are automatically generated: // .vscode/tasks.json (generated) { "version": "2.0.0", "tasks": [ { "label": "WVDS: Build TUI", "type": "shell", "command": "${workspaceFolder}/.wvds/bin/wvds-build", "args": ["build", "tui"] }, { "label": "WVDS: Build Desktop", "type": "shell", "command": "${workspaceFolder}/.wvds/bin/wvds-build", "args": ["build", "desktop"] }, { "label": "WVDS: Build Web", "type": "shell", "command": "${workspaceFolder}/.wvds/bin/wvds-build", "args": ["build", "web"] } ] } Do not edit tasks manually - they are generated by ''wvds-build''. ===== CI/CD Integration ===== # .github/workflows/build.yml build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Install FPC run: sudo apt-get install fpc - name: Install pas2js run: sudo apt-get install pas2js - name: Build run: wvds-build --mode release - name: Package run: wvds-build package ===== Troubleshooting ===== ==== "Unit not found" ==== * Check unit paths in build.cfg * Check case sensitivity (Linux) ==== "JavaScript error" ==== * Use Source Map for debugging * Check pas2js output for warnings ==== "VSIX invalid" ==== * Validate package.json * README.md must exist * Check icon path ===== See also ===== * [[.:targets|Build Targets]] * [[.:release|Release Process]] * [[.:testing|Testing]]