Specify git hash when compiled from source. Bug 763986.

This commit is contained in:
Gautier Pelloux-Prayer 2016-09-29 13:49:02 +02:00 committed by Michael James Gratton
parent 6241b11494
commit e7ace76507
6 changed files with 53 additions and 20 deletions

View file

@ -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

14
cmake/gitversion.cmake Normal file
View file

@ -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")

View file

@ -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}/
)

View file

@ -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;

View file

@ -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);
}

View file

@ -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@";
}