[geary] Specify git hash when compiled from source. Bug 763986.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary] Specify git hash when compiled from source. Bug 763986.
- Date: Fri, 30 Sep 2016 05:26:22 +0000 (UTC)
commit e7ace76507463b84b3347a19800041e8d6bd83d4
Author: Gautier Pelloux-Prayer <gautier+git damsy net>
Date: Thu Sep 29 13:49:02 2016 +0200
Specify git hash when compiled from source. Bug 763986.
CMakeLists.txt | 20 ++++++++++++--------
cmake/gitversion.cmake | 14 ++++++++++++++
src/CMakeLists.txt | 17 ++++++++++++++---
src/client/application/geary-application.vala | 5 ++---
src/console/main.vala | 8 ++------
src/geary-version.vala.in | 9 +++++++++
6 files changed, 53 insertions(+), 20 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b23b332..2966f60 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,7 +19,7 @@ list(APPEND
#
set(GETTEXT_PACKAGE "geary")
set(RELEASE_NAME "Lightweight email client for GNOME.")
-set(VERSION "0.11.0")
+set(VERSION "0.11.2-dev")
set(VERSION_INFO "Release")
set(LANGUAGE_SUPPORT_DIRECTORY ${CMAKE_INSTALL_PREFIX}/share/locale)
@@ -123,6 +123,8 @@ else()
endif()
endif()
+find_package(Git QUIET)
+
# intl
include(Gettext)
if (XGETTEXT_FOUND)
@@ -167,13 +169,15 @@ add_custom_target(
# Dist
# This generates the dist tarballs
-add_custom_target(
- dist
- COMMAND
- git archive --prefix=${ARCHIVE_BASE_NAME}/ HEAD
- | xz -z > ${CMAKE_BINARY_DIR}/${ARCHIVE_FULL_NAME}
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
-)
+if (GIT_FOUND)
+ add_custom_target(
+ dist
+ COMMAND
+ ${GIT_EXECUTABLE} archive --prefix=${ARCHIVE_BASE_NAME}/ HEAD
+ | xz -z > ${CMAKE_BINARY_DIR}/${ARCHIVE_FULL_NAME}
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ )
+endif()
# Ubuntu
# Builds the source Debian package used for the Launchpad PPA
diff --git a/cmake/gitversion.cmake b/cmake/gitversion.cmake
new file mode 100644
index 0000000..303a632
--- /dev/null
+++ b/cmake/gitversion.cmake
@@ -0,0 +1,14 @@
+if (VERSION MATCHES "-dev$")
+ find_package(Git QUIET)
+ if (GIT_FOUND)
+ execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags
+ WORKING_DIRECTORY ${SRC_DIR}
+ OUTPUT_VARIABLE "GIT_VERSION"
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_QUIET)
+ string(REGEX REPLACE "^geary-([0-9\\.]*)-([0-9]*)-(.*)" "\\1+\\2~\\3" GIT_VERSION "${GIT_VERSION}")
+ set(VERSION ${GIT_VERSION})
+ endif()
+endif()
+
+configure_file("${SRC_DIR}/geary-version.vala.in" "${DST_DIR}/geary-version.vala")
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index fadefbb..9972277 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -306,6 +306,8 @@ engine/util/util-string.vala
engine/util/util-synchronization.vala
engine/util/util-time.vala
engine/util/util-trillian.vala
+
+${CMAKE_BINARY_DIR}/geary-version.vala
)
set(CLIENT_SRC
@@ -499,6 +501,15 @@ pkg_check_modules(DEPS REQUIRED
${EXTRA_CLIENT_PKG_CONFIG}
)
+add_custom_target(git-version
+ COMMAND ${CMAKE_COMMAND}
+ -DSRC_DIR=${CMAKE_CURRENT_SOURCE_DIR}
+ -DDST_DIR=${CMAKE_BINARY_DIR}
+ -DVERSION=${VERSION}
+ -P ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/gitversion.cmake
+ BYPRODUCTS ${CMAKE_BINARY_DIR}/geary-version.vala
+)
+
set(ENGINE_PACKAGES
glib-2.0 gee-0.8 gio-2.0 gmime-2.6 posix sqlite3 libxml-2.0
)
@@ -515,10 +526,9 @@ set(CONSOLE_PACKAGES
set(GSETTINGS_DIR ${CMAKE_SOURCE_DIR}/desktop)
-set(CFLAGS
+set(CFLAGS
${DEPS_CFLAGS}
${DEPS_CFLAGS_OTHER}
- -D_VERSION=\"${VERSION}\"
-D_INSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\"
-D_SOURCE_ROOT_DIR=\"${CMAKE_SOURCE_DIR}\"
-D_GSETTINGS_DIR=\"${CMAKE_BINARY_DIR}/gsettings\"
@@ -591,6 +601,7 @@ OPTIONS
)
add_library(geary-static STATIC ${ENGINE_VALA_C})
+add_dependencies(geary-static git-version)
target_link_libraries(geary-static ${DEPS_LIBRARIES} sqlite3-unicodesn gthread-2.0)
# WebKitGTK VAPI generation
@@ -630,7 +641,7 @@ add_custom_command(
TARGET
geary
POST_BUILD
- COMMAND
+ COMMAND
${CMAKE_COMMAND} -E copy geary ${CMAKE_BINARY_DIR}/
)
diff --git a/src/client/application/geary-application.vala b/src/client/application/geary-application.vala
index 6267958..6d7e0b6 100644
--- a/src/client/application/geary-application.vala
+++ b/src/client/application/geary-application.vala
@@ -5,7 +5,6 @@
*/
// Defined by CMake build script.
-extern const string _VERSION;
extern const string _INSTALL_PREFIX;
extern const string _GSETTINGS_DIR;
extern const string _SOURCE_ROOT_DIR;
@@ -20,8 +19,8 @@ public class GearyApplication : Gtk.Application {
public const string WEBSITE = "https://wiki.gnome.org/Apps/Geary";
public const string WEBSITE_LABEL = _("Visit the Geary web site");
public const string BUGREPORT = "https://wiki.gnome.org/Apps/Geary/ReportingABug";
-
- public const string VERSION = _VERSION;
+
+ public const string VERSION = Geary.Version.GEARY_VERSION;
public const string INSTALL_PREFIX = _INSTALL_PREFIX;
public const string GSETTINGS_DIR = _GSETTINGS_DIR;
public const string SOURCE_ROOT_DIR = _SOURCE_ROOT_DIR;
diff --git a/src/console/main.vala b/src/console/main.vala
index 7d0ba12..1523d66 100644
--- a/src/console/main.vala
+++ b/src/console/main.vala
@@ -4,8 +4,6 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-// Defined by CMake build script.
-extern const string _VERSION;
errordomain CommandException {
USAGE,
@@ -13,8 +11,6 @@ errordomain CommandException {
}
class ImapConsole : Gtk.Window {
- public const string VERSION = _VERSION;
-
private const int KEEPALIVE_SEC = 60 * 10;
private Gtk.TextView console = new Gtk.TextView();
@@ -424,8 +420,8 @@ class ImapConsole : Gtk.Window {
Gee.HashMap<string, string> fields = new Gee.HashMap<string, string>();
fields.set("name", "geary-console");
- fields.set("version", VERSION);
-
+ fields.set("version", Geary.Version.GEARY_VERSION);
+
cx.send_async.begin(new Geary.Imap.IdCommand(fields), null, on_id);
}
diff --git a/src/geary-version.vala.in b/src/geary-version.vala.in
new file mode 100644
index 0000000..42a45a3
--- /dev/null
+++ b/src/geary-version.vala.in
@@ -0,0 +1,9 @@
+/* Copyright 2016 Software Freedom Conservancy Inc.
+ *
+ * This software is licensed under the GNU Lesser General Public License
+ * (version 2.1 or later). See the COPYING file in this distribution.
+ */
+
+namespace Geary.Version {
+public const string GEARY_VERSION = "@VERSION@";
+}
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]