| OLD | NEW |
| 1 #!/usr/bin/evn python | 1 #!/usr/bin/evn python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Entry point for the AddIn build bot. | 6 """Entry point for the AddIn build bot. |
| 7 | 7 |
| 8 Perform build steps and output results using the buildbot | 8 Perform build steps and output results using the buildbot |
| 9 annootator syntax | 9 annootator syntax |
| 10 """ | 10 """ |
| 11 | 11 |
| 12 import os | 12 import os |
| 13 import sys | 13 import sys |
| 14 import re | 14 import re |
| 15 import shutil | 15 import shutil |
| 16 import subprocess | 16 import subprocess |
| 17 import urllib2 | 17 import urllib2 |
| 18 import zipfile | 18 import zipfile |
| 19 | 19 |
| 20 GSURL = 'https://commondatastorage.googleapis.com' | 20 GSURL = 'https://commondatastorage.googleapis.com' |
| 21 GSPATH = 'nativeclient-mirror/nacl/nacl_sdk/sdk' | 21 GSPATH = 'nativeclient-mirror/nacl/nacl_sdk/sdk' |
| 22 SDKROOT = os.path.join('..', '..', 'out', 'sdk') | 22 SDKROOT = os.path.join('..', '..', 'out', 'sdk') |
| 23 SDK_VERSIONS = ['pepper_23', 'pepper_24', 'pepper_canary'] |
| 23 | 24 |
| 24 | 25 |
| 25 def Log(msg): | 26 def Log(msg): |
| 26 sys.stdout.write(msg + '\n') | 27 sys.stdout.write(msg + '\n') |
| 27 sys.stdout.flush() | 28 sys.stdout.flush() |
| 28 | 29 |
| 29 | 30 |
| 30 def RunCommand(cmd, env=None): | 31 def RunCommand(cmd, env=None): |
| 31 Log("Running: %s" % cmd) | 32 Log("Running: %s" % cmd) |
| 32 Log("CWD: %s" % os.getcwd()) | 33 Log("CWD: %s" % os.getcwd()) |
| 33 if type(cmd) == str: | 34 if type(cmd) == str: |
| 34 cmd = cmd.split() | 35 cmd = cmd.split() |
| 35 | 36 |
| 36 if sys.platform == 'cygwin': | 37 if sys.platform == 'cygwin': |
| 37 # allow bat files in the current working directory to | 38 # allow bat files in the current working directory to |
| 38 # be executed on cygwin as they are on win32 | 39 # be executed on cygwin as they are on win32 |
| 39 if not os.path.dirname(cmd[0]) and os.path.exists(cmd[0]): | 40 if not os.path.dirname(cmd[0]) and os.path.exists(cmd[0]): |
| 40 cmd[0] = './' + cmd[0] | 41 cmd[0] = './' + cmd[0] |
| 41 | 42 |
| 42 rtn = subprocess.call(cmd, env=env) | 43 rtn = subprocess.call(cmd, env=env) |
| 43 if rtn: | 44 if rtn: |
| 44 Log("Command returned non-zero exit code: %s" % rtn) | 45 Log("Command returned non-zero exit code: %s" % rtn) |
| 45 Log('@@@STEP_FAILURE@@@') | 46 Log('@@@STEP_FAILURE@@@') |
| 46 sys.exit(1) | 47 sys.exit(1) |
| 47 | 48 |
| 48 | 49 |
| 49 def StepBuild(): | 50 def StepBuild(): |
| 50 Log('@@@BUILD_STEP build AddIn@@@') | 51 Log('@@@BUILD_STEP build addin@@@') |
| 51 | 52 |
| 52 rev = os.environ.get('BUILDBOT_GOT_REVISION') | 53 rev = os.environ.get('BUILDBOT_GOT_REVISION') |
| 53 if not rev: | 54 if not rev: |
| 54 Log('No BUILDBOT_GOT_REVISION found in environ') | 55 Log('No BUILDBOT_GOT_REVISION found in environ') |
| 55 Log('@@@STEP_FAILURE@@@') | 56 Log('@@@STEP_FAILURE@@@') |
| 56 sys.exit(1) | 57 sys.exit(1) |
| 57 | 58 |
| 58 if rev[0] == 'r': | 59 if rev[0] == 'r': |
| 59 rev = rev[1:] | 60 rev = rev[1:] |
| 60 | 61 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 78 | 79 |
| 79 RunCommand('build.bat') | 80 RunCommand('build.bat') |
| 80 finally: | 81 finally: |
| 81 # Once build is done restore original file | 82 # Once build is done restore original file |
| 82 os.remove(filename) | 83 os.remove(filename) |
| 83 os.rename(backup, filename) | 84 os.rename(backup, filename) |
| 84 | 85 |
| 85 | 86 |
| 86 | 87 |
| 87 def StepInstall(): | 88 def StepInstall(): |
| 88 Log('@@@BUILD_STEP Install AddIn@@@') | 89 Log('@@@BUILD_STEP install addin@@@') |
| 89 RunCommand('developer_deploy.bat') | 90 RunCommand('developer_deploy.bat') |
| 90 | 91 |
| 91 | 92 |
| 92 def StepInstallSDK(): | 93 def StepInstallSDK(): |
| 93 Log('@@@BUILD_STEP Install SDK@@@') | 94 Log('@@@BUILD_STEP install sdk@@@') |
| 94 naclsdk = os.path.join(SDKROOT, 'nacl_sdk', 'naclsdk.bat') | 95 naclsdk = os.path.join(SDKROOT, 'nacl_sdk', 'naclsdk.bat') |
| 95 if not os.path.exists(naclsdk): | 96 if not os.path.exists(naclsdk): |
| 96 if not os.path.exists(SDKROOT): | 97 if not os.path.exists(SDKROOT): |
| 97 os.makedirs(SDKROOT) | 98 os.makedirs(SDKROOT) |
| 98 filename = os.path.join(SDKROOT, 'nacl_sdk.zip') | 99 filename = os.path.join(SDKROOT, 'nacl_sdk.zip') |
| 99 url = GSURL + "/nativeclient-mirror/nacl/nacl_sdk/nacl_sdk.zip" | 100 url = GSURL + "/nativeclient-mirror/nacl/nacl_sdk/nacl_sdk.zip" |
| 100 contents = urllib2.urlopen(url).read() | 101 contents = urllib2.urlopen(url).read() |
| 101 with open(filename, 'wb') as zfileout: | 102 with open(filename, 'wb') as zfileout: |
| 102 zfileout.write(contents) | 103 zfileout.write(contents) |
| 103 zfile = zipfile.ZipFile(filename) | 104 zfile = zipfile.ZipFile(filename) |
| 104 zfile.extractall(SDKROOT) | 105 zfile.extractall(SDKROOT) |
| 105 | 106 |
| 106 RunCommand([naclsdk, 'update', '--force', 'pepper_23']) | 107 for version in SDK_VERSIONS: |
| 107 RunCommand([naclsdk, 'update', '--force', 'pepper_canary']) | 108 RunCommand([naclsdk, 'update', '--force', version]) |
| 108 | 109 |
| 109 | 110 |
| 110 def StepTest(): | 111 def StepTest(): |
| 111 Log('@@@BUILD_STEP Testing AddIn@@@') | |
| 112 # Don't actually test yet | 112 # Don't actually test yet |
| 113 env = dict(os.environ) | 113 env = dict(os.environ) |
| 114 sdkroot = os.path.abspath(os.path.join(SDKROOT, 'nacl_sdk')) | 114 sdkroot = os.path.abspath(os.path.join(SDKROOT, 'nacl_sdk')) |
| 115 if 'CHROME_PATH' not in os.environ: | 115 if 'CHROME_PATH' not in os.environ: |
| 116 # TODO(sbc): Addin itself should autodetect chrome location | 116 # TODO(sbc): Addin itself should autodetect chrome location |
| 117 # http://crbug.com/154911 | 117 # http://crbug.com/154911 |
| 118 progfiles = os.environ.get('PROGRAMFILES') | 118 progfiles = os.environ.get('PROGRAMFILES') |
| 119 progfiles = os.environ.get('PROGRAMFILES(X86)', progfiles) | 119 progfiles = os.environ.get('PROGRAMFILES(X86)', progfiles) |
| 120 chrome = os.path.join(progfiles, 'Google', 'Chrome', 'Application', | 120 chrome = os.path.join(progfiles, 'Google', 'Chrome', 'Application', |
| 121 'chrome.exe') | 121 'chrome.exe') |
| 122 if not os.path.exists(chrome): | 122 if not os.path.exists(chrome): |
| 123 Log('CHROME_PATH not found') | 123 Log('CHROME_PATH not found') |
| 124 Log('chrome not found in the default location: %s' % chrome) | 124 Log('chrome not found in the default location: %s' % chrome) |
| 125 Log('@@@STEP_FAILURE@@@') | 125 Log('@@@STEP_FAILURE@@@') |
| 126 sys.exit(1) | 126 sys.exit(1) |
| 127 env['CHROME_PATH'] = chrome | 127 env['CHROME_PATH'] = chrome |
| 128 env['NACL_SDK_ROOT'] = os.path.join(sdkroot, 'pepper_23') | 128 for version in SDK_VERSIONS: |
| 129 RunCommand('test.bat', env) | 129 Log('@@@BUILD_STEP test against %s@@@' % version) |
| 130 env['NACL_SDK_ROOT'] = os.path.join(sdkroot, 'pepper_canary') | 130 env['NACL_SDK_ROOT'] = os.path.join(sdkroot, version) |
| 131 RunCommand('test.bat', env) | 131 RunCommand('test.bat', env) |
| 132 | 132 |
| 133 | 133 |
| 134 def _FindInPath(filename): | 134 def _FindInPath(filename): |
| 135 for path in os.environ['PATH'].split(os.pathsep): | 135 for path in os.environ['PATH'].split(os.pathsep): |
| 136 result = os.path.join(path, filename) | 136 result = os.path.join(path, filename) |
| 137 if os.path.exists(result): | 137 if os.path.exists(result): |
| 138 return result | 138 return result |
| 139 | 139 |
| 140 Log('%s not found in PATH' % filename) | 140 Log('%s not found in PATH' % filename) |
| 141 Log('@@@STEP_FAILURE@@@') | 141 Log('@@@STEP_FAILURE@@@') |
| (...skipping 18 matching lines...) Expand all Loading... |
| 160 | 160 |
| 161 return gsutil | 161 return gsutil |
| 162 | 162 |
| 163 | 163 |
| 164 def StepArchive(): | 164 def StepArchive(): |
| 165 rev = os.environ.get('BUILDBOT_GOT_REVISION') | 165 rev = os.environ.get('BUILDBOT_GOT_REVISION') |
| 166 if not rev: | 166 if not rev: |
| 167 Log('No BUILDBOT_GOT_REVISION found in environ') | 167 Log('No BUILDBOT_GOT_REVISION found in environ') |
| 168 Log('@@@STEP_FAILURE@@@') | 168 Log('@@@STEP_FAILURE@@@') |
| 169 sys.exit(1) | 169 sys.exit(1) |
| 170 Log('@@@BUILD_STEP Archiving %s@@@' % rev) | 170 Log('@@@BUILD_STEP archive build [r%s]@@@' % rev) |
| 171 basename = 'vs_addin.tgz' | 171 basename = 'vs_addin.tgz' |
| 172 remote_name = '%s/%s/%s' % (GSPATH, rev, basename) | 172 remote_name = '%s/%s/%s' % (GSPATH, rev, basename) |
| 173 local_filename = os.path.join('..', '..', 'out', | 173 local_filename = os.path.join('..', '..', 'out', |
| 174 'vs_addin', basename) | 174 'vs_addin', basename) |
| 175 cmd = _GetGsutil() | 175 cmd = _GetGsutil() |
| 176 cmd += ['cp', '-a', 'public-read', local_filename, | 176 cmd += ['cp', '-a', 'public-read', local_filename, |
| 177 'gs://' + remote_name] | 177 'gs://' + remote_name] |
| 178 RunCommand(cmd) | 178 RunCommand(cmd) |
| 179 url = "%s/%s" % (GSURL, remote_name) | 179 url = "%s/%s" % (GSURL, remote_name) |
| 180 Log('@@@STEP_LINK@download@%s@@@' % url) | 180 Log('@@@STEP_LINK@download@%s@@@' % url) |
| 181 | 181 |
| 182 | 182 |
| 183 def main(): | 183 def main(): |
| 184 StepBuild() | 184 StepBuild() |
| 185 StepInstall() | 185 StepInstall() |
| 186 StepInstallSDK() | 186 StepInstallSDK() |
| 187 StepTest() | 187 StepTest() |
| 188 StepArchive() | 188 StepArchive() |
| 189 | 189 |
| 190 | 190 |
| 191 if __name__ == '__main__': | 191 if __name__ == '__main__': |
| 192 main() | 192 main() |
| OLD | NEW |