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
|
import os
from devtools.yamaker.modules import Linkable, Switch
from devtools.yamaker.project import NixProject
# libidn contains some weird proxy headers
# intended to emulate glibc compatibility layer.
#
# This headers make use of non-standard include_next statement,
# thus breaking the MSVC build.
# Some of these files are licensed under GPL license, which is non-acceptable.
#
# They will be removed during post_install
GLIBC_EMULATION_HEADERS = (
"gl/fcntl.h",
"gl/limits.h",
"gl/progname.h",
"gl/stddef.h",
"gl/stdio.h",
"gl/stdlib.h",
"gl/string.h",
"gl/sys/stat.h",
"gl/sys/types.h",
"gl/time.h",
"gl/version-etc.h",
"gl/unistd.h",
"lib/gl/limits.h",
"lib/gl/langinfo.h",
"lib/gl/stddef.h",
"lib/gl/stdlib.h",
"lib/gl/string.h",
"lib/gl/sys/types.h",
"lib/gl/unistd.h",
)
GLIBC_EMULATION_SOURCES = (
"gl/cloexec.c",
"gl/fcntl.c",
"gl/unistd.c",
"gl/progname.c",
"gl/version-etc.c",
"lib/gl/unistd.c",
)
LINUX_SPECIFIC_SRCS = [
"gl/getprogname.c",
]
WINDOWS_SPECIFIC_SRCS = [
"gl/getprogname.c",
"lib/gl/strverscmp.c",
]
def post_install(self):
# libidn.map bears GPL-3.0 license and thus can not be used
os.remove(f"{self.dstdir}/lib/libidn.map")
with self.yamakes["static"] as libidn:
# Drop the stuff that breaks Windows build
for src in GLIBC_EMULATION_HEADERS:
os.remove(f"{self.dstdir}/{src}")
for src in GLIBC_EMULATION_SOURCES:
os.remove(f"{self.dstdir}/{src}")
libidn.SRCS.remove(src)
# Support Darwin.
for src in LINUX_SPECIFIC_SRCS:
libidn.SRCS.remove(src)
libidn.after(
"SRCS",
Switch(
OS_LINUX=Linkable(SRCS=LINUX_SPECIFIC_SRCS),
OS_WINDOWS=Linkable(SRCS=WINDOWS_SPECIFIC_SRCS),
),
)
self.make_dll_dispatcher(
switch_flag="USE_IDN",
switch_as_enum=True,
handle_local=True,
default_local_flags={
"CFLAGS": ("USE_LOCAL_IDN_CFLAGS",),
"LDFLAGS": ("USE_LOCAL_IDN_LDFLAGS", "-lidn"),
},
exports_script="libidn.exports",
before_switch="""
IF(EXPORT_CMAKE)
OPENSOURCE_EXPORT_REPLACEMENT(
CMAKE IDN
CMAKE_TARGET IDN::IDN
)
ENDIF()
""",
or_local_condition="EXPORT_CMAKE",
)
libidn = NixProject(
owners=["g:cpp-contrib"],
arcdir="contrib/libs/libidn",
nixattr="libidn",
ignore_commands=["bash", "sed", "cat"],
inclink={
"include": [
"lib/idn-free.h",
"lib/idn-int.h",
"lib/idna.h",
"lib/pr29.h",
"lib/punycode.h",
"lib/stringprep.h",
"lib/tld.h",
]
},
addincl_global={"static": {"../include"}},
install_targets=[
"libidn",
"libgnu",
],
put={
"libidn": "static",
},
put_with={
"libidn": {"libgnu"},
},
disable_includes={
"cheri.h",
"getopt-cdefs.h",
"getopt-pfx-core.h",
"msvc-nothrow.h",
"random.h",
"sys/ps.h",
# sys/random.h is not (yet) present in current version of glibc
# just disable it, as it is not included anyway
"sys/random.h",
"unistring-notinline.h",
},
platform_dispatchers=("config.h",),
keep_paths=["dynamic/libidn.exports"],
copy_sources=("lib/gl/strverscmp.c", "lib/gl/libc-config.h", "lib/gl/cdefs.h"),
post_install=post_install,
use_full_libnames=True,
)
|