mirror of
https://github.com/dart-lang/sdk
synced 2024-10-07 09:35:06 +00:00
First CL for removing our dependency on the checked-in binary for building
R=ricow@google.com Review URL: https://codereview.chromium.org//22393002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25809 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
25041cc9f8
commit
315daf1d72
|
@ -13,13 +13,12 @@ Compiles dart client apps with dartc, and run the client tests both in headless
|
|||
chromium and headless dartium.
|
||||
"""
|
||||
|
||||
import imp
|
||||
import os
|
||||
import re
|
||||
import socket
|
||||
import subprocess
|
||||
import sys
|
||||
import shutil
|
||||
import glob
|
||||
|
||||
BUILDER_NAME = 'BUILDBOT_BUILDERNAME'
|
||||
BUILDER_CLOBBER = 'BUILDBOT_CLOBBER'
|
||||
|
@ -30,6 +29,13 @@ DARTIUM_VERSION_FILE = 'client/tests/drt/LAST_VERSION'
|
|||
DARTIUM_V_MATCHER = (
|
||||
'gs://dartium-archive/[^/]*/dartium-\w*-inc-([0-9]*).([0-9]*).zip')
|
||||
|
||||
def GetUtils():
|
||||
'''Dynamically load the tools/utils.py python module.'''
|
||||
dart_dir = os.path.abspath(os.path.join(__file__, '..', '..', '..'))
|
||||
return imp.load_source('utils', os.path.join(dart_dir, 'tools', 'utils.py'))
|
||||
|
||||
utils = GetUtils()
|
||||
|
||||
def GetBuildInfo():
|
||||
"""Returns a tuple (name, version, mode) where:
|
||||
- name: A name for the build - the buildbot host if a buildbot.
|
||||
|
@ -58,21 +64,7 @@ def GetBuildInfo():
|
|||
version = 'unknown'
|
||||
return (name, version)
|
||||
|
||||
|
||||
def GetUtils():
|
||||
'''
|
||||
dynamically get the utils module
|
||||
We use a dynamic import for tools/util.py because we derive its location
|
||||
dynamically using sys.argv[0]. This allows us to run this script from
|
||||
different directories.
|
||||
|
||||
args:
|
||||
'''
|
||||
sys.path.append(os.path.abspath(os.path.join('.', 'tools')))
|
||||
utils = __import__('utils')
|
||||
return utils
|
||||
|
||||
def GetOutDir(utils, mode):
|
||||
def GetOutDir(mode):
|
||||
'''
|
||||
get the location to place the output
|
||||
|
||||
|
@ -99,8 +91,7 @@ def ProcessTools(mode, name, version):
|
|||
# get the latest changed revision from the current repository sub-tree
|
||||
version = GetLatestChangedRevision()
|
||||
|
||||
utils = GetUtils()
|
||||
outdir = GetOutDir(utils, mode)
|
||||
outdir = GetOutDir(mode)
|
||||
cmds = [sys.executable, toolsBuildScript,
|
||||
'--mode=' + mode, '--revision=' + version,
|
||||
'--name=' + name, '--out=' + outdir]
|
||||
|
@ -162,32 +153,11 @@ def ClobberBuilder():
|
|||
def GetShouldClobber():
|
||||
return os.environ.get(BUILDER_CLOBBER) == "1"
|
||||
|
||||
def RunDart(scriptPath):
|
||||
if sys.platform == 'darwin':
|
||||
pipe = subprocess.Popen(
|
||||
['./tools/testing/bin/macos/dart', scriptPath],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
elif os.name == 'posix':
|
||||
pipe = subprocess.Popen(
|
||||
['./tools/testing/bin/linux/dart', scriptPath],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
else:
|
||||
pipe = subprocess.Popen(
|
||||
['tools\\testing\\bin\\windows\\dart.exe', scriptPath],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
||||
|
||||
output = pipe.communicate()
|
||||
return output[0]
|
||||
|
||||
def GetLatestChangedRevision():
|
||||
# 0.1.2.0_r13661
|
||||
# 0.1.2.0_r13661_username
|
||||
fullVersion = RunDart("tools/version.dart")
|
||||
|
||||
m = re.search('._r(\d+)', fullVersion)
|
||||
svnRev = m.group(1)
|
||||
|
||||
return svnRev
|
||||
revision = utils.GetSVNRevision()
|
||||
if not revision:
|
||||
raise Exception("Couldn't determine last changed revision.")
|
||||
return revision
|
||||
|
||||
def main():
|
||||
if len(sys.argv) == 0:
|
||||
|
|
|
@ -79,8 +79,7 @@
|
|||
'inputs': [
|
||||
'../tools/make_version.py',
|
||||
'../tools/utils.py',
|
||||
'../tools/version.dart',
|
||||
'../tools/release/version.dart',
|
||||
'../tools/print_version.py',
|
||||
'../tools/VERSION',
|
||||
'<(version_in_cc_file)',
|
||||
# Depend on libdart_dependency_helper to track the libraries it
|
||||
|
|
|
@ -13,8 +13,12 @@
|
|||
import sys
|
||||
import utils
|
||||
|
||||
def Main(argv):
|
||||
print(utils.GetVersion())
|
||||
def Main():
|
||||
version = utils.GetVersion()
|
||||
if not version:
|
||||
print 'Error: Couldn\'t determine version string.'
|
||||
return 1
|
||||
print version
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(Main(sys.argv))
|
||||
sys.exit(Main())
|
||||
|
|
|
@ -205,7 +205,6 @@ def GetBuildbotGSUtilPath():
|
|||
return gsutil
|
||||
|
||||
def GetBuildMode(mode):
|
||||
global BUILD_MODES
|
||||
return BUILD_MODES[mode]
|
||||
|
||||
|
||||
|
@ -214,10 +213,10 @@ def GetBuildConf(mode, arch):
|
|||
|
||||
ARCH_GUESS = GuessArchitecture()
|
||||
BASE_DIR = os.path.abspath(os.path.join(os.curdir, '..'))
|
||||
DART_DIR = os.path.abspath(os.path.join(__file__, '..', '..'))
|
||||
|
||||
|
||||
def GetBuildDir(host_os, target_os):
|
||||
global BUILD_ROOT
|
||||
build_dir = BUILD_ROOT[host_os]
|
||||
if target_os and target_os != host_os:
|
||||
build_dir = os.path.join(build_dir, target_os)
|
||||
|
@ -233,28 +232,71 @@ def GetBaseDir():
|
|||
return BASE_DIR
|
||||
|
||||
def GetVersion():
|
||||
dartbin = DartBinary()
|
||||
version_script = VersionScript()
|
||||
p = subprocess.Popen([dartbin, version_script], stdout = subprocess.PIPE,
|
||||
stderr = subprocess.STDOUT, shell=IsWindows())
|
||||
output, not_used = p.communicate()
|
||||
return output.strip()
|
||||
version_tuple = ReadVersionFile()
|
||||
if not version_tuple:
|
||||
return None
|
||||
|
||||
(major, minor, build, patch) = version_tuple
|
||||
revision = GetSVNRevision()
|
||||
user = GetUserName()
|
||||
# We don't add username to release builds (or any builds on the bots)
|
||||
if user == 'chrome-bot':
|
||||
user = ''
|
||||
|
||||
user_string = ''
|
||||
revision_string = ''
|
||||
if user:
|
||||
user_string = '_%s' % user
|
||||
if revision:
|
||||
revision_string = '_r%s' % revision
|
||||
|
||||
return ("%s.%s.%s.%s%s%s" %
|
||||
(major, minor, build, patch, revision_string, user_string))
|
||||
|
||||
def GetUserName():
|
||||
key = 'USER'
|
||||
if sys.platform == 'win32':
|
||||
key = 'USERNAME'
|
||||
return os.environ.get(key, '')
|
||||
|
||||
def ReadVersionFile():
|
||||
version_file = os.path.join(DART_DIR, 'tools', 'VERSION')
|
||||
try:
|
||||
fd = open(version_file)
|
||||
content = fd.read()
|
||||
fd.close()
|
||||
except:
|
||||
print "Warning: Couldn't read VERSION file (%s)" % version_file
|
||||
return None
|
||||
major_match = re.search('MAJOR (\d+)', content)
|
||||
minor_match = re.search('MINOR (\d+)', content)
|
||||
build_match = re.search('BUILD (\d+)', content)
|
||||
patch_match = re.search('PATCH (\d+)', content)
|
||||
if major_match and minor_match and build_match and patch_match:
|
||||
return (major_match.group(1), minor_match.group(1), build_match.group(1),
|
||||
patch_match.group(1))
|
||||
else:
|
||||
print "Warning: VERSION file (%s) has wrong format" % version_file
|
||||
return None
|
||||
|
||||
def GetSVNRevision():
|
||||
# FIXME(kustermann): Make this work for newer SVN versions as well (where
|
||||
# we've got only one '.svn' directory)
|
||||
custom_env = dict(os.environ)
|
||||
custom_env['LC_MESSAGES'] = 'en_GB'
|
||||
p = subprocess.Popen(['svn', 'info'], stdout = subprocess.PIPE,
|
||||
stderr = subprocess.STDOUT, shell=IsWindows(),
|
||||
env = custom_env)
|
||||
output, not_used = p.communicate()
|
||||
env = custom_env,
|
||||
cwd = DART_DIR)
|
||||
output, _ = p.communicate()
|
||||
revision = ParseSvnInfoOutput(output)
|
||||
if revision:
|
||||
return revision
|
||||
|
||||
# maybe the builder is using git-svn, try that
|
||||
p = subprocess.Popen(['git', 'svn', 'info'], stdout = subprocess.PIPE,
|
||||
stderr = subprocess.STDOUT, shell=IsWindows())
|
||||
output, not_used = p.communicate()
|
||||
stderr = subprocess.STDOUT, shell=IsWindows(), cwd = DART_DIR)
|
||||
output, _ = p.communicate()
|
||||
revision = ParseSvnInfoOutput(output)
|
||||
if revision:
|
||||
return revision
|
||||
|
@ -262,9 +304,9 @@ def GetSVNRevision():
|
|||
return None
|
||||
|
||||
def ParseSvnInfoOutput(output):
|
||||
for line in output.split('\n'):
|
||||
if 'Revision' in line:
|
||||
return (line.strip().split())[1]
|
||||
revision_match = re.search('Last Changed Rev: (\d+)', output)
|
||||
if revision_match:
|
||||
return revision_match.group(1)
|
||||
return None
|
||||
|
||||
def RewritePathSeparator(path, workspace):
|
||||
|
@ -389,11 +431,6 @@ def Touch(name):
|
|||
os.utime(name, None)
|
||||
|
||||
|
||||
def VersionScript():
|
||||
tools_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
return os.path.join(tools_dir, 'version.dart')
|
||||
|
||||
|
||||
def DartBinary():
|
||||
tools_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
dart_binary_prefix = os.path.join(tools_dir, 'testing', 'bin')
|
||||
|
|
|
@ -5,19 +5,15 @@
|
|||
import 'dart:io';
|
||||
|
||||
Future<String> getVersion(var options, var rootPath) {
|
||||
var os = Platform.operatingSystem;
|
||||
var suffix = os == 'windows' ? '.exe' : '';
|
||||
var checkedInBinary =
|
||||
rootPath.join(new Path('tools/testing/bin/$os/dart$suffix'));
|
||||
var versionPath = rootPath.append("tools").append("version.dart");
|
||||
return Process.run(checkedInBinary.toNativePath(),
|
||||
[versionPath.toNativePath()])
|
||||
.then((result) {
|
||||
if (result.exitCode != 0) {
|
||||
throw "Could not generate version";
|
||||
}
|
||||
return result.stdout.trim();
|
||||
});
|
||||
var suffix = Platform.operatingSystem == 'windows' ? '.exe' : '';
|
||||
var printVersionScript =
|
||||
rootPath.append("tools").append("print_version.py").toNativePath();
|
||||
return Process.run("python$suffix", [printVersionScript]).then((result) {
|
||||
if (result.exitCode != 0) {
|
||||
throw "Could not generate version";
|
||||
}
|
||||
return result.stdout.trim();
|
||||
});
|
||||
}
|
||||
|
||||
Future<String> getSnapshotGenerationFile(var options, var args, var rootPath) {
|
||||
|
|
Loading…
Reference in a new issue