aboutsummaryrefslogtreecommitdiff
blob: a6673aa0cef6187c065fd5d8acc13b2d651b25c4 (plain)
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
# Copyright 2023-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

MY_VER="$(ver_rs 3 - 4 .)" # 0.8.0_beta15 -> 0.8.0-beta.15

DESCRIPTION="Microsoft language server protocol implementation for D"
HOMEPAGE="https://github.com/Pure-D/serve-d"
SRC_URI="https://code.dlang.org/packages/serve-d/${MY_VER}.zip -> ${P}.zip

https://code.dlang.org/packages/automem/0.6.9.zip -> automem-0.6.9.zip
https://code.dlang.org/packages/botan/1.12.19.zip -> botan-1.12.19.zip
https://code.dlang.org/packages/botan-math/1.0.3.zip -> botan-math-1.0.3.zip
https://code.dlang.org/packages/cachetools/0.4.1.zip -> cachetools-0.4.1.zip
https://code.dlang.org/packages/dcd/0.16.0-beta.2.zip -> dcd-0.16.0-beta.2.zip
https://code.dlang.org/packages/dfmt/0.15.0.zip -> dfmt-0.15.0.zip
https://code.dlang.org/packages/diet-complete/0.0.3.zip -> diet-complete-0.0.3.zip
https://code.dlang.org/packages/diet-ng/1.8.1.zip -> diet-ng-1.8.1.zip
https://code.dlang.org/packages/dscanner/0.16.0-beta.2.zip -> dscanner-0.16.0-beta.2.zip
https://code.dlang.org/packages/dub/1.33.1.zip -> dub-1.33.1.zip
https://code.dlang.org/packages/emsi_containers/0.9.0.zip -> emsi_containers-0.9.0.zip
https://code.dlang.org/packages/eventcore/0.9.25.zip -> eventcore-0.9.25.zip
https://code.dlang.org/packages/fuzzymatch/1.0.0.zip -> fuzzymatch-1.0.0.zip
https://code.dlang.org/packages/inifiled/1.3.3.zip -> inifiled-1.3.3.zip
https://code.dlang.org/packages/isfreedesktop/0.1.1.zip -> isfreedesktop-0.1.1.zip
https://code.dlang.org/packages/libasync/0.8.6.zip -> libasync-0.8.6.zip
https://code.dlang.org/packages/libddoc/0.8.0.zip -> libddoc-0.8.0.zip
https://code.dlang.org/packages/libdparse/0.23.2.zip -> libdparse-0.23.2.zip
https://code.dlang.org/packages/memutils/1.0.9.zip -> memutils-1.0.9.zip
https://code.dlang.org/packages/mir-algorithm/3.20.4.zip -> mir-algorithm-3.20.4.zip
https://code.dlang.org/packages/mir-core/1.5.5.zip -> mir-core-1.5.5.zip
https://code.dlang.org/packages/mir-cpuid/1.2.10.zip -> mir-cpuid-1.2.10.zip
https://code.dlang.org/packages/mir-ion/2.1.8.zip -> mir-ion-2.1.8.zip
https://code.dlang.org/packages/mir-linux-kernel/1.0.1.zip -> mir-linux-kernel-1.0.1.zip
https://code.dlang.org/packages/msgpack-d/1.0.4.zip -> msgpack-d-1.0.4.zip
https://code.dlang.org/packages/openssl/3.3.0.zip -> openssl-3.3.0.zip
https://code.dlang.org/packages/openssl-static/1.0.2+3.0.8.zip -> openssl-static-1.0.2+3.0.8.zip
https://code.dlang.org/packages/requests/2.1.1.zip -> requests-2.1.1.zip
https://code.dlang.org/packages/rm-rf/0.1.0.zip -> rm-rf-0.1.0.zip
https://code.dlang.org/packages/sdlfmt/0.1.1.zip -> sdlfmt-0.1.1.zip
https://code.dlang.org/packages/sdlite/1.1.2.zip -> sdlite-1.1.2.zip
https://code.dlang.org/packages/silly/1.1.1.zip -> silly-1.1.1.zip
https://code.dlang.org/packages/standardpaths/0.8.2.zip -> standardpaths-0.8.2.zip
https://code.dlang.org/packages/stdx-allocator/2.77.5.zip -> stdx-allocator-2.77.5.zip
https://code.dlang.org/packages/taggedalgebraic/0.11.22.zip -> taggedalgebraic-0.11.22.zip
https://code.dlang.org/packages/test_allocator/0.3.4.zip -> test_allocator-0.3.4.zip
https://code.dlang.org/packages/unit-threaded/0.10.8.zip -> unit-threaded-0.10.8.zip
https://code.dlang.org/packages/vibe-core/2.2.0.zip -> vibe-core-2.2.0.zip
https://code.dlang.org/packages/vibe-d/0.9.6.zip -> vibe-d-0.9.6.zip
https://code.dlang.org/packages/xdgpaths/0.2.5.zip -> xdgpaths-0.2.5.zip
"

LICENSE="MIT"
LICENSE+=" Apache-2.0 BSD-2 BSD Boost-1.0 GPL-3 ISC LGPL-3 MIT public-domain Unlicense || ( openssl SSLeay )"
S="${WORKDIR}/${PN}-${MY_VER}"
SLOT="0"
KEYWORDS="~amd64"

DLANG_VERSION_RANGE="2.100-2.107"
DLANG_PACKAGE_TYPE="single"
# gdc currently fails due to a bug in mir-cpuid, see: https://github.com/libmir/mir-cpuid/pull/46
DLANG_COMPILER_DISABLED_BACKENDS=(gdc)

CHECKREQS_MEMORY="10G" # mir is a chonker

inherit check-reqs dlang multiprocessing

# Lower versions of dcd won't immediately fail but they won't work as intended (no autocompletion for example)
RDEPEND=">=dev-util/dcd-0.15.2"
BDEPEND="dev-util/dub app-arch/unzip"

src_unpack() {
	unpack "${P}.zip"
	pushd "${S}" || die

	local dep name ver dub_args
	dub_args=(
		# Don't look up dependencies online or in the system path
		--skip-registry=all
		# Only look for them in the ${T} directory
		--registry=file://"${T}"
		# Prefer verbose operation
		--verbose
		# Unpack dependencies for the local project (put them in ${S}/.dub)
		--cache=local
	)
	for dep in ${A}; do
		if [[ ${dep} != ${P}.zip ]]; then
			# Due to a bug in dub, we can't have similar looking
			# archives in the same directory. Simply put, if we had:
			# foo-1.zip and foo-bar-2.zip when trying to fetch foo dub
			# will fail because it thinks that foo-bar-2.zip is foo's
			# archive. See: https://github.com/dlang/dub/pull/2727
			cp "${DISTDIR}/${dep}" "${T}" || die "Could not copy dependency to temporary directory"

			# This calculation is faulty, dub allows digits in package names, it will
			# probably be needed to save dependencies in a similar to $CRATES variable.
			name="${dep%%-[0-9]*}"
			version="${dep%.zip}"
			version="${version#${name}-}"

			/usr/bin/dub "${dub_args[@]}" fetch "${name}@${version}" \
				|| die "Could not extract dub dependencies"

			rm "${T}/${dep}" || die "Could not remove depedency from temporary directory"
		fi
	done
	popd > /dev/null || die
}

d_src_compile() {
	local dub_args=(
		# It wouldn't be good if the build became interactive
		--non-interactive
		# Let user provided $DCFLAGS dictate the build
		#--build=realease
		# It is good practice to be verbose
		--verbose
		# Don't touch anything outside the ${S} directory
		--skip-registry=all
	)

	DFLAGS="$(get_dflags)" DUB_HOME="${S}" /usr/bin/dub build "${dub_args[@]}" || die
}

d_src_test() {
	local dub_args=(
		# It is good practice to be verbose
		--verbose
		# Don't touch anything outside the ${S} directory
		--skip-registry=all

		# ${PV} uses silly for testing so it supports jobs
		--
		--threads="$(makeopts_jobs)"
	)

	# Tests all submodules in dub.json. :dcd currently fails tests due to a missing dependency and import.
	# It's 1 little test though so no biggie.
	# See: https://github.com/Pure-D/serve-d/pull/350
	local subpkg
	# We also have another issue that testing $PV gives linking errors
	# when the --build configuration is specified (or if $DFLAGS are specified).
	# We can work around it by forcing --build=unittest.
	# See: https://github.com/Pure-D/serve-d/issues/351
	for subpkg in ":http" ":protocol" ":lsp" ":serverbase" ":workspace-d" ""; do
		# Let $subpkg be shell expanded since it can be empty
		DUB_HOME="${S}" DFLAGS="$(get_dflags)" /usr/bin/dub test ${subpkg} --build=unittest "${dub_args[@]}" \
			|| die "Tests failed"
	done
}

d_src_install() {
	dobin "${S}/serve-d"
}

get_dflags() {
	# See https://issues.dlang.org/show_bug.cgi?id=24406 and
	# https://github.com/Pure-D/serve-d/issues/360
	# For short, we have to remove -O from DCFLAGS for dmd.
	#
	# There's also an issue with ldc that when -mcpu=native is specified
	# you get an llvm stack trace. I have to investigate it further
	# before reporting. -mcpu=<resolve-march-native> works though, idk.
	# For now just remove -mcpu=native for ldc2.
	case "${DLANG_VENDOR}" in
		GNU) echo "${DCFLAGS}" ;;
		LDC)
			# Use a file since we can't export variables because we're
			# called in $().
			if [[ ${DCFLAGS} == *-mcpu=native* && ! -e ${T}/ldc2-flags-warned ]]; then
				touch "${T}"/ldc2-flags-warned || die

				ewarn "-mcpu=native causes issues with ldc2 so it will be removed"
				ewarn "from your flags. If you still want to specify it use"
				ewarn "app-misc/resolve-march-native to get your actual architecture"
				ewarn "and use that with -mcpu, like in -mcpu=znver3."
			fi
			echo "${DCFLAGS//-mcpu=native/}"
			;;
		DigitalMars)
			if [[ ${DCFLAGS} == *-O* && ! -e ${T}/dmd-flags-warned ]]; then
				touch "${T}"/dmd-flags-warned || die

				ewarn "Optimizations will be turned off for this build with dmd"
				ewarn "See: https://github.com/Pure-D/serve-d/issues/360"
			fi
			echo "${DCFLAGS//-O/}"
			;;
		*)
			die "Unknown DLANG_VENDOR: ${DLANG_VENDOR}"
			;;
	esac
}