Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NetBSD Support. #703

Merged
merged 16 commits into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/cmake-netbsd.yml
Original file line number Diff line number Diff line change
@@ -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: '10.0'
usesh: true
prepare: |
PATH="/usr/pkg/sbin:/usr/pkg/bin:$PATH"
PKG_PATH="https://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/amd64/10.0/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=OFF
cmake --build build --verbose
2 changes: 2 additions & 0 deletions .github/workflows/continuous-build-freebsd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- 'src/**'
- '!src/linux/**'
- '!src/osx/**'
- '!src/netbsd/**'
- '!src/openbsd/**'
- 'include/**'
- 'Makefile'
Expand All @@ -22,6 +23,7 @@ on:
- 'src/**'
- '!src/linux/**'
- '!src/osx/**'
- '!src/netbsd/**'
- '!src/openbsd/**'
- 'include/**'
- 'Makefile'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/continuous-build-gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- 'src/**'
- '!src/osx/**'
- '!src/freebsd/**'
- '!src/netbsd/**'
- '!src/openbsd/**'
- 'include/**'
- 'Makefile'
Expand All @@ -22,6 +23,7 @@ on:
- 'src/**'
- '!src/osx/**'
- '!src/freebsd/**'
- '!src/netbsd/**'
- '!src/openbsd/**'
- 'include/**'
- 'Makefile'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/continuous-build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- 'src/**'
- '!src/osx/**'
- '!src/freebsd/**'
- '!src/netbsd/**'
- '!src/openbsd/**'
- 'include/**'
- 'Makefile'
Expand All @@ -22,6 +23,7 @@ on:
- 'src/**'
- '!src/osx/**'
- '!src/freebsd/**'
- '!src/netbsd/**'
- '!src/openbsd/**'
- 'include/**'
- 'Makefile'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/continuous-build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- 'src/**'
- '!src/linux/**'
- '!src/freebsd/**'
- '!src/netbsd/**'
- '!src/openbsd/**'
- 'include/**'
- 'Makefile'
Expand All @@ -22,6 +23,7 @@ on:
- 'src/**'
- '!src/linux/**'
- '!src/freebsd/**'
- '!src/netbsd/**'
- '!src/openbsd/**'
- 'include/**'
- 'Makefile'
Expand Down
65 changes: 65 additions & 0 deletions .github/workflows/continuous-build-netbsd.yml
Original file line number Diff line number Diff line change
@@ -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: '10.0'
usesh: true
prepare: |
PATH="/usr/pkg/sbin:/usr/pkg/bin:$PATH"
PKG_PATH="https://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/amd64/10.0/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

2 changes: 2 additions & 0 deletions .github/workflows/continuous-build-openbsd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- '!src/linux/**'
- '!src/osx/**'
- '!src/freebsd/**'
- '!src/netbsd/**'
- 'include/**'
- 'Makefile'
- '.github/workflows/continuous-build-openbsd.yml'
Expand All @@ -23,6 +24,7 @@ on:
- '!src/linux/**'
- '!src/osx/**'
- '!src/freebsd/**'
- '!src/netbsd/**'
- 'include/**'
- 'Makefile'
- '.github/workflows/continuous-build-openbsd.yml'
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test-snap-can-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
- 'src/**'
- '!src/osx/**'
- '!src/freebsd/**'
- '!src/netbsd/**'
- '!src/openbsd/**'
- 'include/**'
- 'Makefile'
- '.github/workflows/test-snap-can-build.yml'
Expand All @@ -18,6 +20,8 @@ on:
- 'src/**'
- '!src/osx/**'
- '!src/freebsd/**'
- '!src/netbsd/**'
- '!src/openbsd/**'
- 'include/**'
- 'Makefile'
- '.github/workflows/test-snap-can-build.yml'
Expand Down
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -214,6 +216,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()


Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,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
Expand Down
Loading
Loading