From 43a0ffd54c9c0995ce918abc805cd3661226d11a Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Wed, 17 Aug 2016 13:30:43 -0400 Subject: [PATCH] ocarina: Add OCARINA_{MAJOR, MINOR}_VERSION constants These can be used for version number comparisons as integers, which will be useful once file version numbers are based off of minor versions. Signed-off-by: Anna Schumaker --- CMakeLists.txt | 5 +++-- gui/ocarina.c | 6 +++--- include/core/version.h | 3 +++ tests/core/version.c | 6 ++++++ 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d933b07..170411e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,10 +9,9 @@ option(CONFIG_TESTING_ALBUM_ARTWORK "Enable album art fetching tests" ON) # Configure settings set(CONFIG_MAJOR 6) set(CONFIG_MINOR 5) -set(CONFIG_MICRO 0) set(CONFIG_RC OFF) -set(CONFIG_VERSION "${CONFIG_MAJOR}.${CONFIG_MINOR}.${CONFIG_MICRO}") +set(CONFIG_VERSION "${CONFIG_MAJOR}.${CONFIG_MINOR}") if (CONFIG_RC) set(CONFIG_VERSION "${CONFIG_VERSION}-rc") @@ -36,6 +35,8 @@ if (GIT_FOUND AND IS_DIRECTORY .git/) endif() add_definitions(-DCONFIG_VERSION=\"${CONFIG_VERSION}\") +add_definitions(-DCONFIG_MAJOR=${CONFIG_MAJOR}) +add_definitions(-DCONFIG_MINOR=${CONFIG_MINOR}) find_package(PkgConfig REQUIRED) function(use_module name module) diff --git a/gui/ocarina.c b/gui/ocarina.c index 5141229b..625a8be1 100644 --- a/gui/ocarina.c +++ b/gui/ocarina.c @@ -16,9 +16,9 @@ #define OCARINA_FLAGS (G_APPLICATION_FLAGS_NONE) #ifndef CONFIG_DEBUG -const static gchar *OCARINA_NAME = "org.gtk.ocarina"; +const static gchar *OCARINA_APP = "org.gtk.ocarina"; #else -const static gchar *OCARINA_NAME = "org.gtk.ocarina-debug"; +const static gchar *OCARINA_APP = "org.gtk.ocarina-debug"; #endif struct core_init_data init_data = { @@ -80,7 +80,7 @@ static void __ocarina_shutdown(GApplication *application, gpointer data) int main(int argc, char **argv) { - GtkApplication *ocarina = gtk_application_new(OCARINA_NAME, OCARINA_FLAGS); + GtkApplication *ocarina = gtk_application_new(OCARINA_APP, OCARINA_FLAGS); startup_argc = argc; startup_argv = argv; diff --git a/include/core/version.h b/include/core/version.h index 2d8c1ed0..9613d266 100644 --- a/include/core/version.h +++ b/include/core/version.h @@ -12,6 +12,9 @@ #define OCARINA_NAME "ocarina" #endif +#define OCARINA_MAJOR_VERSION CONFIG_MAJOR +#define OCARINA_MINOR_VERSION CONFIG_MINOR + /* * Scons sets the current version by passing the * -DCONFIG_VERSION macro when Ocarina is compiled. diff --git a/tests/core/version.c b/tests/core/version.c index 3da7b1d5..bec54ca1 100644 --- a/tests/core/version.c +++ b/tests/core/version.c @@ -8,6 +8,12 @@ static void test_version() { g_assert_cmpstr(get_version(), ==, CONFIG_VERSION); g_assert_cmpstr(OCARINA_NAME, ==, "ocarina-test/core/version"); + + g_assert_cmpuint(CONFIG_MAJOR, >=, 0); + g_assert_cmpuint(CONFIG_MINOR, >=, 0); + + g_assert_cmpuint(OCARINA_MAJOR_VERSION, ==, CONFIG_MAJOR); + g_assert_cmpuint(OCARINA_MINOR_VERSION, ==, CONFIG_MINOR); } int main(int argc, char **argv)