您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

79 行
3.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. $exePath = Join-Path $PSScriptRoot 'sdrd.exe'
  32. $exeDir = Split-Path $exePath -Parent
  33. $dllCandidates = @(
  34. (Join-Path $PSScriptRoot 'internal\demod\gpudemod\build\gpudemod_kernels.dll'),
  35. (Join-Path $PSScriptRoot 'gpudemod_kernels.dll')
  36. )
  37. $dllDst = Join-Path $exeDir 'gpudemod_kernels.dll'
  38. $dllSrc = $dllCandidates | Where-Object { Test-Path $_ } | Sort-Object { (Get-Item $_).LastWriteTimeUtc } -Descending | Select-Object -First 1
  39. if ($dllSrc) {
  40. $resolvedSrc = (Resolve-Path $dllSrc).Path
  41. $resolvedDst = $dllDst
  42. try {
  43. if ((Test-Path $dllDst) -and ((Resolve-Path $dllDst).Path -eq $resolvedSrc)) {
  44. Write-Host "CUDA DLL already current at $dllDst" -ForegroundColor Green
  45. } else {
  46. Copy-Item $dllSrc $dllDst -Force
  47. Write-Host "CUDA DLL copied to $dllDst" -ForegroundColor Green
  48. }
  49. } catch {
  50. Write-Host "WARNING: could not refresh runtime DLL at $dllDst ($($_.Exception.Message))" -ForegroundColor Yellow
  51. }
  52. } else {
  53. Write-Host 'WARNING: gpudemod_kernels.dll not found; build succeeded but runtime GPU demod will not load.' -ForegroundColor Yellow
  54. }
  55. $cudartCandidates = @(
  56. (Join-Path $cudaBin 'cudart64_13.dll'),
  57. 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.2\bin\cudart64_13.dll',
  58. 'C:\CUDA\bin\cudart64_13.dll'
  59. )
  60. $cudartSrc = $cudartCandidates | Where-Object { $_ -and (Test-Path $_) } | Select-Object -First 1
  61. if ($cudartSrc) {
  62. $cudartDst = Join-Path $exeDir 'cudart64_13.dll'
  63. try {
  64. Copy-Item $cudartSrc $cudartDst -Force
  65. Write-Host "CUDA runtime copied to $cudartDst" -ForegroundColor Green
  66. } catch {
  67. Write-Host "WARNING: could not copy CUDA runtime DLL to $cudartDst ($($_.Exception.Message))" -ForegroundColor Yellow
  68. }
  69. } else {
  70. Write-Host 'WARNING: cudart64_13.dll not found; shared CUDA runtime may fail to load at runtime.' -ForegroundColor Yellow
  71. }
  72. Write-Host 'Done.' -ForegroundColor Green