1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 """Small utility library of python functions used during SDK building.
11 # pylint: disable=E0602
13 # Reuse last change utility code.
14 SCRIPT_DIR
= os
.path
.dirname(os
.path
.abspath(__file__
))
15 SRC_DIR
= os
.path
.dirname(os
.path
.dirname(os
.path
.dirname(SCRIPT_DIR
)))
16 sys
.path
.append(os
.path
.join(SRC_DIR
, 'build/util'))
20 # Location of chrome's version file.
21 VERSION_PATH
= os
.path
.join(SRC_DIR
, 'chrome', 'VERSION')
25 '''Extract chrome version from src/chrome/VERSION + svn.
28 Chrome version string or trunk + svn rev.
30 info
= lastchange
.FetchVersionInfo(None)
31 if info
.url
.startswith('/trunk/'):
32 return 'trunk.%s' % info
.revision
34 return ChromeVersionNoTrunk()
37 def ChromeVersionNoTrunk():
38 '''Extract the chrome version from src/chrome/VERSION.
39 Ignore whether this is a trunk build.
42 Chrome version string.
44 exec(open(VERSION_PATH
).read())
45 return '%s.%s.%s.%s' % (MAJOR
, MINOR
, BUILD
, PATCH
)
48 def ChromeMajorVersion():
49 '''Extract chrome major version from src/chrome/VERSION.
54 exec(open(VERSION_PATH
, 'r').read())
59 '''Extract chrome revision from svn.
62 The Chrome revision as a string. e.g. "12345"
64 return lastchange
.FetchVersionInfo(None).revision
67 '''Extract NaCl revision from svn.
70 The NaCl revision as a string. e.g. "12345"
72 nacl_dir
= os
.path
.join(SRC_DIR
, 'native_client')
73 return lastchange
.FetchVersionInfo(None, nacl_dir
).revision