Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

62 wiersze
1.8KB

  1. param(
  2. [string]$CudaRoot = 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.2',
  3. [string]$Source = 'internal/demod/gpudemod/kernels.cu',
  4. [string]$OutDir = 'internal/demod/gpudemod/build'
  5. )
  6. $ErrorActionPreference = 'Stop'
  7. $repo = Split-Path -Parent $PSScriptRoot
  8. Set-Location $repo
  9. $nvcc = Join-Path $CudaRoot 'bin\nvcc.exe'
  10. if (!(Test-Path $nvcc)) {
  11. throw "nvcc not found at $nvcc"
  12. }
  13. New-Item -ItemType Directory -Force -Path $OutDir | Out-Null
  14. $outObj = Join-Path $OutDir 'kernels.obj'
  15. $outLib = Join-Path $OutDir 'gpudemod_kernels.lib'
  16. Write-Host "Using nvcc: $nvcc"
  17. Write-Host "Building $Source -> $outObj"
  18. $nvccArgs = @('-c', $Source, '-o', $outObj, '-I', (Join-Path $CudaRoot 'include'))
  19. if ($HostCompiler) {
  20. Write-Host "Using host compiler: $HostCompiler"
  21. $hostDir = Split-Path -Parent $HostCompiler
  22. $nvccArgs += @('-ccbin', $hostDir)
  23. } else {
  24. $nvccArgs += @('-Xcompiler', '/EHsc')
  25. }
  26. & $nvcc @nvccArgs
  27. if ($LASTEXITCODE -ne 0) {
  28. throw "nvcc failed with exit code $LASTEXITCODE"
  29. }
  30. if ($HostCompiler) {
  31. $ar = Get-Command ar.exe -ErrorAction SilentlyContinue
  32. if (-not $ar) {
  33. throw "ar.exe not found in PATH; required for MinGW-compatible archive"
  34. }
  35. Write-Host "Archiving $outObj -> $outLib with ar.exe"
  36. if (Test-Path $outLib) { Remove-Item $outLib -Force }
  37. & $ar 'rcs' $outLib $outObj
  38. if ($LASTEXITCODE -ne 0) {
  39. throw "ar.exe failed with exit code $LASTEXITCODE"
  40. }
  41. } else {
  42. $libexe = Get-Command lib.exe -ErrorAction SilentlyContinue
  43. if (-not $libexe) {
  44. throw "lib.exe not found in PATH; run from vcvars64.bat environment"
  45. }
  46. Write-Host "Archiving $outObj -> $outLib with lib.exe"
  47. & $libexe /nologo /OUT:$outLib $outObj
  48. if ($LASTEXITCODE -ne 0) {
  49. throw "lib.exe failed with exit code $LASTEXITCODE"
  50. }
  51. }
  52. Write-Host "Built: $outObj"
  53. Write-Host "Archived: $outLib"