diff --git a/build_files/cmake/buildinfo.cmake b/build_files/cmake/buildinfo.cmake index ae2f87b49be..2db03d3efe9 100644 --- a/build_files/cmake/buildinfo.cmake +++ b/build_files/cmake/buildinfo.cmake @@ -5,7 +5,7 @@ # with a default in case anything fails, for examble when using git-svn set(MY_WC_HASH "") set(MY_WC_BRANCH "") -set(MY_WC_CHANGE "unknown") +set(MY_WC_COMMIT_TIMESTAMP 0) # Guess if this is a SVN working copy and then look up the revision if(EXISTS ${SOURCE_DIR}/.git/) @@ -29,19 +29,10 @@ if(EXISTS ${SOURCE_DIR}/.git/) 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() + execute_process(COMMAND git log -1 --format=%ct + WORKING_DIRECTORY ${SOURCE_DIR} + OUTPUT_VARIABLE MY_WC_COMMIT_TIMESTAMP + OUTPUT_STRIP_TRAILING_WHITESPACE) # Update GIT index before getting dirty files execute_process(COMMAND git update-index -q --refresh @@ -61,23 +52,6 @@ if(EXISTS ${SOURCE_DIR}/.git/) 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 @@ -94,7 +68,7 @@ endif() # Write a file with the SVNVERSION define file(WRITE buildinfo.h.txt "#define BUILD_HASH \"${MY_WC_HASH}\"\n" - "#define BUILD_CHANGE \"${MY_WC_CHANGE}\"\n" + "#define BUILD_COMMIT_TIMESTAMP ${MY_WC_COMMIT_TIMESTAMP}\n" "#define BUILD_BRANCH \"${MY_WC_BRANCH}\"\n" "#define BUILD_DATE \"${BUILD_DATE}\"\n" "#define BUILD_TIME \"${BUILD_TIME}\"\n" diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index 06cc6b7f00a..8715c2367e4 100644 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -411,18 +411,9 @@ def buildinfo(lenv, build_type): build_date = time.strftime ("%Y-%m-%d") build_time = time.strftime ("%H:%M:%S") 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_commit_timestamp = os.popen('git log -1 --format=%ct').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' @@ -445,7 +436,7 @@ def buildinfo(lenv, build_type): 'BUILD_DATE=\\"%s\\"'%(build_date), 'BUILD_TYPE=\\"%s\\"'%(build_type), 'BUILD_HASH=\\"%s\\"'%(build_hash), - 'BUILD_CHANGE=\\"%s\\"'%(build_change), + 'BUILD_COMMIT_TIMESTAMP=%s'%(build_commit_timestamp), 'BUILD_BRANCH=\\"%s\\"'%(build_branch), 'WITH_BUILDINFO', 'BUILD_PLATFORM=\\"%s:%s\\"'%(platform.system(), platform.architecture()[0]), diff --git a/release/scripts/modules/sys_info.py b/release/scripts/modules/sys_info.py index 3fd4a60d0b1..83f2647c5b2 100644 --- a/release/scripts/modules/sys_info.py +++ b/release/scripts/modules/sys_info.py @@ -68,10 +68,11 @@ def write_sysinfo(op): output.write("\nBlender:\n") output.write(lilies) if bpy.app.build_branch and bpy.app.build_branch != "Unknown": - output.write("version %s, branch %r, chage %r, hash %r, %r\n" % + output.write("version %s, branch %r, commit date %r %r, hash %r, %r\n" % (bpy.app.version_string, bpy.app.build_branch, - bpy.app.build_change, + bpy.app.build_commit_date, + bpy.app.build_commit_time, bpy.app.build_hash, bpy.app.build_type)) else: diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h index 36c1f5dcf1f..629eda3b583 100644 --- a/source/blender/blenkernel/BKE_main.h +++ b/source/blender/blenkernel/BKE_main.h @@ -53,7 +53,8 @@ typedef struct Main { char name[1024]; /* 1024 = FILE_MAX */ short versionfile, subversionfile; /* see BLENDER_VERSION, BLENDER_SUBVERSION */ short minversionfile, minsubversionfile; - char build_change[16], build_hash[16]; /* change number and hash from buildinfo */ + unsigned long build_commit_timestamp; /* commit's timestamp from buildinfo */ + char build_hash[16]; /* 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 910ff1d9ebe..e2876317e38 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -7293,7 +7293,7 @@ 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; - BLI_strncpy(bfd->main->build_change, fg->build_change, sizeof(bfd->main->build_change)); + bfd->main->build_commit_timestamp = fg->build_commit_timestamp; BLI_strncpy(bfd->main->build_hash, fg->build_hash, sizeof(bfd->main->build_hash)); bfd->winpos = fg->winpos; @@ -7929,9 +7929,14 @@ 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 change %s hash %s\n", + char build_commit_datetime[32]; + time_t temp_time = main->build_commit_timestamp; + struct tm *tm = gmtime(&temp_time); + strftime(build_commit_datetime, sizeof(build_commit_datetime), "%Y-%m-%d %H:%M", tm); + + printf("read file %s\n Version %d sub %d date %s hash %s\n", fd->relabase, main->versionfile, main->subversionfile, - main->build_change, main->build_hash); + build_commit_datetime, main->build_hash); } blo_do_versions_pre250(fd, lib, main); diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index cf7a5329a35..1f417df38d2 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -3285,13 +3285,14 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar) fg.minsubversion= BLENDER_MINSUBVERSION; #ifdef WITH_BUILDINFO { - extern char build_change[], build_hash[]; + extern unsigned long build_commit_timestamp; + extern char build_hash[]; /* TODO(sergey): Add branch name to file as well? */ - BLI_strncpy(fg.build_change, build_change, sizeof(fg.build_change)); + fg.build_commit_timestamp = build_commit_timestamp; BLI_strncpy(fg.build_hash, build_hash, sizeof(fg.build_hash)); } #else - BLI_strncpy(fg.build_change, "unknown", sizeof(fg.build_change)); + fg.build_commit_timestamp = 0; BLI_strncpy(fg.build_hash, "unknown", sizeof(fg.build_hash)); #endif writestruct(wd, GLOB, "FileGlobal", 1, &fg); diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp index 9aa0f6e2831..9d590968481 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_change[]; +extern char build_commit_date[]; +extern char build_commit_time[]; extern char build_hash[]; #endif @@ -227,16 +228,12 @@ void DocumentExporter::exportCurrentScene(Scene *sce) } char version_buf[128]; #ifdef WITH_BUILDINFO - /* 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); - } + BLI_snprintf(version_buf, sizeof(version_buf), "Blender %d.%02d.%d commit date:%s, hash:", + BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION, + build_commit_date, blender_commit_time, build_hash); #else - sprintf(version_buf, "Blender %d.%02d.%d", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION); + BLI_snprintf(version_buf, sizeof(version_buf), "Blender %d.%02d.%d", + BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION); #endif asset.getContributor().mAuthoringTool = version_buf; asset.add(); diff --git a/source/blender/makesdna/DNA_fileglobal_types.h b/source/blender/makesdna/DNA_fileglobal_types.h index 734741fa687..f0f8fe7d40c 100644 --- a/source/blender/makesdna/DNA_fileglobal_types.h +++ b/source/blender/makesdna/DNA_fileglobal_types.h @@ -48,7 +48,8 @@ typedef struct FileGlobal { struct Scene *curscene; int fileflags; int globalf; - char build_change[16], build_hash[16]; /* change number and hash from buildinfo */ + unsigned long build_commit_timestamp; /* commit timestamp from buildinfo */ + char build_hash[12]; /* 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 3a529496f02..21767196e11 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_change[]; +extern unsigned long build_commit_timestamp; +extern char build_commit_date[]; +extern char build_commit_time[]; extern char build_hash[]; extern char build_branch[]; extern char build_platform[]; @@ -77,7 +79,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_change", (char *)"The change number this blender instance was built with"}, + {(char *)"build_commit_timestamp", (char *)"The unix timestamp of commit this blender instance was built"}, + {(char *)"build_commit_date", (char *)"The date of commit this blender instance was built"}, + {(char *)"build_commit_time", (char *)"The time of commit this blender instance was built"}, {(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"}, @@ -111,10 +115,8 @@ static PyObject *make_app_info(void) if (app_info == NULL) { return NULL; } -#if 0 #define SetIntItem(flag) \ PyStructSequence_SET_ITEM(app_info, pos++, PyLong_FromLong(flag)) -#endif #define SetStrItem(str) \ PyStructSequence_SET_ITEM(app_info, pos++, PyUnicode_FromString(str)) #define SetBytesItem(str) \ @@ -137,7 +139,9 @@ static PyObject *make_app_info(void) #ifdef BUILD_DATE SetBytesItem(build_date); SetBytesItem(build_time); - SetBytesItem(build_change); + SetIntItem(build_commit_timestamp); + SetBytesItem(build_commit_date); + SetBytesItem(build_commit_time); SetBytesItem(build_hash); SetBytesItem(build_branch); SetBytesItem(build_platform); @@ -149,6 +153,8 @@ static PyObject *make_app_info(void) #else SetBytesItem("Unknown"); SetBytesItem("Unknown"); + SetIntItem(0); + SetBytesItem("Unknown"); SetBytesItem("Unknown"); SetBytesItem("Unknown"); SetBytesItem("Unknown"); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index ab8dac396c5..6396ef12495 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1677,24 +1677,19 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar #ifdef WITH_BUILDINFO int label_delta = 0; - int hash_width, change_width; - char change_buf[128] = "\0"; + int hash_width, date_width; + char date_buf[128] = "\0"; char hash_buf[128] = "\0"; - extern char build_hash[], build_change[], build_branch[]; + extern unsigned long build_commit_timestamp; + extern char build_hash[], build_commit_date[], build_commit_time[], 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); - } + /* Builds made from tag only shows tag sha */ + BLI_snprintf(hash_buf, sizeof(hash_buf), "Hash: %s", build_hash); + BLI_snprintf(date_buf, sizeof(date_buf), "Date: %s %s", build_commit_date, build_commit_time); BLF_size(style->widgetlabel.uifont_id, style->widgetlabel.points, U.pixelsize * U.dpi); 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; + date_width = (int)BLF_width(style->widgetlabel.uifont_id, date_buf) + 0.5f * U.widget_unit; #endif /* WITH_BUILDINFO */ block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); @@ -1710,16 +1705,13 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar uiBlockSetFunc(block, wm_block_splash_refreshmenu, block, 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); + if (build_commit_timestamp != 0) { + uiDefBut(block, LABEL, 0, date_buf, U.pixelsize * 494 - date_width, U.pixelsize * 270, date_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")) { + if (!STREQ(build_branch, "master")) { char branch_buf[128] = "\0"; int branch_width; BLI_snprintf(branch_buf, sizeof(branch_buf), "Branch: %s", build_branch); diff --git a/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt b/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt index f8fe401cb1c..0d71b157fb6 100644 --- a/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt +++ b/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt @@ -52,7 +52,9 @@ if(WITH_BUILDINFO) ) add_definitions(-DBUILD_DATE="\"\"" -DBUILD_TIME="\"\"" - -DBUILD_CHANGE="\"\"" + -DBUILD_COMMIT_TIMESTAMP=0" + -DBUILD_COMMIT_DATE="\"\"" + -DBUILD_COMMIT_TIME="\"\"" -DBUILD_HASH="\"\"" -DBUILD_PLATFORM="\"\"" -DBUILD_BRANCH="\"\"" diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index b386312bb55..0ef32f4dc02 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -131,7 +131,9 @@ if(WITH_BUILDINFO) # # define in header now, else these get out of date on rebuilds. # -DBUILD_DATE="${BUILD_DATE}" # -DBUILD_TIME="${BUILD_TIME}" - # -DBUILD_CHANGE="${BUILD_CHANGE}" + # -DBUILD_COMMIT_TIMESTAMP="${BUILD_COMMIT_TIMESTAMP}" + # -DBUILD_COMMIT_TIME="${BUILD_COMMIT_TIME}" + # -DBUILD_COMMIT_DATE="${BUILD_COMMIT_DATE}" # -DBUILD_HASH="${BUILD_HASH}" # -DBUILD_BRANCH="${BUILD_BRANCH}" -DWITH_BUILDINFO_HEADER # alternative to lines above diff --git a/source/creator/buildinfo.c b/source/creator/buildinfo.c index d51249980a8..795eec0df40 100644 --- a/source/creator/buildinfo.c +++ b/source/creator/buildinfo.c @@ -40,7 +40,9 @@ char build_date[] = BUILD_DATE; char build_time[] = BUILD_TIME; char build_hash[] = BUILD_HASH; -char build_change[] = BUILD_CHANGE; +unsigned long build_commit_timestamp = BUILD_COMMIT_TIMESTAMP; +char build_commit_date[16] = "\0"; +char build_commit_time[16] = "\0"; char build_branch[] = BUILD_BRANCH; char build_platform[] = BUILD_PLATFORM; diff --git a/source/creator/creator.c b/source/creator/creator.c index 8221552a1d7..508847af5e3 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -154,7 +154,12 @@ extern char build_date[]; extern char build_time[]; extern char build_hash[]; -extern char build_change[]; +extern unsigned long build_commit_timestamp; + +/* TODO(sergey): ideally size need to be in sync with buildinfo.c */ +extern char build_commit_date[16]; +extern char build_commit_time[16]; + extern char build_branch[]; extern char build_platform[]; extern char build_type[]; @@ -221,14 +226,9 @@ static int print_version(int UNUSED(argc), const char **UNUSED(argv), void *UNUS #ifdef BUILD_DATE printf("\tbuild date: %s\n", build_date); printf("\tbuild time: %s\n", build_time); - /* TODO(sergey): As soon as we fully switched to GIT, no need to check build_hash. */ - if (build_hash[0] != '\0') { - printf("\tbuild revision: %s\n", build_change); - } - else { - printf("\tbuild change: %s\n", build_change); - printf("\tbuild hash: %s\n", build_hash); - } + printf("\tbuild commit date: %s\n", build_commit_date); + printf("\tbuild commit time: %s\n", build_commit_time); + printf("\tbuild hash: %s\n", build_hash); printf("\tbuild platform: %s\n", build_platform); printf("\tbuild type: %s\n", build_type); printf("\tbuild c flags: %s\n", build_cflags); @@ -602,13 +602,8 @@ static void blender_crash_handler(int signum) #ifndef BUILD_DATE BLI_snprintf(header, sizeof(header), "# " BLEND_VERSION_FMT ", Unknown revision\n", BLEND_VERSION_ARG); #else - /* TODO(sergey): As soon as we fully switched to GIT, no need to check build_hash. */ - if (build_hash[0] != '\0') { - BLI_snprintf(header, sizeof(header), "# " BLEND_VERSION_FMT ", Change: %s, Hash %s\n", BLEND_VERSION_ARG, build_change, build_hash); - } - else { - BLI_snprintf(header, sizeof(header), "# " BLEND_VERSION_FMT ", Revision: %s\n", BLEND_VERSION_ARG, build_change); - } + BLI_snprintf(header, sizeof(header), "# " BLEND_VERSION_FMT ", Commit date: %s %s, Hash %s\n", + BLEND_VERSION_ARG, build_commit_date, build_commit_time, build_hash); #endif /* open the crash log */ @@ -1517,6 +1512,15 @@ int main(int argc, const char **argv) } } +#ifdef BUILD_DATE + { + time_t temp_time = build_commit_timestamp; + struct tm *tm = gmtime(&temp_time); + strftime(build_commit_date, sizeof(build_commit_date), "%Y-%m-%d", tm); + strftime(build_commit_time, sizeof(build_commit_time), "%H:%M", tm); + } +#endif + C = CTX_create(); #ifdef WITH_PYTHON_MODULE