diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..32129a6 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,20 @@ +pkgname=fantasize +pkgver=0.1.0 +pkgrel=1 +pkgdesc='C++ fan control for Linux' +url='https://github.com/Tabascl/fantasize.git' +source=("$pkgname-$pkgver.tar.gz::https://github.com/Tabascl/fantasize/archive/v$pkgver.tar.gz") +backup=("etc/fantasize/fans.json") +arch=('x86_64') +license=('GPL3') +makedepends=('git' 'cmake' 'nlohmann-json' 'boost' 'cuda') +sha256sums=('ce998dabe4e88ee6b6a4ab99ad7afbf90fad98f47972fac658e26cc95a17d061') + +build() { + cmake -S "$pkgname-$pkgver/app" -B build -DCMAKE_BUILD_TYPE=Release + cmake --build build +} + +package() { + DESTDIR="$pkgdir" cmake --install build +} diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index a9dde3b..b5b2969 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -1,13 +1,13 @@ cmake_minimum_required(VERSION 3.0) -project(fantasize) +project(fantasize VERSION 0.1.0) -set(CMAKE_BUILD_TYPE Debug) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) find_package(nlohmann_json 3.11.2 REQUIRED) +find_package(Boost 1.80 COMPONENTS program_options REQUIRED) -add_executable(app +add_executable(${PROJECT_NAME} src/main.cxx src/sensor/LMSensorsFacade.cxx src/sensor/GPUSensorsFacade.cxx @@ -26,7 +26,9 @@ add_executable(app src/App.cxx ) -set_property(TARGET app PROPERTY CXX_STANDARD 20) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 20) -target_include_directories(app PUBLIC include /opt/cuda) -target_link_libraries(app PUBLIC sensors nvidia-ml nlohmann_json::nlohmann_json tbb) +target_include_directories(${PROJECT_NAME} PUBLIC include /opt/cuda) +target_link_libraries(${PROJECT_NAME} PUBLIC sensors nvidia-ml nlohmann_json::nlohmann_json tbb ${Boost_LIBRARIES}) + +install(TARGETS ${PROJECT_NAME} DESTINATION bin) diff --git a/app/src/FanGenerator.cxx b/app/src/FanGenerator.cxx index 3593c4f..8f64d73 100644 --- a/app/src/FanGenerator.cxx +++ b/app/src/FanGenerator.cxx @@ -56,11 +56,6 @@ FanGenerator::FindFans(vector> rpmSensors, c->pwm(100); } - cout << "Resetting all fans" << endl; - for (auto c : pwmControls) { - c->Reset(); - } - return mapping; } diff --git a/app/src/fan/HwmonFan.cxx b/app/src/fan/HwmonFan.cxx index 0ccd483..37b83aa 100644 --- a/app/src/fan/HwmonFan.cxx +++ b/app/src/fan/HwmonFan.cxx @@ -35,6 +35,7 @@ void HwmonFan::MinPWM(int value) { mMinPWM = value; } void HwmonFan::StartPWM(int value) { mStartPWM = value; } void HwmonFan::FindMinPWM() { + cout << "Looking for minimal PWM" << endl; int minPWM = 0; mMinPWM = 0; diff --git a/app/src/main.cxx b/app/src/main.cxx index 3bcc8dd..17c4456 100644 --- a/app/src/main.cxx +++ b/app/src/main.cxx @@ -1,18 +1,45 @@ +#include +#include +#include +#include #include #include +#include + #include +namespace po = boost::program_options; + App app; +static int doInitialSetup = 0; + void signal_handler(int s) { app.Shutdown(); } -int main() { +int main(int argc, char **argv) { signal(SIGINT, signal_handler); + po::options_description desc("Allowed options"); + desc.add_options()("help", "produce help message")("setup", po::bool_switch(), + "run initial setup"); + + po::variables_map vm; + po::store(po::parse_command_line(argc, argv, desc), vm); + po::notify(vm); + try { - app.Init(); - app.NormalOperation(); + if (vm.count("help")) { + std::cout << desc << "\n"; + return 0; + } + + if (vm.count("setup") && vm["setup"].as()) { + app.InitialSetup(); + } else { + app.Init(); + app.NormalOperation(); + } } catch (const std::exception &e) { std::cout << "An exception was caught: " << e.what() << std::endl; }