summaryrefslogtreecommitdiff
path: root/app-editors/imhex/imhex-1.38.1.ebuild
blob: b4ddab0805f6ab4037038786f49b1a82abbaf27e (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
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

LLVM_COMPAT=( {15..21} )

inherit cmake llvm-r1 toolchain-funcs flag-o-matic xdg-utils

DESCRIPTION="A hex editor for reverse engineers, programmers, and eyesight"
HOMEPAGE="https://github.com/WerWolv/ImHex"
SRC_URI="
	https://github.com/WerWolv/ImHex/releases/download/v${PV}/Full.Sources.tar.gz -> ${P}.gh.tar.gz
	https://github.com/WerWolv/ImHex-Patterns/archive/refs/tags/ImHex-v${PV}.tar.gz -> ${PN}-patterns-${PV}.gh.tar.gz
"
S="${WORKDIR}/ImHex"
S_PATTERNS="${WORKDIR}/ImHex-Patterns-ImHex-v${PV}"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64"
IUSE="+system-llvm test lto +desktop-portal lz4"
RESTRICT="!test? ( test )"

# Skip cmake version detection, as there are a lot of dependencies
# (that we do not use) that wants cmake < 3.5, so it prints a warning
CMAKE_QA_COMPAT_SKIP=yes

PATCHES=(
	# If virtual/dotnet-sdk is installed on your system, then cmake
	# will use it at some point and try to access internet.
	# Because it did not cause any issue, we can disable it
	"${FILESDIR}/remove_dotnet.patch"
	# Correct the cmake MbedTLS search call
	"${FILESDIR}/cmake_mbedtls.patch"
	# Remove -Werror
	"${FILESDIR}/remove_Werror.patch"
)

DOCS+=( LICENSE PLUGINS.md changelog.md )

DEPEND="
	app-arch/bzip2
	app-arch/xz-utils
	app-arch/zstd:=
	>=app-forensics/yara-4.2.0:=
	>=dev-cpp/nlohmann_json-3.10.2
	dev-libs/boost
	>=dev-libs/capstone-5.0.3:=
	<dev-libs/capstone-6
	dev-libs/md4c
	>=dev-libs/libfmt-11.0.2:=
	>=dev-libs/nativefiledialog-extended-1.2.1[desktop-portal?]
	media-libs/fontconfig
	media-libs/freetype
	>=media-libs/glfw-3.4[X]
	media-libs/glm
	media-libs/libglvnd
	net-libs/mbedtls:=
	net-misc/curl
	sys-apps/file
	virtual/zlib:=
	virtual/libiconv
	virtual/libintl
"
RDEPEND="${DEPEND}"
BDEPEND="
	app-admin/chrpath
	gnome-base/librsvg
	lz4? ( app-arch/lz4 )
	system-llvm? ( llvm-core/llvm )
"

pkg_pretend() {
	if tc-is-gcc && [[ $(gcc-major-version) -lt 14 ]]; then
		die "${PN} requires GCC 14 or newer"
	fi
}

src_unpack() {
	default

	mv "${S_PATTERNS}" "${S}/ImHex-Patterns"
}

src_configure() {
	# Building ImHex with -Werror=strict-aliasing gives a failed build
	# for tests/algorithms/source/endian.cpp, and ImHex usually has pretty
	# clean build (without warnings), so it should be safe to do
	filter-flags -Werror=strict-aliasing

	if use test; then
		sed -ie "s/tests EXCLUDE_FROM_ALL/tests ALL/" "${S}/CMakeLists.txt"
	fi

	# The build hardening can be done by the user (by changing CFLAGS/CXXFLAGS)
	# I need to disable system-llvm because on my system the llvm/Demangle/Demangle.h
	# header was found by cmake, but not used during compilation, leading to errors (file not found)
	local mycmakeargs=(
		-D IMHEX_STRIP_RELEASE=OFF \
		-D IMHEX_OFFLINE_BUILD=ON \
		-D IMHEX_IGNORE_BAD_CLONE=ON \
		-D IMHEX_PATTERNS_PULL_MASTER=OFF \
		-D IMHEX_IGNORE_BAD_COMPILER=OFF \
		-D IMHEX_USE_GTK_FILE_PICKER=$(usex !desktop-portal) \
		-D IMHEX_DISABLE_STACKTRACE=OFF \
		-D IMHEX_BUNDLE_DOTNET=OFF \
		-D IMHEX_ENABLE_LTO=$(usex lto) \
		-D IMHEX_USE_DEFAULT_BUILD_SETTINGS=OFF \
		-D IMHEX_STRICT_WARNINGS=OFF \
		-D IMHEX_STATIC_LINK_PLUGINS=OFF \
		-D IMHEX_ENABLE_UNITY_BUILD=OFF \
		-D IMHEX_BUILD_HARDENING=OFF \
		-D IMHEX_ENABLE_STD_ASSERTS=OFF \
		-D IMHEX_ENABLE_UNIT_TESTS=$(usex test) \
		-D IMHEX_ENABLE_PRECOMPILED_HEADERS=OFF \
		-D IMHEX_COMPRESS_DEBUG_INFO=OFF \
		-D IMHEX_VERSION="${PV}" \
		-D PROJECT_VERSION="${PV}" \
		-D LIBPL_ENABLE_TESTS=$(usex test) \
		-D LIBPL_ENABLE_EXAMPLE=ON \
		-D LIBWOLV_ENABLE_TESTS=$(usex test) \
		-D LIBWOLV_ENABLE_EXAMPLES=ON \
		-D USE_SYSTEM_BOOST=ON \
		-D USE_SYSTEM_CAPSTONE=ON \
		-D USE_SYSTEM_FMT=ON \
		-D USE_SYSTEM_LLVM=OFF \
		# -D USE_SYSTEM_LLVM=$(usex system-llvm) \
		-D USE_SYSTEM_MD4C=ON \
		-D USE_SYSTEM_NFD=ON \
		-D USE_SYSTEM_NLOHMANN_JSON=ON \
		-D USE_SYSTEM_YARA=ON \
	)

	cmake_src_configure
}

pkg_postinst() {
	xdg_desktop_database_update
	xdg_mimeinfo_database_update
}
pkg_postrm() {
	xdg_desktop_database_update
	xdg_mimeinfo_database_update
}