OLD | NEW |
---|---|
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 """Entry point for the AddIn build bot. | 5 """Entry point for the AddIn build bot. |
6 | 6 |
7 Perform build steps and output results using the buildbot | 7 Perform build steps and output results using the buildbot |
8 annootator syntax | 8 annootator syntax |
9 """ | 9 """ |
10 | 10 |
11 import os | 11 import os |
12 import sys | 12 import sys |
13 import subprocess | 13 import subprocess |
14 import urllib2 | |
15 import zipfile | |
16 from os.path import join | |
binji
2012/10/09 01:05:11
any reason for this? calling it "join" makes it se
Sam Clegg
2012/10/09 17:04:33
This is a pattern that I've followed over the year
| |
14 | 17 |
15 GSURL = 'https://commondatastorage.googleapis.com' | 18 GSURL = 'https://commondatastorage.googleapis.com' |
16 GSPATH = 'nativeclient-mirror/nacl/nacl_sdk/sdk' | 19 GSPATH = 'nativeclient-mirror/nacl/nacl_sdk/sdk' |
17 | 20 |
18 def Log(msg): | 21 def Log(msg): |
19 sys.stdout.write(msg + '\n') | 22 sys.stdout.write(msg + '\n') |
20 sys.stdout.flush() | 23 sys.stdout.flush() |
21 | 24 |
22 | 25 |
23 def RunCommand(cmd): | 26 def RunCommand(cmd): |
24 Log("Running: %s" % cmd) | 27 Log("Running: %s" % cmd) |
25 Log("CWD: %s" % os.getcwd()) | 28 Log("CWD: %s" % os.getcwd()) |
29 if type(cmd) == str: | |
30 if sys.platform == 'cygwin': | |
binji
2012/10/09 01:05:11
what about when the cmd is a list?
Sam Clegg
2012/10/09 17:04:33
You are right it could be nicer. I'm making the a
| |
31 cmd = './' + cmd | |
32 cmd = [cmd] | |
33 | |
26 rtn = subprocess.call(cmd, shell=True) | 34 rtn = subprocess.call(cmd, shell=True) |
27 if rtn: | 35 if rtn: |
28 Log('@@@STEP_FAILURE@@@') | 36 Log('@@@STEP_FAILURE@@@') |
29 sys.exit(1) | 37 sys.exit(1) |
30 | 38 |
31 | 39 |
32 def StepBuild(): | 40 def StepBuild(): |
33 Log('@@@BUILD_STEP build AddIn@@@') | 41 Log('@@@BUILD_STEP build AddIn@@@') |
34 if sys.platform == 'cygwin': | 42 RunCommand('build.bat') |
35 RunCommand(['./build.bat']) | 43 |
36 else: | 44 |
37 RunCommand(['build.bat']) | 45 def StepInstall(): |
46 Log('@@@BUILD_STEP Install AddIn@@@') | |
47 RunCommand('developer_deploy.bat') | |
48 | |
49 | |
50 def StepInstallSDK(): | |
51 Log('@@@BUILD_STEP Install SDK@@@') | |
52 sdk_root = join('..', '..', 'out', 'sdk') | |
binji
2012/10/09 01:05:11
make this path a constant.
Sam Clegg
2012/10/09 17:04:33
Done.
| |
53 naclsdk = join(sdk_root, 'nacl_sdk', 'naclsdk.bat') | |
54 if not os.path.exists(naclsdk): | |
55 if not os.path.exists(sdk_root): | |
56 os.makedirs(sdk_root) | |
57 filename = join(sdk_root, 'nacl_sdk.zip') | |
58 url = "http://storage.googleapis.com/nativeclient-mirror/nacl/nacl_sdk/nacl_ sdk.zip" | |
binji
2012/10/09 01:05:11
Use GSURL above (and add a new path to this file)
Sam Clegg
2012/10/09 17:04:33
Done.
| |
59 contents = urllib2.urlopen(url).read() | |
60 with open(filename, 'wb') as zfileout: | |
61 zfileout.write(contents) | |
62 zfile = zipfile.ZipFile(filename) | |
63 print zfile | |
binji
2012/10/09 01:05:11
does this print anything useful?
Sam Clegg
2012/10/09 17:04:33
Done.
| |
64 zfile.extractall(sdk_root) | |
65 | |
66 RunCommand([naclsdk, '--update-sdk-tools']) | |
67 RunCommand([naclsdk, 'install', '--force', 'pepper_23']) | |
68 RunCommand([naclsdk, 'install', '--force', 'pepper_canary']) | |
38 | 69 |
39 | 70 |
40 def StepTest(): | 71 def StepTest(): |
41 Log('@@@BUILD_STEP Testing AddIn@@@') | 72 Log('@@@BUILD_STEP Testing AddIn@@@') |
42 # Don't actually test yet | 73 # Don't actually test yet |
43 #RunCommand(['test.bat']) | 74 sdk_root = os.path.abspath(join('..', '..', 'out', 'sdk', 'nacl_sdk')) |
75 os.environ['NACL_SDK_ROOT'] = join(sdk_root, 'pepper_23') | |
binji
2012/10/09 01:05:11
Probably nicer to set the environment in RunComman
Sam Clegg
2012/10/09 17:04:33
Done.
| |
76 RunCommand('test.bat') | |
77 os.environ['NACL_SDK_ROOT'] = join(sdk_root, 'pepper_canary') | |
78 RunCommand('test.bat') | |
44 | 79 |
45 | 80 |
46 def _FindInPath(filename): | 81 def _FindInPath(filename): |
47 for path in os.environ['PATH'].split(os.pathsep): | 82 for path in os.environ['PATH'].split(os.pathsep): |
48 result = os.path.join(path, filename) | 83 result = join(path, filename) |
49 if os.path.exists(result): | 84 if os.path.exists(result): |
50 return result | 85 return result |
51 | 86 |
52 Log('%s not found in PATH' % filename) | 87 Log('%s not found in PATH' % filename) |
53 Log('@@@STEP_FAILURE@@@') | 88 Log('@@@STEP_FAILURE@@@') |
54 sys.exit(1) | 89 sys.exit(1) |
55 | 90 |
56 | 91 |
57 def _GetGsutil(): | 92 def _GetGsutil(): |
58 if os.environ.get('BUILDBOT_BUILDERNAME'): | 93 if os.environ.get('BUILDBOT_BUILDERNAME'): |
59 # When running in a buildbot slave use | 94 # When running in a buildbot slave use |
60 # gsutil from the slave scripts folder | 95 # gsutil from the slave scripts folder |
61 import slave | 96 import slave |
62 slave_dir = os.path.dirname(slave.__file__) | 97 slave_dir = os.path.dirname(slave.__file__) |
63 gsutil = os.path.join(slave_dir, 'gsutil') | 98 gsutil = join(slave_dir, 'gsutil') |
64 if os.name == 'nt': | 99 if os.name == 'nt': |
65 gsutil += '.bat' | 100 gsutil += '.bat' |
66 gsutil = [gsutil] | 101 gsutil = [gsutil] |
67 else: | 102 else: |
68 if os.name == 'nt': | 103 if os.name == 'nt': |
69 gsutil = [sys.executable, _FindInPath('gsutil')] | 104 gsutil = [sys.executable, _FindInPath('gsutil')] |
70 else: | 105 else: |
71 gsutil = ['gsutil'] | 106 gsutil = ['gsutil'] |
72 | 107 |
73 return gsutil | 108 return gsutil |
74 | 109 |
75 | 110 |
76 def StepArchive(): | 111 def StepArchive(): |
77 rev = os.environ.get('BUILDBOT_GOT_REVISION') | 112 rev = os.environ.get('BUILDBOT_GOT_REVISION') |
78 if not rev: | 113 if not rev: |
79 Log('No BUILDBOT_GOT_REVISION found in environ') | 114 Log('No BUILDBOT_GOT_REVISION found in environ') |
80 Log('@@@STEP_FAILURE@@@') | 115 Log('@@@STEP_FAILURE@@@') |
81 sys.exit(1) | 116 sys.exit(1) |
82 Log('@@@BUILD_STEP Archiving %s@@@' % rev) | 117 Log('@@@BUILD_STEP Archiving %s@@@' % rev) |
83 basename = 'vs_addin.tgz' | 118 basename = 'vs_addin.tgz' |
84 remote_name = '%s/%s/%s' % (GSPATH, rev, basename) | 119 remote_name = '%s/%s/%s' % (GSPATH, rev, basename) |
85 local_filename = os.path.join('..', '..', 'out', | 120 local_filename = join('..', '..', 'out', |
86 'vs_addin', basename) | 121 'vs_addin', basename) |
87 cmd = _GetGsutil() | 122 cmd = _GetGsutil() |
88 cmd += ['cp', '-a', 'public-read', local_filename, | 123 cmd += ['cp', '-a', 'public-read', local_filename, |
89 'gs://' + remote_name] | 124 'gs://' + remote_name] |
90 RunCommand(cmd) | 125 RunCommand(cmd) |
91 url = "%s/%s" % (GSURL, remote_name) | 126 url = "%s/%s" % (GSURL, remote_name) |
92 Log('@@@STEP_LINK@download@%s@@@' % url) | 127 Log('@@@STEP_LINK@download@%s@@@' % url) |
93 | 128 |
94 | 129 |
95 def main(): | 130 def main(): |
96 StepBuild() | 131 #StepBuild() |
binji
2012/10/09 01:05:11
debugging?
Sam Clegg
2012/10/09 17:04:33
Done.
| |
132 #StepInstall() | |
133 StepInstallSDK() | |
97 StepTest() | 134 StepTest() |
98 StepArchive() | 135 #StepArchive() |
99 | 136 |
100 | 137 |
101 if __name__ == '__main__': | 138 if __name__ == '__main__': |
102 main() | 139 main() |
OLD | NEW |