first commit

This commit is contained in:
Furqan-14
2026-05-15 10:39:16 +05:30
commit 43eba01201
38 changed files with 2021 additions and 0 deletions
+60
View File
@@ -0,0 +1,60 @@
#requires -Version 5.1
# One-time developer setup (Windows):
# - verifies required tools
# - installs vcpkg if VCPKG_ROOT is not set
# - pins the vcpkg dependency baseline in vcpkg.json
$ErrorActionPreference = 'Stop'
$RepoRoot = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
Set-Location $RepoRoot
Write-Host '>> Checking required tools'
$missing = $false
foreach ($tool in @('git', 'cmake', 'ninja')) {
if (-not (Get-Command $tool -ErrorAction SilentlyContinue)) {
Write-Host " MISSING: $tool"
$missing = $true
}
}
if ($missing) { Write-Error 'Install the missing tools and re-run.' }
# MSVC is only on PATH inside a Developer prompt; detect the install instead.
$vswhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe'
if (Test-Path $vswhere) {
$vc = & $vswhere -latest -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
if ($vc) { Write-Host " MSVC C++ toolchain: $vc" }
else { Write-Host ' WARNING: Visual Studio found but the C++ workload (VC.Tools) is not installed.' }
} else {
Write-Host ' WARNING: Visual Studio not detected. Install VS 2022 with the'
Write-Host ' "Desktop development with C++" workload (MSVC 19.36+ for C++23).'
}
Write-Host '>> Setting up vcpkg'
if (-not $env:VCPKG_ROOT) {
$vcpkgDir = Join-Path $RepoRoot 'vcpkg'
if (-not (Test-Path $vcpkgDir)) {
Write-Host ' Cloning vcpkg into .\vcpkg'
git clone https://github.com/microsoft/vcpkg.git $vcpkgDir
}
& (Join-Path $vcpkgDir 'bootstrap-vcpkg.bat') -disableMetrics
$env:VCPKG_ROOT = $vcpkgDir
Write-Host ' VCPKG_ROOT is not set in your environment. Set it permanently with:'
Write-Host " setx VCPKG_ROOT `"$vcpkgDir`""
} else {
Write-Host " Using VCPKG_ROOT=$env:VCPKG_ROOT"
}
$vcpkgExe = Join-Path $env:VCPKG_ROOT 'vcpkg.exe'
Write-Host '>> Pinning the vcpkg dependency baseline'
if (Select-String -Path 'vcpkg.json' -Pattern '"builtin-baseline"' -Quiet) {
Write-Host ' builtin-baseline already present — leaving it pinned.'
} else {
& $vcpkgExe x-update-baseline --add-initial-baseline
Write-Host ' Added builtin-baseline to vcpkg.json. Commit this change.'
}
Write-Host ''
Write-Host '>> Bootstrap complete. Next steps:'
Write-Host ' cmake --preset windows-debug'
Write-Host ' cmake --build --preset windows-debug'
Write-Host ' ctest --preset windows-debug'
+55
View File
@@ -0,0 +1,55 @@
#!/usr/bin/env bash
# One-time developer setup (Linux / macOS):
# - verifies required tools
# - installs vcpkg if VCPKG_ROOT is not set
# - pins the vcpkg dependency baseline in vcpkg.json
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "${REPO_ROOT}"
echo ">> Checking required tools"
missing=0
for tool in git cmake ninja; do
if ! command -v "${tool}" >/dev/null 2>&1; then
echo " MISSING: ${tool}" >&2
missing=1
fi
done
if [[ "${missing}" -ne 0 ]]; then
echo "ERROR: install the missing tools and re-run." >&2
exit 1
fi
if ! command -v c++ >/dev/null 2>&1 && ! command -v clang++ >/dev/null 2>&1; then
echo "WARNING: no C++ compiler found on PATH (need GCC 13+ or Clang 16+ for C++23)." >&2
fi
echo ">> Setting up vcpkg"
if [[ -z "${VCPKG_ROOT:-}" ]]; then
if [[ ! -d "${REPO_ROOT}/vcpkg" ]]; then
echo " Cloning vcpkg into ./vcpkg"
git clone https://github.com/microsoft/vcpkg.git "${REPO_ROOT}/vcpkg"
fi
"${REPO_ROOT}/vcpkg/bootstrap-vcpkg.sh" -disableMetrics
export VCPKG_ROOT="${REPO_ROOT}/vcpkg"
echo " VCPKG_ROOT is not set in your environment."
echo " Add this to your shell profile (~/.bashrc, ~/.zshrc):"
echo " export VCPKG_ROOT=\"${REPO_ROOT}/vcpkg\""
else
echo " Using VCPKG_ROOT=${VCPKG_ROOT}"
fi
VCPKG_EXE="${VCPKG_ROOT}/vcpkg"
echo ">> Pinning the vcpkg dependency baseline"
if grep -q '"builtin-baseline"' vcpkg.json; then
echo " builtin-baseline already present — leaving it pinned."
else
"${VCPKG_EXE}" x-update-baseline --add-initial-baseline
echo " Added builtin-baseline to vcpkg.json. Commit this change."
fi
echo ""
echo ">> Bootstrap complete. Next steps:"
echo " cmake --preset linux-debug # or macos-debug"
echo " cmake --build --preset linux-debug"
echo " ctest --preset linux-debug"
+42
View File
@@ -0,0 +1,42 @@
#requires -Version 5.1
# Rule R2 enforcement: raw PDFium APIs (FPDF_*) and PDFium headers (fpdf*.h) may
# only appear under engine/src/parser/. Run locally and in CI.
#
# C/C++ comments are stripped before matching, so headers that *document* the
# rule (e.g. engine/include/pdfengine/pdf_document.hpp) don't trip it — only
# real code usage counts.
$ErrorActionPreference = 'Stop'
$RepoRoot = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
Set-Location $RepoRoot
$sep = [IO.Path]::DirectorySeparatorChar
$allowed = "engine${sep}src${sep}parser${sep}"
$pattern = 'FPDF_|#\s*include\s*[<"]fpdf'
$sources = Get-ChildItem -Path 'engine', 'bindings' -Recurse -File -ErrorAction SilentlyContinue `
-Include '*.cpp', '*.cc', '*.h', '*.hpp' |
Where-Object {
$rel = $_.FullName.Substring($RepoRoot.Length + 1)
-not $rel.StartsWith($allowed)
}
$violations = @()
foreach ($file in $sources) {
$text = Get-Content -Raw -LiteralPath $file.FullName
if (-not $text) { continue }
# Strip // line comments and /* ... */ block comments before matching.
$stripped = [regex]::Replace($text, '//[^\r\n]*|/\*[\s\S]*?\*/', '')
if ($stripped -match $pattern) {
$violations += $file.FullName.Substring($RepoRoot.Length + 1)
}
}
if ($violations) {
Write-Host 'ERROR: Rule R2 violation - raw PDFium usage outside engine/src/parser/:'
$violations | ForEach-Object { Write-Host " $_" }
Write-Host 'All PDFium access must go through the parser boundary.'
exit 1
}
Write-Host 'R2 boundary check: OK (no raw PDFium usage outside engine/src/parser/)'
+36
View File
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
# Rule R2 enforcement: raw PDFium APIs (FPDF_*) and PDFium headers (fpdf*.h) may
# only appear under engine/src/parser/. Run locally and in CI.
#
# C/C++ comments are stripped before matching, so headers that *document* the
# rule (e.g. engine/include/pdfengine/pdf_document.hpp) don't trip it — only
# real code usage counts.
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "${REPO_ROOT}"
pattern='FPDF_|#[[:space:]]*include[[:space:]]*[<"]fpdf'
violations=""
while IFS= read -r -d '' file; do
# engine/src/parser/ is the one allowed home of raw PDFium usage.
case "${file}" in
engine/src/parser/*) continue ;;
esac
# Strip // line comments and /* ... */ block comments, then search.
if perl -0777 -pe 's{//[^\n]*|/\*.*?\*/}{}gs' "${file}" | grep -Eq "${pattern}"; then
violations+=" ${file}"$'\n'
fi
done < <(find engine bindings \
\( -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.hpp' \) \
-print0 2>/dev/null)
if [[ -n "${violations}" ]]; then
echo "ERROR: Rule R2 violation — raw PDFium usage outside engine/src/parser/:" >&2
printf '%s' "${violations}" >&2
echo "All PDFium access must go through the parser boundary." >&2
exit 1
fi
echo "R2 boundary check: OK (no raw PDFium usage outside engine/src/parser/)"