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
|
import os
import itertools
from devtools.yamaker.modules import GLOBAL, Linkable, Switch
from devtools.yamaker import pathutil
from devtools.yamaker.project import NixProject
WINDOWS_SRCS = [
"alloca.h",
"close.c",
"dup2.c",
"error.c",
"fcntl.c",
"fd-hook.c",
"fd-hook.h",
"float+.h",
"fpending.c",
"getdtablesize.c",
"getopt.c",
"getopt1.c",
"getopt_int.h",
"isnand-nolibm.h",
"isnanf-nolibm.h",
"isnanl-nolibm.h",
"msvc-inval.c",
"msvc-inval.h",
"msvc-nothrow.c",
"msvc-nothrow.h",
"obstack.c",
"obstack_printf.c",
"open.c",
"raise.c",
"sigaction.c",
"sigprocmask.c",
"stpcpy.c",
"stpncpy.c",
"strndup.c",
"strverscmp.c",
"unitypes.h",
"uniwisth.h",
"w32spawn.h",
"waitpid.c",
"wcwidth.c",
"windows-initguard.h",
"windows-mutex.c",
"windows-mutex.h",
"windows-once.c",
"windows-once.h",
"windows-recmutex.c",
"windows-recmutex.h",
"windows-rwlock.c",
"windows-rwlock.h",
"windows-tls.c",
"windows-tls.h",
]
MUSL_SRCS = [
"error.c",
"obstack.c",
"obstack_printf.c",
]
DARWIN_SRCS = [
"error.c",
"fpending.c",
"obstack.c",
"obstack_printf.c",
"strverscmp.c",
]
EXCESSIVE_SRCS = [
"alloca.h",
"fcntl.h",
"fprintf.c",
"gettime.c",
"iconv.h",
"inttypes.h",
"math.h",
"limits.h",
"locale.h",
"printf.c",
"sched.h",
"signal.h",
"snprintf.c",
"spawn.h",
"sprintf.c",
"stdio.h",
"stdlib.h",
"string.h",
"sys/ioctl.h",
"sys/resource.h",
"sys/time.h",
"sys/times.h",
"sys/types.h",
"sys/wait.h",
"termios.h",
"time.h",
"unistd.h",
"vfprintf.c",
"vsnprintf.c",
"vsprintf.c",
"wchar.h",
"wctype.h",
]
def post_install(self):
with self.yamakes["lib"] as gnulib:
# musl-libc has fseterr
gnulib.SRCS.remove("fseterr.c")
gnulib.after(
"SRCS",
"""
IF (NOT MUSL)
SRCS(
fseterr.c
)
ENDIF()
""",
)
gnulib.after(
"SRCS",
Switch(
MUSL=Linkable(
SRCS=MUSL_SRCS,
),
OS_DARWIN=Linkable(
SRCS=DARWIN_SRCS,
),
OS_WINDOWS=Linkable(
SRCS=[src for src in WINDOWS_SRCS if pathutil.is_source(src)],
ADDINCL=[GLOBAL(f"{self.arcdir}/lib/platform/win64")],
),
),
)
for src in WINDOWS_SRCS:
if pathutil.is_source(src) and src in gnulib.SRCS:
gnulib.SRCS.remove(src)
for src in EXCESSIVE_SRCS:
os.remove(f"{self.dstdir}/lib/{src}")
if pathutil.is_source(src):
gnulib.SRCS.remove(src)
bison = NixProject(
arcdir="contrib/tools/bison",
owners=["g:cpp-contrib"],
nixattr="bison",
ignore_commands=[
"bash",
"cat",
"sed",
],
use_full_libnames=True,
install_targets=[
"bison",
"libbison",
],
put={
"bison": ".",
"libbison": "lib",
},
keep_paths=[
"lib/platform/win64/*.h",
"lib/platform/win64/sys/*.h",
# Keep this for now as upstream code crashes on Windows
"src/scan-skel.c",
],
copy_sources=[
"data/skeletons/*.c",
"data/skeletons/*.cc",
"data/skeletons/*.hh",
"data/skeletons/*.m4",
"data/m4sugar/*.m4",
# These lex / bison sources will not be used
# (how does one bootstrap bison without having bison?)
#
# Just copy them for informational purposes
"src/scan-code.l",
"src/scan-gram.l",
"src/scan-skel.l",
"src/parse-gram.y",
]
+ [f"lib/{src}" for src in itertools.chain(MUSL_SRCS, DARWIN_SRCS, WINDOWS_SRCS)],
copy_sources_except=[
# Don't need them for now, reduce import footprint
"data/skeletons/d.m4",
"data/skeletons/d-skel.m4",
"data/skeletons/glr.c",
"data/skeletons/java.m4",
"data/skeletons/java-skel.m4",
"data/skeletons/traceon.m4",
],
platform_dispatchers=[
"lib/config.h",
"lib/configmake.h",
],
disable_includes=[
"InnoTekLIBC/backend.h",
"bits/libc-lock.h",
"synch.h",
"random.h",
"OS.h",
"os2.h",
"sys/ps.h",
"sys/ptem.h",
"sys/single_threaded.h",
"mbtowc-lock.h",
"mbrtowc-impl.h",
"lc-charset-dispatch.h",
"unistring-notinline.h",
],
post_install=post_install,
)
bison.copy_top_sources_except |= {
"ABOUT-NLS",
"ChangeLog",
"ChangeLog-2012",
"ChangeLog-1998",
"INSTALL",
}
|