Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

64 rindas
1.9KB

  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. if (Test-Path $outObj) { Remove-Item $outObj -Force }
  17. if (Test-Path $outLib) { Remove-Item $outLib -Force }
  18. Write-Host "Using nvcc: $nvcc"
  19. Write-Host "Building $Source -> $outObj"
  20. $nvccArgs = @('-c', $Source, '-o', $outObj, '-I', (Join-Path $CudaRoot 'include'))
  21. if ($HostCompiler) {
  22. Write-Host "Using host compiler: $HostCompiler"
  23. $hostDir = Split-Path -Parent $HostCompiler
  24. $nvccArgs += @('-ccbin', $hostDir)
  25. } else {
  26. $nvccArgs += @('-Xcompiler', '/EHsc')
  27. }
  28. & $nvcc @nvccArgs
  29. if ($LASTEXITCODE -ne 0) {
  30. throw "nvcc failed with exit code $LASTEXITCODE"
  31. }
  32. if ($HostCompiler) {
  33. $ar = Get-Command ar.exe -ErrorAction SilentlyContinue
  34. if (-not $ar) {
  35. throw "ar.exe not found in PATH; required for MinGW-compatible archive"
  36. }
  37. Write-Host "Archiving $outObj -> $outLib with ar.exe"
  38. if (Test-Path $outLib) { Remove-Item $outLib -Force }
  39. & $ar 'rcs' $outLib $outObj
  40. if ($LASTEXITCODE -ne 0) {
  41. throw "ar.exe failed with exit code $LASTEXITCODE"
  42. }
  43. } else {
  44. $libexe = Get-Command lib.exe -ErrorAction SilentlyContinue
  45. if (-not $libexe) {
  46. throw "lib.exe not found in PATH; run from vcvars64.bat environment"
  47. }
  48. Write-Host "Archiving $outObj -> $outLib with lib.exe"
  49. & $libexe /nologo /OUT:$outLib $outObj
  50. if ($LASTEXITCODE -ne 0) {
  51. throw "lib.exe failed with exit code $LASTEXITCODE"
  52. }
  53. }
  54. Write-Host "Built: $outObj"
  55. Write-Host "Archived: $outLib"