blob: 2bbf6049a075522c1721728c9ec8da13f9f610c8 (
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
|
# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
PYTHON_COMPAT=( python3_{10..14} )
ROCM_SKIP_GLOBALS=1
inherit cmake linux-info python-r1 rocm
ESMI_PN=esmi_pkg_ver
ESMI_PV=4.2
DESCRIPTION="AMD System Management Interface for managing and monitoring GPUs"
HOMEPAGE="
https://github.com/ROCm/amdsmi
https://rocm.docs.amd.com/projects/amdsmi/en/latest/
"
SRC_URI="
https://github.com/ROCm/amdsmi/archive/refs/tags/rocm-${PV}.tar.gz -> ${P}.tar.gz
https://github.com/amd/esmi_ib_library/archive/refs/tags/${ESMI_PN}-${ESMI_PV}.tar.gz
"
S="${WORKDIR}/amdsmi-rocm-${PV}"
ESMI_S="${WORKDIR}/esmi_ib_library-${ESMI_PN}-${ESMI_PV}"
LICENSE="MIT"
SLOT="0/$(ver_cut 1-2)"
KEYWORDS="~amd64"
IUSE="test"
RESTRICT="!test? ( test )"
REQUIRED_USE="${PYTHON_REQUIRED_USE}"
DEPEND="
${PYTHON_DEPS}
test? ( dev-cpp/gtest )
x11-libs/libdrm[video_cards_amdgpu]
"
RDEPEND="
${PYTHON_DEPS}
dev-libs/rocm-core:${SLOT}
"
PATCHES=(
"${FILESDIR}"/${PN}-7.0.2-no-git.patch
"${FILESDIR}"/${PN}-7.0.2-unbundle-gtest.patch
)
CONFIG_CHECK="~HSA_AMD ~DRM_AMDGPU"
src_prepare() {
ln -s "${ESMI_S}" esmi_ib_library || die
# Compatibility with CMake < 3.10 will be removed
sed -e "/cmake_minimum_required/ s/3\.5\.0/3.10/" \
-i goamdsmi_shim/CMakeLists.txt "${ESMI_S}"/CMakeLists.txt || die
sed -e "s/-Wall -Wextra//" \
-i CMakeLists.txt "${ESMI_S}"/CMakeLists.txt goamdsmi_shim/CMakeLists.txt || die
# Reset custom installation path
sed -e "/generic_add_rocm/d" -i CMakeLists.txt || die
# Remove /usr/lib to fix multilib
sed -e '/target_link_libraries.*\/lib/d' -i goamdsmi_shim/CMakeLists.txt || die
# Install docs to correct place
sed -e "s:doc/\${CPACK_PACKAGE_NAME}:doc/${P}:" -i CMakeLists.txt || die
# Do not install /usr/share/doc/${P}-asan
sed -e "s/COMPONENT asan/COMPONENT asan EXCLUDE_FROM_ALL/" -i CMakeLists.txt || die
cmake_src_prepare
}
src_configure() {
python_setup
local mycmakeargs=(
-DBUILD_TESTS=$(usex test)
-DUSE_SYSTEM_GTEST=ON
-Wno-dev
)
cmake_src_configure
}
src_test() {
# GPU access in amdsmitstReadOnly.TestSysInfoRead and amdsmitstReadOnly.TestIdInfoRead
addwrite /dev/dri/renderD128
# Few tests fail on ASUS GZ302E: no metrics from kernel?
GTEST_FILTER="-amdsmitstReadOnly.TempRead:amdsmitstReadOnly.TestFrequenciesRead" \
"${BUILD_DIR}/tests/amd_smi_test/amdsmitst" || die "Test failed"
}
src_install() {
cmake_src_install
# Wrong places
rm "${ED}"/usr/share/amd_smi/amdsmi/{libamd_smi.so,LICENSE,README.md} || die
python_fix_shebang "${ED}"/usr/libexec/amdsmi_cli
python_domodule "${ED}"/usr/libexec/amdsmi_cli
python_domodule "${ED}"/usr/share/amd_smi/amdsmi
fperms a+x "/usr/lib/${EPYTHON}/site-packages/amdsmi_cli/amdsmi_cli.py"
dosym -r "/usr/lib/${EPYTHON}/site-packages/amdsmi_cli/amdsmi_cli.py" /usr/bin/amd-smi
rm -rf "${ED}"/usr/share/amd_smi "${ED}"/usr/libexec/amdsmi_cli || die
}
|