From 8a98fb78b67127c72cf67bc1237f8076db648b3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20V=C3=A1rady?= Date: Sat, 28 Jan 2017 20:26:27 +0100 Subject: [PATCH] fix(version): Follow APP_VERSION in POLYBAR_NS --- common/version.sh | 3 +++ include/CMakeLists.txt | 4 ++++ include/common.hpp | 5 +++-- include/settings.hpp.cmake | 4 ++++ include/version.hpp | 1 + 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/common/version.sh b/common/version.sh index db88e141..290b1f0b 100755 --- a/common/version.sh +++ b/common/version.sh @@ -13,8 +13,11 @@ main() { set -- "$(git describe --tags --dirty=-dev)" fi + GIT_TAG_NAMESPACE=$(echo "v$1" | sed "s/[^a-zA-Z0-9_]/_/g") + msg "Current version: $1" sed -r "/#define GIT_TAG/s/GIT_TAG .*/GIT_TAG \"$1\"/" -i include/version.hpp + sed -r "/#define GIT_TAG_NAMESPACE/s/GIT_TAG_NAMESPACE .*/GIT_TAG_NAMESPACE $GIT_TAG_NAMESPACE/" -i include/version.hpp if git diff include/version.hpp 2>/dev/null | grep -q .; then msg "Updated include/version.hpp" diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index bfbf5bff..b6e5c60a 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -29,6 +29,10 @@ execute_process(COMMAND git describe --tags --dirty=-git OUTPUT_VARIABLE APP_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET) +if(APP_VERSION) + STRING(REGEX REPLACE "[^a-zA-Z0-9_]" "_" APP_VERSION_NAMESPACE "v${APP_VERSION}") +endif() + configure_file( ${CMAKE_CURRENT_LIST_DIR}/settings.hpp.cmake ${CMAKE_CURRENT_LIST_DIR}/settings.hpp diff --git a/include/common.hpp b/include/common.hpp index 65a7faa6..e29ef35b 100644 --- a/include/common.hpp +++ b/include/common.hpp @@ -5,13 +5,14 @@ #include #include +#include "settings.hpp" + #define POLYBAR_NS \ namespace polybar { \ - inline namespace v2_0_0 { + inline namespace APP_VERSION_NAMESPACE { #define POLYBAR_NS_END \ } \ } -#define POLYBAR_NS_PATH "polybar::v2_0_0" #ifndef PIPE_READ #define PIPE_READ 0 diff --git a/include/settings.hpp.cmake b/include/settings.hpp.cmake index d3dd34bd..1f21b2b7 100644 --- a/include/settings.hpp.cmake +++ b/include/settings.hpp.cmake @@ -11,6 +11,10 @@ #ifndef APP_VERSION #define APP_VERSION GIT_TAG #endif +#cmakedefine APP_VERSION_NAMESPACE @APP_VERSION_NAMESPACE@ +#ifndef APP_VERSION_NAMESPACE +#define APP_VERSION_NAMESPACE GIT_TAG_NAMESPACE +#endif #define BASE_PATH "@PROJECT_SOURCE_DIR@" #cmakedefine01 ENABLE_ALSA diff --git a/include/version.hpp b/include/version.hpp index cfe533e0..b3a9bd95 100644 --- a/include/version.hpp +++ b/include/version.hpp @@ -1,3 +1,4 @@ #pragma once #define GIT_TAG "3.0.3" +#define GIT_TAG_NAMESPACE v3_0_3