Compare commits

...

12 Commits

Author SHA1 Message Date
Santhosh Raju 0baf893a10
Merge 5611cfee5e into d1680735d9 2024-03-23 09:41:08 +00:00
Santhosh Raju 5611cfee5e Ignore netbsd folder in other builds. 2024-03-23 10:40:58 +01:00
Santhosh Raju eac3086280 Use kvm and ifaddr defs from shared.hpp. 2024-03-23 10:40:58 +01:00
Santhosh Raju 61c5aa1af5 Simplify the CI command. 2024-03-23 10:40:58 +01:00
Santhosh Raju fe4b4b90d3 Add support for reading thermal stats. 2024-03-23 10:40:58 +01:00
Santhosh Raju bd1c9bc164 Add support for reading battery stats. 2024-03-23 10:40:57 +01:00
Santhosh Raju aea95dbafc Get the 64 bit value of physmem. 2024-03-23 10:40:57 +01:00
Santhosh Raju 7cf048d591 Add CMake build support for NetBSD. 2024-03-23 10:40:57 +01:00
Santhosh Raju a61ebacafa Attempt to fix the CI. 2024-03-23 10:40:57 +01:00
Santhosh Raju 284969f395 Fix some of the memory stats. 2024-03-23 10:40:57 +01:00
Santhosh Raju bc2b2c3bfd Add build files for NetBSD. 2024-03-23 10:40:57 +01:00
Santhosh Raju 5641437e1a Add NetBSD Support. 2024-03-23 10:40:57 +01:00
14 changed files with 1581 additions and 5 deletions

45
.github/workflows/cmake-netbsd.yml vendored Executable file
View File

@ -0,0 +1,45 @@
name: NetBSD CMake
on:
push:
branches: main
tags-ignore: '*.*'
paths:
- '.github/workflows/cmake-netbsd.yml'
- 'CMakeLists.txt'
- 'include/**'
- 'src/*pp'
- 'src/netbsd/*pp'
pull_request:
branches: main
paths:
- '.github/workflows/cmake-netbsd.yml'
- 'CMakeLists.txt'
- 'include/**'
- 'src/*pp'
- 'src/netbsd/*pp'
jobs:
cmake_build_on_netbsd:
runs-on: ubuntu-22.04
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
- name: Compile
uses: vmactions/netbsd-vm@v1
with:
release: '9.3'
usesh: true
prepare: |
PATH="/usr/pkg/sbin:/usr/pkg/bin:$PATH"
PKG_PATH="https://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/amd64/9.3/All/"
export PATH PKG_PATH
/usr/sbin/pkg_add pkgin
pkgin -y install cmake ninja-build gcc10 coreutils git
git config --global --add safe.directory /home/runner/work/btop/btop
run: |
cmake -DCMAKE_CXX_COMPILER="/usr/pkg/gcc10/bin/g++" -B build -G Ninja -DBTOP_STATIC=ON
cmake --build build --verbose

View File

@ -11,6 +11,7 @@ on:
- 'src/**'
- '!src/linux/**'
- '!src/osx/**'
- '!src/netbsd/**'
- '!src/openbsd/**'
- 'include/**'
- 'Makefile'
@ -22,6 +23,7 @@ on:
- 'src/**'
- '!src/linux/**'
- '!src/osx/**'
- '!src/netbsd/**'
- '!src/openbsd/**'
- 'include/**'
- 'Makefile'

View File

@ -11,6 +11,7 @@ on:
- 'src/**'
- '!src/osx/**'
- '!src/freebsd/**'
- '!src/netbsd/**'
- '!src/openbsd/**'
- 'include/**'
- 'Makefile'
@ -22,6 +23,7 @@ on:
- 'src/**'
- '!src/osx/**'
- '!src/freebsd/**'
- '!src/netbsd/**'
- '!src/openbsd/**'
- 'include/**'
- 'Makefile'

View File

@ -11,6 +11,7 @@ on:
- 'src/**'
- '!src/osx/**'
- '!src/freebsd/**'
- '!src/netbsd/**'
- '!src/openbsd/**'
- 'include/**'
- 'Makefile'
@ -22,6 +23,7 @@ on:
- 'src/**'
- '!src/osx/**'
- '!src/freebsd/**'
- '!src/netbsd/**'
- '!src/openbsd/**'
- 'include/**'
- 'Makefile'

View File

@ -11,6 +11,7 @@ on:
- 'src/**'
- '!src/linux/**'
- '!src/freebsd/**'
- '!src/netbsd/**'
- '!src/openbsd/**'
- 'include/**'
- 'Makefile'
@ -22,6 +23,7 @@ on:
- 'src/**'
- '!src/linux/**'
- '!src/freebsd/**'
- '!src/netbsd/**'
- '!src/openbsd/**'
- 'include/**'
- 'Makefile'

65
.github/workflows/continuous-build-netbsd.yml vendored Executable file
View File

@ -0,0 +1,65 @@
name: Continuous Build NetBSD
on:
workflow_dispatch:
push:
branches:
- main
tags-ignore:
- '*.*'
paths:
- 'src/**'
- '!src/linux/**'
- '!src/osx/**'
- '!src/freebsd/**'
- '!src/openbsd/**'
- 'include/**'
- 'Makefile'
- '.github/workflows/continuous-build-netbsd.yml'
pull_request:
branches:
- main
paths:
- 'src/**'
- '!src/linux/**'
- '!src/osx/**'
- '!src/freebsd/**'
- '!src/openbsd/**'
- 'include/**'
- 'Makefile'
- '.github/workflows/continuous-build-netbsd.yml'
jobs:
build-netbsd:
runs-on: ubuntu-22.04
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Compile
uses: vmactions/netbsd-vm@v1
with:
release: '9.3'
usesh: true
prepare: |
PATH="/usr/pkg/sbin:/usr/pkg/bin:$PATH"
PKG_PATH="https://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/amd64/9.3/All/"
export PATH PKG_PATH
/usr/sbin/pkg_add pkgin
pkgin -y install gmake gcc10 coreutils git
git config --global --add safe.directory /home/runner/work/btop/btop
run: |
gmake CXX=/usr/pkg/gcc10/bin/g++ CXXFLAGS='-DNDEBUG -I/usr/pkg/gcc10/include -I/usr/include -I/usr/pkg/include' STATIC=true STRIP=true
GIT_HASH=$(git rev-parse --short "$GITHUB_SHA")
mv bin/btop bin/btop-GCC10-"$GIT_HASH"
ls -alh bin
- uses: actions/upload-artifact@v3
with:
name: btop-x86_64-netbsd-9.3
path: 'bin/*'
if-no-files-found: error

View File

@ -12,6 +12,7 @@ on:
- '!src/linux/**'
- '!src/osx/**'
- '!src/freebsd/**'
- '!src/netbsd/**'
- 'include/**'
- 'Makefile'
- '.github/workflows/continuous-build-openbsd.yml'
@ -23,6 +24,7 @@ on:
- '!src/linux/**'
- '!src/osx/**'
- '!src/freebsd/**'
- '!src/netbsd/**'
- 'include/**'
- 'Makefile'
- '.github/workflows/continuous-build-openbsd.yml'

View File

@ -9,6 +9,8 @@ on:
- 'src/**'
- '!src/osx/**'
- '!src/freebsd/**'
- '!src/netbsd/**'
- '!src/openbsd/**'
- 'include/**'
- 'Makefile'
- '.github/workflows/test-snap-can-build.yml'
@ -18,6 +20,8 @@ on:
- 'src/**'
- '!src/osx/**'
- '!src/freebsd/**'
- '!src/netbsd/**'
- '!src/openbsd/**'
- 'include/**'
- 'Makefile'
- '.github/workflows/test-snap-can-build.yml'

View File

@ -66,6 +66,8 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
target_sources(btop PRIVATE src/freebsd/btop_collect.cpp)
elseif(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
target_sources(btop PRIVATE src/openbsd/btop_collect.cpp src/openbsd/sysctlbyname.cpp)
elseif(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
target_sources(btop PRIVATE src/netbsd/btop_collect.cpp)
elseif(LINUX)
target_sources(btop PRIVATE src/linux/btop_collect.cpp)
else()
@ -208,6 +210,13 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
endif()
find_package(kvm REQUIRED)
target_link_libraries(btop kvm::kvm)
elseif(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(btop PRIVATE -static-libstdc++ -std=c++20 -DNDEBUG)
endif()
find_package(kvm REQUIRED)
find_package(proplib REQUIRED)
target_link_libraries(btop kvm::kvm proplib::proplib)
endif()

View File

@ -146,6 +146,12 @@ else ifeq ($(PLATFORM_LC),openbsd)
override ADDFLAGS += -lkvm -static-libstdc++
export MAKE = gmake
SU_GROUP := wheel
else ifeq ($(PLATFORM_LC),netbsd)
PLATFORM_DIR := netbsd
THREADS := $(shell sysctl -n hw.ncpu || echo 1)
override ADDFLAGS += -lkvm -lprop
export MAKE = gmake
SU_GROUP := wheel
else
$(error $(shell printf "\033[1;91mERROR: \033[97mUnsupported platform ($(PLATFORM))\033[0m"))
endif

View File

@ -0,0 +1,23 @@
# SPDX-License-Identifier: Apache-2.0
#
# Find proplib property container object library
#
if(BSD)
find_path(proplib_INCLUDE_DIR NAMES prop/proplib.h)
find_library(proplib_LIBRARY NAMES libprop prop)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(proplib REQUIRED_VARS proplib_LIBRARY proplib_INCLUDE_DIR)
if(proplib_FOUND AND NOT TARGET proplib::proplib)
add_library(proplib::proplib UNKNOWN IMPORTED)
set_target_properties(proplib::proplib PROPERTIES
IMPORTED_LOCATION "${proplib_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${proplib_INCLUDE_DIR}"
)
endif()
mark_as_advanced(proplib_INCLUDE_DIR proplib_LIBRARY)
endif()

View File

@ -293,7 +293,7 @@ void clean_quit(int sig) {
Global::quitting = true;
Runner::stop();
if (Global::_runner_started) {
#if defined __APPLE__ || defined __OpenBSD__
#if defined __APPLE__ || defined __OpenBSD__ || defined __NetBSD__
if (pthread_join(Runner::runner_id, nullptr) != 0) {
Logger::warning("Failed to join _runner thread on exit!");
pthread_cancel(Runner::runner_id);
@ -329,7 +329,7 @@ void clean_quit(int sig) {
const auto excode = (sig != -1 ? sig : 0);
#if defined __APPLE__ || defined __OpenBSD__
#if defined __APPLE__ || defined __OpenBSD__ || defined __NetBSD__
_Exit(excode);
#else
quick_exit(excode);
@ -1024,7 +1024,7 @@ int main(int argc, char **argv) {
Config::set("tty_mode", true);
Logger::info("Forcing tty mode: setting 16 color mode and using tty friendly graph symbols");
}
#if not defined __APPLE__ && not defined __OpenBSD__
#if not defined __APPLE__ && not defined __OpenBSD__ && not defined __NetBSD__
else if (not Global::arg_tty and Term::current_tty.starts_with("/dev/tty")) {
Config::set("tty_mode", true);
Logger::info("Real tty detected: setting 16 color mode and using tty friendly graph symbols");

View File

@ -34,7 +34,7 @@ tab-size = 4
#include <ifaddrs.h>
// clang-format on
#if defined(__FreeBSD__) || defined(__OpenBSD__)
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
# include <kvm.h>
#endif
@ -93,7 +93,7 @@ namespace Shared {
extern long coreCount, page_size, clk_tck;
#if defined(__FreeBSD__) || defined(__OpenBSD__)
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
struct KvmDeleter {
void operator()(kvm_t* handle) {
kvm_close(handle);

1414
src/netbsd/btop_collect.cpp Normal file

File diff suppressed because it is too large Load Diff