Skip to content

Commit e464488

Browse files
committed
Add new linux build script
1 parent 775e70b commit e464488

File tree

4 files changed

+141
-40
lines changed

4 files changed

+141
-40
lines changed

.github/workflows/build_linux_v2.yml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Build Wheels (Linux)
2+
3+
on:
4+
workflow_dispatch:
5+
inputs: {}
6+
7+
jobs:
8+
linux:
9+
strategy:
10+
matrix:
11+
arch:
12+
- x86_64
13+
- i686
14+
- aarch64
15+
- ppc64le
16+
- armv7l
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
submodules: true
22+
23+
- name: Set up QEMU
24+
uses: docker/setup-qemu-action@v3
25+
with:
26+
platforms: all
27+
28+
- name: Cache pip
29+
uses: actions/cache@v4
30+
with:
31+
key: cache--${{ hashFiles('./requirements-dev.txt') }}
32+
path: ~/.cache/pip
33+
34+
- name: Setup python
35+
uses: actions/setup-python@v5
36+
with:
37+
python-version: '3.13'
38+
39+
- run: python -m pip install -U pip wheel setuptools
40+
- run: python -m pip install -Ur requirements-dev.txt
41+
- run: python -m pip install -U 'cibuildwheel==2.*'
42+
43+
- run: make prepare
44+
45+
- run: python -m cibuildwheel --output-dir wheelhouse
46+
env:
47+
CIBW_ARCHS_LINUX: ${{ matrix.arch }}
48+
CIBW_BUILD_FRONTEND: build
49+
CIBW_SKIP: 'cp27-* pp*'
50+
CIBW_DEPENDENCY_VERSIONS: pinned
51+
CIBW_PLATFORM: linux
52+
CIBW_TEST_COMMAND: python {project}/scripts/run-tests.py
53+
54+
- uses: actions/upload-artifact@v4
55+
with:
56+
name: linux-${{ matrix.arch }}
57+
path: ./wheelhouse

scripts/make_unicode_categories.py

+38-10
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,13 @@ def main(input_file, output_file):
7777
demiplane_to_idx = OrderedDict() # demiplane_idx → data_idx
7878
data_to_idx = [None] * 18 * 0x100 # demiplane data → data_idx
7979
print(" // A 'demiplane' is a 1/256th of a Unicode plane.", file=output_file)
80-
print(" // This way a 'demiplane' fits nicely into a cache line.", file=output_file)
81-
print(" alignas(64) static const std::uint8_t demiplane_data[][0x100 / 4] = {", file=output_file)
80+
print(
81+
" // This way a 'demiplane' fits nicely into a cache line.", file=output_file
82+
)
83+
print(
84+
" alignas(64) static const std::uint8_t demiplane_data[][0x100 / 4] = {",
85+
file=output_file,
86+
)
8287
for i in range(18 * 0x100):
8388
plane_data = ""
8489
plane = planes[i]
@@ -95,7 +100,10 @@ def main(input_file, output_file):
95100
produced_idx = demiplane_to_idx.get(plane_data)
96101
if produced_idx is None:
97102
produced_idx = len(demiplane_to_idx)
98-
print(" {{ // {} -> 0x{:02x}u".format(i, produced_idx), file=output_file)
103+
print(
104+
" {{ // {} -> 0x{:02x}u".format(i, produced_idx),
105+
file=output_file,
106+
)
99107
print(plane_data, file=output_file, end="")
100108
print(" },", file=output_file)
101109
demiplane_to_idx[plane_data] = produced_idx
@@ -106,7 +114,10 @@ def main(input_file, output_file):
106114

107115
snd_lookup_lines = OrderedDict()
108116
snd_lookup_indices = OrderedDict()
109-
print(" alignas(64) static const std::uint8_t demiplane_snd_data[][64] = {", file=output_file)
117+
print(
118+
" alignas(64) static const std::uint8_t demiplane_snd_data[][64] = {",
119+
file=output_file,
120+
)
110121
for start in range(0, 18 * 0x100, 64):
111122
snd_lookup_line: str
112123
for i in range(start, min(start + 64, 18 * 0x100)):
@@ -116,19 +127,28 @@ def main(input_file, output_file):
116127
else:
117128
snd_lookup_line += "\n "
118129
snd_lookup_line += " 0x{:02x}u,".format(data_to_idx[i])
119-
130+
120131
snd_lookup_idx = snd_lookup_lines.get(snd_lookup_line, None)
121132
if snd_lookup_idx is None:
122133
snd_lookup_idx = len(snd_lookup_lines)
123-
print(" {{ // {} -> 0x{:02x}u".format(start // 64, snd_lookup_idx), file=output_file)
134+
print(
135+
" {{ // {} -> 0x{:02x}u".format(start // 64, snd_lookup_idx),
136+
file=output_file,
137+
)
124138
print(snd_lookup_line, file=output_file)
125139
print(" },", file=output_file)
126140
snd_lookup_lines[snd_lookup_line] = snd_lookup_idx
127141
snd_lookup_indices[start // 64] = snd_lookup_idx
128142
print(" };", file=output_file)
129143
print(file=output_file)
130144

131-
print(" alignas(64) static const std::uint8_t demiplane_snd[18 * 0x100 / 64] = {{".format(68), end="", file=output_file)
145+
print(
146+
" alignas(64) static const std::uint8_t demiplane_snd[18 * 0x100 / 64] = {{".format(
147+
68
148+
),
149+
end="",
150+
file=output_file,
151+
)
132152
for i in range(18 * 0x100 // 64):
133153
if i % 16 == 0:
134154
print("\n ", end="", file=output_file)
@@ -138,7 +158,10 @@ def main(input_file, output_file):
138158
print(file=output_file)
139159

140160
print(" if (JSON5EncoderCpp_expect(codepoint < 256, true)) {", file=output_file)
141-
print(" return (demiplane_data[0][codepoint / 4] >> (2 * (codepoint % 4))) % 4;", file=output_file)
161+
print(
162+
" return (demiplane_data[0][codepoint / 4] >> (2 * (codepoint % 4))) % 4;",
163+
file=output_file,
164+
)
142165
print(" }", file=output_file)
143166
print(file=output_file)
144167
print(" if (codepoint > 0x110000) codepoint = 0x110000;", file=output_file)
@@ -147,8 +170,13 @@ def main(input_file, output_file):
147170
print(" std::uint32_t snd_row = fst_row / 64;", file=output_file)
148171
print(" std::uint32_t snd_col = fst_row % 64;", file=output_file)
149172
print(file=output_file)
150-
print(" const std::uint8_t *cell = demiplane_data[demiplane_snd_data[demiplane_snd[snd_row]][snd_col]];", file=output_file)
151-
print(" return (cell[fst_col / 4] >> (2 * (fst_col % 4))) % 4;", file=output_file)
173+
print(
174+
" const std::uint8_t *cell = demiplane_data[demiplane_snd_data[demiplane_snd[snd_row]][snd_col]];",
175+
file=output_file,
176+
)
177+
print(
178+
" return (cell[fst_col / 4] >> (2 * (fst_col % 4))) % 4;", file=output_file
179+
)
152180
print("}", file=output_file)
153181
print(file=output_file)
154182
print("}", file=output_file)

scripts/run-minefield-test.py

+25-17
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22

33
from argparse import ArgumentParser
44
from logging import basicConfig, INFO, getLogger
5-
from os import name
5+
from os import chdir, name
66
from pathlib import Path
77
from subprocess import Popen
88
from sys import executable
99

10-
from colorama import init, Fore
11-
from pyjson5 import decode_io
12-
1310

1411
argparser = ArgumentParser(description="Run JSON5 parser tests")
1512
argparser.add_argument(
@@ -28,21 +25,32 @@
2825
if __name__ == "__main__":
2926
basicConfig(level=INFO)
3027
logger = getLogger(__name__)
31-
32-
init()
28+
chdir(Path(__file__).absolute().parent.parent)
3329

3430
good = bad = errors = severe = 0
3531

36-
if name != "nt":
37-
code_severe = Fore.RED + "😱"
38-
code_good = Fore.CYAN + "😄"
39-
code_bad = Fore.YELLOW + "😠"
40-
code_ignored = Fore.BLUE + "🙅"
32+
try:
33+
from colorama import init, Fore
34+
35+
init()
36+
except Exception:
37+
code_severe = "SEVERE"
38+
code_good = "GOOD"
39+
code_bad = "BAD"
40+
code_ignored = "IGNORED"
41+
reset = ""
4142
else:
42-
code_severe = Fore.RED + "SEVERE"
43-
code_good = Fore.CYAN + "GOOD"
44-
code_bad = Fore.YELLOW + "BAD"
45-
code_ignored = Fore.BLUE + "IGNORED"
43+
if name != "nt":
44+
code_severe = Fore.RED + "😱"
45+
code_good = Fore.CYAN + "😄"
46+
code_bad = Fore.YELLOW + "😠"
47+
code_ignored = Fore.BLUE + "🙅"
48+
else:
49+
code_severe = Fore.RED + "SEVERE"
50+
code_good = Fore.CYAN + "GOOD"
51+
code_bad = Fore.YELLOW + "BAD"
52+
code_ignored = Fore.BLUE + "IGNORED"
53+
reset = Fore.RESET
4654

4755
script = str(Path(__file__).absolute().parent / "transcode-to-json.py")
4856

@@ -98,7 +106,7 @@
98106
"> | " "Actual <",
99107
"pass" if outcome == 0 else "FAIL",
100108
">",
101-
Fore.RESET,
109+
reset,
102110
sep="",
103111
)
104112

@@ -115,7 +123,7 @@
115123
" wrong outcomes | ",
116124
severe,
117125
" severe errors",
118-
Fore.RESET,
126+
reset,
119127
sep="",
120128
)
121129
raise SystemExit(2 if is_severe else 0 if is_good else 1)

scripts/run-tests.py

+21-13
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22

33
from argparse import ArgumentParser
44
from logging import basicConfig, INFO, getLogger
5-
from os import name
5+
from os import chdir, name
66
from pathlib import Path
77
from subprocess import Popen
88
from sys import executable
99

10-
from colorama import init, Fore
11-
1210

1311
argparser = ArgumentParser(description="Run JSON5 parser tests")
1412
argparser.add_argument(
@@ -24,17 +22,27 @@
2422
if __name__ == "__main__":
2523
basicConfig(level=INFO)
2624
logger = getLogger(__name__)
25+
chdir(Path(__file__).absolute().parent.parent)
2726

28-
init()
27+
try:
28+
from colorama import init, Fore
2929

30-
if name != "nt":
31-
code_severe = Fore.RED + "😱"
32-
code_good = Fore.CYAN + "😄"
33-
code_bad = Fore.YELLOW + "😠"
30+
init()
31+
except Exception:
32+
code_severe = "SEVERE"
33+
code_good = "GOOD"
34+
code_bad = "BAD"
35+
reset = ""
3436
else:
35-
code_severe = Fore.RED + "SEVERE"
36-
code_good = Fore.CYAN + "GOOD"
37-
code_bad = Fore.YELLOW + "BAD"
37+
if name != "nt":
38+
code_severe = Fore.RED + "😱"
39+
code_good = Fore.CYAN + "😄"
40+
code_bad = Fore.YELLOW + "😠"
41+
else:
42+
code_severe = Fore.RED + "SEVERE"
43+
code_good = Fore.CYAN + "GOOD"
44+
code_bad = Fore.YELLOW + "BAD"
45+
reset = Fore.RESET
3846

3947
good = 0
4048
bad = 0
@@ -82,7 +90,7 @@
8290
"> | " "Actual <",
8391
"pass" if is_success else "FAIL",
8492
">",
85-
Fore.RESET,
93+
reset,
8694
sep="",
8795
)
8896
if is_severe:
@@ -105,7 +113,7 @@
105113
" × wrong outcome | ",
106114
severe,
107115
" × severe errors",
108-
Fore.RESET,
116+
reset,
109117
sep="",
110118
)
111119
raise SystemExit(2 if is_severe else 0 if is_good else 1)

0 commit comments

Comments
 (0)