Wideband autonomous SDR analysis engine forked from sdr-visual-suite
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

95 linhas
3.8KB

  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. $cudaBinX64 = 'C:\CUDA\bin\x64'
  23. if (-not (Test-Path $cudaInc)) { $cudaInc = 'C:\PROGRA~1\NVIDIA~2\CUDA\v13.2\include' }
  24. if (-not (Test-Path $cudaBin)) { $cudaBin = 'C:\PROGRA~1\NVIDIA~2\CUDA\v13.2\bin' }
  25. if (-not (Test-Path $cudaBinX64)) { $cudaBinX64 = 'C:\PROGRA~1\NVIDIA~2\CUDA\v13.2\bin\x64' }
  26. $cudaMingw = Join-Path $PSScriptRoot 'cuda-mingw'
  27. if (Test-Path $cudaInc) { $env:CGO_CFLAGS = "$env:CGO_CFLAGS -I$cudaInc" }
  28. if (Test-Path $cudaBinX64) { $env:PATH = "$cudaBinX64;" + $env:PATH }
  29. if (Test-Path $cudaBin) { $env:PATH = "$cudaBin;" + $env:PATH }
  30. if (Test-Path $cudaMingw) { $env:CGO_LDFLAGS = "$env:CGO_LDFLAGS -L$cudaMingw -lcudart64_13 -lcufft64_12 -lkernel32" }
  31. # Fix for GCC 15 / MSYS2: ensure system headers are found by CGO
  32. $mingwSysInclude = 'C:\msys64\mingw64\include'
  33. if (Test-Path $mingwSysInclude) {
  34. $env:CGO_CFLAGS = "$env:CGO_CFLAGS -I$mingwSysInclude"
  35. }
  36. $mingwCrtInclude = 'C:\msys64\mingw64\x86_64-w64-mingw32\include'
  37. if (Test-Path $mingwCrtInclude) {
  38. $env:CGO_CFLAGS = "$env:CGO_CFLAGS -I$mingwCrtInclude"
  39. }
  40. Write-Host 'Building SDRplay + cuFFT app (Windows DLL path)...' -ForegroundColor Cyan
  41. go build -tags "sdrplay,cufft" ./cmd/sdrd
  42. if ($LASTEXITCODE -ne 0) { throw 'build failed' }
  43. $exePath = Join-Path $PSScriptRoot 'sdrd.exe'
  44. $exeDir = Split-Path $exePath -Parent
  45. $dllCandidates = @(
  46. (Join-Path $PSScriptRoot 'internal\demod\gpudemod\build\gpudemod_kernels.dll'),
  47. (Join-Path $PSScriptRoot 'gpudemod_kernels.dll')
  48. )
  49. $dllDst = Join-Path $exeDir 'gpudemod_kernels.dll'
  50. $dllSrc = $dllCandidates | Where-Object { Test-Path $_ } | Sort-Object { (Get-Item $_).LastWriteTimeUtc } -Descending | Select-Object -First 1
  51. if ($dllSrc) {
  52. $resolvedSrc = (Resolve-Path $dllSrc).Path
  53. $resolvedDst = $dllDst
  54. try {
  55. if ((Test-Path $dllDst) -and ((Resolve-Path $dllDst).Path -eq $resolvedSrc)) {
  56. Write-Host "CUDA DLL already current at $dllDst" -ForegroundColor Green
  57. } else {
  58. Copy-Item $dllSrc $dllDst -Force
  59. Write-Host "CUDA DLL copied to $dllDst" -ForegroundColor Green
  60. }
  61. } catch {
  62. Write-Host "WARNING: could not refresh runtime DLL at $dllDst ($($_.Exception.Message))" -ForegroundColor Yellow
  63. }
  64. } else {
  65. Write-Host 'WARNING: gpudemod_kernels.dll not found; build succeeded but runtime GPU demod will not load.' -ForegroundColor Yellow
  66. }
  67. $cudartCandidates = @(
  68. (Join-Path $cudaBinX64 'cudart64_13.dll'),
  69. (Join-Path $cudaBin 'cudart64_13.dll'),
  70. 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.2\bin\x64\cudart64_13.dll',
  71. 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.2\bin\cudart64_13.dll',
  72. 'C:\CUDA\bin\x64\cudart64_13.dll',
  73. 'C:\CUDA\bin\cudart64_13.dll'
  74. )
  75. $cudartSrc = $cudartCandidates | Where-Object { $_ -and (Test-Path $_) } | Select-Object -First 1
  76. if ($cudartSrc) {
  77. $cudartDst = Join-Path $exeDir 'cudart64_13.dll'
  78. try {
  79. Copy-Item $cudartSrc $cudartDst -Force
  80. Write-Host "CUDA runtime copied to $cudartDst" -ForegroundColor Green
  81. } catch {
  82. Write-Host "WARNING: could not copy CUDA runtime DLL to $cudartDst ($($_.Exception.Message))" -ForegroundColor Yellow
  83. }
  84. } else {
  85. Write-Host 'WARNING: cudart64_13.dll not found; shared CUDA runtime may fail to load at runtime.' -ForegroundColor Yellow
  86. }
  87. Write-Host 'Done.' -ForegroundColor Green