OLD | NEW |
1 # Copyright (c) 2011 The Native Client Authors. All rights reserved. | 1 # Copyright (c) 2011 The Native Client Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Small utility library of python functions used by the various package | 5 """Small utility library of python functions used by the various package |
6 installers. | 6 installers. |
7 """ | 7 """ |
8 | 8 |
9 import datetime | 9 import datetime |
10 import errno | 10 import errno |
11 import fileinput | 11 import fileinput |
12 import os | 12 import os |
13 import platform | 13 import platform |
14 import re | 14 import re |
15 import shutil | 15 import shutil |
16 import subprocess | 16 import subprocess |
17 import sys | 17 import sys |
18 | 18 |
19 from nacl_sdk_scons import nacl_utils | 19 from nacl_sdk_scons import nacl_utils |
20 | 20 |
21 | 21 |
22 def ChromeMilestone(): | 22 # Reuse last change utility code. |
23 '''Extract chrome_milestone from src/DEPS | 23 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 24 SRC_DIR = os.path.dirname(os.path.dirname(os.path.dirname(SCRIPT_DIR))) |
| 25 sys.path.append(os.path.join(SRC_DIR, 'build/util')) |
| 26 import lastchange |
| 27 |
| 28 |
| 29 # Location of chrome's version file. |
| 30 VERSION_PATH = os.path.join(SRC_DIR, 'chrome', 'VERSION') |
| 31 |
| 32 |
| 33 def ChromeVersion(): |
| 34 '''Extract chrome version from src/chrome/VERSION + svn. |
24 | 35 |
25 Returns: | 36 Returns: |
26 Chrome milestone variable value from src/DEPS. | 37 Chrome version string or trunk + svn rev. |
27 ''' | 38 ''' |
28 parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | 39 info = lastchange.FetchVersionInfo(None) |
29 def From(x, y): | 40 if info.url.startswith('/trunk/'): |
30 return '' | 41 return 'trunk.%s' % info.revision |
31 def Var(x): | 42 else: |
32 return '' | 43 exec(open(VERSION_PATH, 'r').read()) |
33 def File(x): | 44 return '%s.%s.%s.%s' % (MAJOR, MINOR, BUILD, PATCH) |
34 return '' | 45 |
35 with open(os.path.join(parent_dir, 'DEPS'), 'r') as fh: | 46 |
36 exec(fh.read()) | 47 def ChromeMajorVersion(): |
37 return vars.get('chrome_milestone') | 48 '''Extract chrome major version from src/chrome/VERSION. |
| 49 |
| 50 Returns: |
| 51 Chrome major version. |
| 52 ''' |
| 53 exec(open(VERSION_PATH, 'r').read()) |
| 54 return str(MAJOR) |
38 | 55 |
39 | 56 |
40 #------------------------------------------------------------------------------ | 57 #------------------------------------------------------------------------------ |
41 # Parameters | 58 # Parameters |
42 | 59 |
43 # Revision numbers for the SDK | 60 # Revision numbers for the SDK |
44 PLATFORM_VERSION = 'pepper_' + ChromeMilestone() | 61 PLATFORM_VERSION = 'pepper_' + ChromeMajorVersion() |
45 | 62 |
46 TOOLCHAIN_AUTODETECT = "AUTODETECT" | 63 TOOLCHAIN_AUTODETECT = "AUTODETECT" |
47 | 64 |
48 #------------------------------------------------------------------------------ | 65 #------------------------------------------------------------------------------ |
49 # Functions | 66 # Functions |
50 | 67 |
51 # Make all the directories in |abs_path|. If |abs_path| points to a regular | 68 # Make all the directories in |abs_path|. If |abs_path| points to a regular |
52 # file, it is removed before an attempt to make the directories. If |abs_path| | 69 # file, it is removed before an attempt to make the directories. If |abs_path| |
53 # already points to a directory, this method does nothing. | 70 # already points to a directory, this method does nothing. |
54 def ForceMakeDirs(abs_path, mode=0755): | 71 def ForceMakeDirs(abs_path, mode=0755): |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 Args: | 315 Args: |
299 dir: The directory to clean | 316 dir: The directory to clean |
300 ''' | 317 ''' |
301 if sys.platform != 'win32': | 318 if sys.platform != 'win32': |
302 shutil.rmtree(dir, ignore_errors=True) | 319 shutil.rmtree(dir, ignore_errors=True) |
303 else: | 320 else: |
304 # Intentionally ignore return value since a directory might be in use. | 321 # Intentionally ignore return value since a directory might be in use. |
305 subprocess.call(['rmdir', '/Q', '/S', dir], | 322 subprocess.call(['rmdir', '/Q', '/S', dir], |
306 env=os.environ.copy(), | 323 env=os.environ.copy(), |
307 shell=True) | 324 shell=True) |
OLD | NEW |