Skip to content

Commit ce21dda

Browse files
authored
stdlib: add wasi.modulemap.gyb for WebAssembly support
WASI libc is substantially different from Glibc, thus we need a separate modulemap for it. Related to SR-9307
1 parent db90ea2 commit ce21dda

File tree

1 file changed

+231
-0
lines changed

1 file changed

+231
-0
lines changed
Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
//===--- wasi.modulemap.gyb ----------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2020 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
/// This is a semi-complete modulemap that maps WASI headers in a roughly
14+
/// similar way to the Darwin SDK modulemap. We do not take care to list every
15+
/// single header which may be included by a particular submodule, so there can
16+
/// still be issues if imported into the same context as one in which someone
17+
/// included those headers directly.
18+
///
19+
/// It's not named just WASI so that it doesn't conflict in the event of a
20+
/// future official WASI modulemap.
21+
module SwiftWASILibc [system] {
22+
// C standard library
23+
module C {
24+
module ctype {
25+
header "${LIBC_INCLUDE_PATH}/ctype.h"
26+
export *
27+
}
28+
module errno {
29+
header "${LIBC_INCLUDE_PATH}/errno.h"
30+
export *
31+
}
32+
33+
module fenv {
34+
header "${LIBC_INCLUDE_PATH}/fenv.h"
35+
export *
36+
}
37+
38+
// note: supplied by compiler
39+
// module float {
40+
// header "${LIBC_INCLUDE_PATH}/float.h"
41+
// export *
42+
// }
43+
44+
module inttypes {
45+
header "${LIBC_INCLUDE_PATH}/inttypes.h"
46+
export *
47+
}
48+
49+
// note: potentially supplied by compiler
50+
// module iso646 {
51+
// header "${LIBC_INCLUDE_PATH}/iso646.h"
52+
// export *
53+
// }
54+
// module limits {
55+
// header "${LIBC_INCLUDE_PATH}/limits.h"
56+
// export *
57+
// }
58+
59+
module locale {
60+
header "${LIBC_INCLUDE_PATH}/locale.h"
61+
export *
62+
}
63+
module math {
64+
header "${LIBC_INCLUDE_PATH}/math.h"
65+
export *
66+
}
67+
module signal {
68+
header "${LIBC_INCLUDE_PATH}/signal.h"
69+
export *
70+
}
71+
72+
// note: supplied by the compiler
73+
// module stdarg {
74+
// header "${LIBC_INCLUDE_PATH}/stdarg.h"
75+
// export *
76+
// }
77+
// module stdbool {
78+
// header "${LIBC_INCLUDE_PATH}/stdbool.h"
79+
// export *
80+
// }
81+
// module stddef {
82+
// header "${LIBC_INCLUDE_PATH}/stddef.h"
83+
// export *
84+
// }
85+
// module stdint {
86+
// header "${LIBC_INCLUDE_PATH}/stdint.h"
87+
// export *
88+
// }
89+
90+
module stdio {
91+
header "${LIBC_INCLUDE_PATH}/stdio.h"
92+
export *
93+
}
94+
module stdlib {
95+
header "${LIBC_INCLUDE_PATH}/stdlib.h"
96+
export *
97+
export stddef
98+
}
99+
module string {
100+
header "${LIBC_INCLUDE_PATH}/string.h"
101+
export *
102+
}
103+
104+
// note: supplied by the compiler
105+
// explicit module tgmath {
106+
// header "${LIBC_INCLUDE_PATH}/tgmath.h"
107+
// export *
108+
// }
109+
110+
module time {
111+
header "${LIBC_INCLUDE_PATH}/time.h"
112+
export *
113+
}
114+
}
115+
116+
// POSIX
117+
module POSIX {
118+
module arpa {
119+
module inet {
120+
header "${LIBC_INCLUDE_PATH}/arpa/inet.h"
121+
export *
122+
}
123+
export *
124+
}
125+
module dirent {
126+
header "${LIBC_INCLUDE_PATH}/dirent.h"
127+
export *
128+
}
129+
module fcntl {
130+
header "${LIBC_INCLUDE_PATH}/fcntl.h"
131+
export *
132+
}
133+
module fnmatch {
134+
header "${LIBC_INCLUDE_PATH}/fnmatch.h"
135+
export *
136+
}
137+
module ioctl {
138+
header "${LIBC_ARCH_INCLUDE_PATH}/sys/ioctl.h"
139+
export *
140+
}
141+
module libgen {
142+
header "${LIBC_INCLUDE_PATH}/libgen.h"
143+
export *
144+
}
145+
module netinet {
146+
module in {
147+
header "${LIBC_INCLUDE_PATH}/netinet/in.h"
148+
export *
149+
150+
exclude header "${LIBC_INCLUDE_PATH}/netinet6/in6.h"
151+
}
152+
module tcp {
153+
header "${LIBC_INCLUDE_PATH}/netinet/tcp.h"
154+
export *
155+
}
156+
}
157+
module poll {
158+
header "${LIBC_INCLUDE_PATH}/poll.h"
159+
export *
160+
}
161+
module regex {
162+
header "${LIBC_INCLUDE_PATH}/regex.h"
163+
export *
164+
}
165+
module sched {
166+
header "${LIBC_INCLUDE_PATH}/sched.h"
167+
export *
168+
}
169+
module semaphore {
170+
header "${LIBC_INCLUDE_PATH}/semaphore.h"
171+
export *
172+
}
173+
module strings {
174+
header "${LIBC_INCLUDE_PATH}/strings.h"
175+
export *
176+
}
177+
178+
module sys {
179+
export *
180+
181+
module mman {
182+
header "${LIBC_ARCH_INCLUDE_PATH}/sys/mman.h"
183+
export *
184+
}
185+
module resource {
186+
header "${LIBC_ARCH_INCLUDE_PATH}/sys/resource.h"
187+
export *
188+
}
189+
module select {
190+
header "${LIBC_ARCH_INCLUDE_PATH}/sys/select.h"
191+
export *
192+
}
193+
module socket {
194+
header "${LIBC_ARCH_INCLUDE_PATH}/sys/socket.h"
195+
export *
196+
}
197+
module stat {
198+
header "${LIBC_ARCH_INCLUDE_PATH}/sys/stat.h"
199+
export *
200+
}
201+
module time {
202+
header "${LIBC_ARCH_INCLUDE_PATH}/sys/time.h"
203+
export *
204+
}
205+
module times {
206+
header "${LIBC_ARCH_INCLUDE_PATH}/sys/times.h"
207+
export *
208+
}
209+
module types {
210+
header "${LIBC_ARCH_INCLUDE_PATH}/sys/types.h"
211+
export *
212+
}
213+
module uio {
214+
header "${LIBC_ARCH_INCLUDE_PATH}/sys/uio.h"
215+
export *
216+
}
217+
module un {
218+
header "${LIBC_ARCH_INCLUDE_PATH}/sys/un.h"
219+
export *
220+
}
221+
module utsname {
222+
header "${LIBC_ARCH_INCLUDE_PATH}/sys/utsname.h"
223+
export *
224+
}
225+
}
226+
module unistd {
227+
header "${LIBC_INCLUDE_PATH}/unistd.h"
228+
export *
229+
}
230+
}
231+
}

0 commit comments

Comments
 (0)