選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

89 行
3.5KB

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