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

62 行
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. $msvcCl = 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64'
  7. if (-not (Test-Path (Join-Path $msvcCl 'cl.exe'))) {
  8. throw "cl.exe not found at $msvcCl"
  9. }
  10. $env:PATH = "$gcc;$msvcCl;" + $env:PATH
  11. $env:CGO_ENABLED = '1'
  12. # SDRplay
  13. $env:CGO_CFLAGS = '-IC:\PROGRA~1\SDRplay\API\inc'
  14. $env:CGO_LDFLAGS = '-LC:\PROGRA~1\SDRplay\API\x64 -lsdrplay_api'
  15. # CUDA (cuFFT)
  16. # Prefer C:\CUDA if present (no spaces)
  17. $cudaInc = 'C:\CUDA\include'
  18. $cudaLib = 'C:\CUDA\lib\x64'
  19. $cudaBin = 'C:\CUDA\bin'
  20. if (-not (Test-Path $cudaInc)) {
  21. $cudaInc = 'C:\PROGRA~1\NVIDIA GPU Computing Toolkit\CUDA\v13.2\include'
  22. $cudaLib = 'C:\PROGRA~1\NVIDIA GPU Computing Toolkit\CUDA\v13.2\lib\x64'
  23. $cudaBin = 'C:\PROGRA~1\NVIDIA GPU Computing Toolkit\CUDA\v13.2\bin'
  24. }
  25. if (Test-Path $cudaInc) {
  26. $env:CGO_CFLAGS = "$env:CGO_CFLAGS -I$cudaInc"
  27. }
  28. if (Test-Path $cudaBin) {
  29. $env:PATH = "$cudaBin;" + $env:PATH
  30. }
  31. $cudaMingw = Join-Path $PSScriptRoot 'cuda-mingw'
  32. if (Test-Path $cudaMingw) {
  33. # Use MinGW import libs to avoid MSVC .lib linking issues
  34. $env:CGO_LDFLAGS = "$env:CGO_LDFLAGS -L$cudaMingw"
  35. } elseif (Test-Path $cudaLib) {
  36. # Fallback to CUDA lib path (requires compatible toolchain)
  37. $env:CGO_LDFLAGS = "$env:CGO_LDFLAGS -L$cudaLib -lcufft -lcudart"
  38. }
  39. Write-Host "Building with SDRplay + cuFFT support..." -ForegroundColor Cyan
  40. Write-Host "WARNING: this path still performs final Go linking through MinGW GCC." -ForegroundColor Yellow
  41. Write-Host "If CUDA kernel artifacts are MSVC-built, final link may fail due to mixed toolchains." -ForegroundColor Yellow
  42. $gccHost = Join-Path $gcc 'g++.exe'
  43. if (!(Test-Path $gccHost)) {
  44. throw "g++.exe not found at $gccHost"
  45. }
  46. # Kernel build currently relies on nvcc + MSVC host compiler availability.
  47. powershell -ExecutionPolicy Bypass -File tools\build-gpudemod-kernel.ps1
  48. if ($LASTEXITCODE -ne 0) { throw "kernel build failed" }
  49. go build -tags "sdrplay,cufft" ./cmd/sdrd
  50. if ($LASTEXITCODE -ne 0) { throw "build failed" }
  51. Write-Host "Done." -ForegroundColor Green