[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [61082] trunk/blender: Made buildinfo aware of builds from GIT

Sergey Sharybin sergey.vfx at gmail.com
Mon Nov 4 14:21:39 CET 2013


Revision: 61082
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=61082
Author:   nazgul
Date:     2013-11-04 13:21:39 +0000 (Mon, 04 Nov 2013)
Log Message:
-----------
Made buildinfo aware of builds from GIT

- Use commit number since last annotated tag as a
  revision number replacement. It'll eb followed
  by 'M' symbol if there're local modification in
  the source tree.

- Commit short SHA1 is included. Helps getting
  information about commit used to build blender
  with much faster.

- If build is not done from master branch, this also
  will be noticed in the splash screen.

This commit also replaces revision stored in the
files with git-specific fields (change and hash).
This is kind of breaks compatibility, meaning
files which were saved before this change wouldn't
display any information about which revision they
were saved with. When we'll finally switch to git,
we'll see proper hash and change number since
previous release in the files, for until then
svn version will be used as a change number and
hash will be empty.

Not a huge deal, since this field was only used
by developers to help torubleshooting things and
isn't needed for blender itself.

Some additional tweaks are probably needed :)

Modified Paths:
--------------
    trunk/blender/build_files/cmake/buildinfo.cmake
    trunk/blender/build_files/scons/tools/Blender.py
    trunk/blender/release/scripts/modules/sys_info.py
    trunk/blender/source/blender/blenkernel/BKE_main.h
    trunk/blender/source/blender/blenloader/intern/readfile.c
    trunk/blender/source/blender/blenloader/intern/writefile.c
    trunk/blender/source/blender/collada/AnimationExporter.h
    trunk/blender/source/blender/collada/DocumentExporter.cpp
    trunk/blender/source/blender/makesdna/DNA_fileglobal_types.h
    trunk/blender/source/blender/python/intern/bpy_app.c
    trunk/blender/source/blender/windowmanager/intern/wm_operators.c
    trunk/blender/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt
    trunk/blender/source/creator/CMakeLists.txt
    trunk/blender/source/creator/buildinfo.c
    trunk/blender/source/creator/creator.c

Modified: trunk/blender/build_files/cmake/buildinfo.cmake
===================================================================
--- trunk/blender/build_files/cmake/buildinfo.cmake	2013-11-04 12:50:33 UTC (rev 61081)
+++ trunk/blender/build_files/cmake/buildinfo.cmake	2013-11-04 13:21:39 UTC (rev 61082)
@@ -1,17 +1,83 @@
 # This is called by cmake as an extermal process from
 # ./source/creator/CMakeLists.txt to write ./source/creator/buildinfo.h
 
-# The FindSubversion.cmake module is part of the standard distribution
-include(FindSubversion)
-
 # Extract working copy information for SOURCE_DIR into MY_XXX variables
 # with a default in case anything fails, for examble when using git-svn
-set(MY_WC_REVISION "unknown")
+set(MY_WC_HASH "")
+set(MY_WC_BRANCH "")
+set(MY_WC_CHANGE "unknown")
+
 # Guess if this is a SVN working copy and then look up the revision
-if(EXISTS ${SOURCE_DIR}/.svn/)
-	if(Subversion_FOUND)
-		Subversion_WC_INFO(${SOURCE_DIR} MY)
+if(EXISTS ${SOURCE_DIR}/.git/)
+	if(EXISTS ${SOURCE_DIR}/.git/)
+		# The FindSubversion.cmake module is part of the standard distribution
+		include(FindGit)
+		if(GIT_FOUND)
+			execute_process(COMMAND git rev-parse --short HEAD
+			                WORKING_DIRECTORY ${SOURCE_DIR}
+			                OUTPUT_VARIABLE MY_WC_HASH
+			                OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+			execute_process(COMMAND git rev-parse --abbrev-ref HEAD
+			                WORKING_DIRECTORY ${SOURCE_DIR}
+			                OUTPUT_VARIABLE MY_WC_BRANCH
+			                OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+			# Get latest version tag
+			execute_process(COMMAND git describe --match "v[0-9]*" --abbrev=0
+			                WORKING_DIRECTORY ${SOURCE_DIR}
+			                OUTPUT_VARIABLE _git_latest_version_tag
+			                OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+			if(NOT _git_latest_version_tag STREQUAL "")
+				execute_process(COMMAND git rev-list HEAD ^${_git_latest_version_tag} --count
+				                WORKING_DIRECTORY ${SOURCE_DIR}
+				                OUTPUT_VARIABLE MY_WC_CHANGE
+				                OUTPUT_STRIP_TRAILING_WHITESPACE)
+			else()
+				# For the time being we don't have annotated release tags,
+				# count all the revisions in branch.
+				execute_process(COMMAND git rev-list HEAD --count
+				                WORKING_DIRECTORY ${SOURCE_DIR}
+				                OUTPUT_VARIABLE MY_WC_CHANGE
+				                OUTPUT_STRIP_TRAILING_WHITESPACE)
+			endif()
+
+			# Update GIT index before getting dirty files
+			execute_process(COMMAND git update-index -q --refresh
+			                WORKING_DIRECTORY ${SOURCE_DIR}
+			                OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+			execute_process(COMMAND git diff-index --name-only HEAD --
+			                WORKING_DIRECTORY ${SOURCE_DIR}
+			                OUTPUT_VARIABLE _git_changed_files
+			                OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+			if(NOT _git_changed_files STREQUAL "")
+				set(MY_WC_CHANGE "${MY_WC_CHANGE}M")
+			endif()
+
+			unset(_git_changed_files)
+			unset(_git_latest_version_tag)
+		endif()
 	endif()
+else()
+	# Some crazy folks like me could have hacked git-svn chekout in a way
+	# so svnversion gives proper svn revision for themm which required having
+	# empty .svn folder.
+	#
+	# For such a crazy blokes put svn check into an else branch.
+	#
+	#                                                              (sergey)
+	if(EXISTS ${SOURCE_DIR}/.svn/)
+		# The FindSubversion.cmake module is part of the standard distribution
+		include(FindSubversion)
+
+		if(Subversion_FOUND)
+			Subversion_WC_INFO(${SOURCE_DIR} MY)
+			set(MY_WC_CHANGE "${MY_WC_REVISION}")
+		endif()
+	endif()
 endif()
 
 # BUILD_PLATFORM and BUILD_PLATFORM are taken from CMake
@@ -27,7 +93,9 @@
 
 # Write a file with the SVNVERSION define
 file(WRITE buildinfo.h.txt
-	"#define BUILD_REV \"${MY_WC_REVISION}\"\n"
+	"#define BUILD_HASH \"${MY_WC_HASH}\"\n"
+	"#define BUILD_CHANGE \"${MY_WC_CHANGE}\"\n"
+	"#define BUILD_BRANCH \"${MY_WC_BRANCH}\"\n"
 	"#define BUILD_DATE \"${BUILD_DATE}\"\n"
 	"#define BUILD_TIME \"${BUILD_TIME}\"\n"
 )

Modified: trunk/blender/build_files/scons/tools/Blender.py
===================================================================
--- trunk/blender/build_files/scons/tools/Blender.py	2013-11-04 12:50:33 UTC (rev 61081)
+++ trunk/blender/build_files/scons/tools/Blender.py	2013-11-04 13:21:39 UTC (rev 61082)
@@ -410,9 +410,24 @@
     """
     build_date = time.strftime ("%Y-%m-%d")
     build_time = time.strftime ("%H:%M:%S")
-    build_rev = os.popen('svnversion').read()[:-1] # remove \n
-    if build_rev == '': 
-        build_rev = '-UNKNOWN-'
+    if os.path.isdir(os.path.abspath('.git')):
+        latest_version_tag = os.popen('git describe --match "v[0-9]*" --abbrev=0').read().strip()
+        if latest_version_tag:
+            build_change = os.popen('git rev-list HEAD ' + latest_version_tag + ' --count').read().strip()
+        else:
+            build_change = os.popen('git rev-list HEAD --count').read().strip()
+
+        build_hash = os.popen('git rev-parse --short HEAD').read().strip()
+        build_branch = os.popen('git rev-parse --abbrev-ref HEAD').read().strip()
+    elif os.path.isdir(os.path.abspath('.svn')):
+        build_hash = ''
+        build_change = os.popen('svnversion').read()[:-1] # remove \n
+        build_branch = ''
+    else:
+        build_hash = ''
+        build_change = 'unknown'
+        build_branch = ''
+
     if lenv['BF_DEBUG']:
         build_type = "Debug"
         build_cflags = ' '.join(lenv['CFLAGS'] + lenv['CCFLAGS'] + lenv['BF_DEBUG_CCFLAGS'] + lenv['CPPFLAGS'])
@@ -429,7 +444,9 @@
         lenv.Append (CPPDEFINES = ['BUILD_TIME=\\"%s\\"'%(build_time),
                                     'BUILD_DATE=\\"%s\\"'%(build_date),
                                     'BUILD_TYPE=\\"%s\\"'%(build_type),
-                                    'BUILD_REV=\\"%s\\"'%(build_rev),
+                                    'BUILD_HASH=\\"%s\\"'%(build_hash),
+                                    'BUILD_CHANGE=\\"%s\\"'%(build_change),
+                                    'BUILD_BRANCH=\\"%s\\"'%(build_branch),
                                     'WITH_BUILDINFO',
                                     'BUILD_PLATFORM=\\"%s:%s\\"'%(platform.system(), platform.architecture()[0]),
                                     'BUILD_CFLAGS=\\"%s\\"'%(build_cflags),

Modified: trunk/blender/release/scripts/modules/sys_info.py
===================================================================
--- trunk/blender/release/scripts/modules/sys_info.py	2013-11-04 12:50:33 UTC (rev 61081)
+++ trunk/blender/release/scripts/modules/sys_info.py	2013-11-04 13:21:39 UTC (rev 61082)
@@ -67,7 +67,19 @@
     # build info
     output.write("\nBlender:\n")
     output.write(lilies)
-    output.write("version %s, revision %r. %r\n" % (bpy.app.version_string, bpy.app.build_revision, bpy.app.build_type))
+    if bpy.app.build_branch and bpy.app.build_branch != "Unknown":
+        output.write("version %s, branch %r, chage %r, hash %r, %r\n" %
+            (bpy.app.version_string,
+             bpy.app.build_branch,
+             bpy.app.build_change,
+             bpy.app.build_hash,
+             bpy.app.build_type))
+    else:
+        output.write("version %s, revision %r. %r\n" %
+            (bpy.app.version_string,
+             bpy.app.build_change,
+             bpy.app.build_type))
+
     output.write("build date: %r, %r\n" % (bpy.app.build_date, bpy.app.build_time))
     output.write("platform: %r\n" % (bpy.app.build_platform))
     output.write("binary path: %r\n" % (bpy.app.binary_path))

Modified: trunk/blender/source/blender/blenkernel/BKE_main.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_main.h	2013-11-04 12:50:33 UTC (rev 61081)
+++ trunk/blender/source/blender/blenkernel/BKE_main.h	2013-11-04 13:21:39 UTC (rev 61082)
@@ -53,7 +53,7 @@
 	char name[1024]; /* 1024 = FILE_MAX */
 	short versionfile, subversionfile;  /* see BLENDER_VERSION, BLENDER_SUBVERSION */
 	short minversionfile, minsubversionfile;
-	int revision;		/* svn revision of binary that saved file */
+	char build_change[16], build_hash[16];  /* change number and hash from buildinfo */
 	short recovered;	/* indicate the main->name (file) is the recovered one */
 	
 	struct Library *curlib;

Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c	2013-11-04 12:50:33 UTC (rev 61081)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c	2013-11-04 13:21:39 UTC (rev 61082)
@@ -7292,7 +7292,8 @@
 	bfd->main->subversionfile = fg->subversion;
 	bfd->main->minversionfile = fg->minversion;
 	bfd->main->minsubversionfile = fg->minsubversion;
-	bfd->main->revision = fg->revision;
+	BLI_strncpy(bfd->main->build_change, fg->build_change, sizeof(bfd->main->build_change));
+	BLI_strncpy(bfd->main->build_hash, fg->build_hash, sizeof(bfd->main->build_hash));
 	
 	bfd->winpos = fg->winpos;
 	bfd->fileflags = fg->fileflags;
@@ -7926,8 +7927,11 @@
 {
 	/* WATCH IT!!!: pointers from libdata have not been converted */
 	
-	if (G.debug & G_DEBUG)
-		printf("read file %s\n  Version %d sub %d svn r%d\n", fd->relabase, main->versionfile, main->subversionfile, main->revision);
+	if (G.debug & G_DEBUG) {
+		printf("read file %s\n  Version %d sub %d change %s hash %s\n",
+		       fd->relabase, main->versionfile, main->subversionfile,
+		       main->build_change, main->build_hash);
+	}
 	
 	blo_do_versions_pre250(fd, lib, main);
 	blo_do_versions_250(fd, lib, main);

Modified: trunk/blender/source/blender/blenloader/intern/writefile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/writefile.c	2013-11-04 12:50:33 UTC (rev 61081)
+++ trunk/blender/source/blender/blenloader/intern/writefile.c	2013-11-04 13:21:39 UTC (rev 61082)
@@ -3261,7 +3261,7 @@
 	char subvstr[8];
 	
 	/* prevent mem checkers from complaining */
-	fg.pads= fg.pad= 0;
+	fg.pads= 0;
 	memset(fg.filename, 0, sizeof(fg.filename));
 
 	current_screen_compat(mainvar, &screen);
@@ -3285,11 +3285,14 @@
 	fg.minsubversion= BLENDER_MINSUBVERSION;
 #ifdef WITH_BUILDINFO
 	{
-		extern char build_rev[];
-		fg.revision= atoi(build_rev);

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list