Skip to content

Commit c84ca8b

Browse files
Reseted
1 parent d76e2ca commit c84ca8b

13 files changed

Lines changed: 3806 additions & 2176 deletions

.clang-format

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
# BasedOnStyle: LLVM
3+
Language: Cpp
4+
5+
IndentWidth: 4
6+
ContinuationIndentWidth: 4
7+
UseTab: Never
8+
ColumnLimit: 130
9+
PPIndentWidth: -1
10+
11+
AlignAfterOpenBracket: BlockIndent
12+
AlignOperands: AlignAfterOperator
13+
AllowShortBlocksOnASingleLine: Empty
14+
AllowShortEnumsOnASingleLine: false
15+
AllowShortFunctionsOnASingleLine: Inline
16+
AlwaysBreakTemplateDeclarations: Yes
17+
BinPackArguments: false
18+
BinPackLongBracedList: false
19+
BinPackParameters: OnePerLine
20+
ExperimentalAutoDetectBinPacking: true
21+
IndentPPDirectives: AfterHash
22+
NamespaceIndentation: All
23+
PenaltyReturnTypeOnItsOwnLine: 300
24+
PointerAlignment: Left
25+
QualifierAlignment: Left
26+
SpaceAfterTemplateKeyword: false
27+
SpaceBeforeCpp11BracedList: true
28+
29+
IncludeBlocks: Regroup
30+
IncludeCategories:
31+
- Regex: '^".*"'
32+
Priority: 1
33+
- Regex: '^<[a-z0-9_]+>$'
34+
Priority: 2
35+
# Make sure 'net/if.h' comes before 'ifaddrs.h'
36+
- Regex: '^<net/if\.h>$'
37+
Priority: 3
38+
- Regex: '^<[^/]+\.h>$'
39+
Priority: 3
40+
SortPriority: 4
41+
- Regex: '^<(arpa|linux|net(inet)?|prop|sys|u?vm)/'
42+
Priority: 3
43+
SortPriority: 4
44+
- Regex: '.*'
45+
Priority: 5

CMakeLists.txt

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ if(BTOP_LTO)
6767
endif()
6868

6969
if(APPLE)
70-
target_sources(libbtop PRIVATE src/osx/btop_collect.cpp src/osx/sensors.cpp src/osx/smc.cpp)
70+
target_sources(libbtop PRIVATE src/osx/btop_collect.cpp src/osx/sensors.cpp src/osx/smc.cpp src/osx/iokit.cpp src/osx/gpu.cpp)
7171
elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR CMAKE_SYSTEM_NAME STREQUAL "MidnightBSD")
7272
target_sources(libbtop PRIVATE src/freebsd/btop_collect.cpp)
7373
elseif(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
@@ -161,35 +161,36 @@ find_package(Threads REQUIRED)
161161
target_link_libraries(libbtop Threads::Threads)
162162

163163
# Enable GPU support
164-
if(LINUX AND BTOP_GPU)
164+
if(BTOP_GPU AND (LINUX OR APPLE))
165165
target_compile_definitions(libbtop PUBLIC GPU_SUPPORT)
166-
167-
if(BTOP_RSMI_STATIC)
168-
# ROCm doesn't properly add it's folders to the module path if `CMAKE_MODULE_PATH` is already
169-
# set
170-
# We could also manually append ROCm's path here
171-
set(_CMAKE_MODULE_PATH CMAKE_MODULE_PATH)
172-
unset(CMAKE_MODULE_PATH)
173-
174-
# NOTE: This might be problematic in the future if other sub projects depend on this or if
175-
# btop starts producing libraries
176-
# Build a static ROCm library
177-
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
178-
179-
add_subdirectory(lib/rocm_smi_lib EXCLUDE_FROM_ALL)
180-
181-
add_library(ROCm INTERFACE)
182-
# Export ROCm's properties to a target
183-
target_compile_definitions(ROCm INTERFACE RSMI_STATIC)
184-
target_include_directories(ROCm INTERFACE lib/rocm_smi_lib/include)
185-
target_link_libraries(ROCm INTERFACE rocm_smi64)
186-
187-
set(CMAKE_MODULE_PATH _CMAKE_MODULE_PATH)
188-
189-
target_link_libraries(libbtop ROCm)
190-
endif()
191-
if(NOT BTOP_STATIC)
192-
target_link_libraries(libbtop ${CMAKE_DL_LIBS})
166+
if(LINUX)
167+
if(BTOP_RSMI_STATIC)
168+
# ROCm doesn't properly add it's folders to the module path if `CMAKE_MODULE_PATH` is already
169+
# set
170+
# We could also manually append ROCm's path here
171+
set(_CMAKE_MODULE_PATH CMAKE_MODULE_PATH)
172+
unset(CMAKE_MODULE_PATH)
173+
174+
# NOTE: This might be problematic in the future if other sub projects depend on this or if
175+
# btop starts producing libraries
176+
# Build a static ROCm library
177+
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
178+
179+
add_subdirectory(lib/rocm_smi_lib EXCLUDE_FROM_ALL)
180+
181+
add_library(ROCm INTERFACE)
182+
# Export ROCm's properties to a target
183+
target_compile_definitions(ROCm INTERFACE RSMI_STATIC)
184+
target_include_directories(ROCm INTERFACE lib/rocm_smi_lib/include)
185+
target_link_libraries(ROCm INTERFACE rocm_smi64)
186+
187+
set(CMAKE_MODULE_PATH _CMAKE_MODULE_PATH)
188+
189+
target_link_libraries(libbtop ROCm)
190+
endif()
191+
if(NOT BTOP_STATIC)
192+
target_link_libraries(libbtop ${CMAKE_DL_LIBS})
193+
endif()
193194
endif()
194195
endif()
195196

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,17 @@ ifeq ($(PLATFORM_LC)$(ARCH),linuxx86_64)
4343
INTEL_GPU_SUPPORT := true
4444
endif
4545
endif
46+
<<<<<<< HEAD
47+
48+
ifeq ($(PLATFORM_LC)$(ARCH),macosarm64)
49+
GPU_SUPPORT := true
50+
endif
51+
52+
=======
4653
ifeq ($(PLATFORM_LC),macos)
4754
GPU_SUPPORT := true
4855
endif
56+
>>>>>>> official
4957
ifneq ($(GPU_SUPPORT),true)
5058
GPU_SUPPORT := false
5159
endif

src/btop.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,18 @@ void clean_quit(int sig) {
229229
}
230230

231231
#ifdef GPU_SUPPORT
232+
#ifndef __APPLE__
232233
Gpu::Nvml::shutdown();
233234
Gpu::Rsmi::shutdown();
235+
<<<<<<< HEAD
236+
#else
237+
Gpu::IOAccelerator::shutdown();
238+
#endif
239+
=======
234240
#ifdef __APPLE__
235241
Gpu::AppleSilicon::shutdown();
236242
#endif
243+
>>>>>>> official
237244
#endif
238245

239246

0 commit comments

Comments
 (0)