annotate repoint.ps1 @ 64:0c94d3065ecd

Fix app signing; remove plugin signing from project files, as we now need to separate out the plugin build, plugin signing, and installer build phases on every platform
author Chris Cannam
date Tue, 11 Feb 2020 10:16:49 +0000
parents eaa4410df4cd
children
rev   line source
Chris@0 1 <#
Chris@0 2
Chris@0 3 .SYNOPSIS
Chris@0 4 A simple manager for third-party source code dependencies.
Chris@0 5 Run "repoint help" for more documentation.
Chris@0 6
Chris@0 7 #>
Chris@0 8
Chris@0 9 Set-StrictMode -Version 2.0
Chris@0 10 $ErrorActionPreference = "Stop"
Chris@0 11 $env:HGPLAIN = "true"
Chris@0 12
Chris@0 13 $sml = $env:REPOINT_SML
Chris@0 14
Chris@0 15 $mydir = Split-Path $MyInvocation.MyCommand.Path -Parent
Chris@0 16 $program = "$mydir/repoint.sml"
Chris@0 17
Chris@0 18 # We need either Poly/ML or SML/NJ. No great preference as to which.
Chris@0 19
Chris@0 20 # Typical locations
Chris@0 21 $env:PATH = "$env:PATH;C:\Program Files (x86)\SMLNJ\bin;C:\Program Files\Poly ML;C:\Program Files (x86)\Poly ML"
Chris@0 22
Chris@0 23 if (!$sml) {
Chris@0 24 if (Get-Command "sml" -ErrorAction SilentlyContinue) {
Chris@0 25 $sml = "smlnj"
Chris@0 26 } elseif (Get-Command "polyml" -ErrorAction SilentlyContinue) {
Chris@0 27 $sml = "poly"
Chris@0 28 } else {
Chris@0 29 echo @"
Chris@0 30
Chris@0 31 ERROR: No supported SML compiler or interpreter found
Chris@0 32
Chris@0 33 The Repoint external source code manager needs a Standard ML (SML)
Chris@0 34 compiler or interpreter to run.
Chris@0 35
Chris@0 36 Please ensure you have one of the following SML implementations
Chris@0 37 installed and present in your PATH, and try again.
Chris@0 38
Chris@0 39 1. Standard ML of New Jersey
Chris@0 40 - executable name: sml
Chris@0 41
Chris@0 42 2. Poly/ML
Chris@0 43 - executable name: polyml
Chris@0 44
Chris@0 45 "@
Chris@0 46 exit 1
Chris@0 47 }
Chris@0 48 }
Chris@0 49
Chris@0 50 if ($args -match "'""") {
Chris@0 51 $arglist = '["usage"]'
Chris@0 52 } else {
Chris@0 53 $arglist = '["' + ($args -join '","') + '"]'
Chris@0 54 }
Chris@0 55
Chris@0 56 if ($sml -eq "poly") {
Chris@0 57
Chris@0 58 $program = $program -replace "\\","\\\\"
Chris@0 59 echo "use ""$program""; repoint $arglist" | polyml -q --error-exit | Out-Host
Chris@0 60
Chris@0 61 if (-not $?) {
Chris@0 62 exit $LastExitCode
Chris@0 63 }
Chris@0 64
Chris@0 65 } elseif ($sml -eq "smlnj") {
Chris@0 66
Chris@0 67 $lines = @(Get-Content $program)
Chris@0 68 $lines = $lines -notmatch "val _ = main ()"
Chris@0 69
Chris@0 70 $intro = @"
Chris@0 71 val smlrun__cp =
Chris@0 72 let val x = !Control.Print.out in
Chris@0 73 Control.Print.out := { say = fn _ => (), flush = fn () => () };
Chris@0 74 x
Chris@0 75 end;
Chris@0 76 val smlrun__prev = ref "";
Chris@0 77 Control.Print.out := {
Chris@0 78 say = fn s =>
Chris@0 79 (if String.isSubstring "Error" s orelse String.isSubstring "Fail" s
Chris@0 80 then (Control.Print.out := smlrun__cp;
Chris@0 81 (#say smlrun__cp) (!smlrun__prev);
Chris@0 82 (#say smlrun__cp) s)
Chris@0 83 else (smlrun__prev := s; ())),
Chris@0 84 flush = fn s => ()
Chris@0 85 };
Chris@0 86 "@ -split "[\r\n]+"
Chris@0 87
Chris@0 88 $outro = @"
Chris@0 89 val _ = repoint $arglist;
Chris@0 90 val _ = OS.Process.exit (OS.Process.success);
Chris@0 91 "@ -split "[\r\n]+"
Chris@0 92
Chris@0 93 $script = @()
Chris@0 94 $script += $intro
Chris@0 95 $script += $lines
Chris@0 96 $script += $outro
Chris@0 97
Chris@0 98 $tmpfile = ([System.IO.Path]::GetTempFileName()) -replace "[.]tmp",".sml"
Chris@0 99
Chris@0 100 $script | Out-File -Encoding "ASCII" $tmpfile
Chris@0 101
Chris@0 102 $env:CM_VERBOSE="false"
Chris@0 103
Chris@0 104 sml $tmpfile
Chris@0 105
Chris@0 106 if (-not $?) {
Chris@0 107 del $tmpfile
Chris@0 108 exit $LastExitCode
Chris@0 109 }
Chris@0 110
Chris@0 111 del $tmpfile
Chris@0 112
Chris@0 113 } else {
Chris@0 114
Chris@0 115 "Unknown SML implementation name: $sml"
Chris@0 116 exit 2
Chris@0 117 }