# compile_vergen.sh Generates compile-time version constants and release badges. ## Overview `compile_vergen.sh` extracts version metadata from Git tags (using semantic versioning), gathers build statistics (line counts, file counts, tool versions), and writes them into a Pascal unit (`core.version.pas`). It also downloads shields.io SVG badges summarizing the release information. ## Prerequisites - `git`, `wget`, `fpc`, `make`, `nasm`, `awk`, `find`, `md5sum`, and `date` must be available. - The repository must have at least one semver-compatible Git tag reachable from HEAD. - `compile_checksum.sh` must be present in the toolchain directory (called to generate `checksums.md5` first). - `loc.sh` must be present in the toolchain directory. - The `bin/`, `release/`, and `src/core/` directories must exist. ## Inputs | Source | Description | |--------|-------------| | Git tags | Parsed via `git describe --tags` to extract semver components. | | `checksums.md5` | Generated by `compile_checksum.sh`; its own MD5 is used as a build fingerprint. | | Source tree (`src/`) | Scanned to count total files and driver files. | | Tool versions | Queried from `fpc -h`, `make -v`, and `nasm -v`. | ## Outputs | File | Description | |------|-------------| | `src/core/core.version.pas` | Pascal unit exposing version constants to the kernel at compile time. | | `release/*.svg` | Shields.io badges for version, revision, release, line count, file count, driver count, tool versions, date, and fingerprint. | ## Behavior 1. Runs `compile_checksum.sh` to produce `checksums.md5`. 2. Downloads the `semver` shell tool from GitHub into `bin/` and adds it to `PATH`. 3. Extracts the following from `git describe --tags`: - Major, minor, and patch version numbers. - Pre-release label (if any). - Build metadata. - Short commit revision (8 characters). 4. Counts total lines of Pascal source (via `loc.sh`), total source files, and driver-specific files. 5. Queries the installed versions of FPC, Make, and NASM. 6. Records the current date and time. 7. Computes an MD5 fingerprint of `checksums.md5`. 8. Writes all values into `src/core/core.version.pas` as Pascal `const` declarations. 9. Downloads SVG badges from shields.io into `release/` for each metric. Badge download failures are non-fatal (`set +e`). ## Notes - The `set -e` at the top causes the script to abort on any error during the critical version-extraction phase. It is relaxed (`set +e`) before badge downloads, since those are cosmetic and may fail in offline or branch builds. - If a pre-release label is present in the tag, it is appended to the version string (e.g., `1.0.0-alpha`). - The generated `core.version.pas` is compiled into the kernel by `compile_sources.sh`, making all version metadata available at runtime.