Add Preprocessing in Compiler

This commit is contained in:
Mr.k 2024-07-26 01:39:37 +03:00
parent 99d88a0a46
commit 3a30f9d4b0
No known key found for this signature in database

View File

@ -1,6 +1,7 @@
param ( param (
[switch]$Debug, [switch]$Debug,
[switch]$Run [switch]$Run,
[switch]$SkipPreprocessing
) )
$OFS = "`r`n" $OFS = "`r`n"
$scriptname = "winutil.ps1" $scriptname = "winutil.ps1"
@ -26,6 +27,29 @@ function Update-Progress {
Write-Progress -Activity $Activity -Status $StatusMessage -PercentComplete $Percent Write-Progress -Activity $Activity -Status $StatusMessage -PercentComplete $Percent
} }
function Do-PreProcessing {
param (
[Parameter(Mandatory, position=0)]
[string]$ProgressStatusMessage,
[Parameter(position=1)]
[string]$ProgressActivity = "Pre-Processing"
)
$excludedFiles = @('.\git\', '.gitignore', '.gitattributes', '.\.github\CODEOWNERS', 'LICENSE', 'winutil.ps1', '.\docs\changelog.md', '*.png', '*.jpg', '*.jpeg', '*.exe')
$files = Get-ChildItem $PSScriptRoot -Recurse -Exclude $excludedFiles -Attributes !Directory
$numOfFiles = $files.Count
for ($i = 0; $i -lt $numOfFiles; $i++) {
$file = $files[$i]
(Get-Content "$file").TrimEnd() | Set-Content "$file"
Write-Progress -Activity $ProgressActivity -Status "$ProgressStatusMessage - Finished $i out of $numOfFiles" -PercentComplete (($i/$numOfFiles)*100)
}
Write-Progress -Activity $ProgressActivity -Status "$ProgressStatusMessage - Finished Task Successfully" -Completed
}
$header = @" $header = @"
################################################################################################################ ################################################################################################################
### ### ### ###
@ -34,6 +58,11 @@ $header = @"
################################################################################################################ ################################################################################################################
"@ "@
if (-NOT $SkipPreprocessing) {
$msg = "Pre-req: Code Formatting"
Update-Progress "Pre-req: Allocating Memory" 0
Do-PreProcessing $msg
}
# Create the script in memory. # Create the script in memory.
Update-Progress "Pre-req: Allocating Memory" 0 Update-Progress "Pre-req: Allocating Memory" 0