summaryrefslogtreecommitdiff
path: root/media-gfx/slic3r/slic3r-1.3.0.ebuild
blob: 536b6f87f04ff447a5c3630437ac2291a2763a0f (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
# Copyright 2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit perl-module

DESCRIPTION="Open Source toolpath generator for 3D printers"
HOMEPAGE="https://slic3r.org"
if [[ ${PV} == *9999* ]] ; then
	inherit git-r3
	EGIT_REPO_URI="https://github.com/slic3r/${PN}"
	S="${WORKDIR}/slic3r-${PV}/xs"
else
	SRC_URI="https://github.com/slic3r/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz"
	KEYWORDS="~amd64"
	S="${WORKDIR}/Slic3r-${PV}/xs"
fi
LICENSE="AGPL-3"
SLOT="0"

IUSE="+gui xs test"

RESTRICT="!test? ( test )"

BDEPEND="
	dev-lang/perl:=
	dev-perl/ExtUtils-CppGuess[${PERL_USEDEP}]
	dev-perl/ExtUtils-Typemaps-Default[${PERL_USEDEP}]
	dev-perl/ExtUtils-XSpp[${PERL_USEDEP}]
	dev-perl/Module-Build[${PERL_USEDEP}]
	dev-perl/Module-Build-WithXSpp[${PERL_USEDEP}]
	dev-perl/Devel-CheckLib[${PERL_USEDEP}]
	virtual/perl-ExtUtils-ParseXS
"

RDEPEND="
	dev-cpp/tbb
	dev-cpp/exprtk
	dev-lang/perl:=
	dev-libs/boost:=
	dev-libs/expat
	dev-libs/miniz:=
	dev-perl/Encode-Locale[${PERL_USEDEP}]
	dev-perl/Moo[${PERL_USEDEP}]
	gui-libs/gtk
	media-libs/admesh
	media-libs/freeglut
	net-misc/curl[openssl]
	virtual/perl-Encode
	virtual/perl-File-Spec
	virtual/perl-Scalar-List-Utils
	virtual/perl-Test-Simple
	virtual/perl-threads
	virtual/perl-Time-HiRes
	virtual/perl-autodie
	virtual/perl-parent
	virtual/perl-IO-Compress
	virtual/perl-Test-Harness
	virtual/perl-Test-Simple
	x11-libs/libXmu
	x11-libs/wxGTK
	gui? (
		>=dev-lang/perl-5.38.2-r3[perl_features_ithreads]
		dev-perl/Alien-wxWidgets[${PERL_USEDEP}]
		dev-perl/Class-Accessor[${PERL_USEDEP}]
		dev-perl/Growl-GNTP[${PERL_USEDEP}]
		dev-perl/libwww-perl[${PERL_USEDEP}]
		dev-perl/Net-Bonjour[${PERL_USEDEP}]
		dev-perl/OpenGL[${PERL_USEDEP}]
		dev-perl/Wx[${PERL_USEDEP}]
		dev-perl/Wx-GLCanvas[${PERL_USEDEP}]
		virtual/perl-Socket
	)
"

DEPEND="${RDEPEND}"

PATCHES=(
	"${FILESDIR}/boost-io-context-${PV}.patch"
	"${FILESDIR}/build-with-system-libs-${PV}.patch"
)

src_prepare() {
	default
	local vendored=( admesh expat exprtk miniz )
	for v in "${vendored[@]}"; do
		rm -rf src/"${v}" || die "Failed to remove vendored ${v}."
	done

	if [[ "${PV}" != *9999* ]]; then
		sed -i "/^src\/admesh/d" MANIFEST || die
		find src/libslic3r/Zip -type f \( -name ZipArchive.hpp -o -name ZipArchive.cpp \) \
			-exec sed -i "s|\"../../miniz/miniz.h\"|<miniz/miniz.h>|" "{}" \; || die

		cd .. || die
		eapply "${FILESDIR}/cmake-with-system-libs.patch"
	else
		sed -i "/^set(EXPAT_INCLUDES$/,/^)$/c\find_package(expat REQUIRED)\n" \
			../src/CMakeLists.txt || die

		sed -i "s|\"miniz/miniz.h\"|<miniz/miniz.h>|" src/Zip/ZipArchive.hpp || die
		sed -i "/^add_library(miniz STATIC$/,/^)$/c\find_package(miniz REQUIRED)\n" \
			../src/CMakeLists.txt || die
	fi
}

src_compile() {
	local myconf_str=""
	if use gui; then
		myconf_str+=" --gui"
	fi

	if use xs; then
		myconf_str+=" --xs"
	fi

	local myconf="$myconf_str"
	perl-module_src_compile
}

src_install() {
	perl-module_src_install

	cd .. || die
	exeinto /usr/libexec/slic3r
	doexe "slic3r.pl" || die

	insinto /usr/libexec/slic3r
	doins -r "lib" "var" "share" || die

	exeinto /usr/bin
	newexe - slic3r <<-EOF || die
		#!/bin/sh
		exec /usr/bin/perl -I/usr/libexec/slic3r/lib /usr/libexec/slic3r/slic3r.pl "\$@"
	EOF
}