Update scripts to support git checkouts of CEF and/or Chromium.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1664 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2014-04-18 18:31:22 +00:00
parent 5e5b753c4c
commit da87cf449d
7 changed files with 109 additions and 61 deletions

View File

@ -9,4 +9,5 @@
{ {
'chromium_url': 'http://src.chromium.org/svn/trunk/src', 'chromium_url': 'http://src.chromium.org/svn/trunk/src',
'chromium_revision': '261035', 'chromium_revision': '261035',
'chromium_checkout': '1312deba7b323a2285202f88acfbd59500bf9779',
} }

View File

@ -4,9 +4,11 @@ Chromium Embedded Framework (CEF) $DISTRIB_TYPE$ Binary Distribution for $PLATFO
Date: $DATE$ Date: $DATE$
CEF Version: $CEF_VER$ CEF Version: $CEF_VER$
CEF URL: $CEF_URL$@$CEF_REV$ CEF URL: $CEF_URL$
@$CEF_REV$
Chromium Verison: $CHROMIUM_VER$ Chromium Verison: $CHROMIUM_VER$
Chromium URL: $CHROMIUM_URL$@$CHROMIUM_REV$ Chromium URL: $CHROMIUM_URL$
@$CHROMIUM_REV$
$DISTRIB_DESC$ $DISTRIB_DESC$

21
tools/exec_util.py Normal file
View File

@ -0,0 +1,21 @@
# Copyright (c) 2014 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 subprocess import Popen, PIPE
import sys
def exec_cmd(cmd, path):
""" Execute the specified command and return the result. """
out = ''
err = ''
parts = cmd.split()
try:
process = Popen(cmd, cwd=path, stdout=PIPE, stderr=PIPE,
shell=(sys.platform == 'win32'))
out, err = process.communicate()
except IOError, (errno, strerror):
raise
except:
raise
return {'out': out, 'err': err}

View File

@ -1,26 +1,44 @@
# Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights # Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that # reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file # can be found in the LICENSE file
from subprocess import Popen, PIPE from exec_util import exec_cmd
import sys import os
def get_svn_revision(path=".", branch="master"): def is_checkout(path):
svn_rev = "None" """ Returns true if the path represents a git checkout. """
cmd = ("git log --grep=^git-svn-id: -n 1 %s" % branch).split() return os.path.exists(os.path.join(path, '.git'))
try:
process = Popen(cmd, cwd=path, stdout = PIPE, stderr = PIPE,
shell=(sys.platform == 'win32'))
for line in process.stdout:
if line.find("git-svn-id") > 0:
svn_rev = line.split("@")[1].split()[0]
break
except IOError, (errno, strerror):
sys.stderr.write('Failed to read git log: ' + strerror + "\n")
raise
return svn_rev
def get_changed_files(path="."): def get_hash(path = '.', branch = 'master'):
""" Returns the git hash for the specified branch/tag/hash. """
cmd = "git rev-parse %s" % (branch)
result = exec_cmd(cmd, path)
if result['out'] != '':
return result['out'].strip()
return 'Unknown'
def get_url(path = '.'):
""" Returns the origin url for the specified path. """
cmd = "git config --get remote.origin.url"
result = exec_cmd(cmd, path)
if result['out'] != '':
return result['out'].strip()
return 'Unknown'
def get_svn_revision(path = '.', branch = 'master'):
""" Returns the SVN revision associated with the specified path and git
branch/tag/hash. """
svn_rev = "None"
cmd = "git log --grep=^git-svn-id: -n 1 %s" % (branch)
result = exec_cmd(cmd, path)
if result['err'] == '':
for line in result['out'].split('\n'):
if line.find("git-svn-id") > 0:
svn_rev = line.split("@")[1].split()[0]
break
return svn_rev
def get_changed_files(path = '.'):
""" Retrieves the list of changed files. """ """ Retrieves the list of changed files. """
# not implemented # not implemented
return [] return []

View File

@ -10,7 +10,8 @@ import os
import re import re
import shlex import shlex
import subprocess import subprocess
from svn_util import * import svn_util as svn
import git_util as git
import sys import sys
import zipfile import zipfile
@ -362,13 +363,28 @@ cef_dir = os.path.abspath(os.path.join(script_dir, os.pardir))
# src directory # src directory
src_dir = os.path.abspath(os.path.join(cef_dir, os.pardir)) src_dir = os.path.abspath(os.path.join(cef_dir, os.pardir))
# retrieve url, revision and date information # retrieve url and revision information for CEF
cef_info = get_svn_info(cef_dir) if svn.is_checkout(cef_dir):
cef_url = cef_info['url'] cef_info = svn.get_svn_info(cef_dir)
cef_rev = cef_info['revision'] cef_url = cef_info['url']
chromium_info = get_svn_info(os.path.join(cef_dir, os.pardir)) cef_rev = cef_info['revision']
chromium_url = chromium_info['url'] elif git.is_checkout(cef_dir):
chromium_rev = chromium_info['revision'] cef_url = git.get_url(cef_dir)
cef_rev = git.get_svn_revision(cef_dir)
else:
raise Exception('Not a valid checkout: %s' % (cef_dir))
# retrieve url and revision information for Chromium
if svn.is_checkout(src_dir):
chromium_info = svn.get_svn_info(src_dir)
chromium_url = cef_info['url']
chromium_rev = cef_info['revision']
elif git.is_checkout(src_dir):
chromium_url = git.get_url(src_dir)
chromium_rev = git.get_hash(src_dir, 'HEAD')
else:
raise Exception('Not a valid checkout: %s' % (src_dir))
date = get_date() date = get_date()
# Read and parse the version file (key=value pairs, one per line) # Read and parse the version file (key=value pairs, one per line)

View File

@ -60,9 +60,9 @@ def write_svn_header(header, chrome_version, cef_version, cpp_header_dir):
year = get_year() year = get_year()
if os.path.exists(os.path.join('.', '.svn')): if svn.is_checkout('.'):
revision = svn.get_revision() revision = svn.get_revision()
elif os.path.exists(os.path.join('.', '.git')): elif git.is_checkout('.'):
revision = git.get_svn_revision() revision = git.get_svn_revision()
else: else:
raise Exception('Not a valid checkout') raise Exception('Not a valid checkout')

View File

@ -1,13 +1,16 @@
# Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights # Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that # reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file. # can be found in the LICENSE file
from exec_util import exec_cmd
import os import os
import sys
import subprocess
import urllib import urllib
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
def is_checkout(path):
""" Returns true if the path represents an svn checkout. """
return os.path.exists(os.path.join(path, '.svn'))
def check_url(url): def check_url(url):
""" Check the URL and raise an exception if invalid. """ """ Check the URL and raise an exception if invalid. """
if ':' in url[:7]: if ':' in url[:7]:
@ -15,42 +18,30 @@ def check_url(url):
if (parts[0] == 'http' or parts[0] == 'https' or parts[0] == 'svn') and \ if (parts[0] == 'http' or parts[0] == 'https' or parts[0] == 'svn') and \
parts[1] == urllib.quote(parts[1]): parts[1] == urllib.quote(parts[1]):
return url return url
sys.stderr.write('Invalid URL: '+url+"\n") raise Exception('Invalid URL: %s' % (url))
raise Exception('Invalid URL: '+url)
def get_svn_info(path): def get_svn_info(path = '.'):
""" Retrieves the URL and revision from svn info. """ """ Retrieves the URL and revision from svn info. """
url = 'None' url = 'None'
rev = 'None' rev = 'None'
if path[0:4] == 'http' or os.path.exists(path): cmd = "svn info --xml %s" % (path)
try: is_http = path[0:4] == 'http'
if sys.platform == 'win32': if is_http or os.path.exists(path):
# Force use of the SVN version bundled with depot_tools. result = exec_cmd(cmd, path if not is_http else '.')
svn = 'svn.bat' if result['err'] == '':
else: tree = ET.ElementTree(ET.fromstring(result['out']))
svn = 'svn' entry = tree.getroot().find('entry')
p = subprocess.Popen([svn, 'info', '--xml', path], \ url = entry.find('url').text
stdout=subprocess.PIPE, stderr=subprocess.PIPE) rev = entry.attrib['revision']
out, err = p.communicate() else:
if err == '': raise Exception("Failed to execute svn info: %s" % (result['err']))
tree = ET.ElementTree(ET.fromstring(out))
entry = tree.getroot().find('entry')
url = entry.find('url').text
rev = entry.attrib['revision']
else:
raise Exception("Failed to execute svn info:\n"+err+"\n")
except IOError, (errno, strerror):
sys.stderr.write('Failed to read svn info: '+strerror+"\n")
raise
except:
raise
return {'url': url, 'revision': rev} return {'url': url, 'revision': rev}
def get_revision(path = '.'): def get_revision(path = '.'):
""" Retrieves the revision from svn info. """ """ Retrieves the revision from svn info. """
info = get_svn_info(path) info = get_svn_info(path)
if info['revision'] == 'None': if info['revision'] == 'None':
raise Exception('Unable to retrieve SVN revision for "'+path+'"') raise Exception('Unable to retrieve SVN revision for %s' % (path))
return info['revision'] return info['revision']
def get_changed_files(path = '.'): def get_changed_files(path = '.'):
@ -65,6 +56,5 @@ def get_changed_files(path = '.'):
if status == 'A' or status == 'M' or status == 'S': if status == 'A' or status == 'M' or status == 'S':
files.append(line[8:].strip()) files.append(line[8:].strip())
except IOError, (errno, strerror): except IOError, (errno, strerror):
sys.stderr.write('Failed to read svn status: '+strerror+"\n")
raise raise
return files return files