aboutsummaryrefslogtreecommitdiffstats
path: root/run_tree.ps1
blob: 7f74bac3230eeb26a05c715ff426e9209a216767 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
param(
    [switch]$NoRun
)

$ErrorActionPreference = "Stop"

$repoRoot = $PSScriptRoot
$projectName = Split-Path -Leaf $repoRoot

Push-Location $repoRoot
try {
    (& opam env) -split '\r?\n' | ForEach-Object {
        if ($_ -ne "") {
            Invoke-Expression $_
        }
    }

    dune build shared/shabptree/sakura_shabptree.dll bin/tree.exe

    $dll = @(
        Get-ChildItem -Path $repoRoot -Filter sakura_shabptree.dll -Recurse -ErrorAction SilentlyContinue
        Get-ChildItem -Path (Join-Path $repoRoot "..") -Filter sakura_shabptree.dll -Recurse -ErrorAction SilentlyContinue |
            Where-Object { $_.FullName -like "*\_build\*\$projectName\shared\shabptree\sakura_shabptree.dll" }
    ) | Select-Object -First 1

    if ($null -eq $dll) {
        throw "Could not find built sakura_shabptree.dll"
    }

    $env:SAKURA_BPLUSTREE_DLL = $dll.FullName

    if (-not $NoRun) {
        dune exec bin/tree.exe
    }
}
finally {
    Pop-Location
}