[chronojump/chronojump_version] Uses the version from the output of "git describe" instead of hardcoding in configure.ac.



commit 94d16f332e44e5f83e6a2fbbc2dcc446d6fedd29
Author: Carles Pina i Estany <carles pina cat>
Date:   Mon Oct 17 19:05:56 2016 +0200

    Uses the version from the output of "git describe" instead of hardcoding in configure.ac.
    
    autoconf now executes "git describe" to know which version is going to
    build. The version depends on the latest git tag (see howto_new_release.txt).
    
    There are two versions: the AssemblyVersion (which is like 1.6.2, since
    it only accepts this format) and the new buildInfo.chronojumpVersion and
    buildInfo.chronojumpLastCommitTimestamp (not used at the moment).
    
    The buildInfo.chronojumpVersion is used as display string: it's like
    1.6.2 if it's a build from a tag or
    1.6.2-number_of_commits_since_last_tag-commit_hash. This way we can
    identify the build uniquely even if it was from a specific branch.

 chronojump.csproj      |    2 ++
 configure.ac           |   16 +++++++++++++---
 howto_new_version.txt  |   13 +++++--------
 src/AssemblyInfo.cs.in |    5 ++++-
 src/Makefile.am        |    1 +
 src/buildInfo.cs       |   17 +++++++++++++++++
 src/buildInfo.cs.in    |   14 ++++++++++++++
 src/chronojump.cs      |    2 +-
 src/gui/chronojump.cs  |    6 +++---
 9 files changed, 60 insertions(+), 16 deletions(-)
---
diff --git a/chronojump.csproj b/chronojump.csproj
index 0525028..ac82eed 100644
--- a/chronojump.csproj
+++ b/chronojump.csproj
@@ -888,6 +888,7 @@
     <Compile Include="src\executeProcess.cs" />
     <Compile Include="src\gui\cjCombo.cs" />
     <Compile Include="src\sqlite\usefulObjects.cs" />
+    <Compile Include="src\buildInfo.cs" />
   </ItemGroup>
   <ItemGroup>
     <Folder Include="src\" />
@@ -1916,6 +1917,7 @@
     <None Include="images\xcf\chronojump_icon_graph.xcf" />
     <None Include="images\xcf\delete_last.xcf" />
     <None Include="images\xcf\pulses.xcf" />
+    <None Include="src\buildInfo.cs.in" />
   </ItemGroup>
   <ItemGroup>
     <Content Include="src\chronojump.desktop">
diff --git a/configure.ac b/configure.ac
index f11e19a..2a360e8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,16 @@
-dnl Warning: This is an automatically generated file, do not edit!
-dnl Process this file with autoconf to produce a configure script.
 AC_PREREQ([2.54])
-AC_INIT([chronojump], [1.6.2])
+
+# chronojump variable is used in the Assembly version and can only have major.minor.release
+AC_INIT([chronojump], [m4_esyscmd_s([git describe --abbrev=0])])
+
+# BUILD_CHRONOJUMP_VERSION is used to display it to the user
+# "git describe" is 1.6.2 if it's a tagged version or
+# 1.6.2-number_of_commits_since_last_tag-sha1 if it's not
+AC_SUBST([BUILD_CHRONOJUMP_VERSION], [m4_esyscmd_s([git describe])])
+
+# Date of the last commit
+AC_SUBST([BUILD_CHRONOJUMP_LAST_COMMIT_TIMESTAMP], [m4_esyscmd_s([git log -1 --format=%ct])])
+
 AM_INIT_AUTOMAKE([foreign])
 
 AC_CONFIG_MACRO_DIR([build/m4])
@@ -156,6 +165,7 @@ chronojump_server/Makefile
 encoder/Makefile
 manual/Makefile
 src/AssemblyInfo.cs
+src/buildInfo.cs
 src/chronojump
 src/chronojump.desktop
 src/Mini/chronojump_mini
diff --git a/howto_new_version.txt b/howto_new_version.txt
index 24ad48b..3b48194 100644
--- a/howto_new_version.txt
+++ b/howto_new_version.txt
@@ -2,23 +2,20 @@
 check is "updated to last version"
 cp ../chronojump-docs/chronojump_manual_e*.pdf manual/
 
-2) change version on configure.ac and src/AssemblyInfo.cs
-3) change buildDate string on src/gui/chronojump.cs
+2) change version on configure.ac
+3) Run autoconf (this will update src/AssemblyInfo.cs - this file is not in the git repo, it's generated 
from src/AssemblyInfo.cs.in)
 
 
 linux stuff
 ------------
-
-sh autogen.sh
-make dist
-
-
 VERSION=1.6.2
-[1]
 git commit -a -m "Bump version $VERSION"
 
 git push
 
+sh autogen.sh
+make dist
+
 #with branching:
 #git checkout -b "tags/$VERSION" # creates a new branch
 # keep doing commits:
diff --git a/src/AssemblyInfo.cs.in b/src/AssemblyInfo.cs.in
index c09977d..56e0112 100644
--- a/src/AssemblyInfo.cs.in
+++ b/src/AssemblyInfo.cs.in
@@ -1,3 +1,6 @@
+// Do not edit the file AssemblyInfo.cs. It gets generated by autoconf
+// Do edit the file AssemblyInfo.cs.in
+
 using System.Reflection;
 using System.Runtime.CompilerServices;
 
@@ -12,7 +15,7 @@ using System.Runtime.CompilerServices;
 [assembly: AssemblyConfiguration("")]
 [assembly: AssemblyCompany("")]
 [assembly: AssemblyProduct("")]
-[assembly: AssemblyCopyright("Copyright (C) 2004-2009   Xavier de Blas <xaviblas gmail com>")]
+[assembly: AssemblyCopyright("Copyright (C) 2004-2016   Xavier de Blas <xaviblas gmail com>")]
 [assembly: AssemblyTrademark("")]
 [assembly: AssemblyCulture("")]
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 0ce5e44..f512190 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -125,6 +125,7 @@ SOURCES = \
        execute/multiChronopic.cs\
        ../chronojump_server/ChronojumpServer.cs\
        AssemblyInfo.cs\
+       buildInfo.cs\
        chronojump.cs\
        config.cs\
        encoder.cs\
diff --git a/src/buildInfo.cs b/src/buildInfo.cs
new file mode 100644
index 0000000..d74f3b1
--- /dev/null
+++ b/src/buildInfo.cs
@@ -0,0 +1,17 @@
+// Do not edit buildInfo.cs - it gets re-generated by autoconf.
+// Do edit buildInfo.cs.in
+
+public class BuildInfo
+{
+       // related: UtilAll::ReadVersion() returns the version file
+       // from the assembly
+       
+       // chronojumpVersion might be like 1.6.2 if it's from a tagged
+       // version and be the same as UtilAll::ReadVersion() or might be
+       // 1.6.2-276-gd579c89 (see output of git describe)
+       public static string chronojumpVersion= "1.6.2-276-gd579c89";
+
+       // It's the timestamp because git log doesn't give anything like
+       // YYYY-MM-DD
+       public static string chronojumpLastCommitTimestamp= "1476703235";
+}
diff --git a/src/buildInfo.cs.in b/src/buildInfo.cs.in
new file mode 100644
index 0000000..806e03b
--- /dev/null
+++ b/src/buildInfo.cs.in
@@ -0,0 +1,14 @@
+public class BuildInfo
+{
+       // related: UtilAll::ReadVersion() returns the version file
+       // from the assembly
+       
+       // chronojumpVersion might be like 1.6.2 if it's from a tagged
+       // version and be the same as UtilAll::ReadVersion() or might be
+       // 1.6.2-276-gd579c89 (see output of git describe)
+       public static string chronojumpVersion= "@BUILD_CHRONOJUMP_VERSION@";
+
+       // It's the timestamp because git log doesn't give anything like
+       // YYYY-MM-DD
+       public static string chronojumpLastCommitTimestamp= "@BUILD_CHRONOJUMP_LAST_COMMIT_TIMESTAMP@";
+}
diff --git a/src/chronojump.cs b/src/chronojump.cs
index 7402b16..c6cb5fa 100644
--- a/src/chronojump.cs
+++ b/src/chronojump.cs
@@ -240,7 +240,7 @@ public class ChronoJump
                }
 
                //print version of chronojump
-               progVersion = UtilAll.ReadVersion();
+               progVersion = BuildInfo.chronojumpVersion;
 
                LogB.Information("Chronojump version: {0}", progVersion);
 
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index f774fd8..48be2d2 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -606,9 +606,9 @@ public partial class ChronoJumpWindow
        
                //leave empty on new releases   
                //string buildDate = " (2016-07-27)";
-               string buildDate = " (d)";
-               label_version.Text = progVersion + buildDate;
-               LogB.Information("Build date:" + buildDate);
+               string buildVersion = BuildInfo.chronojumpVersion;
+               label_version.Text = buildVersion;
+               LogB.Information("Build version:" + buildVersion);
 
                LeastSquares ls = new LeastSquares();
                ls.Test();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]