feat: added CPU variant support for x64 native addons with AVX2/baseline fallback
- Added CPU variant support for x64 native addons with modern (AVX2/x86-64-v3) and baseline (x86-64-v2) variants, enabling automatic fallback when modern variants are unavailable. - Added automatic AVX2 CPU detection on Linux, macOS, and Windows platforms to select appropriate native addon variant at runtime. - Updated native addon filename scheme to include CPU variant suffix (e.g., pi_natives.linux-x64-modern.node) for x64 platforms. - Updated CLI update mechanism to support downloading and installing multiple native addon variants per platform with fallback support. - Removed fallback untagged pi_natives.node binary creation; platform and variant-tagged binaries are now required.
This commit is contained in:
@@ -23,7 +23,8 @@ RUN cd packages/coding-agent && bun run build:binary
|
||||
# Install binary and native addon to PATH
|
||||
RUN mkdir -p /root/.local/bin && \
|
||||
cp packages/coding-agent/dist/omp /root/.local/bin/ && \
|
||||
cp packages/natives/native/pi_natives.linux-x64.node /root/.local/bin/
|
||||
cp packages/natives/native/pi_natives.linux-x64-modern.node /root/.local/bin/ && \
|
||||
cp packages/natives/native/pi_natives.linux-x64-baseline.node /root/.local/bin/
|
||||
ENV PATH="/root/.local/bin:$PATH"
|
||||
|
||||
# Verify
|
||||
|
||||
+11
-8
@@ -20,7 +20,7 @@ $Repo = "can1357/oh-my-pi"
|
||||
$Package = "@oh-my-pi/pi-coding-agent"
|
||||
$InstallDir = if ($env:PI_INSTALL_DIR) { $env:PI_INSTALL_DIR } else { "$env:LOCALAPPDATA\omp" }
|
||||
$BinaryName = "omp-windows-x64.exe"
|
||||
$NativeAddonName = "pi_natives.win32-x64.node"
|
||||
$NativeAddonNames = @("pi_natives.win32-x64-modern.node", "pi_natives.win32-x64-baseline.node")
|
||||
$MinimumBunVersion = "1.3.7"
|
||||
|
||||
function Test-BunInstalled {
|
||||
@@ -263,15 +263,18 @@ function Install-Binary {
|
||||
$OutPath = Join-Path $InstallDir "omp.exe"
|
||||
Invoke-WebRequest -Uri $BinaryUrl -OutFile $OutPath
|
||||
|
||||
# Download native addon
|
||||
$NativeUrl = "https://github.com/$Repo/releases/download/$Latest/$NativeAddonName"
|
||||
Write-Host "Downloading $NativeAddonName..."
|
||||
$NativeOutPath = Join-Path $InstallDir $NativeAddonName
|
||||
Invoke-WebRequest -Uri $NativeUrl -OutFile $NativeOutPath
|
||||
|
||||
# Download native addons
|
||||
$downloadedNative = 0
|
||||
foreach ($nativeAddonName in $NativeAddonNames) {
|
||||
$nativeUrl = "https://github.com/$Repo/releases/download/$Latest/$nativeAddonName"
|
||||
Write-Host "Downloading $nativeAddonName..."
|
||||
$nativeOutPath = Join-Path $InstallDir $nativeAddonName
|
||||
Invoke-WebRequest -Uri $nativeUrl -OutFile $nativeOutPath
|
||||
$downloadedNative += 1
|
||||
}
|
||||
Write-Host ""
|
||||
Write-Host "✓ Installed omp to $OutPath" -ForegroundColor Green
|
||||
Write-Host "✓ Installed native addon to $NativeOutPath" -ForegroundColor Green
|
||||
Write-Host "✓ Installed $downloadedNative native addon file(s) to $InstallDir" -ForegroundColor Green
|
||||
|
||||
# Add to PATH if not already there
|
||||
$UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
|
||||
|
||||
+20
-32
@@ -202,45 +202,33 @@ install_binary() {
|
||||
esac
|
||||
|
||||
BINARY="omp-${PLATFORM}-${ARCH}"
|
||||
NATIVE_ADDON="pi_natives.${PLATFORM}-${ARCH}.node"
|
||||
|
||||
# Get release tag
|
||||
if [ -n "$REF" ]; then
|
||||
echo "Fetching release $REF..."
|
||||
if RELEASE_JSON=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/tags/${REF}"); then
|
||||
LATEST=$(echo "$RELEASE_JSON" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')
|
||||
else
|
||||
echo "Release tag not found: $REF"
|
||||
echo "For branch/commit installs, use --source with --ref."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Fetching latest release..."
|
||||
RELEASE_JSON=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest")
|
||||
LATEST=$(echo "$RELEASE_JSON" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')
|
||||
fi
|
||||
if [ -z "$LATEST" ]; then
|
||||
echo "Failed to fetch release tag"
|
||||
exit 1
|
||||
fi
|
||||
echo "Using version: $LATEST"
|
||||
|
||||
mkdir -p "$INSTALL_DIR"
|
||||
|
||||
# Download binary
|
||||
BINARY_URL="https://github.com/${REPO}/releases/download/${LATEST}/${BINARY}"
|
||||
echo "Downloading ${BINARY}..."
|
||||
curl -fsSL "$BINARY_URL" -o "${INSTALL_DIR}/omp"
|
||||
chmod +x "${INSTALL_DIR}/omp"
|
||||
|
||||
# Download native addon
|
||||
NATIVE_URL="https://github.com/${REPO}/releases/download/${LATEST}/${NATIVE_ADDON}"
|
||||
echo "Downloading ${NATIVE_ADDON}..."
|
||||
curl -fsSL "$NATIVE_URL" -o "${INSTALL_DIR}/${NATIVE_ADDON}"
|
||||
|
||||
downloaded_native=0
|
||||
if [ "$ARCH" = "x64" ]; then
|
||||
for variant in modern baseline; do
|
||||
NATIVE_ADDON="pi_natives.${PLATFORM}-${ARCH}-${variant}.node"
|
||||
NATIVE_URL="https://github.com/${REPO}/releases/download/${LATEST}/${NATIVE_ADDON}"
|
||||
echo "Downloading ${NATIVE_ADDON}..."
|
||||
curl -fsSL "$NATIVE_URL" -o "${INSTALL_DIR}/${NATIVE_ADDON}" || {
|
||||
echo "Failed to download ${NATIVE_ADDON}"
|
||||
exit 1
|
||||
}
|
||||
downloaded_native=$((downloaded_native + 1))
|
||||
done
|
||||
else
|
||||
NATIVE_ADDON="pi_natives.${PLATFORM}-${ARCH}.node"
|
||||
NATIVE_URL="https://github.com/${REPO}/releases/download/${LATEST}/${NATIVE_ADDON}"
|
||||
echo "Downloading ${NATIVE_ADDON}..."
|
||||
curl -fsSL "$NATIVE_URL" -o "${INSTALL_DIR}/${NATIVE_ADDON}"
|
||||
downloaded_native=1
|
||||
fi
|
||||
echo ""
|
||||
echo "✓ Installed omp to ${INSTALL_DIR}/omp"
|
||||
echo "✓ Installed native addon to ${INSTALL_DIR}/${NATIVE_ADDON}"
|
||||
echo "✓ Installed ${downloaded_native} native addon file(s) to ${INSTALL_DIR}"
|
||||
|
||||
# Check if in PATH
|
||||
case ":$PATH:" in
|
||||
|
||||
Reference in New Issue
Block a user