diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-11-04 17:21:39 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-11-04 17:21:39 +0400 |
commit | 2010c6ad6cae41b5f13b36339404ff60c98ae915 (patch) | |
tree | 543e34b74bf56ce9338f3ae0e029852cdd78905a /source/blender | |
parent | d07f3f793b8c7596e36249d589aafcf63611cc1d (diff) |
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 :)
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_main.h | 2 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 10 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 11 | ||||
-rw-r--r-- | source/blender/collada/AnimationExporter.h | 4 | ||||
-rw-r--r-- | source/blender/collada/DocumentExporter.cpp | 12 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_fileglobal_types.h | 3 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_app.c | 14 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 47 |
8 files changed, 71 insertions, 32 deletions
diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h index 264a7421e91..36c1f5dcf1f 100644 --- a/source/blender/blenkernel/BKE_main.h +++ b/source/blender/blenkernel/BKE_main.h @@ -53,7 +53,7 @@ typedef struct Main { 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; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index c3727c0f688..bc7cd2d9143 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -7292,7 +7292,8 @@ static BHead *read_global(BlendFileData *bfd, FileData *fd, BHead *bhead) 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 @@ static void do_versions(FileData *fd, Library *lib, Main *main) { /* 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); diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 83122e24b34..cf7a5329a35 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -3261,7 +3261,7 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar) 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 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar) fg.minsubversion= BLENDER_MINSUBVERSION; #ifdef WITH_BUILDINFO { - extern char build_rev[]; - fg.revision= atoi(build_rev); + extern char build_change[], build_hash[]; + /* TODO(sergey): Add branch name to file as well? */ + BLI_strncpy(fg.build_change, build_change, sizeof(fg.build_change)); + BLI_strncpy(fg.build_hash, build_hash, sizeof(fg.build_hash)); } #else - fg.revision= 0; + BLI_strncpy(fg.build_change, "unknown", sizeof(fg.build_change)); + BLI_strncpy(fg.build_hash, "unknown", sizeof(fg.build_hash)); #endif writestruct(wd, GLOB, "FileGlobal", 1, &fg); } diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h index ea5fd203bea..60224151308 100644 --- a/source/blender/collada/AnimationExporter.h +++ b/source/blender/collada/AnimationExporter.h @@ -53,10 +53,6 @@ extern "C" #include "BIK_api.h" #include "BKE_global.h" #include "ED_object.h" - -#ifdef NAN_BUILDINFO -extern char build_rev[]; -#endif } #include "MEM_guardedalloc.h" diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp index c03316e1fe5..9aa0f6e2831 100644 --- a/source/blender/collada/DocumentExporter.cpp +++ b/source/blender/collada/DocumentExporter.cpp @@ -101,7 +101,8 @@ extern "C" #include "ED_keyframing.h" #ifdef WITH_BUILDINFO -extern char build_rev[]; +extern char build_change[]; +extern char build_hash[]; #endif #include "MEM_guardedalloc.h" @@ -226,7 +227,14 @@ void DocumentExporter::exportCurrentScene(Scene *sce) } char version_buf[128]; #ifdef WITH_BUILDINFO - sprintf(version_buf, "Blender %d.%02d.%d r%s", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION, build_rev); + /* TODO(sergey): As soon as we fully switched to GIT, no need to check build_hash. */ + if (build_hash[0] != '\0') { + sprintf(version_buf, "Blender %d.%02d.%d change:%s, hash:", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION, + build_change, build_hash); + } + else { + sprintf(version_buf, "Blender %d.%02d.%d r%s", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION, build_change); + } #else sprintf(version_buf, "Blender %d.%02d.%d", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION); #endif diff --git a/source/blender/makesdna/DNA_fileglobal_types.h b/source/blender/makesdna/DNA_fileglobal_types.h index 7e81041fe4a..734741fa687 100644 --- a/source/blender/makesdna/DNA_fileglobal_types.h +++ b/source/blender/makesdna/DNA_fileglobal_types.h @@ -48,8 +48,7 @@ typedef struct FileGlobal { struct Scene *curscene; int fileflags; int globalf; - int revision; /* svn revision from buildinfo */ - int pad; + char build_change[16], build_hash[16]; /* change number and hash from buildinfo */ /* file path where this was saved, for recover */ char filename[1024]; /* 1024 = FILE_MAX */ } FileGlobal; diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c index 2edb0aee783..3a529496f02 100644 --- a/source/blender/python/intern/bpy_app.c +++ b/source/blender/python/intern/bpy_app.c @@ -53,7 +53,9 @@ #ifdef BUILD_DATE extern char build_date[]; extern char build_time[]; -extern char build_rev[]; +extern char build_change[]; +extern char build_hash[]; +extern char build_branch[]; extern char build_platform[]; extern char build_type[]; extern char build_cflags[]; @@ -75,7 +77,9 @@ static PyStructSequence_Field app_info_fields[] = { /* buildinfo */ {(char *)"build_date", (char *)"The date this blender instance was built"}, {(char *)"build_time", (char *)"The time this blender instance was built"}, - {(char *)"build_revision", (char *)"The subversion revision this blender instance was built with"}, + {(char *)"build_change", (char *)"The change number this blender instance was built with"}, + {(char *)"build_hash", (char *)"The commit hash this blender instance was built with"}, + {(char *)"build_branch", (char *)"The branch this blender instance was built from"}, {(char *)"build_platform", (char *)"The platform this blender instance was built for"}, {(char *)"build_type", (char *)"The type of build (Release, Debug)"}, {(char *)"build_cflags", (char *)"C compiler flags"}, @@ -133,7 +137,9 @@ static PyObject *make_app_info(void) #ifdef BUILD_DATE SetBytesItem(build_date); SetBytesItem(build_time); - SetBytesItem(build_rev); + SetBytesItem(build_change); + SetBytesItem(build_hash); + SetBytesItem(build_branch); SetBytesItem(build_platform); SetBytesItem(build_type); SetBytesItem(build_cflags); @@ -150,6 +156,8 @@ static PyObject *make_app_info(void) SetBytesItem("Unknown"); SetBytesItem("Unknown"); SetBytesItem("Unknown"); + SetBytesItem("Unknown"); + SetBytesItem("Unknown"); #endif SetObjItem(BPY_app_ffmpeg_struct()); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 7748a2cb4b8..2cd5190cdaf 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1641,18 +1641,25 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar #ifdef WITH_BUILDINFO - int ver_width, rev_width; - char version_buf[128]; - char revision_buf[128]; - extern char build_rev[]; - - BLI_snprintf(version_buf, sizeof(version_buf), - "%d.%02d.%d", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION); - BLI_snprintf(revision_buf, sizeof(revision_buf), "r%s", build_rev); + int label_delta = 0; + int hash_width, change_width; + char change_buf[128] = "\0"; + char hash_buf[128] = "\0"; + extern char build_hash[], build_change[], build_branch[]; + + /* TODO(sergey): As soon as we fully switched to GIT, no need to check build_hash. */ + if (build_hash[0] != '\0') { + /* Builds made from tag only shows tag sha */ + BLI_snprintf(hash_buf, sizeof(hash_buf), "Hash: %s", build_hash); + BLI_snprintf(change_buf, sizeof(change_buf), "Change: %s", build_change); + } + else { + BLI_snprintf(change_buf, sizeof(change_buf), "r%s", build_change); + } BLF_size(style->widgetlabel.uifont_id, style->widgetlabel.points, U.pixelsize * U.dpi); - ver_width = (int)BLF_width(style->widgetlabel.uifont_id, version_buf) + 0.5f * U.widget_unit; - rev_width = (int)BLF_width(style->widgetlabel.uifont_id, revision_buf) + 0.5f * U.widget_unit; + hash_width = (int)BLF_width(style->widgetlabel.uifont_id, hash_buf) + 0.5f * U.widget_unit; + change_width = (int)BLF_width(style->widgetlabel.uifont_id, change_buf) + 0.5f * U.widget_unit; #endif /* WITH_BUILDINFO */ block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); @@ -1667,9 +1674,23 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar uiButSetFunc(but, wm_block_splash_close, block, NULL); uiBlockSetFunc(block, wm_block_splash_refreshmenu, block, NULL); -#ifdef WITH_BUILDINFO - uiDefBut(block, LABEL, 0, version_buf, U.pixelsize * 494 - ver_width, U.pixelsize * 258, ver_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); - uiDefBut(block, LABEL, 0, revision_buf, U.pixelsize * 494 - rev_width, U.pixelsize * 246, rev_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); +#ifdef WITH_BUILDINFO + if (!STREQ(build_change, "0")) { + uiDefBut(block, LABEL, 0, change_buf, U.pixelsize * 494 - change_width, U.pixelsize * 270, change_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); + label_delta = 12; + } + uiDefBut(block, LABEL, 0, hash_buf, U.pixelsize * 494 - hash_width, U.pixelsize * (270 - label_delta), hash_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); + + /* TODO(sergey): As soon as we fully switched to GIT, no need to check + * whether branch is empty or not. + */ + if (build_branch[0] != '\0' && !STREQ(build_branch, "master")) { + char branch_buf[128] = "\0"; + int branch_width; + BLI_snprintf(branch_buf, sizeof(branch_buf), "Branch: %s", build_branch); + branch_width = (int)BLF_width(style->widgetlabel.uifont_id, branch_buf) + 0.5f * U.widget_unit; + uiDefBut(block, LABEL, 0, branch_buf, U.pixelsize * 494 - branch_width, U.pixelsize * (258 - label_delta), branch_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); + } #endif /* WITH_BUILDINFO */ layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 10, 2, U.pixelsize * 480, U.pixelsize * 110, style); |