chore(build): support build lua-tiktoken on Windows (#128)
Signed-off-by: Hanchin Hsieh <me@yuchanns.xyz>
This commit is contained in:
32
Build-LuaTiktoken.ps1
Normal file
32
Build-LuaTiktoken.ps1
Normal file
@@ -0,0 +1,32 @@
|
||||
param (
|
||||
[string]$Version = "luajit"
|
||||
)
|
||||
|
||||
$BuildDir = "build"
|
||||
$BuildFromSource = $true
|
||||
|
||||
function Build-FromSource($feature) {
|
||||
if (-not (Test-Path $BuildDir)) {
|
||||
New-Item -ItemType Directory -Path $BuildDir | Out-Null
|
||||
}
|
||||
|
||||
$tempDir = Join-Path $BuildDir "lua-tiktoken-temp"
|
||||
git clone https://github.com/gptlang/lua-tiktoken.git $tempDir
|
||||
|
||||
Push-Location $tempDir
|
||||
cargo build --features=$feature
|
||||
Pop-Location
|
||||
|
||||
$targetFile = "tiktoken_core.dll"
|
||||
Copy-Item (Join-Path $tempDir "target\debug\tiktoken_core.dll") (Join-Path $BuildDir $targetFile)
|
||||
|
||||
Remove-Item -Recurse -Force $tempDir
|
||||
}
|
||||
|
||||
function Main {
|
||||
Write-Host "Building for $Version..."
|
||||
Build-FromSource $Version
|
||||
}
|
||||
|
||||
# Run the main function
|
||||
Main
|
||||
Reference in New Issue
Block a user