From 335617f1472645f78fc6868d0448114f27132d5c Mon Sep 17 00:00:00 2001 From: Hayden Briese Date: Wed, 22 Jul 2020 12:49:39 +1000 Subject: [PATCH] - Fixed service not warning of requiring root - Removed unnecessary build options - Added build type message - Further broke down protobuf type specific definitions Signed-off-by: Hayden Briese --- CMakeLists.txt | 14 ++++++-------- README.md | 15 +++++++-------- proto/DevicesSpec.proto | 6 ++++-- src/Client.cpp | 7 ------- src/main.cpp | 4 +++- 5 files changed, 20 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 64eddc4..8579dc4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,8 @@ if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) endif () +message("Build type: ${CMAKE_BUILD_TYPE}") + ## Release flags set(OPTIMIZATION_FLAG "-O3") if (CMAKE_BUILD_TYPE STREQUAL "Release") @@ -24,19 +26,15 @@ if (CMAKE_BUILD_TYPE STREQUAL "Release") endif () ## Debug flags -option(OPTIMIZE_DEBUG "Optimize debug build - useful for profiling" OFF) if (CMAKE_BUILD_TYPE STREQUAL "Debug") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -Wpedantic") - if (OPTIMIZE_DEBUG) - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${OPTIMIZATION_FLAG}") - endif () endif () ## Generate protobuf source files execute_process(COMMAND "./gen_proto.sh" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} RESULT_VARIABLE GENPROTO_RES OUTPUT_VARIABLE GENPROTO_OUT ERROR_VARIABLE GENPROTO_OUT) if (${GENPROTO_RES} STREQUAL "0") - message("Generated protobuf files ${GENPROTO_OUT}") + message("Protobuf files generated ${GENPROTO_OUT}") else () message("Failed to generate protobuf files: ${GENPROTO_OUT}") endif () @@ -82,7 +80,7 @@ include_directories(${SENSORS_INCLUDE_DIR}) set(LIBS ${LIBS} ${SENSORS_LIBRARY}) ## NVIDIA Support -option(NVIDIA_SUPPORT "Build with NVIDIA GPU support" ON) +option(NVIDIA_SUPPORT "Support for NVIDIA GPUs" ON) if (NVIDIA_SUPPORT) find_package(X11) find_package(NVCtrl) @@ -124,7 +122,7 @@ include_directories(${GRPC_INCLUDE_DIRS}) set(LIBS ${LIBS} ${GRPC_LIBRARIES}) ## Google Perf Tools profiling -option(PROFILE "Build debug release with support for CPU and heap profiling - REQUIRES Google Perf Tools" OFF) +option(PROFILE "Support for Google Perf Tools CPU & heap profilers" OFF) if (PROFILE AND CMAKE_BUILD_TYPE STREQUAL "Debug") find_package(Profiler REQUIRED) find_package(TCMalloc REQUIRED) @@ -152,7 +150,7 @@ if (CMAKE_INSTALL_BINDIR) endif () ## Run lint if debug build -option(LINT "Run linter with debug build" OFF) +option(LINT "Run Clang-Tidy" OFF) if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND LINT) set(LINT_CXX_FLAGS "${CMAKE_CXX_FLAGS_DEBUG} -std=c++${CMAKE_CXX_STANDARD}") set(LINT_CHECKS "*,-clang-diagnostic-unused-command-line-argument,\ diff --git a/README.md b/README.md index a813e04..737a53c 100644 --- a/README.md +++ b/README.md @@ -167,7 +167,7 @@ https://wiki.archlinux.org/index.php/Running_GUI_applications_as_root sudo apt install clang cmake lm-sensors libsensors5 libsensors4-dev libboost-system-dev libboost-filesystem-dev libboost-log-dev libpthread-stubs0-dev libpstreams-dev libprotobuf-dev protobuf-compiler libgrpc++-dev protobuf-compiler protobuf-compiler-grpc libxnvctrl-dev libx11-dev git clone https://github.com/hbriese/fancon.git && cd fancon; mkdir build; cd build -cmake -DCMAKE_BUILD_TYPE=Release -DNVIDIA_SUPPORT=ON .. && make -j && sudo make install +cmake -DNVIDIA_SUPPORT=ON .. && make -j && sudo make install ``` ##### Without NVIDIA support: @@ -175,12 +175,11 @@ cmake -DCMAKE_BUILD_TYPE=Release -DNVIDIA_SUPPORT=ON .. && make -j && sudo make sudo apt install clang cmake lm-sensors libsensors5 libsensors4-dev libboost-system-dev libboost-filesystem-dev libboost-log-dev libpthread-stubs0-dev libpstreams-dev libprotobuf-dev protobuf-compiler libgrpc++-dev protobuf-compiler protobuf-compiler-grpc git clone https://github.com/hbriese/fancon.git && cd fancon; mkdir build; cd build -cmake -DCMAKE_BUILD_TYPE=Release -DNVIDIA_SUPPORT=OFF .. && make -j && sudo make install +cmake -DNVIDIA_SUPPORT=OFF .. && make -j && sudo make install ``` -| CMake Option | Default | Description | -|:-----------------|:-------:| :-------------------------------------------------------------------------------------------| -| NVIDIA_SUPPORT | ON | Support for NVIDIA GPUs | -| OPTIMIZE_DEBUG | OFF | Enable compiler optimizations on debug build | -| PROFILE | OFF | Support for Google Perf Tools CPU & heap profilers; only recommended for debug builds | -| LINT | OFF | Run lint checker (Clang-Tidy) | +| CMake Option | Default | Description | +|:-----------------|:-------:| :--------------------------------------------------| +| NVIDIA_SUPPORT | ON | Support for NVIDIA GPUs | +| PROFILE | OFF | Support for Google Perf Tools CPU & heap profilers | +| LINT | OFF | Run Clang-Tidy | diff --git a/proto/DevicesSpec.proto b/proto/DevicesSpec.proto index 626d019..12b2e29 100644 --- a/proto/DevicesSpec.proto +++ b/proto/DevicesSpec.proto @@ -35,10 +35,12 @@ message Fan { uint64 interval = 7; bool ignore = 8; - // SYS + // SYS & DELL string pwm_path = 10; string rpm_path = 11; - string enable_path = 12; + + // SYS + string enable_path = 12; int32 driver_flag = 13; // NV diff --git a/src/Client.cpp b/src/Client.cpp index 77e2040..6f0f156 100644 --- a/src/Client.cpp +++ b/src/Client.cpp @@ -159,13 +159,6 @@ bool fc::Client::Test(bool forced) { } return true; - - // for (auto &t : threads) { - // if (t.joinable()) - // t.join(); - // } - // - // return true; } bool fc::Client::Test(const string &fan_label, bool forced) { diff --git a/src/main.cpp b/src/main.cpp index 1b2ffa9..23d2777 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,8 +18,10 @@ int main(int argc, char *argv[]) { // SERVICE if (args.service) { - if (!is_root()) + if (!is_root()) { + LOG(llvl::error) << "Service must be run as root"; return EXIT_FAILURE; + } fc::Service service(config_path, args.daemon); service.run();