-
Notifications
You must be signed in to change notification settings - Fork 4
141 lines (137 loc) · 5.33 KB
/
windows.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
#
#
#
# *** If you edit this file, make sure that CONTRIBUTING.md stays up to date.
#
#
#
on:
push:
branches:
- main
pull_request:
jobs:
build:
# Even though jou.exe runs on windows, it is compiled on linux.
# This is by far the easiest way to compile for Windows that I know of.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download LLVM installer
run: wget --no-verbose https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.1/LLVM-13.0.1-win64.exe
- name: Verify LLVM installer
run: |
ls -lh LLVM-13.0.1-win64.exe
if [ "$(sha256sum LLVM-13.0.1-win64.exe)" == "9d15be034d52ec57cfc97615634099604d88a54761649498daa7405983a7e12f LLVM-13.0.1-win64.exe" ]; then
echo ok
else
echo "sha sum mismatch! something has changed!"
exit 1
fi
# Apparently the exe file is created with nsis installer and 7z can extract from it.
# Figured out by looking at source code of https://github.com/KyleMayes/install-llvm-action
# TODO: could we instead statically link the Jou compiler?
- name: Extract files from LLVM installer
run: |
files="lib/LLVM-C.lib"
for file in $(7z l LLVM-13.0.1-win64.exe | grep -o 'bin/.*\.dll'); do
case $file in
# To figure out which dll files I need, I deleted them one by one and ran
# the compiler again.
#
# Unfortunately you need to do this locally instead of relying on github
# actions, because github actions comes with lots of software and hence lots
# of DLL files preinstalled. I used a Windows VM with nothing installed.
bin/LLVM-C.dll | \
bin/msvcp140.dll | \
bin/ucrtbase.dll | \
bin/vcruntime140.dll | \
bin/vcruntime140_1.dll | \
bin/api-ms-win-*.dll) # Not sure which of these we need and what each one does.
files="$files $file"
;;
*)
echo "*** skip dll: $file ***"
;;
esac
done
echo "Extracting $files"
7z x LLVM-13.0.1-win64.exe $files
- name: Download MinGW
run: wget --no-verbose https://github.com/niXman/mingw-builds-binaries/releases/download/12.2.0-rt_v10-rev1/x86_64-12.2.0-release-win32-seh-rt_v10-rev1.7z
- name: Verify MinGW
run: |
ls -lh x86_64-12.2.0-release-win32-seh-rt_v10-rev1.7z
if [ "$(sha256sum x86_64-12.2.0-release-win32-seh-rt_v10-rev1.7z)" == "774916c4403c5219f8af3a3ee3012de6c017c034895c2c92bc4de99895c2c924 x86_64-12.2.0-release-win32-seh-rt_v10-rev1.7z" ]; then
echo ok
else
echo "sha sum mismatch! something has changed!"
exit 1
fi
# Exctract only the parts needed for linking.
# Figured out by exctracting only gcc.exe and then other files
# until hello world links successfully.
#
# We could get rid of gcc.exe and take only ld.exe, but
# gcc.exe is convenient because ld wants a long and complicated
# list of parameters that gcc can figure out for us.
- name: Extract the linker from MinGW
run: >
7z x x86_64-12.2.0-release-win32-seh-rt_v10-rev1.7z
mingw64/bin/gcc.exe
mingw64/lib/gcc/x86_64-w64-mingw32/12.2.0/libgcc.a
mingw64/lib/gcc/x86_64-w64-mingw32/12.2.0/libgcc_eh.a
mingw64/libexec/gcc/x86_64-w64-mingw32/12.2.0/liblto_plugin.dll
mingw64/x86_64-w64-mingw32/bin/ld.exe
mingw64/x86_64-w64-mingw32/lib/
# llvm-13-dev needed for the header files. They seem to be missing from LLVM windows installer.
# Using gcc instead of clang, because gcc "just works".
- run: sudo apt install -y llvm-13-dev gcc-mingw-w64-x86-64-win32
- run: CC=x86_64-w64-mingw32-gcc LDFLAGS=lib/LLVM-C.lib make
- run: mkdir jou
# Please keep this list of files in sync with update.ps1
- run: cp -rv jou.exe bin/*.dll stdlib mingw64 update.ps1 jou
- run: zip -r jou.zip jou
- uses: actions/upload-artifact@v3
with:
name: windows-zip
path: jou.zip
codeblocks-project:
# Ensure that the codeblocks project contains all source files.
# It gets outdated easily when I create a new file on linux.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: |
diff -u --color=always <(ls src/* | sort) <(grep filename= jou.cbp | cut -d'"' -f2)
test:
needs: build
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
path: repo
- uses: actions/download-artifact@v3
with:
name: windows-zip
- run: unzip jou.zip
- run: mv jou/* repo/tests repo/runtests.sh repo/examples .
shell: bash
- run: .\jou.exe --verbose examples/hello.jou
- run: ./runtests.sh
shell: bash
fuzzer:
needs: build
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
path: repo
- uses: actions/download-artifact@v3
with:
name: windows-zip
- run: unzip jou.zip
- run: mv jou/* repo/tests repo/fuzzer.sh .
shell: bash
- run: ./fuzzer.sh
shell: bash