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 This script is invoked from XXX, usually without arguments | 8 This script is invoked from XXX, usually without arguments |
9 to package an SDK. It automatically determines whether | 9 to package an SDK. It automatically determines whether |
10 this SDK is for mac, win, linux. | 10 this SDK is for mac, win, linux. |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 def GetToolchainNaClLib(tcname, tcpath, arch, xarch): | 109 def GetToolchainNaClLib(tcname, tcpath, arch, xarch): |
110 if arch == 'x86': | 110 if arch == 'x86': |
111 if tcname == 'pnacl': | 111 if tcname == 'pnacl': |
112 return os.path.join(tcpath, 'newlib', 'sdk', 'lib') | 112 return os.path.join(tcpath, 'newlib', 'sdk', 'lib') |
113 if str(xarch) == '32': | 113 if str(xarch) == '32': |
114 return os.path.join(tcpath, 'x86_64-nacl', 'lib32') | 114 return os.path.join(tcpath, 'x86_64-nacl', 'lib32') |
115 if str(xarch) == '64': | 115 if str(xarch) == '64': |
116 return os.path.join(tcpath, 'x86_64-nacl', 'lib') | 116 return os.path.join(tcpath, 'x86_64-nacl', 'lib') |
117 buildbot_common.ErrorExit('Unknown architecture.') | 117 buildbot_common.ErrorExit('Unknown architecture.') |
118 | 118 |
119 | |
119 def GetPNaClNativeLib(tcpath, arch): | 120 def GetPNaClNativeLib(tcpath, arch): |
120 if arch not in ['arm', 'x86-32', 'x86-64']: | 121 if arch not in ['arm', 'x86-32', 'x86-64']: |
121 buildbot_common.ErrorExit('Unknown architecture %s.' % arch) | 122 buildbot_common.ErrorExit('Unknown architecture %s.' % arch) |
122 return os.path.join(tcpath, 'lib-' + arch) | 123 return os.path.join(tcpath, 'lib-' + arch) |
123 | 124 |
125 | |
124 def GetBuildArgs(tcname, tcpath, outdir, arch, xarch=None): | 126 def GetBuildArgs(tcname, tcpath, outdir, arch, xarch=None): |
125 """Return list of scons build arguments to generate user libraries.""" | 127 """Return list of scons build arguments to generate user libraries.""" |
126 scons = GetScons() | 128 scons = GetScons() |
127 mode = '--mode=opt-host,nacl' | 129 mode = '--mode=opt-host,nacl' |
128 arch_name = GetArchName(arch, xarch) | 130 arch_name = GetArchName(arch, xarch) |
129 plat = 'platform=' + arch_name | 131 plat = 'platform=' + arch_name |
130 bin = 'bindir=' + os.path.join(outdir, 'tools') | 132 bin = 'bindir=' + os.path.join(outdir, 'tools') |
131 lib = 'libdir=' + GetToolchainNaClLib(tcname, tcpath, arch, xarch) | 133 lib = 'libdir=' + GetToolchainNaClLib(tcname, tcpath, arch, xarch) |
132 args = [scons, mode, plat, bin, lib, '-j10', | 134 args = [scons, mode, plat, bin, lib, '-j10', |
133 'install_bin', 'install_lib'] | 135 'install_bin', 'install_lib'] |
134 if tcname == 'glibc': | 136 if tcname == 'glibc': |
135 args.append('--nacl_glibc') | 137 args.append('--nacl_glibc') |
136 | 138 |
137 if tcname == 'pnacl': | 139 if tcname == 'pnacl': |
138 args.append('bitcode=1') | 140 args.append('bitcode=1') |
139 | 141 |
140 print "Building %s (%s): %s" % (tcname, arch, ' '.join(args)) | 142 print "Building %s (%s): %s" % (tcname, arch, ' '.join(args)) |
141 return args | 143 return args |
142 | 144 |
143 | 145 |
146 def BuildStepDownloadToolchains(platform): | |
147 buildbot_common.BuildStep('Rerun hooks to get toolchains') | |
148 buildbot_common.Run(['gclient', 'runhooks'], | |
149 cwd=SRC_DIR, shell=(platform=='win')) | |
150 | |
151 | |
152 def BuildStepCleanPepperDirs(pepperdir, pepperdir_old): | |
153 buildbot_common.BuildStep('Clean Pepper Dirs') | |
154 buildbot_common.RemoveDir(pepperdir_old) | |
155 buildbot_common.RemoveDir(pepperdir) | |
156 buildbot_common.MakeDir(pepperdir) | |
157 | |
158 | |
159 def BuildStepMakePepperDirs(pepperdir, subdirs): | |
160 for subdir in subdirs: | |
161 buildbot_common.MakeDir(os.path.join(pepperdir, subdir)) | |
162 | |
163 | |
164 def BuildStepCopyTextFiles(pepperdir, pepper_ver, revision): | |
165 buildbot_common.BuildStep('Add Text Files') | |
166 files = ['AUTHORS', 'COPYING', 'LICENSE', 'NOTICE'] | |
167 files = [os.path.join(SDK_SRC_DIR, filename) for filename in files] | |
168 oshelpers.Copy(['-v'] + files + [pepperdir]) | |
169 | |
170 # Replace a few placeholders in README | |
171 readme_text = open(os.path.join(SDK_SRC_DIR, 'README'), 'rt').read() | |
172 readme_text = readme_text.replace('${VERSION}', pepper_ver) | |
173 readme_text = readme_text.replace('${REVISION}', revision) | |
174 | |
175 # Year/Month/Day Hour:Minute:Second | |
176 time_format = '%Y/%m/%d %H:%M:%S' | |
177 readme_text = readme_text.replace('${DATE}', | |
178 datetime.datetime.now().strftime(time_format)) | |
179 | |
180 open(os.path.join(pepperdir, 'README'), 'wt').write(readme_text) | |
181 | |
182 | |
183 def BuildStepUntarToolchains(pepperdir, platform, arch, toolchains): | |
184 buildbot_common.BuildStep('Untar Toolchains') | |
185 tcname = platform + '_' + arch | |
186 tmpdir = os.path.join(SRC_DIR, 'out', 'tc_temp') | |
187 buildbot_common.RemoveDir(tmpdir) | |
188 buildbot_common.MakeDir(tmpdir) | |
189 | |
190 if 'newlib' in toolchains: | |
191 # Untar the newlib toolchains | |
192 tarfile = GetNewlibToolchain(platform, arch) | |
193 buildbot_common.Run([sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile], | |
194 cwd=NACL_DIR) | |
195 | |
196 # Then rename/move it to the pepper toolchain directory | |
197 srcdir = os.path.join(tmpdir, 'sdk', 'nacl-sdk') | |
198 newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib') | |
199 buildbot_common.Move(srcdir, newlibdir) | |
200 | |
201 if 'glibc' in toolchains: | |
202 # Untar the glibc toolchains | |
203 tarfile = GetGlibcToolchain(platform, arch) | |
204 buildbot_common.Run([sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile], | |
205 cwd=NACL_DIR) | |
206 | |
207 # Then rename/move it to the pepper toolchain directory | |
208 srcdir = os.path.join(tmpdir, 'toolchain', tcname) | |
209 glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc') | |
210 buildbot_common.Move(srcdir, glibcdir) | |
211 | |
212 # Untar the pnacl toolchains | |
213 if 'pnacl' in toolchains: | |
214 tmpdir = os.path.join(tmpdir, 'pnacl') | |
215 buildbot_common.RemoveDir(tmpdir) | |
216 buildbot_common.MakeDir(tmpdir) | |
217 tarfile = GetPNaClToolchain(platform, arch) | |
218 buildbot_common.Run([sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile], | |
219 cwd=NACL_DIR) | |
220 | |
221 # Then rename/move it to the pepper toolchain directory | |
222 pnacldir = os.path.join(pepperdir, 'toolchain', tcname + '_pnacl') | |
223 buildbot_common.Move(tmpdir, pnacldir) | |
224 | |
225 | |
144 HEADER_MAP = { | 226 HEADER_MAP = { |
145 'newlib': { | 227 'newlib': { |
146 'pthread.h': 'src/untrusted/pthread/pthread.h', | 228 'pthread.h': 'src/untrusted/pthread/pthread.h', |
147 'semaphore.h': 'src/untrusted/pthread/semaphore.h', | 229 'semaphore.h': 'src/untrusted/pthread/semaphore.h', |
148 'nacl/dynamic_annotations.h': | 230 'nacl/dynamic_annotations.h': |
149 'src/untrusted/valgrind/dynamic_annotations.h', | 231 'src/untrusted/valgrind/dynamic_annotations.h', |
150 'nacl/nacl_dyncode.h': 'src/untrusted/nacl/nacl_dyncode.h', | 232 'nacl/nacl_dyncode.h': 'src/untrusted/nacl/nacl_dyncode.h', |
151 'nacl/nacl_startup.h': 'src/untrusted/nacl/nacl_startup.h', | 233 'nacl/nacl_startup.h': 'src/untrusted/nacl/nacl_startup.h', |
152 'nacl/nacl_thread.h': 'src/untrusted/nacl/nacl_thread.h', | 234 'nacl/nacl_thread.h': 'src/untrusted/nacl/nacl_thread.h', |
153 'pnacl.h': 'src/untrusted/nacl/pnacl.h', | 235 'pnacl.h': 'src/untrusted/nacl/pnacl.h', |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
241 buildbot_common.MakeDir(os.path.join(tc_dst_inc, 'KHR')) | 323 buildbot_common.MakeDir(os.path.join(tc_dst_inc, 'KHR')) |
242 buildbot_common.CopyDir( | 324 buildbot_common.CopyDir( |
243 os.path.join(PPAPI_DIR,'lib','gl','include','KHR', '*.h'), | 325 os.path.join(PPAPI_DIR,'lib','gl','include','KHR', '*.h'), |
244 os.path.join(tc_dst_inc, 'KHR')) | 326 os.path.join(tc_dst_inc, 'KHR')) |
245 | 327 |
246 # Copy the lib files | 328 # Copy the lib files |
247 buildbot_common.CopyDir(os.path.join(PPAPI_DIR,'lib'), | 329 buildbot_common.CopyDir(os.path.join(PPAPI_DIR,'lib'), |
248 os.path.join(tc_dst_inc, 'ppapi')) | 330 os.path.join(tc_dst_inc, 'ppapi')) |
249 | 331 |
250 | 332 |
251 def UntarToolchains(pepperdir, platform, arch, toolchains): | 333 def BuildStepBuildToolchains(pepperdir, platform, arch, pepper_ver, toolchains): |
252 buildbot_common.BuildStep('Untar Toolchains') | |
253 tcname = platform + '_' + arch | |
254 tmpdir = os.path.join(SRC_DIR, 'out', 'tc_temp') | |
255 buildbot_common.RemoveDir(tmpdir) | |
256 buildbot_common.MakeDir(tmpdir) | |
257 | |
258 if 'newlib' in toolchains: | |
259 # Untar the newlib toolchains | |
260 tarfile = GetNewlibToolchain(platform, arch) | |
261 buildbot_common.Run([sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile], | |
262 cwd=NACL_DIR) | |
263 | |
264 # Then rename/move it to the pepper toolchain directory | |
265 srcdir = os.path.join(tmpdir, 'sdk', 'nacl-sdk') | |
266 newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib') | |
267 buildbot_common.Move(srcdir, newlibdir) | |
268 | |
269 if 'glibc' in toolchains: | |
270 # Untar the glibc toolchains | |
271 tarfile = GetGlibcToolchain(platform, arch) | |
272 buildbot_common.Run([sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile], | |
273 cwd=NACL_DIR) | |
274 | |
275 # Then rename/move it to the pepper toolchain directory | |
276 srcdir = os.path.join(tmpdir, 'toolchain', tcname) | |
277 glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc') | |
278 buildbot_common.Move(srcdir, glibcdir) | |
279 | |
280 # Untar the pnacl toolchains | |
281 if 'pnacl' in toolchains: | |
282 tmpdir = os.path.join(tmpdir, 'pnacl') | |
283 buildbot_common.RemoveDir(tmpdir) | |
284 buildbot_common.MakeDir(tmpdir) | |
285 tarfile = GetPNaClToolchain(platform, arch) | |
286 buildbot_common.Run([sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile], | |
287 cwd=NACL_DIR) | |
288 | |
289 # Then rename/move it to the pepper toolchain directory | |
290 pnacldir = os.path.join(pepperdir, 'toolchain', tcname + '_pnacl') | |
291 buildbot_common.Move(tmpdir, pnacldir) | |
292 | |
293 | |
294 def BuildToolchains(pepperdir, platform, arch, pepper_ver, toolchains): | |
295 buildbot_common.BuildStep('SDK Items') | 334 buildbot_common.BuildStep('SDK Items') |
296 | 335 |
297 tcname = platform + '_' + arch | 336 tcname = platform + '_' + arch |
298 newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib') | 337 newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib') |
299 glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc') | 338 glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc') |
300 pnacldir = os.path.join(pepperdir, 'toolchain', tcname + '_pnacl') | 339 pnacldir = os.path.join(pepperdir, 'toolchain', tcname + '_pnacl') |
301 | 340 |
302 # Run scons TC build steps | 341 # Run scons TC build steps |
303 if arch == 'x86': | 342 if arch == 'x86': |
304 if 'newlib' in toolchains: | 343 if 'newlib' in toolchains: |
(...skipping 30 matching lines...) Expand all Loading... | |
335 buildbot_common.Move( | 374 buildbot_common.Move( |
336 os.path.join(GetToolchainNaClLib('pnacl', pnacldir, 'x86', '64'), | 375 os.path.join(GetToolchainNaClLib('pnacl', pnacldir, 'x86', '64'), |
337 'libpnacl_irt_shim.a'), | 376 'libpnacl_irt_shim.a'), |
338 GetPNaClNativeLib(pnacldir, 'x86-64')) | 377 GetPNaClNativeLib(pnacldir, 'x86-64')) |
339 InstallHeaders(GetToolchainNaClInclude('pnacl', pnacldir, 'x86'), | 378 InstallHeaders(GetToolchainNaClInclude('pnacl', pnacldir, 'x86'), |
340 pepper_ver, | 379 pepper_ver, |
341 'newlib') | 380 'newlib') |
342 else: | 381 else: |
343 buildbot_common.ErrorExit('Missing arch %s' % arch) | 382 buildbot_common.ErrorExit('Missing arch %s' % arch) |
344 | 383 |
384 | |
385 def BuildStepCopyBuildHelpers(pepperdir, platform): | |
386 buildbot_common.BuildStep('Copy build helpers') | |
387 buildbot_common.CopyDir(os.path.join(SDK_SRC_DIR, 'tools', '*.py'), | |
388 os.path.join(pepperdir, 'tools')) | |
389 if platform == 'win': | |
390 buildbot_common.BuildStep('Add MAKE') | |
391 http_download.HttpDownload(GSTORE + MAKE, | |
392 os.path.join(pepperdir, 'tools' ,'make.exe')) | |
393 rename_list = ['ncval_x86_32', 'ncval_x86_64', | |
394 'sel_ldr_x86_32', 'sel_ldr_x86_64'] | |
395 tools = os.path.join(pepperdir, 'tools') | |
396 for name in rename_list: | |
397 src = os.path.join(pepperdir, 'tools', name) | |
398 dst = os.path.join(pepperdir, 'tools', name + '.exe') | |
399 buildbot_common.Move(src, dst) | |
400 | |
401 | |
345 EXAMPLE_LIST = [ | 402 EXAMPLE_LIST = [ |
346 'debugging', | 403 'debugging', |
347 'file_histogram', | 404 'file_histogram', |
348 'file_io', | 405 'file_io', |
349 'fullscreen_tumbler', | 406 'fullscreen_tumbler', |
350 'gamepad', | 407 'gamepad', |
351 'geturl', | 408 'geturl', |
352 'hello_world_interactive', | 409 'hello_world_interactive', |
353 'hello_world', | 410 'hello_world', |
354 'hello_world_gles', | 411 'hello_world_gles', |
(...skipping 13 matching lines...) Expand all Loading... | |
368 'ppapi_cpp', | 425 'ppapi_cpp', |
369 'ppapi_gles2', | 426 'ppapi_gles2', |
370 ] | 427 ] |
371 | 428 |
372 LIB_DICT = { | 429 LIB_DICT = { |
373 'linux': [], | 430 'linux': [], |
374 'mac': [], | 431 'mac': [], |
375 'win': ['x86_32'] | 432 'win': ['x86_32'] |
376 } | 433 } |
377 | 434 |
378 def CopyExamples(pepperdir, toolchains): | 435 def BuildStepCopyExamples(pepperdir, toolchains): |
379 buildbot_common.BuildStep('Copy examples') | 436 buildbot_common.BuildStep('Copy examples') |
380 | 437 |
381 if not os.path.exists(os.path.join(pepperdir, 'tools')): | 438 if not os.path.exists(os.path.join(pepperdir, 'tools')): |
382 buildbot_common.ErrorExit('Examples depend on missing tools.') | 439 buildbot_common.ErrorExit('Examples depend on missing tools.') |
383 if not os.path.exists(os.path.join(pepperdir, 'toolchain')): | 440 if not os.path.exists(os.path.join(pepperdir, 'toolchain')): |
384 buildbot_common.ErrorExit('Examples depend on missing toolchains.') | 441 buildbot_common.ErrorExit('Examples depend on missing toolchains.') |
385 | 442 |
386 exampledir = os.path.join(pepperdir, 'examples') | 443 exampledir = os.path.join(pepperdir, 'examples') |
387 buildbot_common.RemoveDir(exampledir) | 444 buildbot_common.RemoveDir(exampledir) |
388 buildbot_common.MakeDir(exampledir) | 445 buildbot_common.MakeDir(exampledir) |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
456 stdout, _ = process.communicate() | 513 stdout, _ = process.communicate() |
457 | 514 |
458 # Parse environment from "set" command above. | 515 # Parse environment from "set" command above. |
459 # It looks like this: | 516 # It looks like this: |
460 # KEY1=VALUE1\r\n | 517 # KEY1=VALUE1\r\n |
461 # KEY2=VALUE2\r\n | 518 # KEY2=VALUE2\r\n |
462 # ... | 519 # ... |
463 return dict(line.split('=') for line in stdout.split('\r\n')[:-1]) | 520 return dict(line.split('=') for line in stdout.split('\r\n')[:-1]) |
464 | 521 |
465 | 522 |
523 def BuildStepBuildLibraries(pepperdir, platform): | |
524 buildbot_common.BuildStep('Build Libraries') | |
525 src_dir = os.path.join(pepperdir, 'src') | |
526 makefile = os.path.join(src_dir, 'Makefile') | |
527 if os.path.isfile(makefile): | |
528 print "\n\nMake: " + src_dir | |
529 if platform == 'win': | |
530 # We need to modify the environment to build host on Windows. | |
531 env = GetWindowsEnvironment() | |
532 else: | |
533 env = os.environ | |
534 | |
noelallen1
2012/07/24 20:48:24
I should've added a comment:
make clean to remo
binji
2012/07/24 22:46:15
Done.
| |
535 buildbot_common.Run(['make', '-j8'], | |
536 cwd=os.path.abspath(src_dir), shell=True, env=env) | |
537 buildbot_common.Run(['make', '-j8', 'clean'], | |
538 cwd=os.path.abspath(src_dir), shell=True) | |
539 | |
540 | |
541 def BuildStepTarBundle(pepper_ver, tarfile): | |
542 buildbot_common.BuildStep('Tar Pepper Bundle') | |
543 buildbot_common.MakeDir(os.path.dirname(tarfile)) | |
544 buildbot_common.Run([sys.executable, CYGTAR, '-C', OUT_DIR, '-cjf', tarfile, | |
545 'pepper_' + pepper_ver], cwd=NACL_DIR) | |
546 | |
547 | |
548 def BuildStepBuildToolsTests(): | |
549 buildbot_common.BuildStep('Run build_tools tests') | |
550 buildbot_common.Run([sys.executable, | |
551 os.path.join(SDK_SRC_DIR, 'build_tools', 'tests', 'test_all.py')]) | |
552 | |
553 | |
554 def GetManifestBundle(pepper_ver, revision, tarfile, archive_url): | |
555 with open(tarfile, 'rb') as tarfile_stream: | |
556 archive_sha1, archive_size = manifest_util.DownloadAndComputeHash( | |
557 tarfile_stream) | |
558 | |
559 archive = manifest_util.Archive(manifest_util.GetHostOS()) | |
560 archive.url = archive_url | |
binji
2012/07/24 18:04:04
changed this to use the manifest_util properties.
| |
561 archive.size = archive_size | |
562 archive.checksum = archive_sha1 | |
563 | |
564 bundle = manifest_util.Bundle('pepper_' + pepper_ver) | |
binji
2012/07/24 18:04:04
here too
| |
565 bundle.revision = int(revision) | |
566 bundle.repath = 'pepper_' + pepper_ver | |
567 bundle.version = int(pepper_ver) | |
568 bundle.description = 'Chrome %s bundle, revision %s' % ( | |
569 pepper_ver, revision), | |
570 bundle.stability = 'dev' | |
571 bundle.recommended = 'no' | |
572 bundle.archives = [archive] | |
573 return bundle | |
574 | |
575 | |
576 def BuildStepTestUpdater(platform, pepper_ver, revision, tarfile): | |
577 tarname = os.path.basename(tarfile) | |
578 server = None | |
579 try: | |
580 buildbot_common.BuildStep('Run local server') | |
581 server = test_server.LocalHTTPServer(SERVER_DIR) | |
582 | |
583 buildbot_common.BuildStep('Generate manifest') | |
584 bundle = GetManifestBundle(pepper_ver, revision, tarfile, | |
585 server.GetURL(tarname)) | |
586 | |
587 manifest = manifest_util.SDKManifest() | |
588 manifest.SetBundle(bundle) | |
589 manifest_name = 'naclsdk_manifest2.json' | |
590 with open(os.path.join(SERVER_DIR, manifest_name), 'wb') as \ | |
591 manifest_stream: | |
592 manifest_stream.write(manifest.GetDataAsString()) | |
593 | |
594 # use newly built sdk updater to pull this bundle | |
595 buildbot_common.BuildStep('Update from local server') | |
596 naclsdk_sh = os.path.join(OUT_DIR, 'nacl_sdk', 'naclsdk') | |
597 if platform == 'win': | |
598 naclsdk_sh += '.bat' | |
599 buildbot_common.Run([naclsdk_sh, '-U', | |
600 server.GetURL(manifest_name), 'update', 'pepper_' + pepper_ver]) | |
601 | |
602 # Return the new pepper directory as the one inside the downloaded SDK. | |
603 return os.path.join(OUT_DIR, 'nacl_sdk', 'pepper_' + pepper_ver) | |
604 | |
605 # kill server | |
606 finally: | |
607 if server: | |
608 server.Shutdown() | |
609 | |
610 | |
611 def BuildStepBuildExamples(pepperdir, platform): | |
612 buildbot_common.BuildStep('Build Examples') | |
613 example_dir = os.path.join(pepperdir, 'examples') | |
614 makefile = os.path.join(example_dir, 'Makefile') | |
615 if os.path.isfile(makefile): | |
616 print "\n\nMake: " + example_dir | |
617 if platform == 'win': | |
618 # We need to modify the environment to build host on Windows. | |
619 env = GetWindowsEnvironment() | |
620 else: | |
621 env = os.environ | |
622 | |
623 buildbot_common.Run(['make', '-j8'], | |
624 cwd=os.path.abspath(example_dir), shell=True, env=env) | |
625 | |
626 | |
627 def BuildStepTestExamples(pepperdir, platform, pepper_ver): | |
628 buildbot_common.BuildStep('Test Examples') | |
629 env = copy.copy(os.environ) | |
630 env['PEPPER_VER'] = pepper_ver | |
631 env['NACL_SDK_ROOT'] = pepperdir | |
632 | |
633 pyauto_script = os.path.join(SRC_DIR, 'chrome', 'test', 'functional', | |
634 'nacl_sdk.py') | |
635 pyauto_script_args = ['nacl_sdk.NaClSDKTest.NaClSDKExamples'] | |
636 | |
637 if platform == 'linux' and buildbot_common.IsSDKBuilder(): | |
638 # linux buildbots need to run the pyauto tests through xvfb. Running | |
639 # using runtest.py does this. | |
640 #env['PYTHON_PATH'] = '.:' + env.get('PYTHON_PATH', '.') | |
641 build_dir = os.path.dirname(SRC_DIR) | |
642 runtest_py = os.path.join(build_dir, '..', '..', '..', 'scripts', 'slave', | |
643 'runtest.py') | |
644 buildbot_common.Run([sys.executable, runtest_py, '--target', 'Release', | |
645 '--build-dir', 'src/build', sys.executable, | |
646 pyauto_script] + pyauto_script_args, | |
647 cwd=build_dir, env=env) | |
648 else: | |
649 buildbot_common.Run([sys.executable, 'nacl_sdk.py', | |
650 'nacl_sdk.NaClSDKTest.NaClSDKExamples'], | |
651 cwd=os.path.dirname(pyauto_script), | |
652 env=env) | |
653 | |
654 | |
655 def BuildStepArchiveBundle(pepper_ver, revision, tarfile): | |
656 buildbot_common.BuildStep('Archive build') | |
657 bucket_path = 'nativeclient-mirror/nacl/nacl_sdk/%s' % ( | |
658 build_utils.ChromeVersion(),) | |
659 tarname = os.path.basename(tarfile) | |
660 tarfile_dir = os.path.dirname(tarfile) | |
661 buildbot_common.Archive(tarname, bucket_path, tarfile_dir) | |
662 | |
663 # generate "manifest snippet" for this archive. | |
664 archive_url = GSTORE + 'nacl_sdk/%s/%s' % ( | |
665 build_utils.ChromeVersion(), tarname) | |
666 bundle = GetManifestBundle(pepper_ver, revision, tarfile, archive_url) | |
667 | |
668 manifest_snippet_file = os.path.join(OUT_DIR, tarname + '.json') | |
669 with open(manifest_snippet_file, 'wb') as manifest_snippet_stream: | |
670 manifest_snippet_stream.write(bundle.GetDataAsString()) | |
671 | |
672 buildbot_common.Archive(tarname + '.json', bucket_path, OUT_DIR, | |
673 step_link=False) | |
674 | |
675 | |
676 def BuildStepArchiveSDKTools(): | |
binji
2012/07/24 18:04:04
This used to be part of the BuildStepArchiveBundle
| |
677 # Only push up sdk_tools.tgz on the linux buildbot. | |
678 builder_name = os.getenv('BUILDBOT_BUILDERNAME','') | |
679 if builder_name == 'linux-sdk-multi': | |
680 buildbot_common.BuildStep('Archive SDK Tools') | |
681 bucket_path = 'nativeclient-mirror/nacl/nacl_sdk/%s' % ( | |
682 build_utils.ChromeVersion(),) | |
683 buildbot_common.Archive('sdk_tools.tgz', bucket_path, OUT_DIR, | |
684 step_link=False) | |
685 | |
686 | |
466 def main(args): | 687 def main(args): |
467 parser = optparse.OptionParser() | 688 parser = optparse.OptionParser() |
468 parser.add_option('--pnacl', help='Enable pnacl build.', | 689 parser.add_option('--pnacl', help='Enable pnacl build.', |
469 action='store_true', dest='pnacl', default=False) | 690 action='store_true', dest='pnacl', default=False) |
470 parser.add_option('--examples', help='Only build the examples.', | 691 parser.add_option('--examples', help='Only build the examples.', |
471 action='store_true', dest='only_examples', default=False) | 692 action='store_true', dest='only_examples', default=False) |
472 parser.add_option('--update', help='Only build the updater.', | 693 parser.add_option('--update', help='Only build the updater.', |
473 action='store_true', dest='only_updater', default=False) | 694 action='store_true', dest='only_updater', default=False) |
474 parser.add_option('--test-examples', | 695 parser.add_option('--test-examples', |
475 help='Run the pyauto tests for examples.', action='store_true', | 696 help='Run the pyauto tests for examples.', action='store_true', |
(...skipping 22 matching lines...) Expand all Loading... | |
498 # TODO(binji) for now, only test examples on non-trybots. Trybots don't build | 719 # TODO(binji) for now, only test examples on non-trybots. Trybots don't build |
499 # pyauto Chrome. | 720 # pyauto Chrome. |
500 if buildbot_common.IsSDKBuilder(): | 721 if buildbot_common.IsSDKBuilder(): |
501 options.test_examples = True | 722 options.test_examples = True |
502 | 723 |
503 if options.pnacl: | 724 if options.pnacl: |
504 toolchains = ['pnacl'] | 725 toolchains = ['pnacl'] |
505 else: | 726 else: |
506 toolchains = ['newlib', 'glibc', 'host'] | 727 toolchains = ['newlib', 'glibc', 'host'] |
507 print 'Building: ' + ' '.join(toolchains) | 728 print 'Building: ' + ' '.join(toolchains) |
508 skip = options.only_examples or options.only_updater | |
509 | |
510 skip_examples = skip and not options.only_examples | |
511 skip_update = skip and not options.only_updater | |
512 skip_untar = skip | |
513 skip_build = skip | |
514 skip_test_updater = skip | |
515 skip_test_examples = skip_examples or not options.test_examples | |
516 skip_test_build_tools = skip | |
517 skip_tar = skip or options.skip_tar | |
518 | 729 |
519 if options.archive and (options.only_examples or options.skip_tar): | 730 if options.archive and (options.only_examples or options.skip_tar): |
520 parser.error('Incompatible arguments with archive.') | 731 parser.error('Incompatible arguments with archive.') |
521 | 732 |
522 pepper_ver = str(int(build_utils.ChromeMajorVersion())) | 733 pepper_ver = str(int(build_utils.ChromeMajorVersion())) |
523 pepper_old = str(int(build_utils.ChromeMajorVersion()) - 1) | 734 pepper_old = str(int(build_utils.ChromeMajorVersion()) - 1) |
735 pepperdir = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_ver) | |
736 pepperdir_old = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_old) | |
524 clnumber = build_utils.ChromeRevision() | 737 clnumber = build_utils.ChromeRevision() |
738 tarname = 'naclsdk_' + platform + '.tar.bz2' | |
739 if 'pnacl' in toolchains: | |
740 tarname = 'p' + tarname | |
741 tarfile = os.path.join(SERVER_DIR, tarname) | |
binji
2012/07/24 18:04:04
I write the tarfile directly into the local server
| |
742 | |
525 if options.release: | 743 if options.release: |
526 pepper_ver = options.release | 744 pepper_ver = options.release |
527 print 'Building PEPPER %s at %s' % (pepper_ver, clnumber) | 745 print 'Building PEPPER %s at %s' % (pepper_ver, clnumber) |
528 | 746 |
529 if not skip_build: | 747 if options.only_examples: |
530 buildbot_common.BuildStep('Rerun hooks to get toolchains') | 748 BuildStepCopyExamples(pepperdir, toolchains) |
binji
2012/07/24 18:04:04
This is duplicated below, but I think this makes t
| |
531 buildbot_common.Run(['gclient', 'runhooks'], | 749 BuildStepBuildExamples(pepperdir, platform) |
532 cwd=SRC_DIR, shell=(platform=='win')) | 750 if options.test_examples: |
751 BuildStepTestExamples(pepperdir, platform, pepper_ver) | |
752 elif options.only_updater: | |
753 build_updater.BuildUpdater(OUT_DIR) | |
754 else: # Build everything. | |
755 BuildStepBuildToolsTests() | |
binji
2012/07/24 18:04:04
I moved this suite of tests first. It is unrelated
| |
533 | 756 |
534 buildbot_common.BuildStep('Clean Pepper Dirs') | 757 BuildStepDownloadToolchains(platform) |
535 pepperdir = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_ver) | 758 BuildStepCleanPepperDirs(pepperdir, pepperdir_old) |
536 pepperold = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_old) | 759 BuildStepMakePepperDirs(pepperdir, ['include', 'toolchain', 'tools']) |
537 buildbot_common.RemoveDir(pepperold) | 760 BuildStepCopyTextFiles(pepperdir, pepper_ver, clnumber) |
538 if not skip_untar: | 761 BuildStepUntarToolchains(pepperdir, platform, arch, toolchains) |
539 buildbot_common.RemoveDir(pepperdir) | 762 BuildStepBuildToolchains(pepperdir, platform, arch, pepper_ver, toolchains) |
540 buildbot_common.MakeDir(os.path.join(pepperdir, 'include')) | 763 InstallHeaders(os.path.join(pepperdir, 'include'), None, 'libs') |
541 buildbot_common.MakeDir(os.path.join(pepperdir, 'toolchain')) | 764 BuildStepCopyBuildHelpers(pepperdir, platform) |
542 buildbot_common.MakeDir(os.path.join(pepperdir, 'tools')) | 765 BuildStepCopyExamples(pepperdir, toolchains) |
543 else: | |
544 buildbot_common.MakeDir(pepperdir) | |
545 | 766 |
546 if not skip_build: | 767 # Ship with libraries prebuilt, so run that first. |
547 buildbot_common.BuildStep('Add Text Files') | 768 BuildStepBuildLibraries(pepperdir, platform) |
548 files = ['AUTHORS', 'COPYING', 'LICENSE', 'NOTICE'] | |
549 files = [os.path.join(SDK_SRC_DIR, filename) for filename in files] | |
550 oshelpers.Copy(['-v'] + files + [pepperdir]) | |
551 | 769 |
552 # Replace a few placeholders in README | 770 if not options.skip_tar: |
noelallen1
2012/07/24 20:48:24
I think by default we want to skip_tar on example
binji
2012/07/24 22:46:15
The example build is handled as a special case abo
| |
553 readme_text = open(os.path.join(SDK_SRC_DIR, 'README'), 'rt').read() | 771 BuildStepTarBundle(pepper_ver, tarfile) |
554 readme_text = readme_text.replace('${VERSION}', pepper_ver) | 772 build_updater.BuildUpdater(OUT_DIR) |
555 readme_text = readme_text.replace('${REVISION}', clnumber) | |
556 | 773 |
557 # Year/Month/Day Hour:Minute:Second | 774 # BuildStepTestUpdater downloads the bundle to its own directory. Build |
558 time_format = '%Y/%m/%d %H:%M:%S' | 775 # the examples and test from this directory instead of the original. |
559 readme_text = readme_text.replace('${DATE}', | 776 pepperdir = BuildStepTestUpdater(platform, pepper_ver, clnumber, tarfile) |
560 datetime.datetime.now().strftime(time_format)) | 777 BuildStepBuildExamples(pepperdir, platform) |
778 if options.test_examples: | |
779 BuildStepTestExamples(pepperdir, platform, pepper_ver) | |
561 | 780 |
562 open(os.path.join(pepperdir, 'README'), 'wt').write(readme_text) | 781 # Archive on non-trybots. |
563 | 782 if options.archive or buildbot_common.IsSDKBuilder(): |
564 # Clean out the temporary toolchain untar directory | 783 BuildStepArchiveBundle(pepper_ver, clnumber, tarfile) |
565 if not skip_untar: | 784 BuildStepArchiveSDKTools() |
566 UntarToolchains(pepperdir, platform, arch, toolchains) | |
567 | |
568 if not skip_build: | |
569 BuildToolchains(pepperdir, platform, arch, pepper_ver, toolchains) | |
570 InstallHeaders(os.path.join(pepperdir, 'include'), None, 'libs') | |
571 | |
572 if not skip_build: | |
573 buildbot_common.BuildStep('Copy make OS helpers') | |
574 buildbot_common.CopyDir(os.path.join(SDK_SRC_DIR, 'tools', '*.py'), | |
575 os.path.join(pepperdir, 'tools')) | |
576 if platform == 'win': | |
577 buildbot_common.BuildStep('Add MAKE') | |
578 http_download.HttpDownload(GSTORE + MAKE, | |
579 os.path.join(pepperdir, 'tools' ,'make.exe')) | |
580 rename_list = ['ncval_x86_32', 'ncval_x86_64', | |
581 'sel_ldr_x86_32', 'sel_ldr_x86_64'] | |
582 tools = os.path.join(pepperdir, 'tools') | |
583 for name in rename_list: | |
584 src = os.path.join(pepperdir, 'tools', name) | |
585 dst = os.path.join(pepperdir, 'tools', name + '.exe') | |
586 buildbot_common.Move(src, dst) | |
587 | |
588 if not skip_examples: | |
589 CopyExamples(pepperdir, toolchains) | |
590 | |
591 tarname = 'naclsdk_' + platform + '.tar.bz2' | |
592 if 'pnacl' in toolchains: | |
593 tarname = 'p' + tarname | |
594 tarfile = os.path.join(OUT_DIR, tarname) | |
595 | |
596 # Ship with libraries prebuilt, so run that first | |
597 buildbot_common.BuildStep('Build Libraries') | |
598 src_dir = os.path.join(pepperdir, 'src') | |
599 makefile = os.path.join(src_dir, 'Makefile') | |
600 if os.path.isfile(makefile): | |
601 print "\n\nMake: " + src_dir | |
602 if platform == 'win': | |
603 # We need to modify the environment to build host on Windows. | |
604 env = GetWindowsEnvironment() | |
605 else: | |
606 env = os.environ | |
607 | |
608 buildbot_common.Run(['make', '-j8'], | |
609 cwd=os.path.abspath(src_dir), shell=True, env=env) | |
610 buildbot_common.Run(['make', '-j8', 'clean'], | |
611 cwd=os.path.abspath(src_dir), shell=True) | |
612 | |
613 if not skip_tar: | |
614 buildbot_common.BuildStep('Tar Pepper Bundle') | |
615 buildbot_common.Run([sys.executable, CYGTAR, '-C', OUT_DIR, '-cjf', tarfile, | |
616 'pepper_' + pepper_ver], cwd=NACL_DIR) | |
617 | |
618 # Run build tests | |
619 if not skip_test_build_tools: | |
620 buildbot_common.BuildStep('Run build_tools tests') | |
621 buildbot_common.Run([sys.executable, | |
622 os.path.join(SDK_SRC_DIR, 'build_tools', 'tests', 'test_all.py')]) | |
623 | |
624 # build sdk update | |
625 if not skip_update: | |
626 build_updater.BuildUpdater(OUT_DIR) | |
627 | |
628 # start local server sharing a manifest + the new bundle | |
629 if not skip_test_updater and not skip_tar: | |
630 buildbot_common.BuildStep('Move bundle to localserver dir') | |
631 buildbot_common.MakeDir(SERVER_DIR) | |
632 buildbot_common.Move(tarfile, SERVER_DIR) | |
633 tarfile = os.path.join(SERVER_DIR, tarname) | |
634 | |
635 server = None | |
636 try: | |
637 buildbot_common.BuildStep('Run local server') | |
638 server = test_server.LocalHTTPServer(SERVER_DIR) | |
639 | |
640 buildbot_common.BuildStep('Generate manifest') | |
641 with open(tarfile, 'rb') as tarfile_stream: | |
642 archive_sha1, archive_size = manifest_util.DownloadAndComputeHash( | |
643 tarfile_stream) | |
644 archive = manifest_util.Archive(manifest_util.GetHostOS()) | |
645 archive.CopyFrom({'url': server.GetURL(tarname), | |
646 'size': archive_size, | |
647 'checksum': {'sha1': archive_sha1}}) | |
648 bundle = manifest_util.Bundle('pepper_' + pepper_ver) | |
649 bundle.CopyFrom({ | |
650 'revision': int(clnumber), | |
651 'repath': 'pepper_' + pepper_ver, | |
652 'version': int(pepper_ver), | |
653 'description': 'Chrome %s bundle, revision %s' % ( | |
654 pepper_ver, clnumber), | |
655 'stability': 'dev', | |
656 'recommended': 'no', | |
657 'archives': [archive]}) | |
658 manifest = manifest_util.SDKManifest() | |
659 manifest.SetBundle(bundle) | |
660 manifest_name = 'naclsdk_manifest2.json' | |
661 with open(os.path.join(SERVER_DIR, manifest_name), 'wb') as \ | |
662 manifest_stream: | |
663 manifest_stream.write(manifest.GetDataAsString()) | |
664 | |
665 # use newly built sdk updater to pull this bundle | |
666 buildbot_common.BuildStep('Update from local server') | |
667 naclsdk_sh = os.path.join(OUT_DIR, 'nacl_sdk', 'naclsdk') | |
668 if platform == 'win': | |
669 naclsdk_sh += '.bat' | |
670 buildbot_common.Run([naclsdk_sh, '-U', | |
671 server.GetURL(manifest_name), 'update', 'pepper_' + pepper_ver]) | |
672 | |
673 # If we are testing examples, do it in the newly pulled directory. | |
674 pepperdir = os.path.join(OUT_DIR, 'nacl_sdk', 'pepper_' + pepper_ver) | |
675 | |
676 # kill server | |
677 finally: | |
678 if server: | |
679 server.Shutdown() | |
680 | |
681 # Build Examples (libraries built previously). | |
682 if not skip_examples: | |
683 buildbot_common.BuildStep('Build Examples') | |
684 example_dir = os.path.join(pepperdir, 'examples') | |
685 makefile = os.path.join(example_dir, 'Makefile') | |
686 if os.path.isfile(makefile): | |
687 print "\n\nMake: " + example_dir | |
688 if platform == 'win': | |
689 # We need to modify the environment to build host on Windows. | |
690 env = GetWindowsEnvironment() | |
691 else: | |
692 env = os.environ | |
693 | |
694 buildbot_common.Run(['make', '-j8'], | |
695 cwd=os.path.abspath(example_dir), shell=True, env=env) | |
696 | |
697 # Test examples. | |
698 if not skip_examples and not skip_test_examples: | |
699 buildbot_common.BuildStep('Test Examples') | |
700 env = copy.copy(os.environ) | |
701 env['PEPPER_VER'] = pepper_ver | |
702 env['NACL_SDK_ROOT'] = pepperdir | |
703 | |
704 pyauto_script = os.path.join(SRC_DIR, 'chrome', 'test', 'functional', | |
705 'nacl_sdk.py') | |
706 pyauto_script_args = ['nacl_sdk.NaClSDKTest.NaClSDKExamples'] | |
707 | |
708 if platform == 'linux' and buildbot_common.IsSDKBuilder(): | |
709 # linux buildbots need to run the pyauto tests through xvfb. Running | |
710 # using runtest.py does this. | |
711 #env['PYTHON_PATH'] = '.:' + env.get('PYTHON_PATH', '.') | |
712 build_dir = os.path.dirname(SRC_DIR) | |
713 runtest_py = os.path.join(build_dir, '..', '..', '..', 'scripts', 'slave', | |
714 'runtest.py') | |
715 buildbot_common.Run([sys.executable, runtest_py, '--target', 'Release', | |
716 '--build-dir', 'src/build', sys.executable, | |
717 pyauto_script] + pyauto_script_args, | |
718 cwd=build_dir, env=env) | |
719 else: | |
720 buildbot_common.Run([sys.executable, 'nacl_sdk.py', | |
721 'nacl_sdk.NaClSDKTest.NaClSDKExamples'], | |
722 cwd=os.path.dirname(pyauto_script), | |
723 env=env) | |
724 | |
725 # Archive on non-trybots. | |
726 if options.archive or buildbot_common.IsSDKBuilder(): | |
727 buildbot_common.BuildStep('Archive build') | |
728 bucket_path = 'nativeclient-mirror/nacl/nacl_sdk/%s' % \ | |
729 build_utils.ChromeVersion() | |
730 buildbot_common.Archive(tarname, bucket_path, os.path.dirname(tarfile)) | |
731 | |
732 if not skip_update: | |
733 # Only push up sdk_tools.tgz on the linux buildbot. | |
734 if builder_name == 'linux-sdk-multi': | |
735 sdk_tools = os.path.join(OUT_DIR, 'sdk_tools.tgz') | |
736 buildbot_common.Archive('sdk_tools.tgz', bucket_path, OUT_DIR, | |
737 step_link=False) | |
738 | |
739 # generate "manifest snippet" for this archive. | |
740 if not skip_test_updater: | |
741 archive = bundle.GetArchive(manifest_util.GetHostOS()) | |
742 archive.url = 'https://commondatastorage.googleapis.com/' \ | |
743 'nativeclient-mirror/nacl/nacl_sdk/%s/%s' % ( | |
744 build_utils.ChromeVersion(), tarname) | |
745 manifest_snippet_file = os.path.join(OUT_DIR, tarname + '.json') | |
746 with open(manifest_snippet_file, 'wb') as manifest_snippet_stream: | |
747 manifest_snippet_stream.write(bundle.GetDataAsString()) | |
748 | |
749 buildbot_common.Archive(tarname + '.json', bucket_path, OUT_DIR, | |
750 step_link=False) | |
751 | 785 |
752 return 0 | 786 return 0 |
753 | 787 |
754 | 788 |
755 if __name__ == '__main__': | 789 if __name__ == '__main__': |
756 sys.exit(main(sys.argv)) | 790 sys.exit(main(sys.argv)) |
OLD | NEW |