From 6dee882cf28c27f79e138237ef4022fee281e00a Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Tue, 18 Oct 2011 17:56:10 +0000 Subject: [PATCH] Set the product version string using make_version_header.py and the chrome/VERSION file (issue #383). git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@323 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- cef_create_projects.bat | 1 - libcef/cef_process_ui_thread.cc | 8 ++++--- libcef_dll/libcef_dll.rc | 10 ++++----- tools/gclient_hook.py | 10 +++++++-- tools/make_version_header.bat | 2 +- tools/make_version_header.py | 37 +++++++++++++++++++++++++-------- 6 files changed, 47 insertions(+), 21 deletions(-) diff --git a/cef_create_projects.bat b/cef_create_projects.bat index 34da6a46f..9392c34f8 100644 --- a/cef_create_projects.bat +++ b/cef_create_projects.bat @@ -1,3 +1,2 @@ @echo off -CALL tools\make_version_header.bat ..\third_party\python_26\python.exe tools\gclient_hook.py diff --git a/libcef/cef_process_ui_thread.cc b/libcef/cef_process_ui_thread.cc index 2655f62b4..65bd5c2e7 100644 --- a/libcef/cef_process_ui_thread.cc +++ b/libcef/cef_process_ui_thread.cc @@ -7,6 +7,7 @@ #include "browser_webkit_glue.h" #include "browser_webkit_init.h" #include "cef_context.h" +#include "../version.h" #include "base/bind.h" #include "base/command_line.h" @@ -14,6 +15,7 @@ #include "base/metrics/stats_table.h" #include "base/rand_util.h" #include "base/string_number_conversions.h" +#include "base/stringprintf.h" #include "build/build_config.h" #include "net/base/net_module.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifier.h" @@ -142,9 +144,9 @@ void CefProcessUIThread::Init() { if (settings.product_version.length > 0) { product_version = CefString(&settings.product_version).ToString(); } else { - // Keep synchronized with the newest Dev Channel release announced at - // http://googlechromereleases.blogspot.com/ - product_version = "Chrome/16.0.904.0"; + product_version = base::StringPrintf("Chrome/%d.%d.%d.%d", + CHROME_VERSION_MAJOR, CHROME_VERSION_MINOR, CHROME_VERSION_BUILD, + CHROME_VERSION_PATCH); } webkit_glue::SetUserAgent( diff --git a/libcef_dll/libcef_dll.rc b/libcef_dll/libcef_dll.rc index 3925a96c1..4c7c39e27 100644 --- a/libcef_dll/libcef_dll.rc +++ b/libcef_dll/libcef_dll.rc @@ -10,7 +10,7 @@ #define APSTUDIO_HIDDEN_SYMBOLS #include "windows.h" #undef APSTUDIO_HIDDEN_SYMBOLS -#include "version.h" +#include "../version.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS @@ -59,8 +59,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,SVN_REVISION,0 - PRODUCTVERSION 1,0,SVN_REVISION,0 + FILEVERSION 1,0,CEF_REVISION,0 + PRODUCTVERSION 1,0,CEF_REVISION,0 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L @@ -76,12 +76,12 @@ BEGIN BLOCK "040904b0" BEGIN VALUE "FileDescription", "Chromium Embedded Framework (CEF) Dynamic Link Library" - VALUE "FileVersion", "1.0." MAKE_STRING(SVN_REVISION) + VALUE "FileVersion", "1.0." MAKE_STRING(CEF_REVISION) VALUE "InternalName", "libcef" VALUE "LegalCopyright", "Copyright (C) " MAKE_STRING(COPYRIGHT_YEAR) " The Chromium Embedded Framework Authors" VALUE "OriginalFilename", "libcef.dll" VALUE "ProductName", "Chromium Embedded Framework (CEF) Dynamic Link Library" - VALUE "ProductVersion", "1.0." MAKE_STRING(SVN_REVISION) + VALUE "ProductVersion", "1.0." MAKE_STRING(CEF_REVISION) END END BLOCK "VarFileInfo" diff --git a/tools/gclient_hook.py b/tools/gclient_hook.py index 46602ba75..b88bd2699 100644 --- a/tools/gclient_hook.py +++ b/tools/gclient_hook.py @@ -9,12 +9,18 @@ import os, sys # The CEF root directory is the parent directory of _this_ script. cef_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) +print "\nGenerating CEF version header file..." +gyper = [ 'python', 'tools/make_version_header.py', + '--header', 'version.h', + '--version', '../chrome/VERSION' ] +RunAction(cef_dir, gyper) + print "\nPatching build configuration and source files for CEF..." patcher = [ 'python', 'tools/patcher.py', '--patch-config', 'patch/patch.cfg' ]; -RunAction(cef_dir, patcher); +RunAction(cef_dir, patcher) print "\nGenerating CEF project files..." os.environ['CEF_DIRECTORY'] = os.path.basename(cef_dir); gyper = [ 'python', 'tools/gyp_cef', 'cef.gyp', '-I', 'cef.gypi' ] -RunAction(cef_dir, gyper); +RunAction(cef_dir, gyper) diff --git a/tools/make_version_header.bat b/tools/make_version_header.bat index c115b75c4..5e4944c2b 100644 --- a/tools/make_version_header.bat +++ b/tools/make_version_header.bat @@ -1,2 +1,2 @@ @echo off -..\third_party\python_26\python.exe tools\make_version_header.py --header libcef_dll\version.h +..\third_party\python_26\python.exe tools\make_version_header.py --header version.h --version ../chrome/VERSION diff --git a/tools/make_version_header.py b/tools/make_version_header.py index fd5205846..bb3767cc2 100644 --- a/tools/make_version_header.py +++ b/tools/make_version_header.py @@ -22,21 +22,35 @@ This utility creates the version header file. parser = OptionParser(description=disc) parser.add_option('--header', dest='header', metavar='FILE', help='output version header file [required]') +parser.add_option('--version', dest='version', metavar='FILE', + help='input Chrome version config file [required]') parser.add_option('-q', '--quiet', action='store_true', dest='quiet', default=False, help='do not output detailed status information') (options, args) = parser.parse_args() # the header option is required -if options.header is None: +if options.header is None or options.version is None: parser.print_help(sys.stdout) sys.exit() -def write_svn_header(file): - """ Creates the header file for the current revision if the revision has - changed or if the file doesn't already exist. """ - if path_exists(file): - oldcontents = read_file(file) +def write_svn_header(header, version): + """ Creates the header file for the current revision and Chrome version information + if the information has changed or if the file doesn't already exist. """ + + if not path_exists(version): + raise Exception('Version file '+version+' does not exist.') + + # Read and parse the version file (key=value pairs, one per line) + chrome = {} + lines = read_file(version).split("\n") + for line in lines: + parts = line.split('=', 1) + if len(parts) == 2: + chrome[parts[0]] = parts[1] + + if path_exists(header): + oldcontents = read_file(header) else: oldcontents = '' @@ -44,20 +58,25 @@ def write_svn_header(file): '#ifndef _VERSION_H\n'+\ '#define _VERSION_H\n'+\ '\n'+\ - '#define SVN_REVISION ' + get_revision() + '\n'+\ + '#define CEF_REVISION ' + get_revision() + '\n'+\ '#define COPYRIGHT_YEAR ' + get_year() + '\n'+\ '\n'+\ + '#define CHROME_VERSION_MAJOR ' + chrome['MAJOR'] + '\n'+\ + '#define CHROME_VERSION_MINOR ' + chrome['MINOR'] + '\n'+\ + '#define CHROME_VERSION_BUILD ' + chrome['BUILD'] + '\n'+\ + '#define CHROME_VERSION_PATCH ' + chrome['PATCH'] + '\n'+\ + '\n'+\ '#define DO_MAKE_STRING(p) #p\n'+\ '#define MAKE_STRING(p) DO_MAKE_STRING(p)\n'+\ '\n'+\ '#endif\n' if newcontents != oldcontents: - write_file(file, newcontents) + write_file(header, newcontents) return True return False -written = write_svn_header(options.header) +written = write_svn_header(options.header, options.version) if not options.quiet: if written: sys.stdout.write('File '+options.header+' updated.\n')