Add a new check_revision.py tool that is called from cef_create_projects to verify the current Chromium revision and URL against the values specified in CHROMIUM_BUILD_COMPATIBILITY.txt (issue #297).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@349 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2011-10-31 15:51:01 +00:00
parent 1897d14214
commit 3f91de1cea
3 changed files with 97 additions and 11 deletions

60
tools/check_revision.py Normal file
View File

@ -0,0 +1,60 @@
# Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file.
from file_util import *
from optparse import OptionParser
from svn_util import *
import sys
# cannot be loaded as a module
if __name__ != "__main__":
sys.stderr.write('This file cannot be loaded as a module!')
sys.exit()
# parse command-line options
disc = """
This utility checks that the correct Chromium revision is being used.
"""
parser = OptionParser(description=disc)
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 CEF root directory is the parent directory of _this_ script.
cef_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
# Retrieve the CEF SVN info.
cef_info = get_svn_info(cef_dir)
if not options.quiet:
sys.stdout.write('Using CEF revision '+cef_info['revision']+' @ '+\
cef_info['url']+"\n")
# Retrieve the Chromium SVN info.
chromium_info = get_svn_info(os.path.join(cef_dir, os.pardir))
if not options.quiet:
sys.stdout.write('Using Chromium revision '+chromium_info['revision']+' @ '+\
chromium_info['url']+"\n")
# Parse the compatibility file contents.
compat_file = os.path.join(cef_dir, 'CHROMIUM_BUILD_COMPATIBILITY.txt')
config = eval(read_file(compat_file), {'__builtins__': None}, None)
error = False
if chromium_info['url'] != config['chromium_url']:
error = True
sys.stderr.write("\nWARNING: Incorrect Chromium URL; found "+\
chromium_info['url']+', expected '+config['chromium_url']+"\n")
if chromium_info['revision'] != config['chromium_revision']:
error = True
sys.stderr.write("\nWARNING: Incorrect Chromium revision; found "+\
chromium_info['revision']+', expected '+config['chromium_revision']+"\n")
if error:
sys.stderr.write("\nPlease see CHROMIUM_BUILD_COMPATIBILITY.txt for "\
"instructions.\n")

View File

@ -9,6 +9,10 @@ import os, sys
# The CEF root directory is the parent directory of _this_ script. # 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)) cef_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
print "\nChecking CEF and Chromium revisions..."
gyper = [ 'python', 'tools/check_revision.py' ]
RunAction(cef_dir, gyper)
print "\nGenerating CEF version header file..." print "\nGenerating CEF version header file..."
gyper = [ 'python', 'tools/make_version_header.py', gyper = [ 'python', 'tools/make_version_header.py',
'--header', 'version.h', '--header', 'version.h',

View File

@ -3,16 +3,38 @@
# can be found in the LICENSE file. # can be found in the LICENSE file.
import os import os
import urllib
def check_url(url):
""" Check the URL and raise an exception if invalid. """
if ':' in url[:7]:
parts = url.split(':', 1)
if (parts[0] == 'http' or parts[0] == 'https') and \
parts[1] == urllib.quote(parts[1]):
return url
sys.stderr.write('Invalid URL: '+url+"\n")
raise Exception('Invalid URL: '+url)
def get_svn_info(path):
""" Retrieves the URL and revision from svn info. """
url = 'None'
rev = 'None'
if path[0:4] == 'http' or os.path.exists(path):
try:
stream = os.popen('svn info '+path)
for line in stream:
if line[0:4] == "URL:":
url = check_url(line[5:-1])
elif line[0:9] == "Revision:":
rev = str(int(line[10:-1]))
except IOError, (errno, strerror):
sys.stderr.write('Failed to read svn info: '+strerror+"\n")
raise
return {'url': url, 'revision': rev}
def get_revision(path = '.'): def get_revision(path = '.'):
""" Retrieves the revision number from stdin. """ """ Retrieves the revision from svn info. """
try: info = get_svn_info(path)
stream = os.popen('svn info '+path); if info['revision'] == 'None':
# read the revision number raise Exception('Unable to retrieve SVN revision for "'+path+'"')
for line in stream: return info['revision']
if line[0:9] == "Revision:":
return line[10:-1];
raise IOError("Revision line not found.")
except IOError, (errno, strerror):
sys.stderr.write('Failed to read revision from "svn info": ' + strerror)
raise