OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env 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 both build and try bots''' | 6 """Entry point for both build and try bots |
7 | 7 |
8 import build_utils | 8 This script is invoked from XXX, usually without arguments |
9 import lastchange | 9 to package an SDK. It automatically determines whether |
| 10 this SDK is for mac, win, linux. |
| 11 |
| 12 The script inspects the following environment variables: |
| 13 |
| 14 BUILDBOT_BUILDERNAME to determine whether the script is run locally |
| 15 and whether it should upload an SDK to file storage (GSTORE) |
| 16 """ |
| 17 |
| 18 # std python includes |
10 import os | 19 import os |
11 import subprocess | 20 import subprocess |
12 import sys | 21 import sys |
13 | 22 |
| 23 # local includes |
| 24 import build_utils |
| 25 import lastchange |
| 26 |
| 27 |
14 # Create the various paths of interest | 28 # Create the various paths of interest |
15 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | 29 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
16 SDK_SRC_DIR = os.path.dirname(SCRIPT_DIR) | 30 SDK_SRC_DIR = os.path.dirname(SCRIPT_DIR) |
17 SDK_DIR = os.path.dirname(SDK_SRC_DIR) | 31 SDK_DIR = os.path.dirname(SDK_SRC_DIR) |
18 SRC_DIR = os.path.dirname(SDK_DIR) | 32 SRC_DIR = os.path.dirname(SDK_DIR) |
19 NACL_DIR = os.path.join(SRC_DIR, 'native_client') | 33 NACL_DIR = os.path.join(SRC_DIR, 'native_client') |
20 OUT_DIR = os.path.join(SRC_DIR, 'out') | 34 OUT_DIR = os.path.join(SRC_DIR, 'out') |
21 PPAPI_DIR = os.path.join(SRC_DIR, 'ppapi') | 35 PPAPI_DIR = os.path.join(SRC_DIR, 'ppapi') |
22 | 36 |
23 | 37 |
24 # Add SDK make tools scripts to the python path. | 38 # Add SDK make tools scripts to the python path. |
25 sys.path.append(os.path.join(SDK_SRC_DIR, 'tools')) | 39 sys.path.append(os.path.join(SDK_SRC_DIR, 'tools')) |
26 sys.path.append(os.path.join(NACL_DIR, 'build')) | 40 sys.path.append(os.path.join(NACL_DIR, 'build')) |
27 | 41 |
28 | 42 import getos |
29 import http_download | 43 import http_download |
30 from getos import GetPlatform | |
31 import oshelpers | 44 import oshelpers |
32 | 45 |
33 GSTORE = 'http://commondatastorage.googleapis.com/nativeclient-mirror/nacl/' | 46 GSTORE = 'http://commondatastorage.googleapis.com/nativeclient-mirror/nacl/' |
34 MAKE = 'nacl_sdk/make_3_81/make.exe' | 47 MAKE = 'nacl_sdk/make_3_81/make.exe' |
35 GSUTIL = '/b/build/scripts/slave/gsutil' | 48 # For buildbots assume gsutil is stored in the build directory. |
| 49 BOT_GSUTIL = '/b/build/scripts/slave/gsutil' |
| 50 # For local runs just make sure gsutil is in your PATH. |
| 51 LOCAL_GSUTIL = 'gsutil' |
| 52 CYGTAR = os.path.join(NACL_DIR, 'build', 'cygtar.py') |
| 53 |
36 | 54 |
37 def ErrorExit(msg): | 55 def ErrorExit(msg): |
38 """Write and error to stderr, then exit with 1 signaling failure.""" | 56 """Write and error to stderr, then exit with 1 signaling failure.""" |
39 sys.stderr.write(msg + '\n') | 57 sys.stderr.write(msg + '\n') |
40 sys.exit(1) | 58 sys.exit(1) |
41 | 59 |
42 | 60 |
43 def BuildStep(name): | 61 def BuildStep(name): |
44 """Annotate a buildbot build step.""" | 62 """Annotate a buildbot build step.""" |
45 sys.stdout.flush() | 63 sys.stdout.flush() |
(...skipping 15 matching lines...) Expand all Loading... |
61 | 79 |
62 | 80 |
63 def Archive(filename): | 81 def Archive(filename): |
64 """Upload the given filename to Google Store.""" | 82 """Upload the given filename to Google Store.""" |
65 chrome_version = build_utils.ChromeVersion() | 83 chrome_version = build_utils.ChromeVersion() |
66 bucket_path = 'nativeclient-mirror/nacl/nacl_sdk/%s/%s' % ( | 84 bucket_path = 'nativeclient-mirror/nacl/nacl_sdk/%s/%s' % ( |
67 chrome_version, filename) | 85 chrome_version, filename) |
68 full_dst = 'gs://%s' % bucket_path | 86 full_dst = 'gs://%s' % bucket_path |
69 | 87 |
70 if os.environ.get('BUILDBOT_BUILDERNAME', ''): | 88 if os.environ.get('BUILDBOT_BUILDERNAME', ''): |
71 # For buildbots assume gsutil is stored in the build directory. | 89 gsutil = BOT_GSUTIL |
72 gsutil = '/b/build/scripts/slave/gsutil' | |
73 else: | 90 else: |
74 # For non buildpots, you must have it in your path. | 91 gsutil = LOCAL_GSUTIL |
75 gsutil = 'gsutil' | |
76 | 92 |
77 subprocess.check_call( | 93 subprocess.check_call( |
78 '%s cp -a public-read %s %s' % ( | 94 '%s cp -a public-read %s %s' % ( |
79 gsutil, filename, full_dst), shell=True, cwd=OUT_DIR) | 95 gsutil, filename, full_dst), shell=True, cwd=OUT_DIR) |
80 url = 'https://commondatastorage.googleapis.com/%s' % bucket_path | 96 url = 'https://commondatastorage.googleapis.com/%s' % bucket_path |
81 print '@@@STEP_LINK@download@%s@@@' % url | 97 print '@@@STEP_LINK@download@%s@@@' % url |
82 sys.stdout.flush() | 98 sys.stdout.flush() |
83 | 99 |
84 | 100 |
85 def AddMakeBat(makepath): | 101 def AddMakeBat(makepath): |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 | 176 |
161 | 177 |
162 def GetBuildArgs(tcname, tcpath, arch, xarch=None): | 178 def GetBuildArgs(tcname, tcpath, arch, xarch=None): |
163 """Return list of scons build arguments to generate user libraries.""" | 179 """Return list of scons build arguments to generate user libraries.""" |
164 scons = GetScons() | 180 scons = GetScons() |
165 mode = '--mode=opt-host,nacl' | 181 mode = '--mode=opt-host,nacl' |
166 arch_name = GetArchName(arch, xarch) | 182 arch_name = GetArchName(arch, xarch) |
167 plat = 'platform=' + arch_name | 183 plat = 'platform=' + arch_name |
168 bin = ('bindir=' + | 184 bin = ('bindir=' + |
169 BuildOutputDir('pepper_' + build_utils.ChromeMajorVersion(), 'tools')) | 185 BuildOutputDir('pepper_' + build_utils.ChromeMajorVersion(), 'tools')) |
170 lib = ('libdir=' + | 186 lib = 'libdir=' + GetToolchainNaClLib(tcpath, arch, xarch) |
171 os.path.join(GetToolchainNaClLib(tcpath, arch, xarch))) | |
172 args = [scons, mode, plat, bin, lib, '-j10', | 187 args = [scons, mode, plat, bin, lib, '-j10', |
173 'install_bin', 'install_lib'] | 188 'install_bin', 'install_lib'] |
174 if tcname == 'glibc': | 189 if tcname == 'glibc': |
175 args.append('--nacl_glibc') | 190 args.append('--nacl_glibc') |
176 return args | 191 return args |
177 | 192 |
178 header_map = { | 193 header_map = { |
179 'newlib': { | 194 'newlib': { |
180 'pthread.h': 'src/untrusted/pthread/pthread.h', | 195 'pthread.h': 'src/untrusted/pthread/pthread.h', |
181 'semaphore.h': 'src/untrusted/pthread/semaphore.h', | 196 'semaphore.h': 'src/untrusted/pthread/semaphore.h', |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 CopyDir(os.path.join(PPAPI_DIR,'lib','gl','include','GLES2', '*.h'), | 271 CopyDir(os.path.join(PPAPI_DIR,'lib','gl','include','GLES2', '*.h'), |
257 os.path.join(tc_dst_inc, 'GLES2')) | 272 os.path.join(tc_dst_inc, 'GLES2')) |
258 | 273 |
259 # Copy the KHR headers | 274 # Copy the KHR headers |
260 MakeDir(os.path.join(tc_dst_inc, 'KHR')) | 275 MakeDir(os.path.join(tc_dst_inc, 'KHR')) |
261 CopyDir(os.path.join(PPAPI_DIR,'lib','gl','include','KHR', '*.h'), | 276 CopyDir(os.path.join(PPAPI_DIR,'lib','gl','include','KHR', '*.h'), |
262 os.path.join(tc_dst_inc, 'KHR')) | 277 os.path.join(tc_dst_inc, 'KHR')) |
263 | 278 |
264 | 279 |
265 def main(): | 280 def main(): |
266 platform = GetPlatform() | 281 platform = getos.GetPlatform() |
267 arch = 'x86' | 282 arch = 'x86' |
| 283 # the vars below are intended for debugging |
268 skip_untar = 0 | 284 skip_untar = 0 |
269 skip_build = 0 | 285 skip_build = 0 |
270 skip_tar = 0 | 286 skip_tar = 0 |
271 skip_examples = 0 | 287 skip_examples = 0 |
272 skip_headers = 0 | 288 skip_headers = 0 |
273 skip_make = 0 | 289 skip_make = 0 |
274 force_archive = 0 | 290 force_archive = 0 |
275 | 291 |
276 pepper_ver = build_utils.ChromeMajorVersion() | 292 pepper_ver = build_utils.ChromeMajorVersion() |
277 clnumber = lastchange.FetchVersionInfo(None).revision | 293 clnumber = lastchange.FetchVersionInfo(None).revision |
278 print 'Building PEPPER %s at %s' % (pepper_ver, clnumber) | 294 print 'Building PEPPER %s at %s' % (pepper_ver, clnumber) |
279 | 295 |
280 BuildStep('Clean Pepper Dir') | 296 BuildStep('Clean Pepper Dir') |
281 pepperdir = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_ver) | 297 pepperdir = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_ver) |
282 if not skip_untar: | 298 if not skip_untar: |
283 RemoveDir(pepperdir) | 299 RemoveDir(pepperdir) |
284 MakeDir(os.path.join(pepperdir, 'toolchain')) | 300 MakeDir(os.path.join(pepperdir, 'toolchain')) |
285 MakeDir(os.path.join(pepperdir, 'tools')) | 301 MakeDir(os.path.join(pepperdir, 'tools')) |
286 | 302 |
287 BuildStep('Untar Toolchains') | 303 BuildStep('Untar Toolchains') |
288 tmpdir = os.path.join(SRC_DIR, 'out', 'tc_temp') | |
289 tcname = platform + '_' + arch | 304 tcname = platform + '_' + arch |
290 tmpdir = os.path.join(SRC_DIR, 'out', 'tc_temp') | 305 tmpdir = os.path.join(SRC_DIR, 'out', 'tc_temp') |
291 cygtar = os.path.join(NACL_DIR, 'build', 'cygtar.py') | |
292 | 306 |
293 # Clean out the temporary toolchain untar directory | 307 # Clean out the temporary toolchain untar directory |
294 if not skip_untar: | 308 if not skip_untar: |
295 RemoveDir(tmpdir) | 309 RemoveDir(tmpdir) |
296 MakeDir(tmpdir) | 310 MakeDir(tmpdir) |
297 tcname = platform + '_' + arch | 311 tcname = platform + '_' + arch |
298 | 312 |
299 # Untar the newlib toolchains | 313 # Untar the newlib toolchains |
300 tarfile = GetNewlibToolchain(platform, arch) | 314 tarfile = GetNewlibToolchain(platform, arch) |
301 Run([sys.executable, cygtar, '-C', tmpdir, '-xf', tarfile], cwd=NACL_DIR) | 315 Run([sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile], cwd=NACL_DIR) |
302 | 316 |
303 # Then rename/move it to the pepper toolchain directory | 317 # Then rename/move it to the pepper toolchain directory |
304 srcdir = os.path.join(tmpdir, 'sdk', 'nacl-sdk') | 318 srcdir = os.path.join(tmpdir, 'sdk', 'nacl-sdk') |
305 newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib') | 319 newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib') |
306 print "Buildbot mv %s to %s" % (srcdir, newlibdir) | 320 print "Buildbot mv %s to %s" % (srcdir, newlibdir) |
307 MoveDir(srcdir, newlibdir) | 321 MoveDir(srcdir, newlibdir) |
308 print "Done with buildbot move" | 322 print "Done with buildbot move" |
309 # Untar the glibc toolchains | 323 # Untar the glibc toolchains |
310 tarfile = GetGlibcToolchain(platform, arch) | 324 tarfile = GetGlibcToolchain(platform, arch) |
311 Run([sys.executable, cygtar, '-C', tmpdir, '-xf', tarfile], cwd=NACL_DIR) | 325 Run([sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile], cwd=NACL_DIR) |
312 | 326 |
313 # Then rename/move it to the pepper toolchain directory | 327 # Then rename/move it to the pepper toolchain directory |
314 srcdir = os.path.join(tmpdir, 'toolchain', tcname) | 328 srcdir = os.path.join(tmpdir, 'toolchain', tcname) |
315 glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc') | 329 glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc') |
316 MoveDir(srcdir, glibcdir) | 330 MoveDir(srcdir, glibcdir) |
317 else: | 331 else: |
318 newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib') | 332 newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib') |
319 glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc') | 333 glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc') |
320 | 334 |
321 BuildStep('SDK Items') | 335 BuildStep('SDK Items') |
(...skipping 30 matching lines...) Expand all Loading... |
352 if not skip_examples: | 366 if not skip_examples: |
353 BuildStep('Copy examples') | 367 BuildStep('Copy examples') |
354 RemoveDir(os.path.join(pepperdir, 'examples')) | 368 RemoveDir(os.path.join(pepperdir, 'examples')) |
355 CopyDir(os.path.join(SDK_SRC_DIR, 'examples'), pepperdir) | 369 CopyDir(os.path.join(SDK_SRC_DIR, 'examples'), pepperdir) |
356 | 370 |
357 | 371 |
358 tarname = 'naclsdk_' + platform + '.bz2' | 372 tarname = 'naclsdk_' + platform + '.bz2' |
359 BuildStep('Tar Pepper Bundle') | 373 BuildStep('Tar Pepper Bundle') |
360 if not skip_tar: | 374 if not skip_tar: |
361 tarfile = os.path.join(OUT_DIR, 'naclsdk_' + platform + '.bz2') | 375 tarfile = os.path.join(OUT_DIR, 'naclsdk_' + platform + '.bz2') |
362 Run([sys.executable, cygtar, '-C', OUT_DIR, '-cjf', tarfile, | 376 Run([sys.executable, CYGTAR, '-C', OUT_DIR, '-cjf', tarfile, |
363 'pepper_' + pepper_ver], cwd=NACL_DIR) | 377 'pepper_' + pepper_ver], cwd=NACL_DIR) |
364 | 378 |
365 # Archive on non-trybots. | 379 # Archive on non-trybots. |
366 if force_archive or '-sdk' in os.environ.get('BUILDBOT_BUILDERNAME', ''): | 380 if force_archive or '-sdk' in os.environ.get('BUILDBOT_BUILDERNAME', ''): |
367 BuildStep('Archive build') | 381 BuildStep('Archive build') |
368 Archive(tarname) | 382 Archive(tarname) |
369 | 383 |
370 if not skip_make: | 384 if not skip_make: |
371 BuildStep('Test Build Examples') | 385 BuildStep('Test Build Examples') |
372 filelist = os.listdir(os.path.join(pepperdir, 'examples')) | 386 filelist = os.listdir(os.path.join(pepperdir, 'examples')) |
373 for filenode in filelist: | 387 for filenode in filelist: |
374 dirnode = os.path.join(pepperdir, 'examples', filenode) | 388 dirnode = os.path.join(pepperdir, 'examples', filenode) |
375 makefile = os.path.join(dirnode, 'Makefile') | 389 makefile = os.path.join(dirnode, 'Makefile') |
376 if os.path.isfile(makefile): | 390 if os.path.isfile(makefile): |
377 if platform == 'win': | 391 if platform == 'win': |
378 AddMakeBat(dirnode) | 392 AddMakeBat(dirnode) |
379 print "\n\nMake: " + dirnode | 393 print "\n\nMake: " + dirnode |
380 Run(['make', 'all', '-j8'], cwd=os.path.abspath(dirnode), shell=True) | 394 Run(['make', 'all', '-j8'], cwd=os.path.abspath(dirnode), shell=True) |
381 | 395 |
382 return 0 | 396 return 0 |
383 | 397 |
384 | 398 |
385 if __name__ == '__main__': | 399 if __name__ == '__main__': |
386 sys.exit(main()) | 400 sys.exit(main()) |
387 | |
OLD | NEW |