Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(410)

Side by Side Diff: native_client_sdk/src/build_tools/build_sdk.py

Issue 10808103: [NaCl SDK] Clean up build_sdk.py (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: feedback Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 BuildStepBuildToolsTests():
147 buildbot_common.BuildStep('Run build_tools tests')
148 buildbot_common.Run([sys.executable,
149 os.path.join(SDK_SRC_DIR, 'build_tools', 'tests', 'test_all.py')])
150
151
152 def BuildStepDownloadToolchains(platform):
153 buildbot_common.BuildStep('Rerun hooks to get toolchains')
154 buildbot_common.Run(['gclient', 'runhooks'],
155 cwd=SRC_DIR, shell=(platform=='win'))
156
157
158 def BuildStepCleanPepperDirs(pepperdir, pepperdir_old):
159 buildbot_common.BuildStep('Clean Pepper Dirs')
160 buildbot_common.RemoveDir(pepperdir_old)
161 buildbot_common.RemoveDir(pepperdir)
162 buildbot_common.MakeDir(pepperdir)
163
164
165 def BuildStepMakePepperDirs(pepperdir, subdirs):
166 for subdir in subdirs:
167 buildbot_common.MakeDir(os.path.join(pepperdir, subdir))
168
169
170 def BuildStepCopyTextFiles(pepperdir, pepper_ver, revision):
171 buildbot_common.BuildStep('Add Text Files')
172 files = ['AUTHORS', 'COPYING', 'LICENSE', 'NOTICE']
173 files = [os.path.join(SDK_SRC_DIR, filename) for filename in files]
174 oshelpers.Copy(['-v'] + files + [pepperdir])
175
176 # Replace a few placeholders in README
177 readme_text = open(os.path.join(SDK_SRC_DIR, 'README'), 'rt').read()
178 readme_text = readme_text.replace('${VERSION}', pepper_ver)
179 readme_text = readme_text.replace('${REVISION}', revision)
180
181 # Year/Month/Day Hour:Minute:Second
182 time_format = '%Y/%m/%d %H:%M:%S'
183 readme_text = readme_text.replace('${DATE}',
184 datetime.datetime.now().strftime(time_format))
185
186 open(os.path.join(pepperdir, 'README'), 'wt').write(readme_text)
187
188
189 def BuildStepUntarToolchains(pepperdir, platform, arch, toolchains):
190 buildbot_common.BuildStep('Untar Toolchains')
191 tcname = platform + '_' + arch
192 tmpdir = os.path.join(SRC_DIR, 'out', 'tc_temp')
193 buildbot_common.RemoveDir(tmpdir)
194 buildbot_common.MakeDir(tmpdir)
195
196 if 'newlib' in toolchains:
197 # Untar the newlib toolchains
198 tarfile = GetNewlibToolchain(platform, arch)
199 buildbot_common.Run([sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile],
200 cwd=NACL_DIR)
201
202 # Then rename/move it to the pepper toolchain directory
203 srcdir = os.path.join(tmpdir, 'sdk', 'nacl-sdk')
204 newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib')
205 buildbot_common.Move(srcdir, newlibdir)
206
207 if 'glibc' in toolchains:
208 # Untar the glibc toolchains
209 tarfile = GetGlibcToolchain(platform, arch)
210 buildbot_common.Run([sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile],
211 cwd=NACL_DIR)
212
213 # Then rename/move it to the pepper toolchain directory
214 srcdir = os.path.join(tmpdir, 'toolchain', tcname)
215 glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc')
216 buildbot_common.Move(srcdir, glibcdir)
217
218 # Untar the pnacl toolchains
219 if 'pnacl' in toolchains:
220 tmpdir = os.path.join(tmpdir, 'pnacl')
221 buildbot_common.RemoveDir(tmpdir)
222 buildbot_common.MakeDir(tmpdir)
223 tarfile = GetPNaClToolchain(platform, arch)
224 buildbot_common.Run([sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile],
225 cwd=NACL_DIR)
226
227 # Then rename/move it to the pepper toolchain directory
228 pnacldir = os.path.join(pepperdir, 'toolchain', tcname + '_pnacl')
229 buildbot_common.Move(tmpdir, pnacldir)
230
231
144 HEADER_MAP = { 232 HEADER_MAP = {
145 'newlib': { 233 'newlib': {
146 'pthread.h': 'src/untrusted/pthread/pthread.h', 234 'pthread.h': 'src/untrusted/pthread/pthread.h',
147 'semaphore.h': 'src/untrusted/pthread/semaphore.h', 235 'semaphore.h': 'src/untrusted/pthread/semaphore.h',
148 'nacl/dynamic_annotations.h': 236 'nacl/dynamic_annotations.h':
149 'src/untrusted/valgrind/dynamic_annotations.h', 237 'src/untrusted/valgrind/dynamic_annotations.h',
150 'nacl/nacl_dyncode.h': 'src/untrusted/nacl/nacl_dyncode.h', 238 'nacl/nacl_dyncode.h': 'src/untrusted/nacl/nacl_dyncode.h',
151 'nacl/nacl_startup.h': 'src/untrusted/nacl/nacl_startup.h', 239 'nacl/nacl_startup.h': 'src/untrusted/nacl/nacl_startup.h',
152 'nacl/nacl_thread.h': 'src/untrusted/nacl/nacl_thread.h', 240 'nacl/nacl_thread.h': 'src/untrusted/nacl/nacl_thread.h',
153 'pnacl.h': 'src/untrusted/nacl/pnacl.h', 241 'pnacl.h': 'src/untrusted/nacl/pnacl.h',
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 buildbot_common.MakeDir(os.path.join(tc_dst_inc, 'KHR')) 329 buildbot_common.MakeDir(os.path.join(tc_dst_inc, 'KHR'))
242 buildbot_common.CopyDir( 330 buildbot_common.CopyDir(
243 os.path.join(PPAPI_DIR,'lib','gl','include','KHR', '*.h'), 331 os.path.join(PPAPI_DIR,'lib','gl','include','KHR', '*.h'),
244 os.path.join(tc_dst_inc, 'KHR')) 332 os.path.join(tc_dst_inc, 'KHR'))
245 333
246 # Copy the lib files 334 # Copy the lib files
247 buildbot_common.CopyDir(os.path.join(PPAPI_DIR,'lib'), 335 buildbot_common.CopyDir(os.path.join(PPAPI_DIR,'lib'),
248 os.path.join(tc_dst_inc, 'ppapi')) 336 os.path.join(tc_dst_inc, 'ppapi'))
249 337
250 338
251 def UntarToolchains(pepperdir, platform, arch, toolchains): 339 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') 340 buildbot_common.BuildStep('SDK Items')
296 341
297 tcname = platform + '_' + arch 342 tcname = platform + '_' + arch
298 newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib') 343 newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib')
299 glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc') 344 glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc')
300 pnacldir = os.path.join(pepperdir, 'toolchain', tcname + '_pnacl') 345 pnacldir = os.path.join(pepperdir, 'toolchain', tcname + '_pnacl')
301 346
302 # Run scons TC build steps 347 # Run scons TC build steps
303 if arch == 'x86': 348 if arch == 'x86':
304 if 'newlib' in toolchains: 349 if 'newlib' in toolchains:
(...skipping 30 matching lines...) Expand all
335 buildbot_common.Move( 380 buildbot_common.Move(
336 os.path.join(GetToolchainNaClLib('pnacl', pnacldir, 'x86', '64'), 381 os.path.join(GetToolchainNaClLib('pnacl', pnacldir, 'x86', '64'),
337 'libpnacl_irt_shim.a'), 382 'libpnacl_irt_shim.a'),
338 GetPNaClNativeLib(pnacldir, 'x86-64')) 383 GetPNaClNativeLib(pnacldir, 'x86-64'))
339 InstallHeaders(GetToolchainNaClInclude('pnacl', pnacldir, 'x86'), 384 InstallHeaders(GetToolchainNaClInclude('pnacl', pnacldir, 'x86'),
340 pepper_ver, 385 pepper_ver,
341 'newlib') 386 'newlib')
342 else: 387 else:
343 buildbot_common.ErrorExit('Missing arch %s' % arch) 388 buildbot_common.ErrorExit('Missing arch %s' % arch)
344 389
390
391 def BuildStepCopyBuildHelpers(pepperdir, platform):
392 buildbot_common.BuildStep('Copy build helpers')
393 buildbot_common.CopyDir(os.path.join(SDK_SRC_DIR, 'tools', '*.py'),
394 os.path.join(pepperdir, 'tools'))
395 if platform == 'win':
396 buildbot_common.BuildStep('Add MAKE')
397 http_download.HttpDownload(GSTORE + MAKE,
398 os.path.join(pepperdir, 'tools' ,'make.exe'))
399 rename_list = ['ncval_x86_32', 'ncval_x86_64',
400 'sel_ldr_x86_32', 'sel_ldr_x86_64']
401 tools = os.path.join(pepperdir, 'tools')
402 for name in rename_list:
403 src = os.path.join(pepperdir, 'tools', name)
404 dst = os.path.join(pepperdir, 'tools', name + '.exe')
405 buildbot_common.Move(src, dst)
406
407
345 EXAMPLE_LIST = [ 408 EXAMPLE_LIST = [
346 'debugging', 409 'debugging',
347 'file_histogram', 410 'file_histogram',
348 'file_io', 411 'file_io',
349 'fullscreen_tumbler', 412 'fullscreen_tumbler',
350 'gamepad', 413 'gamepad',
351 'geturl', 414 'geturl',
352 'hello_world_interactive', 415 'hello_world_interactive',
353 'hello_world', 416 'hello_world',
354 'hello_world_gles', 417 'hello_world_gles',
(...skipping 13 matching lines...) Expand all
368 'ppapi_cpp', 431 'ppapi_cpp',
369 'ppapi_gles2', 432 'ppapi_gles2',
370 ] 433 ]
371 434
372 LIB_DICT = { 435 LIB_DICT = {
373 'linux': [], 436 'linux': [],
374 'mac': [], 437 'mac': [],
375 'win': ['x86_32'] 438 'win': ['x86_32']
376 } 439 }
377 440
378 def CopyExamples(pepperdir, toolchains): 441 def BuildStepCopyExamples(pepperdir, toolchains):
379 buildbot_common.BuildStep('Copy examples') 442 buildbot_common.BuildStep('Copy examples')
380 443
381 if not os.path.exists(os.path.join(pepperdir, 'tools')): 444 if not os.path.exists(os.path.join(pepperdir, 'tools')):
382 buildbot_common.ErrorExit('Examples depend on missing tools.') 445 buildbot_common.ErrorExit('Examples depend on missing tools.')
383 if not os.path.exists(os.path.join(pepperdir, 'toolchain')): 446 if not os.path.exists(os.path.join(pepperdir, 'toolchain')):
384 buildbot_common.ErrorExit('Examples depend on missing toolchains.') 447 buildbot_common.ErrorExit('Examples depend on missing toolchains.')
385 448
386 exampledir = os.path.join(pepperdir, 'examples') 449 exampledir = os.path.join(pepperdir, 'examples')
387 buildbot_common.RemoveDir(exampledir) 450 buildbot_common.RemoveDir(exampledir)
388 buildbot_common.MakeDir(exampledir) 451 buildbot_common.MakeDir(exampledir)
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 stdout, _ = process.communicate() 519 stdout, _ = process.communicate()
457 520
458 # Parse environment from "set" command above. 521 # Parse environment from "set" command above.
459 # It looks like this: 522 # It looks like this:
460 # KEY1=VALUE1\r\n 523 # KEY1=VALUE1\r\n
461 # KEY2=VALUE2\r\n 524 # KEY2=VALUE2\r\n
462 # ... 525 # ...
463 return dict(line.split('=') for line in stdout.split('\r\n')[:-1]) 526 return dict(line.split('=') for line in stdout.split('\r\n')[:-1])
464 527
465 528
529 def BuildStepBuildLibraries(pepperdir, platform):
530 buildbot_common.BuildStep('Build Libraries')
531 src_dir = os.path.join(pepperdir, 'src')
532 makefile = os.path.join(src_dir, 'Makefile')
533 if os.path.isfile(makefile):
534 print "\n\nMake: " + src_dir
535 if platform == 'win':
536 # We need to modify the environment to build host on Windows.
537 env = GetWindowsEnvironment()
538 else:
539 env = os.environ
540
541 buildbot_common.Run(['make', '-j8'],
542 cwd=os.path.abspath(src_dir), shell=True, env=env)
543 # Clean to remove temporary files but keep the built libraries.
544 buildbot_common.Run(['make', '-j8', 'clean'],
545 cwd=os.path.abspath(src_dir), shell=True)
546
547
548 def BuildStepTarBundle(pepper_ver, tarfile):
549 buildbot_common.BuildStep('Tar Pepper Bundle')
550 buildbot_common.MakeDir(os.path.dirname(tarfile))
551 buildbot_common.Run([sys.executable, CYGTAR, '-C', OUT_DIR, '-cjf', tarfile,
552 'pepper_' + pepper_ver], cwd=NACL_DIR)
553
554
555 def GetManifestBundle(pepper_ver, revision, tarfile, archive_url):
556 with open(tarfile, 'rb') as tarfile_stream:
557 archive_sha1, archive_size = manifest_util.DownloadAndComputeHash(
558 tarfile_stream)
559
560 archive = manifest_util.Archive(manifest_util.GetHostOS())
561 archive.url = archive_url
562 archive.size = archive_size
563 archive.checksum = archive_sha1
564
565 bundle = manifest_util.Bundle('pepper_' + pepper_ver)
566 bundle.revision = int(revision)
567 bundle.repath = 'pepper_' + pepper_ver
568 bundle.version = int(pepper_ver)
569 bundle.description = 'Chrome %s bundle, revision %s' % (
570 pepper_ver, revision),
571 bundle.stability = 'dev'
572 bundle.recommended = 'no'
573 bundle.archives = [archive]
574 return bundle
575
576
577 def BuildStepTestUpdater(platform, pepper_ver, revision, tarfile):
578 tarname = os.path.basename(tarfile)
579 server = None
580 try:
581 buildbot_common.BuildStep('Run local server')
582 server = test_server.LocalHTTPServer(SERVER_DIR)
583
584 buildbot_common.BuildStep('Generate manifest')
585 bundle = GetManifestBundle(pepper_ver, revision, tarfile,
586 server.GetURL(tarname))
587
588 manifest = manifest_util.SDKManifest()
589 manifest.SetBundle(bundle)
590 manifest_name = 'naclsdk_manifest2.json'
591 with open(os.path.join(SERVER_DIR, manifest_name), 'wb') as \
592 manifest_stream:
593 manifest_stream.write(manifest.GetDataAsString())
594
595 # use newly built sdk updater to pull this bundle
596 buildbot_common.BuildStep('Update from local server')
597 naclsdk_sh = os.path.join(OUT_DIR, 'nacl_sdk', 'naclsdk')
598 if platform == 'win':
599 naclsdk_sh += '.bat'
600 buildbot_common.Run([naclsdk_sh, '-U',
601 server.GetURL(manifest_name), 'update', 'pepper_' + pepper_ver])
602
603 # Return the new pepper directory as the one inside the downloaded SDK.
604 return os.path.join(OUT_DIR, 'nacl_sdk', 'pepper_' + pepper_ver)
605
606 # kill server
607 finally:
608 if server:
609 server.Shutdown()
610
611
612 def BuildStepBuildExamples(pepperdir, platform):
613 buildbot_common.BuildStep('Build Examples')
614 example_dir = os.path.join(pepperdir, 'examples')
615 makefile = os.path.join(example_dir, 'Makefile')
616 if os.path.isfile(makefile):
617 print "\n\nMake: " + example_dir
618 if platform == 'win':
619 # We need to modify the environment to build host on Windows.
620 env = GetWindowsEnvironment()
621 else:
622 env = os.environ
623
624 buildbot_common.Run(['make', '-j8'],
625 cwd=os.path.abspath(example_dir), shell=True, env=env)
626
627
628 def BuildStepTestExamples(pepperdir, platform, pepper_ver):
629 buildbot_common.BuildStep('Test Examples')
630 env = copy.copy(os.environ)
631 env['PEPPER_VER'] = pepper_ver
632 env['NACL_SDK_ROOT'] = pepperdir
633
634 pyauto_script = os.path.join(SRC_DIR, 'chrome', 'test', 'functional',
635 'nacl_sdk.py')
636 pyauto_script_args = ['nacl_sdk.NaClSDKTest.NaClSDKExamples']
637
638 if platform == 'linux' and buildbot_common.IsSDKBuilder():
639 # linux buildbots need to run the pyauto tests through xvfb. Running
640 # using runtest.py does this.
641 #env['PYTHON_PATH'] = '.:' + env.get('PYTHON_PATH', '.')
642 build_dir = os.path.dirname(SRC_DIR)
643 runtest_py = os.path.join(build_dir, '..', '..', '..', 'scripts', 'slave',
644 'runtest.py')
645 buildbot_common.Run([sys.executable, runtest_py, '--target', 'Release',
646 '--build-dir', 'src/build', sys.executable,
647 pyauto_script] + pyauto_script_args,
648 cwd=build_dir, env=env)
649 else:
650 buildbot_common.Run([sys.executable, 'nacl_sdk.py',
651 'nacl_sdk.NaClSDKTest.NaClSDKExamples'],
652 cwd=os.path.dirname(pyauto_script),
653 env=env)
654
655
656 def BuildStepArchiveBundle(pepper_ver, revision, tarfile):
657 buildbot_common.BuildStep('Archive build')
658 bucket_path = 'nativeclient-mirror/nacl/nacl_sdk/%s' % (
659 build_utils.ChromeVersion(),)
660 tarname = os.path.basename(tarfile)
661 tarfile_dir = os.path.dirname(tarfile)
662 buildbot_common.Archive(tarname, bucket_path, tarfile_dir)
663
664 # generate "manifest snippet" for this archive.
665 archive_url = GSTORE + 'nacl_sdk/%s/%s' % (
666 build_utils.ChromeVersion(), tarname)
667 bundle = GetManifestBundle(pepper_ver, revision, tarfile, archive_url)
668
669 manifest_snippet_file = os.path.join(OUT_DIR, tarname + '.json')
670 with open(manifest_snippet_file, 'wb') as manifest_snippet_stream:
671 manifest_snippet_stream.write(bundle.GetDataAsString())
672
673 buildbot_common.Archive(tarname + '.json', bucket_path, OUT_DIR,
674 step_link=False)
675
676
677 def BuildStepArchiveSDKTools():
678 # Only push up sdk_tools.tgz on the linux buildbot.
679 builder_name = os.getenv('BUILDBOT_BUILDERNAME','')
680 if builder_name == 'linux-sdk-multi':
681 buildbot_common.BuildStep('Archive SDK Tools')
682 bucket_path = 'nativeclient-mirror/nacl/nacl_sdk/%s' % (
683 build_utils.ChromeVersion(),)
684 buildbot_common.Archive('sdk_tools.tgz', bucket_path, OUT_DIR,
685 step_link=False)
686
687
466 def main(args): 688 def main(args):
467 parser = optparse.OptionParser() 689 parser = optparse.OptionParser()
468 parser.add_option('--pnacl', help='Enable pnacl build.', 690 parser.add_option('--pnacl', help='Enable pnacl build.',
469 action='store_true', dest='pnacl', default=False) 691 action='store_true', dest='pnacl', default=False)
470 parser.add_option('--examples', help='Only build the examples.', 692 parser.add_option('--examples', help='Only build the examples.',
471 action='store_true', dest='only_examples', default=False) 693 action='store_true', dest='only_examples', default=False)
472 parser.add_option('--update', help='Only build the updater.', 694 parser.add_option('--update', help='Only build the updater.',
473 action='store_true', dest='only_updater', default=False) 695 action='store_true', dest='only_updater', default=False)
474 parser.add_option('--test-examples', 696 parser.add_option('--test-examples',
475 help='Run the pyauto tests for examples.', action='store_true', 697 help='Run the pyauto tests for examples.', action='store_true',
(...skipping 22 matching lines...) Expand all
498 # TODO(binji) for now, only test examples on non-trybots. Trybots don't build 720 # TODO(binji) for now, only test examples on non-trybots. Trybots don't build
499 # pyauto Chrome. 721 # pyauto Chrome.
500 if buildbot_common.IsSDKBuilder(): 722 if buildbot_common.IsSDKBuilder():
501 options.test_examples = True 723 options.test_examples = True
502 724
503 if options.pnacl: 725 if options.pnacl:
504 toolchains = ['pnacl'] 726 toolchains = ['pnacl']
505 else: 727 else:
506 toolchains = ['newlib', 'glibc', 'host'] 728 toolchains = ['newlib', 'glibc', 'host']
507 print 'Building: ' + ' '.join(toolchains) 729 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 730
519 if options.archive and (options.only_examples or options.skip_tar): 731 if options.archive and (options.only_examples or options.skip_tar):
520 parser.error('Incompatible arguments with archive.') 732 parser.error('Incompatible arguments with archive.')
521 733
522 pepper_ver = str(int(build_utils.ChromeMajorVersion())) 734 pepper_ver = str(int(build_utils.ChromeMajorVersion()))
523 pepper_old = str(int(build_utils.ChromeMajorVersion()) - 1) 735 pepper_old = str(int(build_utils.ChromeMajorVersion()) - 1)
736 pepperdir = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_ver)
737 pepperdir_old = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_old)
524 clnumber = build_utils.ChromeRevision() 738 clnumber = build_utils.ChromeRevision()
739 tarname = 'naclsdk_' + platform + '.tar.bz2'
740 if 'pnacl' in toolchains:
741 tarname = 'p' + tarname
742 tarfile = os.path.join(SERVER_DIR, tarname)
743
525 if options.release: 744 if options.release:
526 pepper_ver = options.release 745 pepper_ver = options.release
527 print 'Building PEPPER %s at %s' % (pepper_ver, clnumber) 746 print 'Building PEPPER %s at %s' % (pepper_ver, clnumber)
528 747
529 if not skip_build: 748 if options.only_examples:
530 buildbot_common.BuildStep('Rerun hooks to get toolchains') 749 BuildStepCopyExamples(pepperdir, toolchains)
531 buildbot_common.Run(['gclient', 'runhooks'], 750 BuildStepBuildExamples(pepperdir, platform)
532 cwd=SRC_DIR, shell=(platform=='win')) 751 if options.test_examples:
752 BuildStepTestExamples(pepperdir, platform, pepper_ver)
753 elif options.only_updater:
754 build_updater.BuildUpdater(OUT_DIR)
755 else: # Build everything.
756 BuildStepBuildToolsTests()
533 757
534 buildbot_common.BuildStep('Clean Pepper Dirs') 758 BuildStepDownloadToolchains(platform)
535 pepperdir = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_ver) 759 BuildStepCleanPepperDirs(pepperdir, pepperdir_old)
536 pepperold = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_old) 760 BuildStepMakePepperDirs(pepperdir, ['include', 'toolchain', 'tools'])
537 buildbot_common.RemoveDir(pepperold) 761 BuildStepCopyTextFiles(pepperdir, pepper_ver, clnumber)
538 if not skip_untar: 762 BuildStepUntarToolchains(pepperdir, platform, arch, toolchains)
539 buildbot_common.RemoveDir(pepperdir) 763 BuildStepBuildToolchains(pepperdir, platform, arch, pepper_ver, toolchains)
540 buildbot_common.MakeDir(os.path.join(pepperdir, 'include')) 764 InstallHeaders(os.path.join(pepperdir, 'include'), None, 'libs')
541 buildbot_common.MakeDir(os.path.join(pepperdir, 'toolchain')) 765 BuildStepCopyBuildHelpers(pepperdir, platform)
542 buildbot_common.MakeDir(os.path.join(pepperdir, 'tools')) 766 BuildStepCopyExamples(pepperdir, toolchains)
543 else:
544 buildbot_common.MakeDir(pepperdir)
545 767
546 if not skip_build: 768 # Ship with libraries prebuilt, so run that first.
547 buildbot_common.BuildStep('Add Text Files') 769 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 770
552 # Replace a few placeholders in README 771 if not options.skip_tar:
553 readme_text = open(os.path.join(SDK_SRC_DIR, 'README'), 'rt').read() 772 BuildStepTarBundle(pepper_ver, tarfile)
554 readme_text = readme_text.replace('${VERSION}', pepper_ver) 773 build_updater.BuildUpdater(OUT_DIR)
555 readme_text = readme_text.replace('${REVISION}', clnumber)
556 774
557 # Year/Month/Day Hour:Minute:Second 775 # BuildStepTestUpdater downloads the bundle to its own directory. Build
558 time_format = '%Y/%m/%d %H:%M:%S' 776 # the examples and test from this directory instead of the original.
559 readme_text = readme_text.replace('${DATE}', 777 pepperdir = BuildStepTestUpdater(platform, pepper_ver, clnumber, tarfile)
560 datetime.datetime.now().strftime(time_format)) 778 BuildStepBuildExamples(pepperdir, platform)
779 if options.test_examples:
780 BuildStepTestExamples(pepperdir, platform, pepper_ver)
561 781
562 open(os.path.join(pepperdir, 'README'), 'wt').write(readme_text) 782 # Archive on non-trybots.
563 783 if options.archive or buildbot_common.IsSDKBuilder():
564 # Clean out the temporary toolchain untar directory 784 BuildStepArchiveBundle(pepper_ver, clnumber, tarfile)
565 if not skip_untar: 785 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 786
752 return 0 787 return 0
753 788
754 789
755 if __name__ == '__main__': 790 if __name__ == '__main__':
756 sys.exit(main(sys.argv)) 791 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698