aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Horodniceanu <a.horodniceanu@proton.me>2024-05-02 22:34:17 +0300
committerAndrei Horodniceanu <a.horodniceanu@proton.me>2024-05-02 22:34:17 +0300
commitf319287a4bc201424dc10f5e0b6f9efe8b89ff4f (patch)
tree6df0148880881453441ed1ee9f7b674bd9aa010c /dev-util/dfmt
parentdev-util/dfmt: enable ldc2-1_37 (diff)
downloaddlang-f319287a4bc201424dc10f5e0b6f9efe8b89ff4f.tar.gz
dlang-f319287a4bc201424dc10f5e0b6f9efe8b89ff4f.tar.bz2
dlang-f319287a4bc201424dc10f5e0b6f9efe8b89ff4f.zip
dev-util/dfmt: refactor src_compile to use upstream makefile
Additional changes: - don't include the stdx-allocator submodule since it's unused - strip -march=native with gdc - build and run unittests Bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114171 Signed-off-by: Andrei Horodniceanu <a.horodniceanu@proton.me>
Diffstat (limited to 'dev-util/dfmt')
-rw-r--r--dev-util/dfmt/dfmt-0.15.1-r2.ebuild72
1 files changed, 72 insertions, 0 deletions
diff --git a/dev-util/dfmt/dfmt-0.15.1-r2.ebuild b/dev-util/dfmt/dfmt-0.15.1-r2.ebuild
new file mode 100644
index 0000000..f9d0034
--- /dev/null
+++ b/dev-util/dfmt/dfmt-0.15.1-r2.ebuild
@@ -0,0 +1,72 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DESCRIPTION="Dfmt is a formatter for D source code"
+HOMEPAGE="https://github.com/dlang-community/dfmt"
+
+LIBDPARSE="fe6d1e38fb4fc04323170389cfec67ed7fd4e24a"
+SRC_URI="
+ https://github.com/dlang-community/dfmt/archive/v${PV}.tar.gz -> ${PN}-${PV}.tar.gz
+ https://github.com/dlang-community/libdparse/archive/${LIBDPARSE}.tar.gz -> libdparse-${LIBDPARSE}.tar.gz
+ "
+LICENSE="Boost-1.0"
+
+SLOT="0"
+KEYWORDS="~amd64 ~arm64 ~x86"
+
+DLANG_COMPAT=( dmd-2_{106..108} gdc-13 ldc2-1_{35..37} )
+
+inherit dlang-single bash-completion-r1
+
+REQUIRED_USE=${DLANG_REQUIRED_USE}
+DEPEND=${DLANG_DEPS}
+BDEPEND=${DLANG_DEPS}
+RDEPEND=${DLANG_DEPS}
+
+src_prepare() {
+ mv -T "../libdparse-${LIBDPARSE}" libdparse || die "Couldn't move submodule libdparse"
+ # Make a dummy folder to silence a find warning in the makefile
+ mkdir -p stdx-allocator/source || die "Couldn't create dummy stdx-allocator directory"
+
+ default
+
+ mkdir bin || die "Failed to create 'bin' directory."
+ echo "v${PV}" > bin/githash.txt
+ touch githash
+
+ # Use our user's flags + $(INCLUDE_PATHS) defined in the makefile
+ export D_FLAGS="$(dlang_get_dmdw_dcflags) $(dlang_get_dmdw_ldflags) \$(INCLUDE_PATHS)"
+ # Tests fail with -march=native and -O2 with <sys-devel/gcc-13.2.1_p20240330,
+ # probably https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114171 again.
+ if [[ ${EDC} == gdc* && ${D_FLAGS} == *-march=native* ]]; then
+ ewarn '-march=native has been removed from your flags.'
+ ewarn 'See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114171'
+ # Interestingly `-q,` is a valid gdmd flag.
+ export D_FLAGS=${D_FLAGS//-march=native}
+ fi
+}
+
+src_compile() {
+ emake DC="$(dlang_get_dmdw)" DMD_FLAGS="${D_FLAGS}"
+}
+
+src_test() {
+ # minimal workaround for https://github.com/dlang-community/dfmt/pull/600
+ touch githash.d
+ # Let the makefile add -unittest -g, keeps our code simpler
+ emake bin/dfmt-test DC="$(dlang_get_dmdw)" DMD_COMMON_FLAGS="${D_FLAGS}"
+ ./bin/dfmt-test || die "Unittests failed"
+
+ cd tests || die
+
+ dlang_compile_bin "run_tests" "test.d"
+ ./run_tests || die "Tests failed"
+}
+
+src_install() {
+ dobin bin/dfmt
+ dodoc README.md LICENSE.txt
+ dobashcomp bash-completion/completions/dfmt
+}