build: Move non-macro variables into settings.cpp
Since APP_VERSION is different for every commit and almost all file include settings.hpp, the whole project has to be rebuilt for every commit. With this, hopefully, this can be greatly reduced and only changed files need to be rebuilt. This will also help ccache
This commit is contained in:
parent
c6194c06eb
commit
6f882ba3b2
@ -4,8 +4,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#define APP_NAME "@PROJECT_NAME@"
|
extern const char* const APP_NAME;
|
||||||
#cmakedefine APP_VERSION "@APP_VERSION@"
|
extern const char* const APP_VERSION;
|
||||||
|
|
||||||
#cmakedefine01 ENABLE_ALSA
|
#cmakedefine01 ENABLE_ALSA
|
||||||
#cmakedefine01 ENABLE_MPD
|
#cmakedefine01 ENABLE_MPD
|
||||||
@ -59,54 +59,20 @@ static const int SINK_PRIORITY_SCREEN{2};
|
|||||||
static const int SINK_PRIORITY_TRAY{3};
|
static const int SINK_PRIORITY_TRAY{3};
|
||||||
static const int SINK_PRIORITY_MODULE{4};
|
static const int SINK_PRIORITY_MODULE{4};
|
||||||
|
|
||||||
static constexpr const char* ALSA_SOUNDCARD{"@SETTING_ALSA_SOUNDCARD@"};
|
extern const char* const ALSA_SOUNDCARD;
|
||||||
static constexpr const char* BSPWM_SOCKET_PATH{"@SETTING_BSPWM_SOCKET_PATH@"};
|
extern const char* const BSPWM_SOCKET_PATH;
|
||||||
static constexpr const char* BSPWM_STATUS_PREFIX{"@SETTING_BSPWM_STATUS_PREFIX@"};
|
extern const char* const BSPWM_STATUS_PREFIX;
|
||||||
static constexpr const char* CONNECTION_TEST_IP{"@SETTING_CONNECTION_TEST_IP@"};
|
extern const char* const CONNECTION_TEST_IP;
|
||||||
static constexpr const char* PATH_ADAPTER{"@SETTING_PATH_ADAPTER@"};
|
extern const char* const PATH_ADAPTER;
|
||||||
static constexpr const char* PATH_BACKLIGHT{"@SETTING_PATH_BACKLIGHT@"};
|
extern const char* const PATH_BACKLIGHT;
|
||||||
static constexpr const char* PATH_BATTERY{"@SETTING_PATH_BATTERY@"};
|
extern const char* const PATH_BATTERY;
|
||||||
static constexpr const char* PATH_CPU_INFO{"@SETTING_PATH_CPU_INFO@"};
|
extern const char* const PATH_CPU_INFO;
|
||||||
static constexpr const char* PATH_MEMORY_INFO{"@SETTING_PATH_MEMORY_INFO@"};
|
extern const char* const PATH_MEMORY_INFO;
|
||||||
static constexpr const char* PATH_MESSAGING_FIFO{"@SETTING_PATH_MESSAGING_FIFO@"};
|
extern const char* const PATH_MESSAGING_FIFO;
|
||||||
static constexpr const char* PATH_TEMPERATURE_INFO{"@SETTING_PATH_TEMPERATURE_INFO@"};
|
extern const char* const PATH_TEMPERATURE_INFO;
|
||||||
|
|
||||||
const auto version_details = [](const std::vector<std::string>& args) {
|
extern bool version_details(const std::vector<std::string>& args);
|
||||||
for (auto&& arg : args) {
|
|
||||||
if (arg.compare(0, 3, "-vv") == 0)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
// clang-format off
|
extern void print_build_info(bool extended = false);
|
||||||
const auto print_build_info = [](bool extended = false) {
|
|
||||||
printf("%s %s\n\n", APP_NAME, APP_VERSION);
|
|
||||||
printf("Features: %calsa %ccurl %ci3 %cmpd %cnetwork(%s) %cpulseaudio %cxkeyboard\n",
|
|
||||||
(ENABLE_ALSA ? '+' : '-'),
|
|
||||||
(ENABLE_CURL ? '+' : '-'),
|
|
||||||
(ENABLE_I3 ? '+' : '-'),
|
|
||||||
(ENABLE_MPD ? '+' : '-'),
|
|
||||||
(ENABLE_NETWORK ? '+' : '-'),
|
|
||||||
WIRELESS_LIB,
|
|
||||||
(ENABLE_PULSEAUDIO ? '+' : '-'),
|
|
||||||
(ENABLE_XKEYBOARD ? '+' : '-'));
|
|
||||||
if (extended) {
|
|
||||||
printf("\n");
|
|
||||||
printf("X extensions: %crandr (%cmonitors) %ccomposite %cxkb %cxrm %cxcursor\n",
|
|
||||||
(WITH_XRANDR ? '+' : '-'),
|
|
||||||
(WITH_XRANDR_MONITORS ? '+' : '-'),
|
|
||||||
(WITH_XCOMPOSITE ? '+' : '-'),
|
|
||||||
(WITH_XKB ? '+' : '-'),
|
|
||||||
(WITH_XRM ? '+' : '-'),
|
|
||||||
(WITH_XCURSOR ? '+' : '-'));
|
|
||||||
printf("\n");
|
|
||||||
printf("Build type: @CMAKE_BUILD_TYPE@\n");
|
|
||||||
printf("Compiler: @CMAKE_CXX_COMPILER@\n");
|
|
||||||
printf("Compiler flags: @CMAKE_CXX_FLAGS@ ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}\n");
|
|
||||||
printf("Linker flags: @CMAKE_EXE_LINKER_FLAGS@ ${CMAKE_EXE_LINKER_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}\n");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
// clang-format on
|
|
||||||
|
|
||||||
// vim:ft=cpp
|
// vim:ft=cpp
|
||||||
|
@ -7,6 +7,13 @@
|
|||||||
file(GLOB_RECURSE files RELATIVE ${CMAKE_CURRENT_LIST_DIR} *.c[p]*)
|
file(GLOB_RECURSE files RELATIVE ${CMAKE_CURRENT_LIST_DIR} *.c[p]*)
|
||||||
list(REMOVE_ITEM files main.cpp ipc.cpp)
|
list(REMOVE_ITEM files main.cpp ipc.cpp)
|
||||||
|
|
||||||
|
configure_file(
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/settings.cpp.cmake
|
||||||
|
${CMAKE_BINARY_DIR}/generated-sources/settings.cpp
|
||||||
|
ESCAPE_QUOTES)
|
||||||
|
|
||||||
|
list(APPEND files ${CMAKE_BINARY_DIR}/generated-sources/settings.cpp)
|
||||||
|
|
||||||
if(NOT ENABLE_ALSA)
|
if(NOT ENABLE_ALSA)
|
||||||
list(REMOVE_ITEM files modules/alsa.cpp)
|
list(REMOVE_ITEM files modules/alsa.cpp)
|
||||||
list(REMOVE_ITEM files adapters/alsa/control.cpp)
|
list(REMOVE_ITEM files adapters/alsa/control.cpp)
|
||||||
@ -55,7 +62,6 @@ endif()
|
|||||||
if(NOT WITH_XCURSOR)
|
if(NOT WITH_XCURSOR)
|
||||||
list(REMOVE_ITEM files x11/cursor.cpp)
|
list(REMOVE_ITEM files x11/cursor.cpp)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# Target: polybar {{{
|
# Target: polybar {{{
|
||||||
|
56
src/settings.cpp.cmake
Normal file
56
src/settings.cpp.cmake
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#include "settings.hpp"
|
||||||
|
|
||||||
|
const char* const APP_NAME{"@PROJECT_NAME@"};
|
||||||
|
const char* const APP_VERSION{"@APP_VERSION@"};
|
||||||
|
|
||||||
|
const char* const ALSA_SOUNDCARD{"@SETTING_ALSA_SOUNDCARD@"};
|
||||||
|
const char* const BSPWM_SOCKET_PATH{"@SETTING_BSPWM_SOCKET_PATH@"};
|
||||||
|
const char* const BSPWM_STATUS_PREFIX{"@SETTING_BSPWM_STATUS_PREFIX@"};
|
||||||
|
const char* const CONNECTION_TEST_IP{"@SETTING_CONNECTION_TEST_IP@"};
|
||||||
|
const char* const PATH_ADAPTER{"@SETTING_PATH_ADAPTER@"};
|
||||||
|
const char* const PATH_BACKLIGHT{"@SETTING_PATH_BACKLIGHT@"};
|
||||||
|
const char* const PATH_BATTERY{"@SETTING_PATH_BATTERY@"};
|
||||||
|
const char* const PATH_CPU_INFO{"@SETTING_PATH_CPU_INFO@"};
|
||||||
|
const char* const PATH_MEMORY_INFO{"@SETTING_PATH_MEMORY_INFO@"};
|
||||||
|
const char* const PATH_MESSAGING_FIFO{"@SETTING_PATH_MESSAGING_FIFO@"};
|
||||||
|
const char* const PATH_TEMPERATURE_INFO{"@SETTING_PATH_TEMPERATURE_INFO@"};
|
||||||
|
|
||||||
|
bool version_details(const std::vector<std::string>& args) {
|
||||||
|
for (auto&& arg : args) {
|
||||||
|
if (arg.compare(0, 3, "-vv") == 0)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
|
void print_build_info(bool extended) {
|
||||||
|
printf("%s %s\n\n", APP_NAME, APP_VERSION);
|
||||||
|
printf("Features: %calsa %ccurl %ci3 %cmpd %cnetwork(%s) %cpulseaudio %cxkeyboard\n",
|
||||||
|
(ENABLE_ALSA ? '+' : '-'),
|
||||||
|
(ENABLE_CURL ? '+' : '-'),
|
||||||
|
(ENABLE_I3 ? '+' : '-'),
|
||||||
|
(ENABLE_MPD ? '+' : '-'),
|
||||||
|
(ENABLE_NETWORK ? '+' : '-'),
|
||||||
|
WIRELESS_LIB,
|
||||||
|
(ENABLE_PULSEAUDIO ? '+' : '-'),
|
||||||
|
(ENABLE_XKEYBOARD ? '+' : '-'));
|
||||||
|
if (extended) {
|
||||||
|
printf("\n");
|
||||||
|
printf("X extensions: %crandr (%cmonitors) %ccomposite %cxkb %cxrm %cxcursor\n",
|
||||||
|
(WITH_XRANDR ? '+' : '-'),
|
||||||
|
(WITH_XRANDR_MONITORS ? '+' : '-'),
|
||||||
|
(WITH_XCOMPOSITE ? '+' : '-'),
|
||||||
|
(WITH_XKB ? '+' : '-'),
|
||||||
|
(WITH_XRM ? '+' : '-'),
|
||||||
|
(WITH_XCURSOR ? '+' : '-'));
|
||||||
|
printf("\n");
|
||||||
|
printf("Build type: @CMAKE_BUILD_TYPE@\n");
|
||||||
|
printf("Compiler: @CMAKE_CXX_COMPILER@\n");
|
||||||
|
printf("Compiler flags: @CMAKE_CXX_FLAGS@ ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}\n");
|
||||||
|
printf("Linker flags: @CMAKE_EXE_LINKER_FLAGS@ ${CMAKE_EXE_LINKER_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
|
// vim:ft=cpp
|
@ -14,7 +14,7 @@ http_downloader::http_downloader(int connection_timeout) {
|
|||||||
curl_easy_setopt(m_curl, CURLOPT_CONNECTTIMEOUT, connection_timeout);
|
curl_easy_setopt(m_curl, CURLOPT_CONNECTTIMEOUT, connection_timeout);
|
||||||
curl_easy_setopt(m_curl, CURLOPT_FOLLOWLOCATION, true);
|
curl_easy_setopt(m_curl, CURLOPT_FOLLOWLOCATION, true);
|
||||||
curl_easy_setopt(m_curl, CURLOPT_NOSIGNAL, true);
|
curl_easy_setopt(m_curl, CURLOPT_NOSIGNAL, true);
|
||||||
curl_easy_setopt(m_curl, CURLOPT_USERAGENT, "polybar/" APP_VERSION);
|
curl_easy_setopt(m_curl, CURLOPT_USERAGENT, "polybar/" + string{APP_VERSION});
|
||||||
curl_easy_setopt(m_curl, CURLOPT_WRITEFUNCTION, http_downloader::write);
|
curl_easy_setopt(m_curl, CURLOPT_WRITEFUNCTION, http_downloader::write);
|
||||||
curl_easy_setopt(m_curl, CURLOPT_FORBID_REUSE, true);
|
curl_easy_setopt(m_curl, CURLOPT_FORBID_REUSE, true);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user