chore(build): support build lua-tiktoken on Windows (#128)
Signed-off-by: Hanchin Hsieh <me@yuchanns.xyz>
This commit is contained in:
parent
2e48d387a9
commit
83d067695e
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
|
11
README.md
11
README.md
@ -51,6 +51,17 @@ Install `avante.nvim` using [lazy.nvim](https://github.com/folke/lazy.nvim):
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
For Windows users, change the build command to the following:
|
||||||
|
|
||||||
|
```lua
|
||||||
|
{
|
||||||
|
"yetone/avante.nvim",
|
||||||
|
event = "VeryLazy",
|
||||||
|
build = "powershell -ExecutionPolicy Bypass -File Build-LuaTiktoken.ps1",
|
||||||
|
-- rest of the config
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
> [!IMPORTANT]
|
> [!IMPORTANT]
|
||||||
>
|
>
|
||||||
> `avante.nvim` is currently only compatible with Neovim 0.10.0 or later. Please ensure that your Neovim version meets these requirements before proceeding.
|
> `avante.nvim` is currently only compatible with Neovim 0.10.0 or later. Please ensure that your Neovim version meets these requirements before proceeding.
|
||||||
|
@ -7,6 +7,8 @@ H.get_os_name = function()
|
|||||||
return "linux"
|
return "linux"
|
||||||
elseif os_name == "Darwin" then
|
elseif os_name == "Darwin" then
|
||||||
return "macOS"
|
return "macOS"
|
||||||
|
elseif os_name == "Windows_NT" then
|
||||||
|
return "windows"
|
||||||
else
|
else
|
||||||
error("Unsupported operating system: " .. os_name)
|
error("Unsupported operating system: " .. os_name)
|
||||||
end
|
end
|
||||||
@ -14,7 +16,7 @@ end
|
|||||||
|
|
||||||
H.library_path = function()
|
H.library_path = function()
|
||||||
local os_name = H.get_os_name()
|
local os_name = H.get_os_name()
|
||||||
local ext = os_name == "linux" and "so" or "dylib"
|
local ext = os_name == "linux" and "so" or (os_name == "macOS" and "dylib" or "dll")
|
||||||
local dirname = string.sub(debug.getinfo(1).source, 2, #"/tiktoken_lib.lua" * -1)
|
local dirname = string.sub(debug.getinfo(1).source, 2, #"/tiktoken_lib.lua" * -1)
|
||||||
return dirname .. ("../build/?.%s"):format(ext)
|
return dirname .. ("../build/?.%s"):format(ext)
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user