Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

55 рядки
2.1KB

  1. $ErrorActionPreference = 'Stop'
  2. $gcc = 'C:\msys64\mingw64\bin'
  3. if (-not (Test-Path (Join-Path $gcc 'gcc.exe'))) {
  4. throw "gcc not found at $gcc"
  5. }
  6. if (-not (Test-Path (Join-Path $gcc 'g++.exe'))) {
  7. throw "g++ not found at $gcc"
  8. }
  9. $env:PATH = "$gcc;" + $env:PATH
  10. $env:CGO_ENABLED = '1'
  11. $env:CC = 'gcc'
  12. $env:CXX = 'g++'
  13. # SDRplay
  14. $sdrplayInc = 'C:\PROGRA~1\SDRplay\API\inc'
  15. $sdrplayBin = 'C:\PROGRA~1\SDRplay\API\x64'
  16. $env:CGO_CFLAGS = "-I$sdrplayInc"
  17. $env:CGO_LDFLAGS = "-L$sdrplayBin -lsdrplay_api"
  18. if (Test-Path $sdrplayBin) { $env:PATH = "$sdrplayBin;" + $env:PATH }
  19. # CUDA runtime / cuFFT
  20. $cudaInc = 'C:\CUDA\include'
  21. $cudaBin = 'C:\CUDA\bin'
  22. if (-not (Test-Path $cudaInc)) { $cudaInc = 'C:\PROGRA~1\NVIDIA~2\CUDA\v13.2\include' }
  23. if (-not (Test-Path $cudaBin)) { $cudaBin = 'C:\PROGRA~1\NVIDIA~2\CUDA\v13.2\bin' }
  24. $cudaMingw = Join-Path $PSScriptRoot 'cuda-mingw'
  25. if (Test-Path $cudaInc) { $env:CGO_CFLAGS = "$env:CGO_CFLAGS -I$cudaInc" }
  26. if (Test-Path $cudaBin) { $env:PATH = "$cudaBin;" + $env:PATH }
  27. if (Test-Path $cudaMingw) { $env:CGO_LDFLAGS = "$env:CGO_LDFLAGS -L$cudaMingw -lcudart64_13 -lcufft64_12 -lkernel32" }
  28. Write-Host 'Building SDRplay + cuFFT app (Windows DLL path)...' -ForegroundColor Cyan
  29. go build -tags "sdrplay,cufft" ./cmd/sdrd
  30. if ($LASTEXITCODE -ne 0) { throw 'build failed' }
  31. $dllCandidates = @(
  32. (Join-Path $PSScriptRoot 'internal\demod\gpudemod\build\gpudemod_kernels.dll'),
  33. (Join-Path $PSScriptRoot 'gpudemod_kernels.dll')
  34. )
  35. $dllDst = Join-Path $PSScriptRoot 'gpudemod_kernels.dll'
  36. $dllSrc = $dllCandidates | Where-Object { Test-Path $_ } | Select-Object -First 1
  37. if ($dllSrc) {
  38. if ((Resolve-Path $dllSrc).Path -ne (Resolve-Path (Split-Path $dllDst -Parent)).Path + '\gpudemod_kernels.dll') {
  39. try {
  40. Copy-Item $dllSrc $dllDst -Force
  41. } catch {
  42. Write-Host "WARNING: could not refresh runtime DLL at $dllDst ($($_.Exception.Message))" -ForegroundColor Yellow
  43. }
  44. }
  45. Write-Host "CUDA DLL ready at $dllDst" -ForegroundColor Green
  46. } else {
  47. Write-Host 'WARNING: gpudemod_kernels.dll not found; build succeeded but runtime GPU demod will not load.' -ForegroundColor Yellow
  48. }
  49. Write-Host 'Done.' -ForegroundColor Green