MQL5-SyntheticTestHarness/Install-Symlinks.ps1

55 lines
1.9 KiB
PowerShell
Raw Permalink Normal View History

2026-07-18 22:59:46 -03:00
param(
2026-07-18 23:14:16 -03:00
[Parameter(Mandatory=$true, HelpMessage="Full path to the MT5 Data Folder (e.g. C:\Users\User\AppData\Roaming\MetaQuotes\Terminal\...)")]
2026-07-18 22:59:46 -03:00
[string]$Mt5DataFolder
)
$ErrorActionPreference = "Stop"
2026-07-18 23:14:16 -03:00
# Project root directory (where this script is located)
2026-07-18 22:59:46 -03:00
$ProjectRoot = $PSScriptRoot
2026-07-18 23:14:16 -03:00
# Source directories in the project
2026-07-18 22:59:46 -03:00
$SourceInclude = Join-Path $ProjectRoot "MQL5\Include\SyntheticTestHarness"
$SourceScripts = Join-Path $ProjectRoot "MQL5\Scripts\SyntheticTestHarness"
2026-07-18 23:14:16 -03:00
# Target directories in MT5
2026-07-18 22:59:46 -03:00
$TargetInclude = Join-Path $Mt5DataFolder "MQL5\Include\SyntheticTestHarness"
$TargetScripts = Join-Path $Mt5DataFolder "MQL5\Scripts\SyntheticTestHarness"
function Create-MkLink {
param(
[string]$Target,
[string]$Source
)
if (Test-Path $Target) {
2026-07-18 23:14:16 -03:00
Write-Host "Symlink or folder already exists at: $Target" -ForegroundColor Yellow
2026-07-18 22:59:46 -03:00
return
}
2026-07-18 23:14:16 -03:00
# Verify if source directory actually exists in the project
2026-07-18 22:59:46 -03:00
if (-not (Test-Path $Source)) {
2026-07-18 23:14:16 -03:00
Write-Host "Warning: Source directory not found ($Source)" -ForegroundColor Red
2026-07-18 22:59:46 -03:00
return
}
2026-07-18 23:14:16 -03:00
# Create parent folder in destination if it does not exist (e.g. ensures MQL5\Include exists)
2026-07-18 22:59:46 -03:00
$ParentDir = Split-Path $Target -Parent
if (-not (Test-Path $ParentDir)) {
New-Item -ItemType Directory -Path $ParentDir | Out-Null
}
2026-07-18 23:14:16 -03:00
Write-Host "Creating symlink: $Target -> $Source" -ForegroundColor Cyan
2026-07-18 22:59:46 -03:00
2026-07-18 23:14:16 -03:00
# Executes cmd mklink (may require running as Administrator depending on Windows settings,
# although Windows 10/11 with Developer Mode enabled does not require it).
2026-07-18 22:59:46 -03:00
$cmd = "cmd /c mklink /D `"$Target`" `"$Source`""
Invoke-Expression $cmd
}
2026-07-18 23:14:16 -03:00
Write-Host "Installing symbolic links..." -ForegroundColor Green
2026-07-18 22:59:46 -03:00
Create-MkLink -Target $TargetInclude -Source $SourceInclude
Create-MkLink -Target $TargetScripts -Source $SourceScripts
2026-07-18 23:14:16 -03:00
Write-Host "Done!" -ForegroundColor Green