<commit_before>﻿<#
.SYNOPSIS
    Builds the project.
#>
param (
    [string] $ProjectRootDirectory = "$PSScriptRoot/..",
    [string] $BinaryDirectory = "$ProjectRootDirectory/bin",
    [string] $CompilerDirectory = "$ProjectRootDirectory/compiler",
    [string] $LibraryDirectory = "$ProjectRootDirectory/libs",

    [string] $CompilerPath = "$CompilerDirectory/pabcnetc.exe"
)

$ErrorActionPreference = 'Stop'

function prepare-libraries {
    Write-Output 'Preparing library packages…'

    $libraries = @(
        "$ProjectRootDirectory/packages/Avalonia/lib/portable-windows8+net45/*"
        "$ProjectRootDirectory/packages/Avalonia.Desktop/lib/net45/*"
        "$ProjectRootDirectory/packages/SharpDX/lib/net45/*"
        "$ProjectRootDirectory/packages/SharpDX.Direct2D1/lib/net45/*"
        "$ProjectRootDirectory/packages/SharpDX.DXGI/lib/net45/*"
        "$ProjectRootDirectory/packages/Sprache/lib/net40/*"
        "$ProjectRootDirectory/packages/System.Reactive.Core/lib/net45/*"
        "$ProjectRootDirectory/packages/System.Reactive.Interfaces/lib/net45/*"
        "$ProjectRootDirectory/packages/System.Reactive.Linq/lib/net45/*"
    )

    if (-not (Test-Path $LibraryDirectory)) {
        New-Item -ItemType Directory $LibraryDirectory
    }

    Copy-Item $libraries $LibraryDirectory
}

function patch-compiler {
    Write-Output 'Patching compiler to support assembly redirection'
    Copy-Item "$ProjectRootDirectory/src/app.config" "$CompilerDirectory/pabcnetc.exe.config"
}

function compile-sources {
    Write-Output 'Compiling sources…'

    Push-Location "$ProjectRootDirectory/src"
    try {
        & $CompilerPath Program.pas
    } finally {
        Pop-Location
    }
}

function deploy-binaries {
    Write-Output 'Deploying binaries…'
    if (-not (Test-Path $BinaryDirectory)) {
        $null = New-Item -ItemType Directory $BinaryDirectory
    }

    $binaries = @(
        "$ProjectRootDirectory/src/Program.exe"
        "$ProjectRootDirectory/src/Program.pdb"
    )
<commit_msg>#3: use "clear" compiler to workaround terminal issues<commit_after>﻿<#
.SYNOPSIS
    Builds the project.
#>
param (
    [string] $ProjectRootDirectory = "$PSScriptRoot/..",
    [string] $BinaryDirectory = "$ProjectRootDirectory/bin",
    [string] $CompilerDirectory = "$ProjectRootDirectory/compiler",
    [string] $LibraryDirectory = "$ProjectRootDirectory/libs",

    [string] $CompilerPath = "$CompilerDirectory/pabcnetcclear.exe"
)

$ErrorActionPreference = 'Stop'

function prepare-libraries {
    Write-Output 'Preparing library packages…'

    $libraries = @(
        "$ProjectRootDirectory/packages/Avalonia/lib/portable-windows8+net45/*"
        "$ProjectRootDirectory/packages/Avalonia.Desktop/lib/net45/*"
        "$ProjectRootDirectory/packages/SharpDX/lib/net45/*"
        "$ProjectRootDirectory/packages/SharpDX.Direct2D1/lib/net45/*"
        "$ProjectRootDirectory/packages/SharpDX.DXGI/lib/net45/*"
        "$ProjectRootDirectory/packages/Sprache/lib/net40/*"
        "$ProjectRootDirectory/packages/System.Reactive.Core/lib/net45/*"
        "$ProjectRootDirectory/packages/System.Reactive.Interfaces/lib/net45/*"
        "$ProjectRootDirectory/packages/System.Reactive.Linq/lib/net45/*"
    )

    if (-not (Test-Path $LibraryDirectory)) {
        New-Item -ItemType Directory $LibraryDirectory
    }

    Copy-Item $libraries $LibraryDirectory
}

function patch-compiler {
    Write-Output 'Patching compiler to support assembly redirection'
    Copy-Item "$ProjectRootDirectory/src/app.config" "$CompilerPath.config"
}

function compile-sources {
    Write-Output 'Compiling sources…'

    Push-Location "$ProjectRootDirectory/src"
    try {
        & $CompilerPath Program.pas
        if (-not $?) {
            throw 'Compilation error'
        }
    } finally {
        Pop-Location
    }
}

function deploy-binaries {
    Write-Output 'Deploying binaries…'
    if (-not (Test-Path $BinaryDirectory)) {
        $null = New-Item -ItemType Directory $BinaryDirectory
    }

    $binaries = @(
        "$ProjectRootDirectory/src/Program.exe"
        "$ProjectRootDirectory/src/Program.pdb"
    )

{'fraction_non_alphanumeric': 0.12751028308734574, 'fraction_numerical': 0.010404064843939027, 'mean_word_length': 3.3931987247608926, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1256876', 'n_tokens_mistral': 1285, 'n_tokens_neox': 1239, 'n_words': 194}