chore(build): support download-windows-artifacts
Signed-off-by: Hanchin Hsieh <me@yuchanns.xyz>
This commit is contained in:
parent
f77bacb10b
commit
f239733e61
51
Build.ps1
51
Build.ps1
@ -1,9 +1,14 @@
|
|||||||
param (
|
param (
|
||||||
[string]$Version = "luajit"
|
[string]$Version = "luajit",
|
||||||
|
[string]$BuildFromSource = "true"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
$Build = [System.Convert]::ToBoolean($BuildFromSource)
|
||||||
|
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
$ProgressPreference = "SilentlyContinue"
|
||||||
|
|
||||||
$BuildDir = "build"
|
$BuildDir = "build"
|
||||||
$BuildFromSource = $true
|
|
||||||
|
|
||||||
function Build-FromSource($feature) {
|
function Build-FromSource($feature) {
|
||||||
if (-not (Test-Path $BuildDir)) {
|
if (-not (Test-Path $BuildDir)) {
|
||||||
@ -14,16 +19,54 @@ function Build-FromSource($feature) {
|
|||||||
|
|
||||||
$targetTokenizerFile = "avante_tokenizers.dll"
|
$targetTokenizerFile = "avante_tokenizers.dll"
|
||||||
$targetTemplatesFile = "avante_templates.dll"
|
$targetTemplatesFile = "avante_templates.dll"
|
||||||
Copy-Item (Join-Path "target\release\libavante_tokenizers.dll") (Join-Path $BuildDir $targetTokenizerFile)
|
Copy-Item (Join-Path "target\release\avante_tokenizers.dll") (Join-Path $BuildDir $targetTokenizerFile)
|
||||||
Copy-Item (Join-Path "target\release\libavante_templates.dll") (Join-Path $BuildDir $targetTemplatesFile)
|
Copy-Item (Join-Path "target\release\avante_templates.dll") (Join-Path $BuildDir $targetTemplatesFile)
|
||||||
|
|
||||||
Remove-Item -Recurse -Force "target"
|
Remove-Item -Recurse -Force "target"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Download-Prebuilt($feature) {
|
||||||
|
$REPO_OWNER = "yetone"
|
||||||
|
$REPO_NAME = "avante.nvim"
|
||||||
|
|
||||||
|
$SCRIPT_DIR = $PSScriptRoot
|
||||||
|
# Set the target directory to clone the artifact
|
||||||
|
$TARGET_DIR = Join-Path $SCRIPT_DIR "build"
|
||||||
|
|
||||||
|
# Set the platform to Windows
|
||||||
|
$PLATFORM = "windows"
|
||||||
|
|
||||||
|
# Set the Lua version (lua51 or luajit)
|
||||||
|
$LUA_VERSION = if ($feature) { $feature } else { "luajit" }
|
||||||
|
|
||||||
|
# Set the artifact name pattern
|
||||||
|
$ARTIFACT_NAME_PATTERN = "avante_lib-$PLATFORM-latest-$LUA_VERSION"
|
||||||
|
|
||||||
|
# Get the artifact download URL
|
||||||
|
$LATEST_RELEASE = Invoke-RestMethod -Uri "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/releases/latest"
|
||||||
|
$ARTIFACT_URL = $LATEST_RELEASE.assets | Where-Object { $_.name -like "*$ARTIFACT_NAME_PATTERN*" } | Select-Object -ExpandProperty browser_download_url
|
||||||
|
|
||||||
|
# Create target directory if it doesn't exist
|
||||||
|
if (-not (Test-Path $TARGET_DIR)) {
|
||||||
|
New-Item -ItemType Directory -Path $TARGET_DIR | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
# Download and extract the artifact
|
||||||
|
$TempFile = New-TemporaryFile | Rename-Item -NewName { $_.Name + ".zip" } -PassThru
|
||||||
|
Invoke-WebRequest -Uri $ARTIFACT_URL -OutFile $TempFile
|
||||||
|
Expand-Archive -Path $TempFile -DestinationPath $TARGET_DIR -Force
|
||||||
|
Remove-Item $TempFile
|
||||||
|
}
|
||||||
|
|
||||||
function Main {
|
function Main {
|
||||||
Set-Location $PSScriptRoot
|
Set-Location $PSScriptRoot
|
||||||
|
if ($Build) {
|
||||||
Write-Host "Building for $Version..."
|
Write-Host "Building for $Version..."
|
||||||
Build-FromSource $Version
|
Build-FromSource $Version
|
||||||
|
} else {
|
||||||
|
Write-Host "Downloading for $Version..."
|
||||||
|
Download-Prebuilt $Version
|
||||||
|
}
|
||||||
Write-Host "Completed!"
|
Write-Host "Completed!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,6 +61,8 @@ M.build = function(opts)
|
|||||||
string.format("%s\\Build.ps1", build_directory),
|
string.format("%s\\Build.ps1", build_directory),
|
||||||
"-WorkingDirectory",
|
"-WorkingDirectory",
|
||||||
build_directory,
|
build_directory,
|
||||||
|
"-BuildFromSource",
|
||||||
|
string.format("%s", opts.source == true and "true" or "false"),
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
error("Unsupported operating system: " .. os_name, 2)
|
error("Unsupported operating system: " .. os_name, 2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user