Skip to content
This repository has been archived by the owner on Jan 20, 2025. It is now read-only.

Commit

Permalink
add build.bat for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
dnjulek committed Feb 3, 2024
1 parent ffcc0e3 commit cfa3e43
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ ssim = core.ssimulacra2.SSIMULACRA2(ref, dist)
```

## Building
``zig build -Doptimize=ReleaseFast``
[Download](https://ziglang.org/download/) the latest zig-dev and run ``zig build -Doptimize=ReleaseFast``

[Download](https://ziglang.org/download/) the latest zig-dev, or run the ``build.sh`` file if you're on Linux.
Or run the script that downloads it for you:
- Windows: [build.bat](/build.bat)
- Linux: [build.sh](/build.sh)
14 changes: 14 additions & 0 deletions build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@echo OFF
:: This batch file exists to run RunWithBAT.ps1 without hassle

:: Check if pwsh is in the system's PATH
where pwsh >nul 2>nul
if %errorlevel% equ 0 (
:: pwsh is in PATH, so run the script using Windows Powershell
pwsh -NoProfile -NoLogo -ExecutionPolicy Bypass -File powershell\RunWithBAT.ps1
) else (
:: pwsh is not in PATH, run the script using PowerShell Core
powershell -NoProfile -NoLogo -ExecutionPolicy Bypass -File powershell\RunWithBAT.ps1
)

pause
32 changes: 32 additions & 0 deletions powershell/RunWithBAT.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
$jsonUrl = "https://raw.githubusercontent.com/ziglang/www.ziglang.org/master/data/releases.json"
$jsonContent = Invoke-RestMethod -Uri $jsonUrl -Method Get
$version = $jsonContent.master.version
$zipUrl = $jsonContent.master.'x86_64-windows'.tarball

$parentFolder = Split-Path -Path $PSScriptRoot -Parent
$zipFilePath = Join-Path $PSScriptRoot "zig-windows-x86_64-$version.zip"
$zigPath = Join-Path $PSScriptRoot "\zig-windows-x86_64-$version\zig.exe"
$dllFilePath = Join-Path $parentFolder "\zig-out\lib\invert_example.dll"
$destinationFileFolder = Join-Path $env:APPDATA "\VapourSynth\plugins64"
New-Item -ItemType Directory -Force -Path $destinationFileFolder | Out-Null
$destinationFilePath = Join-Path $destinationFileFolder "\invert_example.dll"

if (-not (Test-Path $zipFilePath)){
Write-Host "Downloading zig-windows-x86_64-$version.zip..." -ForegroundColor Green
Invoke-WebRequest -Uri $zipUrl -OutFile $zipFilePath
}

if (-not (Test-Path $zigPath)){
Write-Host "Extracting zig-windows-x86_64-$version.zip..." -ForegroundColor Green
Expand-Archive -Path $zipFilePath -DestinationPath $PSScriptRoot -Force
}

Write-Host "Building invert_example.dll..." -ForegroundColor Green
& $zigPath build -Doptimize=ReleaseFast

if (Test-Path $dllFilePath){
Write-Host "Installing 'invert_example.dll' to '$destinationFilePath'" -ForegroundColor Blue
Copy-Item -Path $dllFilePath -Destination $destinationFilePath -Force
} else {
Write-Host "No '\zig-out\lib\invert_example.dll' file, build error." -ForegroundColor Red
}

0 comments on commit cfa3e43

Please sign in to comment.