60 lines
2.1 KiB
PowerShell
60 lines
2.1 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
Recompileaza formularele/clasele VFP dupa un write-back din text (bin_din_text.ps1).
|
|
|
|
.DESCRIPTION
|
|
FoxBin2Prg regenereaza .scx/.sct DIN TEXT, dar fara codul obiect compilat. Un formular
|
|
regenerat si NErecompilat ruleaza fara `#INCLUDE`-uri: constantele din comun.h (CT_SUCCES,
|
|
CT_INSUCCES...) devin "Variable not found" abia in RUNTIME, nu la verificarea de sintaxa.
|
|
|
|
De aceea, dupa FIECARE bin_din_text.ps1 se ruleaza si scriptul asta.
|
|
|
|
.EXAMPLE
|
|
powershell -ExecutionPolicy Bypass -File Teste\bin_din_text.ps1 -TextFile frm_import.sc2
|
|
powershell -ExecutionPolicy Bypass -File Teste\recompileaza_binare.ps1
|
|
#>
|
|
[CmdletBinding()]
|
|
param(
|
|
[string[]]$Formular = @('frm_import.scx'),
|
|
[string]$ProjectRoot
|
|
)
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
if (-not $ProjectRoot) { $ProjectRoot = Split-Path $PSScriptRoot -Parent }
|
|
|
|
$vfp = 'C:\Program Files (x86)\Microsoft Visual FoxPro 9\vfp9.exe'
|
|
if (-not (Test-Path $vfp)) { throw "Nu gasesc $vfp" }
|
|
|
|
$prg = Join-Path $env:TEMP ("recompile_" + [guid]::NewGuid().ToString('N') + '.prg')
|
|
$linii = @(
|
|
"SET DEFAULT TO `"$ProjectRoot`"",
|
|
"SET PATH TO `"$ProjectRoot`""
|
|
)
|
|
foreach ($f in $Formular) {
|
|
$cale = Join-Path $ProjectRoot $f
|
|
if (-not (Test-Path $cale)) { throw "Nu exista $cale" }
|
|
$linii += "COMPILE FORM `"$f`""
|
|
}
|
|
$linii += 'QUIT'
|
|
[IO.File]::WriteAllLines($prg, $linii, [Text.Encoding]::GetEncoding(1252))
|
|
|
|
try {
|
|
& $vfp -A -T $prg | Out-Null
|
|
} finally {
|
|
Remove-Item $prg -ErrorAction SilentlyContinue
|
|
}
|
|
|
|
# verificare: .sct trebuie sa contina cod obiect, nu doar textul metodelor
|
|
$rezultate = foreach ($f in $Formular) {
|
|
$sct = Join-Path $ProjectRoot ([IO.Path]::ChangeExtension($f, '.sct'))
|
|
[pscustomobject]@{
|
|
Formular = $f
|
|
SCT_KB = if (Test-Path $sct) { [math]::Round((Get-Item $sct).Length / 1KB) } else { 0 }
|
|
Stare = if ((Test-Path $sct) -and (Get-Item $sct).Length -gt 0) { 'OK' } else { 'LIPSA' }
|
|
}
|
|
}
|
|
$rezultate | Format-Table -AutoSize
|
|
|
|
if ($rezultate | Where-Object { $_.Stare -ne 'OK' }) { exit 1 }
|
|
Write-Host 'Recompilare terminata.' -ForegroundColor Green
|