File: setup-build.ps1

package info (click to toggle)
llama.cpp 8064%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 76,488 kB
  • sloc: cpp: 353,828; ansic: 51,268; python: 30,090; lisp: 11,788; sh: 6,290; objc: 1,395; javascript: 924; xml: 384; makefile: 233
file content (105 lines) | stat: -rw-r--r-- 4,157 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# Requires Run as Administrator is NOT strictly necessary for User-scope env vars,
# but recommended for creating directories in C:\ root if permissions are restricted.

$ErrorActionPreference = "Stop"

# --- Configuration ---
$BaseDir = "C:\Qualcomm"

# SDK 1: Hexagon
$HexagonUrl     = "https://github.com/snapdragon-toolchain/hexagon-sdk/releases/download/v6.4.0.2/hexagon-sdk-v6.4.0.2-arm64-wos.tar.xz"
$HexagonParent  = Join-Path $BaseDir "Hexagon_SDK"
$HexagonSdkVersion   = "6.4.0.2"
$HexagonToolsVersion = "19.0.04"
$HexagonSdkTarget    = Join-Path $HexagonParent $HexagonSdkVersion
$HexagonToolsTarget  = Join-Path $HexagonSdkTarget "\tools\HEXAGON_Tools\$HexagonToolsVersion"

# SDK 2: OpenCL
$OpenCLUrl      = "https://github.com/snapdragon-toolchain/opencl-sdk/releases/download/v2.3.2/adreno-opencl-sdk-v2.3.2-arm64-wos.tar.xz"
$OpenCLParent   = Join-Path $BaseDir "OpenCL_SDK"
$OpenCLVersion  = "2.3.2"
$OpenCLTarget   = Join-Path $OpenCLParent $OpenCLVersion

# --- Helper Function ---
function Install-QualcommSDK {
    param (
        [string]$Url,
        [string]$ParentDir,
        [string]$TargetDir,
        [string]$Name
    )

    # 1. Create Parent Directory
    if (-not (Test-Path -Path $ParentDir)) {
        Write-Host "Creating directory: $ParentDir" -ForegroundColor Cyan
        New-Item -Path $ParentDir -ItemType Directory -Force | Out-Null
    }

    # 2. Check for Specific Version Directory
    if (Test-Path -Path $TargetDir) {
        Write-Host "$Name ($TargetDir) already exists. Skipping download." -ForegroundColor Green
    }
    else {
        Write-Host "$Name not found. preparing to download..." -ForegroundColor Yellow

        # Create the target directory to extract into
        New-Item -Path $TargetDir -ItemType Directory -Force | Out-Null

        # Define temporary archive path
        $TempFile = Join-Path $ParentDir "temp_sdk.tar.xz"

        try {
            # Download
            Write-Host "Downloading from: $Url"
            Invoke-WebRequest -Uri $Url -OutFile $TempFile

            # Untar
            # Note: We assume Windows includes tar.exe (Win 10 build 17063+)
            Write-Host "Extracting archive to $TargetDir..."

            # We use -C to extract contents INTO the target directory created above
            tar -xJvf $TempFile -C $TargetDir\..

            Write-Host "Extraction complete." -ForegroundColor Green
        }
        catch {
            Write-Error "Failed to download or extract $Name. Error: $_"
            # Cleanup target dir if failed so script tries again next time
            Remove-Item -Path $TargetDir -Recurse -Force -ErrorAction SilentlyContinue
        }
        finally {
            # Cleanup Archive
            if (Test-Path $TempFile) { Remove-Item $TempFile -Force }
        }
    }
}

# --- Execution ---

# 1. Ensure Base C:\Qualcomm exists
if (-not (Test-Path $BaseDir)) {
    New-Item -Path $BaseDir -ItemType Directory -Force | Out-Null
}

# 2. Run Install Logic
Install-QualcommSDK -Url $HexagonUrl -ParentDir $HexagonParent -TargetDir $HexagonSdkTarget -Name "Hexagon SDK"
Install-QualcommSDK -Url $OpenCLUrl -ParentDir $OpenCLParent -TargetDir $OpenCLTarget -Name "OpenCL SDK"

# --- Environment Variables ---

Write-Host "`nSetting Environment Variables..." -ForegroundColor Cyan

# Set OPENCL_SDK_ROOT
[System.Environment]::SetEnvironmentVariable('OPENCL_SDK_ROOT', $OpenCLTarget, [System.EnvironmentVariableTarget]::User)
$env:OPENCL_SDK_ROOT = $OpenCLTarget # Set for current session as well
Write-Host "OPENCL_SDK_ROOT set to:  $OpenCLTarget"

# Set HEXAGON_SDK_ROOT
[System.Environment]::SetEnvironmentVariable('HEXAGON_SDK_ROOT', $HexagonSdkTarget, [System.EnvironmentVariableTarget]::User)
$env:HEXAGON_SDK_ROOT = $HexagonSdkTarget # Set for current session as well
Write-Host "HEXAGON_SDK_ROOT set to: $HexagonSdkTarget"

# Set HEXAGON_SDK_ROOT
[System.Environment]::SetEnvironmentVariable('HEXAGON_TOOLS_ROOT', $HexagonToolsTarget, [System.EnvironmentVariableTarget]::User)
$env:HEXAGON_TOOLS_ROOT = $HexagonToolsTarget # Set for current session as well
Write-Host "HEXAGON_TOOLS_ROOT set to: $HexagonToolsTarget"