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

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

Issue 10915213: [NaCl SDK] build_sdk uses gyp to build, not scons. * (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mac fixes Created 8 years, 3 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
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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 buildbot_common.MakeDir(os.path.join(tc_dst_inc, 'KHR')) 344 buildbot_common.MakeDir(os.path.join(tc_dst_inc, 'KHR'))
345 buildbot_common.CopyDir( 345 buildbot_common.CopyDir(
346 os.path.join(PPAPI_DIR, 'lib', 'gl', 'include', 'KHR', '*.h'), 346 os.path.join(PPAPI_DIR, 'lib', 'gl', 'include', 'KHR', '*.h'),
347 os.path.join(tc_dst_inc, 'KHR')) 347 os.path.join(tc_dst_inc, 'KHR'))
348 348
349 # Copy the lib files 349 # Copy the lib files
350 buildbot_common.CopyDir(os.path.join(PPAPI_DIR, 'lib'), 350 buildbot_common.CopyDir(os.path.join(PPAPI_DIR, 'lib'),
351 os.path.join(tc_dst_inc, 'ppapi')) 351 os.path.join(tc_dst_inc, 'ppapi'))
352 352
353 353
354 def MakeNinjaRelPath(path):
355 return os.path.join(os.path.relpath(OUT_DIR, SRC_DIR), path)
356
357
358 def GypNinjaBuild_X86(pepperdir, platform, toolchains):
359 build_dir = 'gypbuild'
360 GypNinjaBuild_X86_Nacl(platform, build_dir)
361 GypNinjaBuild_X86_Chrome(build_dir)
362
363 ninja_out_dir = os.path.join(OUT_DIR, build_dir, 'Release')
364 # src_file, dst_file, is_host_exe?
365 tools_files = [
366 ('sel_ldr', 'sel_ldr_x86_32', True),
367 ('ncval_x86_32', 'ncval_x86_32', True),
368 ('irt_core_newlib_x32.nexe', 'irt_core_newlib_x32.nexe', False),
369 ('irt_core_newlib_x64.nexe', 'irt_core_newlib_x64.nexe', False),
370 ]
371 if platform != 'mac':
372 # Mac doesn't build 64-bit binaries.
373 tools_files.append(('sel_ldr64', 'sel_ldr_x86_64', True))
374 tools_files.append(('ncval_x86_64', 'ncval_x86_64', True))
375
376 if platform == 'linux':
377 tools_files.append(('nacl_helper_bootstrap',
378 'nacl_helper_bootstrap_x86_32', True))
379 tools_files.append(('nacl_helper_bootstrap64',
380 'nacl_helper_bootstrap_x86_64', True))
381
382 buildbot_common.MakeDir(os.path.join(pepperdir, 'tools'))
383 for src, dst, host_exe in tools_files:
384 if platform == 'win' and host_exe:
385 src += '.exe'
386 dst += '.exe'
387
388 buildbot_common.CopyFile(
389 os.path.join(ninja_out_dir, src),
390 os.path.join(pepperdir, 'tools', dst))
391
392 for tc in set(toolchains) & set(['newlib', 'glibc']):
393 for bits in '32', '64':
394 tc_dir = 'tc_' + tc
395 lib_dir = 'lib' + bits
396 src_dir = os.path.join(ninja_out_dir, 'gen', tc_dir, lib_dir)
397 tcpath = os.path.join(pepperdir, 'toolchain',
398 '%s_x86_%s' % (platform, tc))
399 dst_dir = GetToolchainNaClLib(tc, tcpath, 'x86', bits)
400
401 buildbot_common.MakeDir(dst_dir)
402 buildbot_common.CopyDir(os.path.join(src_dir, '*.a'), dst_dir)
403 if tc == 'newlib':
404 buildbot_common.CopyDir(os.path.join(src_dir, '*.o'), dst_dir)
405 # TODO(binji) crt1.o for newlib/32 is installed to a subdirectory for
406 # some reason. Can this be fixed in the gyp script?
407 if bits == '32':
408 buildbot_common.CopyFile(os.path.join(src_dir, '32', 'crt1.o'),
409 dst_dir)
410
411 if tc == 'glibc':
412 buildbot_common.CopyDir(os.path.join(src_dir, '*.so'), dst_dir)
413
414
415 def GypNinjaBuild_X86_Nacl(platform, rel_out_dir):
416 gyp_py = os.path.join(NACL_DIR, 'build', 'gyp_nacl')
417 nacl_core_sdk_gyp = os.path.join(NACL_DIR, 'build', 'nacl_core_sdk.gyp')
418 all_gyp = os.path.join(NACL_DIR, 'build', 'all.gyp')
419
420 out_dir = MakeNinjaRelPath(rel_out_dir)
421 GypNinjaBuild('ia32', gyp_py, nacl_core_sdk_gyp, 'nacl_core_sdk', out_dir)
422 GypNinjaBuild('ia32', gyp_py, all_gyp, 'ncval_x86_32', out_dir)
423
424 if platform == 'win':
425 NinjaBuild('sel_ldr64', out_dir)
426 NinjaBuild('ncval_x86_64', out_dir)
427 elif platform == 'linux':
428 out_dir_64 = MakeNinjaRelPath(rel_out_dir + '_64')
429 GypNinjaBuild('x64', gyp_py, nacl_core_sdk_gyp, 'sel_ldr', out_dir_64)
430 GypNinjaBuild('x64', gyp_py, all_gyp, 'ncval_x86_64', out_dir_64)
431
432 # We only need sel_ldr and ncval_x86_64 from the 64-bit out directory.
433 # sel_ldr needs to be renamed, so we'll call it sel_ldr64.
434 files_to_copy = [
435 ('sel_ldr', 'sel_ldr64'),
436 ('ncval_x86_64', 'ncval_x86_64'),
437 ]
438 files_to_copy.append(('nacl_helper_bootstrap', 'nacl_helper_bootstrap64'))
439
440 for src, dst in files_to_copy:
441 buildbot_common.CopyFile(
442 os.path.join(SRC_DIR, out_dir_64, 'Release', src),
443 os.path.join(SRC_DIR, out_dir, 'Release', dst))
444
445
446 def GypNinjaBuild_X86_Chrome(rel_out_dir):
447 gyp_py = os.path.join(SRC_DIR, 'build', 'gyp_chromium')
448
449 out_dir = MakeNinjaRelPath(rel_out_dir)
450 gyp_file = os.path.join(SRC_DIR, 'ppapi', 'ppapi_untrusted.gyp')
451 targets = ['ppapi_cpp_lib', 'ppapi_gles2_lib']
452 GypNinjaBuild('ia32', gyp_py, gyp_file, targets, out_dir)
453
454 gyp_file = os.path.join(
455 SRC_DIR, 'ppapi', 'native_client', 'native_client.gyp')
456 GypNinjaBuild('ia32', gyp_py, gyp_file, 'ppapi_lib', out_dir)
457
458
459 def GypNinjaBuild(arch, gyp_py_script, gyp_file, targets, out_dir):
460 gyp_env = copy.copy(os.environ)
461 gyp_env['GYP_GENERATORS'] = 'ninja'
462 gyp_env['GYP_DEFINES'] = 'target_arch=%s' % (arch,)
463 gyp_generator_flags = ['-G', 'output_dir=%s' % (out_dir,)]
464 buildbot_common.Run(
465 [sys.executable, gyp_py_script, gyp_file] + gyp_generator_flags,
466 cwd=SRC_DIR,
467 env=gyp_env)
468 NinjaBuild(targets, out_dir)
469
470
471 def NinjaBuild(targets, out_dir):
472 if type(targets) is not list:
473 targets = [targets]
474 out_config_dir = os.path.join(out_dir, 'Release')
475 buildbot_common.Run(['ninja', '-C', out_config_dir] + targets, cwd=SRC_DIR)
476
477
354 def BuildStepBuildToolchains(pepperdir, platform, arch, pepper_ver, toolchains): 478 def BuildStepBuildToolchains(pepperdir, platform, arch, pepper_ver, toolchains):
355 buildbot_common.BuildStep('SDK Items') 479 buildbot_common.BuildStep('SDK Items')
356 480
357 tcname = platform + '_' + arch 481 tcname = platform + '_' + arch
358 newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib') 482 newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib')
359 glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc') 483 glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc')
360 pnacldir = os.path.join(pepperdir, 'toolchain', tcname + '_pnacl') 484 pnacldir = os.path.join(pepperdir, 'toolchain', tcname + '_pnacl')
361 485
362 # Run scons TC build steps 486 # Run scons TC build steps
363 if arch == 'x86': 487 if arch == 'x86':
488 if set(toolchains) & set(['newlib', 'glibc']):
489 GypNinjaBuild_X86(pepperdir, platform, toolchains)
490
364 if 'newlib' in toolchains: 491 if 'newlib' in toolchains:
365 buildbot_common.Run(
366 GetBuildArgs('newlib', newlibdir, pepperdir, 'x86', '32'),
367 cwd=NACL_DIR, shell=(platform=='win'))
368 buildbot_common.Run(
369 GetBuildArgs('newlib', newlibdir, pepperdir, 'x86', '64'),
370 cwd=NACL_DIR, shell=(platform=='win'))
371 InstallHeaders(GetToolchainNaClInclude('newlib', newlibdir, 'x86'), 492 InstallHeaders(GetToolchainNaClInclude('newlib', newlibdir, 'x86'),
372 pepper_ver, 493 pepper_ver,
373 'newlib') 494 'newlib')
374 495
375 if 'glibc' in toolchains: 496 if 'glibc' in toolchains:
376 buildbot_common.Run(
377 GetBuildArgs('glibc', glibcdir, pepperdir, 'x86', '32'),
378 cwd=NACL_DIR, shell=(platform=='win'))
379 buildbot_common.Run(
380 GetBuildArgs('glibc', glibcdir, pepperdir, 'x86', '64'),
381 cwd=NACL_DIR, shell=(platform=='win'))
382 InstallHeaders(GetToolchainNaClInclude('glibc', glibcdir, 'x86'), 497 InstallHeaders(GetToolchainNaClInclude('glibc', glibcdir, 'x86'),
383 pepper_ver, 498 pepper_ver,
384 'glibc') 499 'glibc')
385 500
386 if 'pnacl' in toolchains: 501 if 'pnacl' in toolchains:
387 buildbot_common.Run( 502 buildbot_common.Run(
388 GetBuildArgs('pnacl', pnacldir, pepperdir, 'x86', '32'), 503 GetBuildArgs('pnacl', pnacldir, pepperdir, 'x86', '32'),
389 cwd=NACL_DIR, shell=(platform=='win')) 504 cwd=NACL_DIR, shell=(platform=='win'))
390 buildbot_common.Run( 505 buildbot_common.Run(
391 GetBuildArgs('pnacl', pnacldir, pepperdir, 'x86', '64'), 506 GetBuildArgs('pnacl', pnacldir, pepperdir, 'x86', '64'),
(...skipping 18 matching lines...) Expand all
410 525
411 526
412 def BuildStepCopyBuildHelpers(pepperdir, platform): 527 def BuildStepCopyBuildHelpers(pepperdir, platform):
413 buildbot_common.BuildStep('Copy build helpers') 528 buildbot_common.BuildStep('Copy build helpers')
414 buildbot_common.CopyDir(os.path.join(SDK_SRC_DIR, 'tools', '*.py'), 529 buildbot_common.CopyDir(os.path.join(SDK_SRC_DIR, 'tools', '*.py'),
415 os.path.join(pepperdir, 'tools')) 530 os.path.join(pepperdir, 'tools'))
416 if platform == 'win': 531 if platform == 'win':
417 buildbot_common.BuildStep('Add MAKE') 532 buildbot_common.BuildStep('Add MAKE')
418 http_download.HttpDownload(GSTORE + MAKE, 533 http_download.HttpDownload(GSTORE + MAKE,
419 os.path.join(pepperdir, 'tools' ,'make.exe')) 534 os.path.join(pepperdir, 'tools' ,'make.exe'))
420 rename_list = ['ncval_x86_32', 'ncval_x86_64',
421 'sel_ldr_x86_32', 'sel_ldr_x86_64']
422 for name in rename_list:
423 src = os.path.join(pepperdir, 'tools', name)
424 dst = os.path.join(pepperdir, 'tools', name + '.exe')
425 buildbot_common.Move(src, dst)
426 535
427 536
428 EXAMPLE_LIST = [ 537 EXAMPLE_LIST = [
429 'debugging', 538 'debugging',
430 'file_histogram', 539 'file_histogram',
431 'file_io', 540 'file_io',
432 'fullscreen_tumbler', 541 'fullscreen_tumbler',
433 'gamepad', 542 'gamepad',
434 'geturl', 543 'geturl',
435 'hello_world_interactive', 544 'hello_world_interactive',
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 # Archive on non-trybots. 967 # Archive on non-trybots.
859 if options.archive or buildbot_common.IsSDKBuilder(): 968 if options.archive or buildbot_common.IsSDKBuilder():
860 BuildStepArchiveBundle(pepper_ver, clnumber, tarfile) 969 BuildStepArchiveBundle(pepper_ver, clnumber, tarfile)
861 BuildStepArchiveSDKTools() 970 BuildStepArchiveSDKTools()
862 971
863 return 0 972 return 0
864 973
865 974
866 if __name__ == '__main__': 975 if __name__ == '__main__':
867 sys.exit(main(sys.argv)) 976 sys.exit(main(sys.argv))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698