From d74dd7f3efda0fcad32dd698cedd2cf940c64334 Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Thu, 3 Nov 2016 19:01:45 +0100 Subject: [PATCH] fix(build): Remove disabled libs --- include/utils/io.hpp | 2 +- src/CMakeLists.txt | 18 ++++++++++++++++++ src/components/controller.cpp | 1 + src/utils/io.cpp | 5 +++-- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/include/utils/io.hpp b/include/utils/io.hpp index f9c4a09a..c89ae35a 100644 --- a/include/utils/io.hpp +++ b/include/utils/io.hpp @@ -20,7 +20,7 @@ namespace io_util { bool poll_read(int fd, int timeout_ms = 1); bool poll_write(int fd, int timeout_ms = 1); - void interrupt_read(int write_fd); + bool interrupt_read(int write_fd); } LEMONBUDDY_NS_END diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9f25fb45..9eee1d4c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,6 +7,7 @@ set(LIBRARY_NAME lib${PROJECT_NAME}) file(GLOB_RECURSE HEADERS RELATIVE ${PROJECT_SOURCE_DIR}/include *.h[p]*) file(GLOB_RECURSE SOURCES RELATIVE ${PROJECT_SOURCE_DIR}/src *.c[p]*) + list(REMOVE_ITEM SOURCES main.cpp) configure_file( @@ -14,6 +15,23 @@ configure_file( ${CMAKE_SOURCE_DIR}/include/config.hpp ESCAPE_QUOTES @ONLY) +# Strip disabled libs {{{ + +if(NOT ENABLE_ALSA) + list(REMOVE_ITEM SOURCES adapters/alsa.cpp modules/volume.cpp) +endif() +if(NOT ENABLE_MPD) + list(REMOVE_ITEM SOURCES adapters/mpd.cpp modules/mpd.cpp) +endif() +if(NOT ENABLE_NETWORK) + list(REMOVE_ITEM SOURCES adapters/net.cpp modules/network.cpp) +endif() +if(NOT ENABLE_I3) + list(REMOVE_ITEM SOURCES modules/i3.cpp utils/i3.cpp) +endif() + +# }}} + # Target: main library {{{ make_library(${LIBRARY_NAME} STATIC diff --git a/src/components/controller.cpp b/src/components/controller.cpp index bb48bcfe..81824304 100644 --- a/src/components/controller.cpp +++ b/src/components/controller.cpp @@ -1,4 +1,5 @@ #include +#include #include "components/controller.hpp" #include "components/signals.hpp" diff --git a/src/utils/io.cpp b/src/utils/io.cpp index 5860b070..59865331 100644 --- a/src/utils/io.cpp +++ b/src/utils/io.cpp @@ -109,9 +109,10 @@ namespace io_util { return poll(fd, POLLOUT, timeout_ms); } - void interrupt_read(int write_fd) { + bool interrupt_read(int write_fd) { char end[1] = {'\n'}; - (void)::write(write_fd, end, 1); + size_t bytes = ::write(write_fd, end, 1); + return bytes > 0; } }