-
Notifications
You must be signed in to change notification settings - Fork 0
/
BuildAndPackage.ps1
140 lines (123 loc) · 4.77 KB
/
BuildAndPackage.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# Copyright 2020-2021 Sizhe Zhao
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
[CmdletBinding()]
param (
[string]$CoreVersion = '2021.09',
[string]$ZefVersion = '0.12.0',
[switch]$KeepBuild = $False,
[switch]$KeepSource = $False,
[string]$Postfix = ''
)
where.exe /Q cl.exe
if (-not $?) {
Write-Error "Can't locate cl."
exit 1
}
where.exe /Q perl.exe
if (-not $?) {
Write-Error "Can't locate perl."
exit 1
}
if (!(Test-Path -Path "MoarVM-$CoreVersion" -PathType Container)) {
if (!(Test-Path -Path "MoarVM-$CoreVersion.tar.gz" -PathType Leaf)) {
Invoke-WebRequest -Uri "https://github.com/MoarVM/MoarVM/releases/download/$CoreVersion/MoarVM-$CoreVersion.tar.gz" -OutFile "MoarVM-$CoreVersion.tar.gz"
}
where.exe /Q tar.exe
if (-not $?) {
Write-Error "Can't locate tar. You can get one from libarchive."
exit 1
}
tar.exe xf "MoarVM-$CoreVersion.tar.gz"
}
if (!(Test-Path -Path "nqp-$CoreVersion" -PathType Container)) {
if (!(Test-Path -Path "nqp-$CoreVersion.tar.gz" -PathType Leaf)) {
Invoke-WebRequest -Uri "https://github.com/Raku/nqp/releases/download/$CoreVersion/nqp-$CoreVersion.tar.gz" -OutFile "nqp-$CoreVersion.tar.gz"
}
where.exe /Q tar.exe
if (-not $?) {
Write-Error "Can't locate tar. You can get one from libarchive."
exit 1
}
tar.exe xf "nqp-$CoreVersion.tar.gz"
}
if (!(Test-Path -Path "rakudo-$CoreVersion" -PathType Container)) {
if (!(Test-Path -Path "rakudo-$CoreVersion.tar.gz" -PathType Leaf)) {
Invoke-WebRequest -Uri "https://github.com/rakudo/rakudo/releases/download/$CoreVersion/rakudo-$CoreVersion.tar.gz" -OutFile "rakudo-$CoreVersion.tar.gz"
}
where.exe /Q tar.exe
if (-not $?) {
Write-Error "Can't locate tar. You can get one from libarchive."
exit 1
}
tar.exe xf "rakudo-$CoreVersion.tar.gz"
}
if (!(Test-Path -Path "zef-$ZefVersion" -PathType Container)) {
if (!(Test-Path -Path "zef-$ZefVersion.tar.gz" -PathType Leaf)) {
Invoke-WebRequest -Uri "https://github.com/ugexe/zef/archive/v$ZefVersion.tar.gz" -OutFile "zef-$ZefVersion.tar.gz"
}
where.exe /Q tar.exe
if (-not $?) {
Write-Error "Can't locate tar. You can get one from libarchive."
exit 1
}
tar.exe xf "zef-$ZefVersion.tar.gz"
}
# Need to patch MoarVM
if ("x$CoreVersion" -eq "x2020.02.1" -or "x$CoreVersion" -eq "x2020.05") {
where.exe /Q sed.exe
if (-not $?) {
Write-Error "Can't locate sed. You can get one from MSYS2."
exit 1
}
# See https://github.com/MoarVM/MoarVM/issues/1279
sed.exe -i -e "s@if defined@if defined(_M_IX86) || defined@" "MoarVM-$CoreVersion/3rdparty/libtommath/bn_mp_set_double.c"
}
$BuildRoot = Get-Location
# Make nqp and rakudo recognize nmake in non-English environment.
chcp.com 437
Set-Location "MoarVM-$CoreVersion"
perl.exe ./Configure.pl --os win32 --shell win32 --toolchain msvc --compiler cl --prefix "$BuildRoot/prefix" --relocatable
nmake.exe install
Set-Location ..
Set-Location "nqp-$CoreVersion"
perl.exe ./Configure.pl "--prefix=$BuildRoot/prefix" --relocatable --backends=moar "--with-moar=$BuildRoot/prefix/bin/moar.exe" --make-install
Set-Location ..
Set-Location "rakudo-$CoreVersion"
perl.exe ./Configure.pl "--prefix=$BuildRoot/prefix" --relocatable --backends=moar "--with-nqp=$BuildRoot/prefix/bin/nqp.exe" --make-install
Set-Location ..
Set-Location "zef-$ZefVersion"
& "$BuildRoot/prefix/bin/raku.exe" -I . bin/zef install .
Set-Location ..
Compress-Archive prefix\* -DestinationPath "rakudo-$CoreVersion$Postfix.zip"
Remove-Item -Recurse prefix
if (!$KeepBuild) {
Remove-Item -Recurse "MoarVM-$CoreVersion"
Remove-Item -Recurse "nqp-$CoreVersion"
Remove-Item -Recurse "rakudo-$CoreVersion"
Remove-Item -Recurse "zef-$ZefVersion"
}
if (!$KeepSource) {
if (Test-Path -Path "MoarVM-$CoreVersion.tar.gz" -PathType Leaf) {
Remove-Item "MoarVM-$CoreVersion.tar.gz"
}
if (Test-Path -Path "nqp-$CoreVersion.tar.gz" -PathType Leaf) {
Remove-Item "nqp-$CoreVersion.tar.gz"
}
if (Test-Path -Path "rakudo-$CoreVersion.tar.gz" -PathType Leaf) {
Remove-Item "rakudo-$CoreVersion.tar.gz"
}
if (Test-Path -Path "zef-$ZefVersion.tar.gz" -PathType Leaf) {
Remove-Item "zef-$ZefVersion.tar.gz"
}
}