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_revision': '261035',
'chromium_checkout': '1312deba7b323a2285202f88acfbd59500bf9779',
}

View File

@ -4,9 +4,11 @@ Chromium Embedded Framework (CEF) $DISTRIB_TYPE$ Binary Distribution for $PLATFO
Date: $DATE$
CEF Version: $CEF_VER$
CEF URL: $CEF_URL$@$CEF_REV$
CEF URL: $CEF_URL$
@$CEF_REV$
Chromium Verison: $CHROMIUM_VER$
Chromium URL: $CHROMIUM_URL$@$CHROMIUM_REV$
Chromium URL: $CHROMIUM_URL$
@$CHROMIUM_REV$
$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
# can be found in the LICENSE file
from subprocess import Popen, PIPE
import sys
from exec_util import exec_cmd
import os
def get_svn_revision(path=".", branch="master"):
def is_checkout(path):
""" Returns true if the path represents a git checkout. """
return os.path.exists(os.path.join(path, '.git'))
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).split()
try:
process = Popen(cmd, cwd=path, stdout = PIPE, stderr = PIPE,
shell=(sys.platform == 'win32'))
for line in process.stdout:
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
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_changed_files(path = '.'):
""" Retrieves the list of changed files. """
# not implemented
return []

View File

@ -10,7 +10,8 @@ import os
import re
import shlex
import subprocess
from svn_util import *
import svn_util as svn
import git_util as git
import sys
import zipfile
@ -362,13 +363,28 @@ cef_dir = os.path.abspath(os.path.join(script_dir, os.pardir))
# src directory
src_dir = os.path.abspath(os.path.join(cef_dir, os.pardir))
# retrieve url, revision and date information
cef_info = get_svn_info(cef_dir)
cef_url = cef_info['url']
cef_rev = cef_info['revision']
chromium_info = get_svn_info(os.path.join(cef_dir, os.pardir))
chromium_url = chromium_info['url']
chromium_rev = chromium_info['revision']
# retrieve url and revision information for CEF
if svn.is_checkout(cef_dir):
cef_info = svn.get_svn_info(cef_dir)
cef_url = cef_info['url']
cef_rev = cef_info['revision']
elif git.is_checkout(cef_dir):
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()
# 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()
if os.path.exists(os.path.join('.', '.svn')):
if svn.is_checkout('.'):
revision = svn.get_revision()
elif os.path.exists(os.path.join('.', '.git')):
elif git.is_checkout('.'):
revision = git.get_svn_revision()
else:
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
# can be found in the LICENSE file.
# can be found in the LICENSE file
from exec_util import exec_cmd
import os
import sys
import subprocess
import urllib
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):
""" Check the URL and raise an exception if invalid. """
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 \
parts[1] == urllib.quote(parts[1]):
return url
sys.stderr.write('Invalid URL: '+url+"\n")
raise Exception('Invalid URL: '+url)
raise Exception('Invalid URL: %s' % (url))
def get_svn_info(path):
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:
if sys.platform == 'win32':
# Force use of the SVN version bundled with depot_tools.
svn = 'svn.bat'
else:
svn = 'svn'
p = subprocess.Popen([svn, 'info', '--xml', path], \
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
if err == '':
tree = ET.ElementTree(ET.fromstring(out))
cmd = "svn info --xml %s" % (path)
is_http = path[0:4] == 'http'
if is_http or os.path.exists(path):
result = exec_cmd(cmd, path if not is_http else '.')
if result['err'] == '':
tree = ET.ElementTree(ET.fromstring(result['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
raise Exception("Failed to execute svn info: %s" % (result['err']))
return {'url': url, 'revision': rev}
def get_revision(path = '.'):
""" Retrieves the revision from svn info. """
info = get_svn_info(path)
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']
def get_changed_files(path = '.'):
@ -65,6 +56,5 @@ def get_changed_files(path = '.'):
if status == 'A' or status == 'M' or status == 'S':
files.append(line[8:].strip())
except IOError, (errno, strerror):
sys.stderr.write('Failed to read svn status: '+strerror+"\n")
raise
return files