25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
2.2KB

  1. # pcbuild.ps1 - build a Power C program with the improved toolchain.
  2. #
  3. # powershell -NoProfile -File reference\powerc-re\tools\pcbuild.ps1 -Src a.c,b.c -Name prog [-Dir build] [-Run 'keys\n'] [-NoOpt]
  4. #
  5. # 1. compiles every source with the ORIGINAL Power C compiler running in VICE (copy of POWERc.d81)
  6. # 2. runs pcopt.py on each object file (peephole optimizer; -NoOpt skips this)
  7. # 3. links with the original linker, using the improved runtime objects from optlib\
  8. # (faster multiply / divide, fixed unsigned >=), again on a copy of the disk
  9. # 4. with -Run, loads the program in BASIC, runs it and types the given keys; the final
  10. # screen is saved as <Dir>\run.png
  11. # Prerequisite (once): python reference\powerc-re\tools\setup.py
  12. # The original reference\POWERc.d81 is never written.
  13. param([string[]]$Src, [string]$Name = "prog", [string]$Dir = "build", [string]$Run = "", [switch]$NoOpt,
  14. [int]$Settle = 30)
  15. $ErrorActionPreference = "Stop"
  16. $here = $PSScriptRoot
  17. $root = (Resolve-Path (Join-Path $here "..")).Path
  18. $Src = @($Src | % { $_ -split "," } | % { (Resolve-Path $_).Path })
  19. New-Item -ItemType Directory -Force -Path $Dir | Out-Null
  20. $Dir = (Resolve-Path $Dir).Path
  21. $obj = Join-Path $Dir "obj"; $opt = Join-Path $Dir "opt"
  22. New-Item -ItemType Directory -Force -Path $obj, $opt | Out-Null
  23. if (-not (Test-Path (Join-Path $root "optlib\cmulti.obj"))) { throw "run tools\setup.py first" }
  24. & (Join-Path $here "pc-compile.ps1") -Src $Src -Out $obj | Where-Object { $_ -match "^(ok|FAIL)" }
  25. $names = $Src | % { [IO.Path]::GetFileNameWithoutExtension($_) }
  26. foreach ($n in $names) { if (-not (Test-Path (Join-Path $obj "$n.o"))) { throw "$n.c did not compile - see work\last.png" } }
  27. $final = @()
  28. foreach ($n in $names) {
  29. $in = Join-Path $obj "$n.o"
  30. if ($NoOpt) { $final += $in; continue }
  31. $out = Join-Path $opt "$n.o"
  32. & python (Join-Path $here "pcopt.py") $in $out --lib (Join-Path $root "lib")
  33. $final += $out
  34. }
  35. $lib = (Get-ChildItem (Join-Path $root "optlib") -Filter *.obj | % { $_.FullName }) -join ","
  36. $p = @{ Obj = ($final -join ","); Name = $Name; Dir = $Dir; Settle = $Settle }
  37. if (-not $NoOpt) { $p.LibObj = $lib }
  38. if ($Run -ne "") { $p.Keys = $Run }
  39. & (Join-Path $here "pc-run.ps1") @p | Where-Object { $_ -match "linked|FAILED" }

Powered by TurnKey Linux.