-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
371 lines (341 loc) · 14.8 KB
/
win.yml
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
name: Windows CI
on: [push, pull_request]
jobs:
x86_64-linux-job:
runs-on: ubuntu-latest
container: crystallang/crystal:1.5.0-build
steps:
- name: Download Crystal source
uses: actions/checkout@v2
- name: Build C extensions
run: |
make deps
- name: Cross-compile Crystal
run: |
LLVM_TARGETS=X86 bin/crystal build --cross-compile --target x86_64-pc-windows-msvc src/compiler/crystal.cr -Dwithout_playground -Dwithout_iconv -Dwithout_interpreter
- name: Upload Crystal object file
uses: actions/upload-artifact@v2
with:
name: objs
path: crystal.obj
x86_64-windows-job:
needs: x86_64-linux-job
runs-on: windows-latest
steps:
- name: Disable CRLF line ending substitution
run: |
git config --global core.autocrlf false
- name: Enable Developer Command Prompt
uses: ilammy/msvc-dev-cmd@ed94116c4d30d2091601b81f339a2eaa1c2ba0a6
- name: Download Crystal source
uses: actions/checkout@v2
- name: Cache libraries
id: cache-libs
uses: actions/cache@v2
with:
path: | # openssl and llvm take much longer to build so they are cached separately
libs/pcre.lib
libs/iconv.lib
libs/gc.lib
libs/ffi.lib
libs/z.lib
libs/mpir.lib
libs/yaml.lib
libs/xml2.lib
key: win-libs-${{ hashFiles('.github/workflows/win.yml') }}-msvc-${{ env.VSCMD_VER }}
- name: Download libgc
if: steps.cache-libs.outputs.cache-hit != 'true'
uses: actions/checkout@v2
with:
repository: ivmai/bdwgc
ref: v8.2.0
path: bdwgc
- name: Download libatomic_ops
if: steps.cache-libs.outputs.cache-hit != 'true'
uses: actions/checkout@v2
with:
repository: ivmai/libatomic_ops
ref: v7.6.10
path: bdwgc/libatomic_ops
- name: Build libgc
if: steps.cache-libs.outputs.cache-hit != 'true'
working-directory: ./bdwgc
run: |
cmake . -DBUILD_SHARED_LIBS=OFF -Denable_large_config=ON -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DCMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH=OFF
cmake --build . --config Release
- name: Download libpcre
if: steps.cache-libs.outputs.cache-hit != 'true'
run: |
iwr https://cs.stanford.edu/pub/exim/pcre/pcre-8.43.zip -OutFile pcre.zip
(Get-FileHash -Algorithm SHA256 .\pcre.zip).hash -eq "ae236dc25d7e0e738a94e103218e0085eb02ff9bd98f637b6e061a48decdb433"
7z x pcre.zip
mv pcre-* pcre
- name: Build libpcre
if: steps.cache-libs.outputs.cache-hit != 'true'
working-directory: ./pcre
run: |
cmake . -DBUILD_SHARED_LIBS=OFF -DPCRE_SUPPORT_UNICODE_PROPERTIES=ON -DPCRE_SUPPORT_JIT=ON -DPCRE_STATIC_RUNTIME=ON -DCMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH=OFF
cmake --build . --config Release
- name: Download libiconv
if: steps.cache-libs.outputs.cache-hit != 'true'
uses: actions/checkout@v2
with:
repository: pffang/libiconv-for-Windows
ref: 9b7aba8da6e125ef33912fa4412779279f204003 # master @ 2021-08-24
path: libiconv
- name: Build libiconv
if: steps.cache-libs.outputs.cache-hit != 'true'
working-directory: ./libiconv
run: |
echo '<Project>
<PropertyGroup>
<ForceImportAfterCppTargets>$(MsbuildThisFileDirectory)\Override.props</ForceImportAfterCppTargets>
</PropertyGroup>
</Project>' > 'Directory.Build.props'
echo '<Project>
<ItemDefinitionGroup>
<ClCompile>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<DebugInformationFormat>None</DebugInformationFormat>
<WholeProgramOptimization>false</WholeProgramOptimization>
</ClCompile>
</ItemDefinitionGroup>
</Project>' > 'Override.props'
MSBuild.exe /p:Platform=x64 /p:Configuration=ReleaseStatic libiconv.vcxproj
- name: Download libffi
if: steps.cache-libs.outputs.cache-hit != 'true'
uses: actions/checkout@v2
with:
repository: winlibs/libffi
ref: libffi-3.3
path: libffi
- name: Build libffi
if: steps.cache-libs.outputs.cache-hit != 'true'
working-directory: ./libffi
run: |
echo '<Project>
<PropertyGroup>
<ForceImportAfterCppTargets>$(MsbuildThisFileDirectory)\Override.props</ForceImportAfterCppTargets>
</PropertyGroup>
</Project>' > 'Directory.Build.props'
echo '<Project>
<ItemDefinitionGroup Label="Configuration">
<ClCompile>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<DebugInformationFormat>None</DebugInformationFormat>
<WholeProgramOptimization>false</WholeProgramOptimization>
</ClCompile>
<Link>
<GenerateDebugInformation>false</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
</Project>' > 'Override.props'
MSBuild.exe /p:PlatformToolset=v143 /p:Platform=x64 /p:Configuration=Release win32\vs16_x64\libffi-msvc.sln -target:libffi:Rebuild
- name: Download zlib
if: steps.cache-libs.outputs.cache-hit != 'true'
run: |
iwr https://github.com/madler/zlib/archive/v1.2.11.zip -OutFile zlib.zip
(Get-FileHash -Algorithm SHA256 .\zlib.zip).hash -eq "f5cc4ab910db99b2bdbba39ebbdc225ffc2aa04b4057bc2817f1b94b6978cfc3"
7z x zlib.zip
mv zlib-* zlib
- name: Build zlib
if: steps.cache-libs.outputs.cache-hit != 'true'
working-directory: ./zlib
run: |
cmake . -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DCMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH=OFF
cmake --build . --config Release
- name: Download mpir
if: steps.cache-libs.outputs.cache-hit != 'true'
uses: actions/checkout@v2
with:
repository: BrianGladman/mpir
ref: d9c9a842be6475bef74324f367ce2c5a78c55d06 # master @ 2021-10-14
path: mpir
- name: Build mpir
if: steps.cache-libs.outputs.cache-hit != 'true'
working-directory: ./mpir
run: |
$VsVersion = "vs$((& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -property displayName) -replace '.*\b\d\d(\d\d)\b.*', '$1')"
echo '<Project>
<PropertyGroup>
<ForceImportAfterCppTargets>$(MsbuildThisFileDirectory)\Override.props</ForceImportAfterCppTargets>
</PropertyGroup>
</Project>' > 'msvc\Directory.Build.props'
echo '<Project>
<ItemDefinitionGroup Label="Configuration">
<ClCompile>
<DebugInformationFormat>None</DebugInformationFormat>
<WholeProgramOptimization>false</WholeProgramOptimization>
</ClCompile>
</ItemDefinitionGroup>
</Project>' > 'msvc\Override.props'
MSBuild.exe /p:Platform=x64 /p:Configuration=Release /p:DefineConstants=MSC_BUILD_DLL ".\msvc\$VsVersion\lib_mpir_gc\lib_mpir_gc.vcxproj"
- name: Download libyaml
if: steps.cache-libs.outputs.cache-hit != 'true'
run: |
iwr https://github.com/yaml/libyaml/archive/0.2.4.zip -OutFile libyaml.zip
(Get-FileHash -Algorithm SHA256 .\libyaml.zip).hash -eq "5882285b8265096d045ecebbee651b73bef6cead34e439b63e86bf393c936793"
7z x libyaml.zip
mv libyaml-* libyaml
- name: Build libyaml
if: steps.cache-libs.outputs.cache-hit != 'true'
working-directory: ./libyaml
run: |
cmake . -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DCMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH=OFF
cmake --build . --config Release
- name: Download libxml2
if: steps.cache-libs.outputs.cache-hit != 'true'
uses: actions/checkout@v2
with:
repository: GNOME/libxml2
ref: a230b728f1289dd24c1666856ac4fb55579c6dfb # master @ 2020-05-04
path: libxml2
- name: Build libxml2
if: steps.cache-libs.outputs.cache-hit != 'true'
working-directory: ./libxml2
run: |
cmake . -DBUILD_SHARED_LIBS=OFF -DLIBXML2_WITH_PROGRAMS=OFF -DLIBXML2_WITH_HTTP=OFF -DLIBXML2_WITH_FTP=OFF -DLIBXML2_WITH_TESTS=OFF -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DCMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH=OFF
echo '<Project>
<PropertyGroup>
<ForceImportAfterCppTargets>$(MsbuildThisFileDirectory)\Override.props</ForceImportAfterCppTargets>
</PropertyGroup>
</Project>' > 'Directory.Build.props'
echo '<Project>
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>LIBXML_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
</Project>' > 'Override.props'
cmake --build . --config Release
- name: Gather libraries
if: steps.cache-libs.outputs.cache-hit != 'true'
run: |
mkdir libs
mv pcre/Release/pcre.lib libs/
mv libiconv/lib64/libiconvStatic.lib libs/iconv.lib
mv bdwgc/Release/gc.lib libs/
mv libffi/win32/vs16_x64/x64/Release/libffi.lib libs/ffi.lib
mv zlib/Release/zlibstatic.lib libs/z.lib
mv mpir/lib/x64/Release/mpir.lib libs/
mv libyaml/Release/yaml.lib libs/
mv libxml2/Release/libxml2s.lib libs/xml2.lib
- name: Cache OpenSSL
id: cache-openssl
uses: actions/cache@v2
with:
path: |
libs/crypto.lib
libs/ssl.lib
libs/openssl_VERSION
key: win-openssl-libs-3.0.0-msvc-${{ env.VSCMD_VER }}
- name: Set up NASM
if: steps.cache-openssl.outputs.cache-hit != 'true'
uses: ilammy/setup-nasm@e2335e5fc95548c09cd2deea2768793e0e8f0941 # v1.2.1
- name: Download OpenSSL
if: steps.cache-openssl.outputs.cache-hit != 'true'
run: |
iwr https://www.openssl.org/source/openssl-3.0.0.tar.gz -OutFile openssl.tar.gz
(Get-FileHash -Algorithm SHA256 .\openssl.tar.gz).hash -eq "59eedfcb46c25214c9bd37ed6078297b4df01d012267fe9e9eee31f61bc70536"
7z x openssl.tar.gz
7z x openssl.tar
mv openssl-* openssl
- name: Build OpenSSL
if: steps.cache-openssl.outputs.cache-hit != 'true'
working-directory: ./openssl
run: |
sed -i 's|/Zi /Fd.*\.pdb||' Configurations/10-main.conf
sed -i 's|/debug|/debug:none|' Configurations/10-main.conf
perl Configure VC-WIN64A /MT -static no-tests --with-zlib-lib=..\zlib\Release --with-zlib-include=..\zlib
nmake
- name: Gather OpenSSL
if: steps.cache-openssl.outputs.cache-hit != 'true'
run: |
cp openssl/libcrypto.lib libs/crypto.lib
cp openssl/libssl.lib libs/ssl.lib
[IO.File]::WriteAllLines("libs/openssl_VERSION", "3.0.0")
- name: Cache LLVM
id: cache-llvm
uses: actions/cache@v2
with:
path: llvm
key: llvm-libs-13.0.0-msvc-${{ env.VSCMD_VER }}
- name: Download LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true'
run: |
iwr https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/llvm-13.0.0.src.tar.xz -OutFile llvm.tar.xz
(Get-FileHash -Algorithm SHA256 .\llvm.tar.xz).hash -eq "408d11708643ea826f519ff79761fcdfc12d641a2510229eec459e72f8163020"
7z x llvm.tar.xz
7z x llvm.tar
mv llvm-* llvm-src
- name: Patch LLVM for VS 2019 16.7.0
working-directory: ./llvm-src
if: steps.cache-llvm.outputs.cache-hit != 'true'
run: |
sed -i 's/#ifdef HAVE_STD_IS_TRIVIALLY_COPYABLE/#if 0/' include/llvm/Support/type_traits.h
- name: Build LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true'
working-directory: ./llvm-src
run: |
cmake . -Thost=x64 -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_USE_CRT_RELEASE=MT -DBUILD_SHARED_LIBS=OFF -DCMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH=OFF
cmake --build . --config Release
- name: Gather LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true'
run: |
mv llvm-src/Release llvm
mv llvm-src/include llvm/
- name: Set up environment
run: |
echo "CRYSTAL_LIBRARY_PATH=$(pwd)\libs" >> ${env:GITHUB_ENV}
echo "CRYSTAL_SPEC_COMPILER_BIN=$(pwd)\.build\crystal.exe" >> ${env:GITHUB_ENV}
echo "LLVM_CONFIG=$(pwd)\llvm\bin\llvm-config.exe" >> ${env:GITHUB_ENV}
- name: Download Crystal object file
uses: actions/download-artifact@v2
with:
name: objs
- name: Build LLVM extensions
run: make -f Makefile.win deps
- name: Link Crystal executable
run: |
Invoke-Expression "cl crystal.obj /Fecrystal src\llvm\ext\llvm_ext.obj $(llvm\bin\llvm-config.exe --libs) libs\pcre.lib libs\gc.lib WS2_32.lib advapi32.lib libcmt.lib dbghelp.lib ole32.lib shell32.lib legacy_stdio_definitions.lib /link /LIBPATH:$(pwd)\libs /STACK:0x800000 /ENTRY:wmainCRTStartup"
mkdir .build
mv crystal.exe .build/
- name: Re-build Crystal
run: |
bin/crystal.bat env
make -f Makefile.win -B
- name: Download shards release
uses: actions/checkout@v2
with:
repository: crystal-lang/shards
ref: v0.17.0
path: shards
- name: Download molinillo release
uses: actions/checkout@v2
with:
repository: crystal-lang/crystal-molinillo
ref: v0.2.0
path: shards/lib/molinillo
- name: Build shards release
working-directory: ./shards
run: ../bin/crystal.bat build src/shards.cr
- name: Gather Crystal binaries
run: |
mkdir crystal/src
mkdir crystal/lib
cp .build/crystal.exe crystal/
cp shards/shards.exe crystal/
cp libs/* crystal/lib/
cp src/* crystal/src -Recurse
rm crystal/src/llvm/ext/llvm_ext.obj
- name: Upload Crystal binaries
uses: actions/upload-artifact@v2
with:
name: crystal
path: crystal
- name: Run stdlib specs
run: make -f Makefile.win std_spec
- name: Run compiler specs
run: make -f Makefile.win compiler_spec
- name: Run primitives specs
run: make -f Makefile.win primitives_spec