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 print SRC_DIR | |
noelallen_use_chromium
2011/12/01 01:42:40
debugging info?
bradn
2011/12/01 01:52:02
Done.
| |
26 sys.path.append(os.path.join(SRC_DIR, 'build/util')) | |
27 import lastchange | |
28 | |
29 | |
30 def ChromeVersion(): | |
31 '''Extract chrome version from src/chrome/VERSION + svn. | |
24 | 32 |
25 Returns: | 33 Returns: |
26 Chrome milestone variable value from src/DEPS. | 34 Chrome version string or trunk + svn rev. |
27 ''' | 35 ''' |
28 parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | 36 info = lastchange.FetchVersionInfo(None) |
29 def From(x, y): | 37 if info.url.startswith('/trunk/'): |
30 return '' | 38 return 'trunk.%s' % info.revision |
31 def Var(x): | 39 else: |
32 return '' | 40 with open(os.path.join(SRC_DIR, 'chrome', 'VERSION'), 'r') as fh: |
noelallen_use_chromium
2011/12/01 01:42:40
Does this hide the e exception so that you get a r
bradn
2011/12/01 01:52:02
Done.
| |
33 def File(x): | 41 exec(fh.read()) |
34 return '' | 42 return '%s.%s.%s.%s' % (MAJOR, MINOR, BUILD, PATCH) |
35 with open(os.path.join(parent_dir, 'DEPS'), 'r') as fh: | |
36 exec(fh.read()) | |
37 return vars.get('chrome_milestone') | |
38 | 43 |
39 | 44 |
40 #------------------------------------------------------------------------------ | 45 #------------------------------------------------------------------------------ |
41 # Parameters | 46 # Parameters |
42 | 47 |
43 # Revision numbers for the SDK | 48 # Revision numbers for the SDK |
44 PLATFORM_VERSION = 'pepper_' + ChromeMilestone() | 49 PLATFORM_VERSION = ChromeVersion() |
noelallen_use_chromium
2011/12/01 01:42:40
This might effect the "pepper_XX" string used in t
bradn
2011/12/01 01:52:02
Done.
| |
45 | 50 |
46 TOOLCHAIN_AUTODETECT = "AUTODETECT" | 51 TOOLCHAIN_AUTODETECT = "AUTODETECT" |
47 | 52 |
48 #------------------------------------------------------------------------------ | 53 #------------------------------------------------------------------------------ |
49 # Functions | 54 # Functions |
50 | 55 |
51 # Make all the directories in |abs_path|. If |abs_path| points to a regular | 56 # 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| | 57 # file, it is removed before an attempt to make the directories. If |abs_path| |
53 # already points to a directory, this method does nothing. | 58 # already points to a directory, this method does nothing. |
54 def ForceMakeDirs(abs_path, mode=0755): | 59 def ForceMakeDirs(abs_path, mode=0755): |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
298 Args: | 303 Args: |
299 dir: The directory to clean | 304 dir: The directory to clean |
300 ''' | 305 ''' |
301 if sys.platform != 'win32': | 306 if sys.platform != 'win32': |
302 shutil.rmtree(dir, ignore_errors=True) | 307 shutil.rmtree(dir, ignore_errors=True) |
303 else: | 308 else: |
304 # Intentionally ignore return value since a directory might be in use. | 309 # Intentionally ignore return value since a directory might be in use. |
305 subprocess.call(['rmdir', '/Q', '/S', dir], | 310 subprocess.call(['rmdir', '/Q', '/S', dir], |
306 env=os.environ.copy(), | 311 env=os.environ.copy(), |
307 shell=True) | 312 shell=True) |
OLD | NEW |