Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / native_client_sdk / src / build_tools / build_sdk.py
blobcbe88a0ac08afce96120fd9dbe9a7ea43734763a
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
6 """Entry point for both build and try bots.
8 This script is invoked from XXX, usually without arguments
9 to package an SDK. It automatically determines whether
10 this SDK is for mac, win, linux.
12 The script inspects the following environment variables:
14 BUILDBOT_BUILDERNAME to determine whether the script is run locally
15 and whether it should upload an SDK to file storage (GSTORE)
16 """
18 # pylint: disable=W0621
20 # std python includes
21 import argparse
22 import datetime
23 import glob
24 import os
25 import re
26 import sys
28 if sys.version_info < (2, 7, 0):
29 sys.stderr.write("python 2.7 or later is required run this script\n")
30 sys.exit(1)
32 # local includes
33 import buildbot_common
34 import build_projects
35 import build_updater
36 import build_version
37 import generate_notice
38 import manifest_util
39 import parse_dsc
40 import verify_filelist
42 from build_paths import SCRIPT_DIR, SDK_SRC_DIR, SRC_DIR, NACL_DIR, OUT_DIR
43 from build_paths import NACLPORTS_DIR, GSTORE, GONACL_APPENGINE_SRC_DIR
45 # Add SDK make tools scripts to the python path.
46 sys.path.append(os.path.join(SDK_SRC_DIR, 'tools'))
47 sys.path.append(os.path.join(NACL_DIR, 'build'))
49 import getos
50 import oshelpers
52 BUILD_DIR = os.path.join(NACL_DIR, 'build')
53 NACL_TOOLCHAIN_DIR = os.path.join(NACL_DIR, 'toolchain')
54 NACL_TOOLCHAINTARS_DIR = os.path.join(NACL_TOOLCHAIN_DIR, '.tars')
56 CYGTAR = os.path.join(BUILD_DIR, 'cygtar.py')
57 PKGVER = os.path.join(BUILD_DIR, 'package_version', 'package_version.py')
59 NACLPORTS_URL = 'https://chromium.googlesource.com/external/naclports.git'
60 NACLPORTS_REV = '65c71c1524a74ff8415573e5e5ef7c59ce4ac437'
62 GYPBUILD_DIR = 'gypbuild'
64 options = None
66 # Map of: ToolchainName: (PackageName, SDKDir, arch).
67 TOOLCHAIN_PACKAGE_MAP = {
68 'arm_newlib': ('nacl_arm_newlib', '%(platform)s_arm_newlib', 'arm'),
69 'arm_glibc': ('nacl_arm_glibc', '%(platform)s_arm_glibc', 'arm'),
70 'x86_newlib': ('nacl_x86_newlib', '%(platform)s_x86_newlib', 'x86'),
71 'x86_glibc': ('nacl_x86_glibc', '%(platform)s_x86_glibc', 'x86'),
72 'arm_bionic': ('nacl_arm_bionic', '%(platform)s_arm_bionic', 'arm'),
73 'pnacl': ('pnacl_newlib', '%(platform)s_pnacl', 'pnacl')
77 def GetToolchainDirName(tcname):
78 """Return the directory name for a given toolchain"""
79 return TOOLCHAIN_PACKAGE_MAP[tcname][1] % {'platform': getos.GetPlatform()}
82 def GetToolchainDir(pepperdir, tcname):
83 """Return the full path to a given toolchain within a given sdk root"""
84 return os.path.join(pepperdir, 'toolchain', GetToolchainDirName(tcname))
87 def GetToolchainLibc(tcname):
88 if tcname == 'pnacl':
89 return 'newlib'
90 for libc in ('bionic', 'glibc', 'newlib', 'host'):
91 if libc in tcname:
92 return libc
95 def GetToolchainNaClInclude(pepperdir, tcname, arch=None):
96 tcpath = GetToolchainDir(pepperdir, tcname)
97 if arch is None:
98 arch = TOOLCHAIN_PACKAGE_MAP[tcname][2]
99 if arch == 'x86':
100 return os.path.join(tcpath, 'x86_64-nacl', 'include')
101 elif arch == 'pnacl':
102 return os.path.join(tcpath, 'le32-nacl', 'include')
103 elif arch == 'arm':
104 return os.path.join(tcpath, 'arm-nacl', 'include')
105 else:
106 buildbot_common.ErrorExit('Unknown architecture: %s' % arch)
109 def GetConfigDir(arch):
110 if arch.endswith('x64') and getos.GetPlatform() == 'win':
111 return 'Release_x64'
112 else:
113 return 'Release'
116 def GetNinjaOutDir(arch):
117 return os.path.join(OUT_DIR, GYPBUILD_DIR + '-' + arch, GetConfigDir(arch))
120 def GetGypBuiltLib(tcname, arch):
121 if arch == 'ia32':
122 lib_suffix = '32'
123 elif arch == 'x64':
124 lib_suffix = '64'
125 elif arch == 'arm':
126 lib_suffix = 'arm'
127 else:
128 lib_suffix = ''
130 if tcname == 'arm_bionic':
131 tcdir = 'tc_newlib'
132 else:
133 tcdir = 'tc_' + GetToolchainLibc(tcname)
135 if tcname == 'pnacl':
136 if arch is None:
137 lib_suffix = ''
138 tcdir = 'tc_pnacl_newlib'
139 arch = 'x64'
140 else:
141 arch = 'clang-' + arch
143 return os.path.join(GetNinjaOutDir(arch), 'gen', tcdir, 'lib' + lib_suffix)
146 def GetToolchainNaClLib(tcname, tcpath, arch):
147 if arch == 'ia32':
148 return os.path.join(tcpath, 'x86_64-nacl', 'lib32')
149 elif arch == 'x64':
150 return os.path.join(tcpath, 'x86_64-nacl', 'lib')
151 elif arch == 'arm':
152 return os.path.join(tcpath, 'arm-nacl', 'lib')
153 elif tcname == 'pnacl':
154 return os.path.join(tcpath, 'le32-nacl', 'lib')
158 def GetOutputToolchainLib(pepperdir, tcname, arch):
159 tcpath = os.path.join(pepperdir, 'toolchain', GetToolchainDirName(tcname))
160 return GetToolchainNaClLib(tcname, tcpath, arch)
163 def GetPNaClTranslatorLib(tcpath, arch):
164 if arch not in ['arm', 'x86-32', 'x86-64']:
165 buildbot_common.ErrorExit('Unknown architecture %s.' % arch)
166 return os.path.join(tcpath, 'translator', arch, 'lib')
169 def BuildStepDownloadToolchains(toolchains):
170 buildbot_common.BuildStep('Running package_version.py')
171 args = [sys.executable, PKGVER, '--mode', 'nacl_core_sdk']
172 if 'arm_bionic' in toolchains:
173 build_platform = '%s_x86' % getos.GetPlatform()
174 args.extend(['--append', os.path.join(build_platform, 'nacl_arm_bionic')])
175 args.extend(['sync', '--extract'])
176 buildbot_common.Run(args, cwd=NACL_DIR)
179 def BuildStepCleanPepperDirs(pepperdir, pepperdir_old):
180 buildbot_common.BuildStep('Clean Pepper Dirs')
181 dirs_to_remove = (
182 pepperdir,
183 pepperdir_old,
184 os.path.join(OUT_DIR, 'arm_trusted')
186 for dirname in dirs_to_remove:
187 if os.path.exists(dirname):
188 buildbot_common.RemoveDir(dirname)
189 buildbot_common.MakeDir(pepperdir)
192 def BuildStepMakePepperDirs(pepperdir, subdirs):
193 for subdir in subdirs:
194 buildbot_common.MakeDir(os.path.join(pepperdir, subdir))
196 TEXT_FILES = [
197 'AUTHORS',
198 'COPYING',
199 'LICENSE',
200 'README.Makefiles',
201 'getting_started/README',
204 def BuildStepCopyTextFiles(pepperdir, pepper_ver, chrome_revision,
205 nacl_revision):
206 buildbot_common.BuildStep('Add Text Files')
207 InstallFiles(SDK_SRC_DIR, pepperdir, TEXT_FILES)
209 # Replace a few placeholders in README
210 readme_text = open(os.path.join(SDK_SRC_DIR, 'README')).read()
211 readme_text = readme_text.replace('${VERSION}', pepper_ver)
212 readme_text = readme_text.replace('${CHROME_REVISION}', chrome_revision)
213 readme_text = readme_text.replace('${CHROME_COMMIT_POSITION}',
214 build_version.ChromeCommitPosition())
215 readme_text = readme_text.replace('${NACL_REVISION}', nacl_revision)
217 # Year/Month/Day Hour:Minute:Second
218 time_format = '%Y/%m/%d %H:%M:%S'
219 readme_text = readme_text.replace('${DATE}',
220 datetime.datetime.now().strftime(time_format))
222 open(os.path.join(pepperdir, 'README'), 'w').write(readme_text)
225 def BuildStepUntarToolchains(pepperdir, toolchains):
226 buildbot_common.BuildStep('Untar Toolchains')
227 platform = getos.GetPlatform()
228 build_platform = '%s_x86' % platform
229 tmpdir = os.path.join(OUT_DIR, 'tc_temp')
230 buildbot_common.RemoveDir(tmpdir)
231 buildbot_common.MakeDir(tmpdir)
233 # Create a list of extract packages tuples, the first part should be
234 # "$PACKAGE_TARGET/$PACKAGE". The second part should be the destination
235 # directory relative to pepperdir/toolchain.
236 extract_packages = []
237 for toolchain in toolchains:
238 toolchain_map = TOOLCHAIN_PACKAGE_MAP.get(toolchain, None)
239 if toolchain_map:
240 package_name, tcdir, _ = toolchain_map
241 package_tuple = (os.path.join(build_platform, package_name),
242 tcdir % {'platform': platform})
243 extract_packages.append(package_tuple)
246 # On linux we also want to extract the arm_trusted package which contains
247 # the ARM libraries we ship in support of sel_ldr_arm.
248 if platform == 'linux':
249 extract_packages.append((os.path.join(build_platform, 'arm_trusted'),
250 'arm_trusted'))
251 if extract_packages:
252 # Extract all of the packages into the temp directory.
253 package_names = [package_tuple[0] for package_tuple in extract_packages]
254 buildbot_common.Run([sys.executable, PKGVER,
255 '--packages', ','.join(package_names),
256 '--tar-dir', NACL_TOOLCHAINTARS_DIR,
257 '--dest-dir', tmpdir,
258 'extract'])
260 # Move all the packages we extracted to the correct destination.
261 for package_name, dest_dir in extract_packages:
262 full_src_dir = os.path.join(tmpdir, package_name)
263 full_dst_dir = os.path.join(pepperdir, 'toolchain', dest_dir)
264 buildbot_common.Move(full_src_dir, full_dst_dir)
266 # Cleanup the temporary directory we are no longer using.
267 buildbot_common.RemoveDir(tmpdir)
270 # List of toolchain headers to install.
271 # Source is relative to top of Chromium tree, destination is relative
272 # to the toolchain header directory.
273 NACL_HEADER_MAP = {
274 'newlib': [
275 ('native_client/src/include/nacl/nacl_exception.h', 'nacl/'),
276 ('native_client/src/include/nacl/nacl_minidump.h', 'nacl/'),
277 ('native_client/src/untrusted/irt/irt.h', ''),
278 ('native_client/src/untrusted/irt/irt_dev.h', ''),
279 ('native_client/src/untrusted/irt/irt_extension.h', ''),
280 ('native_client/src/untrusted/nacl/nacl_dyncode.h', 'nacl/'),
281 ('native_client/src/untrusted/nacl/nacl_startup.h', 'nacl/'),
282 ('native_client/src/untrusted/pthread/pthread.h', ''),
283 ('native_client/src/untrusted/pthread/semaphore.h', ''),
284 ('native_client/src/untrusted/valgrind/dynamic_annotations.h', 'nacl/'),
285 ('ppapi/nacl_irt/public/irt_ppapi.h', ''),
287 'glibc': [
288 ('native_client/src/include/nacl/nacl_exception.h', 'nacl/'),
289 ('native_client/src/include/nacl/nacl_minidump.h', 'nacl/'),
290 ('native_client/src/untrusted/irt/irt.h', ''),
291 ('native_client/src/untrusted/irt/irt_dev.h', ''),
292 ('native_client/src/untrusted/irt/irt_extension.h', ''),
293 ('native_client/src/untrusted/nacl/nacl_dyncode.h', 'nacl/'),
294 ('native_client/src/untrusted/nacl/nacl_startup.h', 'nacl/'),
295 ('native_client/src/untrusted/valgrind/dynamic_annotations.h', 'nacl/'),
296 ('ppapi/nacl_irt/public/irt_ppapi.h', ''),
298 'bionic': [
299 ('ppapi/nacl_irt/public/irt_ppapi.h', ''),
303 def InstallFiles(src_root, dest_root, file_list):
304 """Copy a set of files from src_root to dest_root according
305 to the given mapping. This allows files to be copied from
306 to a location in the destination tree that is different to the
307 location in the source tree.
309 If the destination mapping ends with a '/' then the destination
310 basename is inherited from the the source file.
312 Wildcards can be used in the source list but it is not recommended
313 as this can end up adding things to the SDK unintentionally.
315 for file_spec in file_list:
316 # The list of files to install can be a simple list of
317 # strings or a list of pairs, where each pair corresponds
318 # to a mapping from source to destination names.
319 if type(file_spec) == str:
320 src_file = dest_file = file_spec
321 else:
322 src_file, dest_file = file_spec
324 src_file = os.path.join(src_root, src_file)
326 # Expand sources files using glob.
327 sources = glob.glob(src_file)
328 if not sources:
329 sources = [src_file]
331 if len(sources) > 1 and not dest_file.endswith('/'):
332 buildbot_common.ErrorExit("Target file must end in '/' when "
333 "using globbing to install multiple files")
335 for source in sources:
336 if dest_file.endswith('/'):
337 dest = os.path.join(dest_file, os.path.basename(source))
338 else:
339 dest = dest_file
340 dest = os.path.join(dest_root, dest)
341 if not os.path.isdir(os.path.dirname(dest)):
342 buildbot_common.MakeDir(os.path.dirname(dest))
343 buildbot_common.CopyFile(source, dest)
346 def InstallNaClHeaders(tc_dst_inc, tcname):
347 """Copies NaCl headers to expected locations in the toolchain."""
348 InstallFiles(SRC_DIR, tc_dst_inc, NACL_HEADER_MAP[GetToolchainLibc(tcname)])
351 def MakeNinjaRelPath(path):
352 return os.path.join(os.path.relpath(OUT_DIR, SRC_DIR), path)
355 # TODO(ncbray): stop building and copying libraries into the SDK that are
356 # already provided by the toolchain.
357 # Mapping from libc to libraries gyp-build trusted libraries
358 TOOLCHAIN_LIBS = {
359 'bionic' : [
360 'libminidump_generator.a',
361 'libnacl_dyncode.a',
362 'libnacl_exception.a',
363 'libnacl_list_mappings.a',
364 'libppapi.a',
366 'newlib' : [
367 'libminidump_generator.a',
368 'libnacl.a',
369 'libnacl_dyncode.a',
370 'libnacl_exception.a',
371 'libnacl_list_mappings.a',
372 'libnosys.a',
373 'libppapi.a',
374 'libppapi_stub.a',
375 'libpthread.a',
377 'glibc': [
378 'libminidump_generator.a',
379 'libminidump_generator.so',
380 'libnacl.a',
381 'libnacl_dyncode.a',
382 'libnacl_dyncode.so',
383 'libnacl_exception.a',
384 'libnacl_exception.so',
385 'libnacl_list_mappings.a',
386 'libnacl_list_mappings.so',
387 'libppapi.a',
388 'libppapi.so',
389 'libppapi_stub.a',
394 def GypNinjaInstall(pepperdir, toolchains):
395 tools_files_32 = [
396 ['sel_ldr', 'sel_ldr_x86_32'],
397 ['irt_core_newlib_x32.nexe', 'irt_core_x86_32.nexe'],
398 ['irt_core_newlib_x64.nexe', 'irt_core_x86_64.nexe'],
401 tools_files_64 = []
403 platform = getos.GetPlatform()
405 # TODO(binji): dump_syms doesn't currently build on Windows. See
406 # http://crbug.com/245456
407 if platform != 'win':
408 tools_files_64 += [
409 ['dump_syms', 'dump_syms'],
410 ['minidump_dump', 'minidump_dump'],
411 ['minidump_stackwalk', 'minidump_stackwalk']
414 tools_files_64.append(['sel_ldr', 'sel_ldr_x86_64'])
415 tools_files_64.append(['ncval_new', 'ncval'])
417 if platform == 'linux':
418 tools_files_32.append(['nacl_helper_bootstrap',
419 'nacl_helper_bootstrap_x86_32'])
420 tools_files_64.append(['nacl_helper_bootstrap',
421 'nacl_helper_bootstrap_x86_64'])
422 tools_files_32.append(['nonsfi_loader_newlib_x32_nonsfi.nexe',
423 'nonsfi_loader_x86_32'])
425 tools_dir = os.path.join(pepperdir, 'tools')
426 buildbot_common.MakeDir(tools_dir)
428 # Add .exe extensions to all windows tools
429 for pair in tools_files_32 + tools_files_64:
430 if platform == 'win' and not pair[0].endswith('.nexe'):
431 pair[0] += '.exe'
432 pair[1] += '.exe'
434 InstallFiles(GetNinjaOutDir('x64'), tools_dir, tools_files_64)
435 InstallFiles(GetNinjaOutDir('ia32'), tools_dir, tools_files_32)
437 # Add ARM binaries
438 if platform == 'linux' and not options.no_arm_trusted:
439 arm_files = [
440 ['irt_core_newlib_arm.nexe', 'irt_core_arm.nexe'],
441 ['elf_loader_newlib_arm.nexe', 'elf_loader_arm.nexe'],
442 ['nacl_helper_bootstrap', 'nacl_helper_bootstrap_arm'],
443 ['nonsfi_loader_newlib_arm_nonsfi.nexe', 'nonsfi_loader_arm'],
444 ['sel_ldr', 'sel_ldr_arm']
446 InstallFiles(GetNinjaOutDir('arm'), tools_dir, arm_files)
448 for tc in toolchains:
449 if tc in ('host', 'clang-newlib'):
450 continue
451 elif tc == 'pnacl':
452 xarches = (None, 'ia32', 'x64', 'arm')
453 elif tc in ('x86_glibc', 'x86_newlib'):
454 xarches = ('ia32', 'x64')
455 elif tc in ('arm_glibc', 'arm_newlib', 'arm_bionic'):
456 xarches = ('arm',)
457 else:
458 raise AssertionError('unexpected toolchain value: %s' % tc)
460 for xarch in xarches:
461 src_dir = GetGypBuiltLib(tc, xarch)
462 dst_dir = GetOutputToolchainLib(pepperdir, tc, xarch)
463 libc = GetToolchainLibc(tc)
464 InstallFiles(src_dir, dst_dir, TOOLCHAIN_LIBS[libc])
467 def GypNinjaBuild_NaCl(rel_out_dir):
468 # TODO(binji): gyp_nacl doesn't build properly on Windows anymore; it only
469 # can use VS2010, not VS2013 which is now required by the Chromium repo. NaCl
470 # needs to be updated to perform the same logic as Chromium in detecting VS,
471 # which can now exist in the depot_tools directory.
472 # See https://code.google.com/p/nativeclient/issues/detail?id=4022
474 # For now, let's use gyp_chromium to build these components.
475 # gyp_py = os.path.join(NACL_DIR, 'build', 'gyp_nacl')
476 gyp_py = os.path.join(SRC_DIR, 'build', 'gyp_chromium')
477 nacl_core_sdk_gyp = os.path.join(NACL_DIR, 'build', 'nacl_core_sdk.gyp')
478 all_gyp = os.path.join(NACL_DIR, 'build', 'all.gyp')
480 out_dir_32 = MakeNinjaRelPath(rel_out_dir + '-ia32')
481 out_dir_64 = MakeNinjaRelPath(rel_out_dir + '-x64')
482 out_dir_arm = MakeNinjaRelPath(rel_out_dir + '-arm')
483 out_dir_clang_32 = MakeNinjaRelPath(rel_out_dir + '-clang-ia32')
484 out_dir_clang_64 = MakeNinjaRelPath(rel_out_dir + '-clang-x64')
485 out_dir_clang_arm = MakeNinjaRelPath(rel_out_dir + '-clang-arm')
487 GypNinjaBuild('ia32', gyp_py, nacl_core_sdk_gyp, 'nacl_core_sdk', out_dir_32,
488 gyp_defines=['use_nacl_clang=0'])
489 GypNinjaBuild('x64', gyp_py, nacl_core_sdk_gyp, 'nacl_core_sdk', out_dir_64,
490 gyp_defines=['use_nacl_clang=0'])
491 GypNinjaBuild('arm', gyp_py, nacl_core_sdk_gyp, 'nacl_core_sdk', out_dir_arm,
492 gyp_defines=['use_nacl_clang=0'])
493 GypNinjaBuild('ia32', gyp_py, nacl_core_sdk_gyp, 'nacl_core_sdk',
494 out_dir_clang_32, gyp_defines=['use_nacl_clang=1'])
495 GypNinjaBuild('x64', gyp_py, nacl_core_sdk_gyp, 'nacl_core_sdk',
496 out_dir_clang_64, gyp_defines=['use_nacl_clang=1'])
497 GypNinjaBuild('arm', gyp_py, nacl_core_sdk_gyp, 'nacl_core_sdk',
498 out_dir_clang_arm, gyp_defines=['use_nacl_clang=1'])
499 GypNinjaBuild('x64', gyp_py, all_gyp, 'ncval_new', out_dir_64)
502 def GypNinjaBuild_Breakpad(rel_out_dir):
503 # TODO(binji): dump_syms doesn't currently build on Windows. See
504 # http://crbug.com/245456
505 if getos.GetPlatform() == 'win':
506 return
508 gyp_py = os.path.join(SRC_DIR, 'build', 'gyp_chromium')
509 out_dir = MakeNinjaRelPath(rel_out_dir)
510 gyp_file = os.path.join(SRC_DIR, 'breakpad', 'breakpad.gyp')
511 build_list = ['dump_syms', 'minidump_dump', 'minidump_stackwalk']
512 GypNinjaBuild('x64', gyp_py, gyp_file, build_list, out_dir)
515 def GypNinjaBuild_PPAPI(arch, rel_out_dir, gyp_defines=None):
516 gyp_py = os.path.join(SRC_DIR, 'build', 'gyp_chromium')
517 out_dir = MakeNinjaRelPath(rel_out_dir)
518 gyp_file = os.path.join(SRC_DIR, 'ppapi', 'native_client',
519 'native_client.gyp')
520 GypNinjaBuild(arch, gyp_py, gyp_file, 'ppapi_lib', out_dir,
521 gyp_defines=gyp_defines)
524 def GypNinjaBuild_Pnacl(rel_out_dir, target_arch):
525 # TODO(binji): This will build the pnacl_irt_shim twice; once as part of the
526 # Chromium build, and once here. When we move more of the SDK build process
527 # to gyp, we can remove this.
528 gyp_py = os.path.join(SRC_DIR, 'build', 'gyp_chromium')
530 out_dir = MakeNinjaRelPath(rel_out_dir)
531 gyp_file = os.path.join(SRC_DIR, 'ppapi', 'native_client', 'src',
532 'untrusted', 'pnacl_irt_shim', 'pnacl_irt_shim.gyp')
533 targets = ['aot']
534 GypNinjaBuild(target_arch, gyp_py, gyp_file, targets, out_dir)
537 def GypNinjaBuild(arch, gyp_py_script, gyp_file, targets,
538 out_dir, gyp_defines=None):
539 gyp_env = dict(os.environ)
540 gyp_env['GYP_GENERATORS'] = 'ninja'
541 gyp_defines = gyp_defines or []
542 gyp_defines.append('nacl_allow_thin_archives=0')
543 if not options.no_use_sysroot:
544 gyp_defines.append('use_sysroot=1')
545 if options.mac_sdk:
546 gyp_defines.append('mac_sdk=%s' % options.mac_sdk)
548 if arch is not None:
549 gyp_defines.append('target_arch=%s' % arch)
550 if arch == 'arm':
551 gyp_env['GYP_CROSSCOMPILE'] = '1'
552 if options.no_arm_trusted:
553 gyp_defines.append('disable_cross_trusted=1')
554 if getos.GetPlatform() == 'mac':
555 gyp_defines.append('clang=1')
557 gyp_env['GYP_DEFINES'] = ' '.join(gyp_defines)
558 # We can't use windows path separators in GYP_GENERATOR_FLAGS since
559 # gyp uses shlex to parse them and treats '\' as an escape char.
560 gyp_env['GYP_GENERATOR_FLAGS'] = 'output_dir=%s' % out_dir.replace('\\', '/')
562 # Print relevant environment variables
563 for key, value in gyp_env.iteritems():
564 if key.startswith('GYP') or key in ('CC',):
565 print ' %s="%s"' % (key, value)
567 buildbot_common.Run(
568 [sys.executable, gyp_py_script, gyp_file, '--depth=.'],
569 cwd=SRC_DIR,
570 env=gyp_env)
572 NinjaBuild(targets, out_dir, arch)
575 def NinjaBuild(targets, out_dir, arch):
576 if type(targets) is not list:
577 targets = [targets]
578 out_config_dir = os.path.join(out_dir, GetConfigDir(arch))
579 buildbot_common.Run(['ninja', '-C', out_config_dir] + targets, cwd=SRC_DIR)
582 def BuildStepBuildToolchains(pepperdir, toolchains, build, clean):
583 buildbot_common.BuildStep('SDK Items')
585 if clean:
586 for dirname in glob.glob(os.path.join(OUT_DIR, GYPBUILD_DIR + '*')):
587 buildbot_common.RemoveDir(dirname)
588 build = True
590 if build:
591 GypNinjaBuild_NaCl(GYPBUILD_DIR)
592 GypNinjaBuild_Breakpad(GYPBUILD_DIR + '-x64')
594 if set(toolchains) & set(['x86_glibc', 'x86_newlib']):
595 GypNinjaBuild_PPAPI('ia32', GYPBUILD_DIR + '-ia32',
596 ['use_nacl_clang=0'])
597 GypNinjaBuild_PPAPI('x64', GYPBUILD_DIR + '-x64',
598 ['use_nacl_clang=0'])
600 if set(toolchains) & set(['arm_glibc', 'arm_newlib']):
601 GypNinjaBuild_PPAPI('arm', GYPBUILD_DIR + '-arm',
602 ['use_nacl_clang=0'] )
604 if 'pnacl' in toolchains:
605 GypNinjaBuild_PPAPI('ia32', GYPBUILD_DIR + '-clang-ia32',
606 ['use_nacl_clang=1'])
607 GypNinjaBuild_PPAPI('x64', GYPBUILD_DIR + '-clang-x64',
608 ['use_nacl_clang=1'])
609 GypNinjaBuild_PPAPI('arm', GYPBUILD_DIR + '-clang-arm',
610 ['use_nacl_clang=1'])
612 # NOTE: For ia32, gyp builds both x86-32 and x86-64 by default.
613 for arch in ('ia32', 'arm'):
614 # Fill in the latest native pnacl shim library from the chrome build.
615 build_dir = GYPBUILD_DIR + '-pnacl-' + arch
616 GypNinjaBuild_Pnacl(build_dir, arch)
618 GypNinjaInstall(pepperdir, toolchains)
620 for toolchain in toolchains:
621 if toolchain not in ('host', 'clang-newlib'):
622 InstallNaClHeaders(GetToolchainNaClInclude(pepperdir, toolchain),
623 toolchain)
626 if 'pnacl' in toolchains:
627 # NOTE: For ia32, gyp builds both x86-32 and x86-64 by default.
628 for arch in ('ia32', 'arm'):
629 # Fill in the latest native pnacl shim library from the chrome build.
630 build_dir = GYPBUILD_DIR + '-pnacl-' + arch
631 if arch == 'ia32':
632 nacl_arches = ['x86-32', 'x86-64']
633 elif arch == 'arm':
634 nacl_arches = ['arm']
635 else:
636 buildbot_common.ErrorExit('Unknown architecture: %s' % arch)
637 for nacl_arch in nacl_arches:
638 release_build_dir = os.path.join(OUT_DIR, build_dir, 'Release',
639 'gen', 'tc_pnacl_translate',
640 'lib-' + nacl_arch)
642 pnacldir = GetToolchainDir(pepperdir, 'pnacl')
643 pnacl_translator_lib_dir = GetPNaClTranslatorLib(pnacldir, nacl_arch)
644 if not os.path.isdir(pnacl_translator_lib_dir):
645 buildbot_common.ErrorExit('Expected %s directory to exist.' %
646 pnacl_translator_lib_dir)
648 buildbot_common.CopyFile(
649 os.path.join(release_build_dir, 'libpnacl_irt_shim.a'),
650 pnacl_translator_lib_dir)
652 InstallNaClHeaders(GetToolchainNaClInclude(pepperdir, 'pnacl', 'x86'),
653 'pnacl')
654 InstallNaClHeaders(GetToolchainNaClInclude(pepperdir, 'pnacl', 'arm'),
655 'pnacl')
658 def MakeDirectoryOrClobber(pepperdir, dirname, clobber):
659 dirpath = os.path.join(pepperdir, dirname)
660 if clobber:
661 buildbot_common.RemoveDir(dirpath)
662 buildbot_common.MakeDir(dirpath)
664 return dirpath
667 def BuildStepUpdateHelpers(pepperdir, clobber):
668 buildbot_common.BuildStep('Update project helpers')
669 build_projects.UpdateHelpers(pepperdir, clobber=clobber)
672 def BuildStepUpdateUserProjects(pepperdir, toolchains,
673 build_experimental, clobber):
674 buildbot_common.BuildStep('Update examples and libraries')
676 filters = {}
677 if not build_experimental:
678 filters['EXPERIMENTAL'] = False
680 dsc_toolchains = []
681 for t in toolchains:
682 if t.startswith('x86_') or t.startswith('arm_'):
683 if t[4:] not in dsc_toolchains:
684 dsc_toolchains.append(t[4:])
685 elif t == 'host':
686 dsc_toolchains.append(getos.GetPlatform())
687 else:
688 dsc_toolchains.append(t)
690 filters['TOOLS'] = dsc_toolchains
692 # Update examples and libraries
693 filters['DEST'] = [
694 'getting_started',
695 'examples/api',
696 'examples/demo',
697 'examples/tutorial',
698 'src'
701 tree = parse_dsc.LoadProjectTree(SDK_SRC_DIR, include=filters)
702 build_projects.UpdateProjects(pepperdir, tree, clobber=clobber,
703 toolchains=dsc_toolchains)
706 def BuildStepMakeAll(pepperdir, directory, step_name,
707 deps=True, clean=False, config='Debug', args=None):
708 buildbot_common.BuildStep(step_name)
709 build_projects.BuildProjectsBranch(pepperdir, directory, clean,
710 deps, config, args)
713 def BuildStepBuildLibraries(pepperdir, directory):
714 BuildStepMakeAll(pepperdir, directory, 'Build Libraries Debug',
715 clean=True, config='Debug')
716 BuildStepMakeAll(pepperdir, directory, 'Build Libraries Release',
717 clean=True, config='Release')
719 # Cleanup .pyc file generated while building libraries. Without
720 # this we would end up shipping the pyc in the SDK tarball.
721 buildbot_common.RemoveFile(os.path.join(pepperdir, 'tools', '*.pyc'))
724 def GenerateNotice(fileroot, output_filename='NOTICE', extra_files=None):
725 # Look for LICENSE files
726 license_filenames_re = re.compile('LICENSE|COPYING|COPYRIGHT')
728 license_files = []
729 for root, _, files in os.walk(fileroot):
730 for filename in files:
731 if license_filenames_re.match(filename):
732 path = os.path.join(root, filename)
733 license_files.append(path)
735 if extra_files:
736 license_files += [os.path.join(fileroot, f) for f in extra_files]
737 print '\n'.join(license_files)
739 if not os.path.isabs(output_filename):
740 output_filename = os.path.join(fileroot, output_filename)
741 generate_notice.Generate(output_filename, fileroot, license_files)
744 def BuildStepVerifyFilelist(pepperdir):
745 buildbot_common.BuildStep('Verify SDK Files')
746 file_list_path = os.path.join(SCRIPT_DIR, 'sdk_files.list')
747 try:
748 print 'SDK directory: %s' % pepperdir
749 verify_filelist.Verify(file_list_path, pepperdir)
750 print 'OK'
751 except verify_filelist.ParseException, e:
752 buildbot_common.ErrorExit('Parsing sdk_files.list failed:\n\n%s' % e)
753 except verify_filelist.VerifyException, e:
754 file_list_rel = os.path.relpath(file_list_path)
755 verify_filelist_py = os.path.splitext(verify_filelist.__file__)[0] + '.py'
756 verify_filelist_py = os.path.relpath(verify_filelist_py)
757 pepperdir_rel = os.path.relpath(pepperdir)
759 msg = """\
760 SDK verification failed:
763 Add/remove files from %s to fix.
765 Run:
766 ./%s %s %s
767 to test.""" % (e, file_list_rel, verify_filelist_py, file_list_rel,
768 pepperdir_rel)
769 buildbot_common.ErrorExit(msg)
772 def BuildStepTarBundle(pepper_ver, tarfile):
773 buildbot_common.BuildStep('Tar Pepper Bundle')
774 buildbot_common.MakeDir(os.path.dirname(tarfile))
775 buildbot_common.Run([sys.executable, CYGTAR, '-C', OUT_DIR, '-cjf', tarfile,
776 'pepper_' + pepper_ver], cwd=NACL_DIR)
779 def GetManifestBundle(pepper_ver, chrome_revision, nacl_revision, tarfile,
780 archive_url):
781 with open(tarfile, 'rb') as tarfile_stream:
782 archive_sha1, archive_size = manifest_util.DownloadAndComputeHash(
783 tarfile_stream)
785 archive = manifest_util.Archive(manifest_util.GetHostOS())
786 archive.url = archive_url
787 archive.size = archive_size
788 archive.checksum = archive_sha1
790 bundle = manifest_util.Bundle('pepper_' + pepper_ver)
791 bundle.revision = int(chrome_revision)
792 bundle.repath = 'pepper_' + pepper_ver
793 bundle.version = int(pepper_ver)
794 bundle.description = (
795 'Chrome %s bundle. Chrome revision: %s. NaCl revision: %s' % (
796 pepper_ver, chrome_revision, nacl_revision))
797 bundle.stability = 'dev'
798 bundle.recommended = 'no'
799 bundle.archives = [archive]
800 return bundle
803 def Archive(filename, from_directory, step_link=True):
804 if buildbot_common.IsSDKBuilder():
805 bucket_path = 'nativeclient-mirror/nacl/nacl_sdk/'
806 else:
807 bucket_path = 'nativeclient-mirror/nacl/nacl_sdk_test/'
808 bucket_path += build_version.ChromeVersion()
809 buildbot_common.Archive(filename, bucket_path, from_directory, step_link)
812 def BuildStepArchiveBundle(name, pepper_ver, chrome_revision, nacl_revision,
813 tarfile):
814 buildbot_common.BuildStep('Archive %s' % name)
815 tarname = os.path.basename(tarfile)
816 tarfile_dir = os.path.dirname(tarfile)
817 Archive(tarname, tarfile_dir)
819 # generate "manifest snippet" for this archive.
820 archive_url = GSTORE + 'nacl_sdk/%s/%s' % (
821 build_version.ChromeVersion(), tarname)
822 bundle = GetManifestBundle(pepper_ver, chrome_revision, nacl_revision,
823 tarfile, archive_url)
825 manifest_snippet_file = os.path.join(OUT_DIR, tarname + '.json')
826 with open(manifest_snippet_file, 'wb') as manifest_snippet_stream:
827 manifest_snippet_stream.write(bundle.GetDataAsString())
829 Archive(tarname + '.json', OUT_DIR, step_link=False)
832 def BuildStepBuildPNaClComponent(version, revision):
833 # Sadly revision can go backwords for a given version since when a version
834 # is built from master, revision will be a huge number (in the hundreds of
835 # thousands. Once the branch happens the revision will reset to zero.
836 # TODO(sbc): figure out how to compensate for this in some way such that
837 # revisions always go forward for a given version.
838 buildbot_common.BuildStep('PNaCl Component')
839 # Version numbers must follow the format specified in:
840 # https://developer.chrome.com/extensions/manifest/version
841 # So ensure that rev_major/rev_minor don't overflow and ensure there
842 # are no leading zeros.
843 if len(revision) > 4:
844 rev_minor = int(revision[-4:])
845 rev_major = int(revision[:-4])
846 version = "0.%s.%s.%s" % (version, rev_major, rev_minor)
847 else:
848 version = "0.%s.0.%s" % (version, revision)
849 buildbot_common.Run(['./make_pnacl_component.sh',
850 'pnacl_multicrx_%s.zip' % revision,
851 version], cwd=SCRIPT_DIR)
854 def BuildStepArchivePNaClComponent(revision):
855 buildbot_common.BuildStep('Archive PNaCl Component')
856 Archive('pnacl_multicrx_%s.zip' % revision, OUT_DIR)
859 def BuildStepArchiveSDKTools():
860 buildbot_common.BuildStep('Build SDK Tools')
861 build_updater.BuildUpdater(OUT_DIR)
863 buildbot_common.BuildStep('Archive SDK Tools')
864 Archive('sdk_tools.tgz', OUT_DIR, step_link=False)
865 Archive('nacl_sdk.zip', OUT_DIR, step_link=False)
868 def BuildStepSyncNaClPorts():
869 """Pull the pinned revision of naclports from SVN."""
870 buildbot_common.BuildStep('Sync naclports')
872 # In case a previous non-gclient checkout exists, remove it.
873 # TODO(sbc): remove this once all the build machines
874 # have removed the old checkout
875 if (os.path.exists(NACLPORTS_DIR) and
876 not os.path.exists(os.path.join(NACLPORTS_DIR, 'src'))):
877 buildbot_common.RemoveDir(NACLPORTS_DIR)
879 if not os.path.exists(NACLPORTS_DIR):
880 buildbot_common.MakeDir(NACLPORTS_DIR)
881 # checkout new copy of naclports
882 cmd = ['gclient', 'config', '--name=src', NACLPORTS_URL]
883 buildbot_common.Run(cmd, cwd=NACLPORTS_DIR)
885 # sync to required revision
886 cmd = ['gclient', 'sync', '-R', '-r', 'src@' + str(NACLPORTS_REV)]
887 buildbot_common.Run(cmd, cwd=NACLPORTS_DIR)
890 def BuildStepBuildNaClPorts(pepper_ver, pepperdir):
891 """Build selected naclports in all configurations."""
892 # TODO(sbc): currently naclports doesn't know anything about
893 # Debug builds so the Debug subfolders are all empty.
895 env = dict(os.environ)
896 env['NACL_SDK_ROOT'] = pepperdir
897 env['PEPPER_DIR'] = os.path.basename(pepperdir) # pepper_NN
898 env['NACLPORTS_NO_ANNOTATE'] = "1"
899 env['NACLPORTS_NO_UPLOAD'] = "1"
900 env['BUILDBOT_GOT_REVISION'] = str(NACLPORTS_REV)
902 build_script = 'build_tools/buildbot_sdk_bundle.sh'
903 buildbot_common.BuildStep('Build naclports')
905 naclports_src = os.path.join(NACLPORTS_DIR, 'src')
906 bundle_dir = os.path.join(naclports_src, 'out', 'sdk_bundle')
907 out_dir = os.path.join(bundle_dir, 'pepper_%s' % pepper_ver)
909 # Remove the sdk_bundle directory to remove stale files from previous builds.
910 buildbot_common.RemoveDir(bundle_dir)
912 buildbot_common.Run([build_script], env=env, cwd=naclports_src)
914 # Some naclports do not include a standalone LICENSE/COPYING file
915 # so we explicitly list those here for inclusion.
916 extra_licenses = ('tinyxml/readme.txt',
917 'jpeg-8d/README',
918 'zlib-1.2.3/README')
919 src_root = os.path.join(naclports_src, 'out', 'build')
920 output_license = os.path.join(out_dir, 'ports', 'LICENSE')
921 GenerateNotice(src_root, output_license, extra_licenses)
922 readme = os.path.join(out_dir, 'ports', 'README')
923 oshelpers.Copy(['-v', os.path.join(SDK_SRC_DIR, 'README.naclports'), readme])
926 def BuildStepTarNaClPorts(pepper_ver, tarfile):
927 """Create tar archive containing headers and libs from naclports build."""
928 buildbot_common.BuildStep('Tar naclports Bundle')
929 buildbot_common.MakeDir(os.path.dirname(tarfile))
930 pepper_dir = 'pepper_%s' % pepper_ver
931 archive_dirs = [os.path.join(pepper_dir, 'ports')]
933 ports_out = os.path.join(NACLPORTS_DIR, 'src', 'out', 'sdk_bundle')
934 cmd = [sys.executable, CYGTAR, '-C', ports_out, '-cjf', tarfile]
935 cmd += archive_dirs
936 buildbot_common.Run(cmd, cwd=NACL_DIR)
939 def BuildStepBuildAppEngine(pepperdir, chrome_revision):
940 """Build the projects found in src/gonacl_appengine/src"""
941 buildbot_common.BuildStep('Build GoNaCl AppEngine Projects')
942 cmd = ['make', 'upload', 'REVISION=%s' % chrome_revision]
943 env = dict(os.environ)
944 env['NACL_SDK_ROOT'] = pepperdir
945 env['NACLPORTS_NO_ANNOTATE'] = "1"
946 buildbot_common.Run(cmd, env=env, cwd=GONACL_APPENGINE_SRC_DIR)
949 def main(args):
950 parser = argparse.ArgumentParser(description=__doc__)
951 parser.add_argument('--nacl-tree-path',
952 help='Path to native client tree for bionic build.',
953 dest='nacl_tree_path')
954 parser.add_argument('--qemu', help='Add qemu for ARM.',
955 action='store_true')
956 parser.add_argument('--bionic', help='Add bionic build.',
957 action='store_true')
958 parser.add_argument('--tar', help='Force the tar step.',
959 action='store_true')
960 parser.add_argument('--archive', help='Force the archive step.',
961 action='store_true')
962 parser.add_argument('--release', help='PPAPI release version.',
963 dest='release', default=None)
964 parser.add_argument('--build-ports',
965 help='Build naclport bundle.', action='store_true')
966 parser.add_argument('--build-app-engine',
967 help='Build AppEngine demos.', action='store_true')
968 parser.add_argument('--experimental',
969 help='build experimental examples and libraries', action='store_true',
970 dest='build_experimental')
971 parser.add_argument('--skip-toolchain', help='Skip toolchain untar',
972 action='store_true')
973 parser.add_argument('--no-clean', dest='clean', action='store_false',
974 help="Don't clean gypbuild directories")
975 parser.add_argument('--mac-sdk',
976 help='Set the mac-sdk (e.g. 10.6) to use when building with ninja.')
977 parser.add_argument('--no-arm-trusted', action='store_true',
978 help='Disable building of ARM trusted components (sel_ldr, etc).')
979 parser.add_argument('--no-use-sysroot', action='store_true',
980 help='Disable building against sysroot.')
982 # To setup bash completion for this command first install optcomplete
983 # and then add this line to your .bashrc:
984 # complete -F _optcomplete build_sdk.py
985 try:
986 import optcomplete
987 optcomplete.autocomplete(parser)
988 except ImportError:
989 pass
991 global options
992 options = parser.parse_args(args)
994 buildbot_common.BuildStep('build_sdk')
996 if options.nacl_tree_path:
997 options.bionic = True
998 toolchain_build = os.path.join(options.nacl_tree_path, 'toolchain_build')
999 print 'WARNING: Building bionic toolchain from NaCl checkout.'
1000 print 'This option builds bionic from the sources currently in the'
1001 print 'provided NativeClient checkout, and the results instead of '
1002 print 'downloading a toolchain from the builder. This may result in a'
1003 print 'NaCl SDK that can not run on ToT chrome.'
1004 print 'NOTE: To clobber you will need to run toolchain_build_bionic.py'
1005 print 'directly from the NativeClient checkout.'
1006 print ''
1007 response = raw_input("Type 'y' and hit enter to continue.\n")
1008 if response != 'y' and response != 'Y':
1009 print 'Aborting.'
1010 return 1
1012 # Get head version of NativeClient tree
1013 buildbot_common.BuildStep('Build bionic toolchain.')
1014 buildbot_common.Run([sys.executable, 'toolchain_build_bionic.py', '-f'],
1015 cwd=toolchain_build)
1016 else:
1017 toolchain_build = None
1019 if buildbot_common.IsSDKBuilder():
1020 options.archive = True
1021 options.build_ports = True
1022 # TODO(binji): re-enable app_engine build when the linux builder stops
1023 # breaking when trying to git clone from github.
1024 # See http://crbug.com/412969.
1025 options.build_app_engine = False
1026 options.tar = True
1028 # NOTE: order matters here. This will be the order that is specified in the
1029 # Makefiles; the first toolchain will be the default.
1030 toolchains = ['pnacl', 'x86_newlib', 'x86_glibc', 'arm_newlib', 'arm_glibc',
1031 'clang-newlib', 'host']
1033 # Changes for experimental bionic builder
1034 if options.bionic:
1035 toolchains.append('arm_bionic')
1036 options.build_ports = False
1037 options.build_app_engine = False
1039 print 'Building: ' + ' '.join(toolchains)
1040 platform = getos.GetPlatform()
1042 if options.archive and not options.tar:
1043 parser.error('Incompatible arguments with archive.')
1045 chrome_version = int(build_version.ChromeMajorVersion())
1046 chrome_revision = build_version.ChromeRevision()
1047 nacl_revision = build_version.NaClRevision()
1048 pepper_ver = str(chrome_version)
1049 pepper_old = str(chrome_version - 1)
1050 pepperdir = os.path.join(OUT_DIR, 'pepper_' + pepper_ver)
1051 pepperdir_old = os.path.join(OUT_DIR, 'pepper_' + pepper_old)
1052 if options.bionic:
1053 tarname = 'naclsdk_bionic.tar.bz2'
1054 else:
1055 tarname = 'naclsdk_%s.tar.bz2' % platform
1056 tarfile = os.path.join(OUT_DIR, tarname)
1058 if options.release:
1059 pepper_ver = options.release
1060 print 'Building PEPPER %s at %s' % (pepper_ver, chrome_revision)
1062 if 'NACL_SDK_ROOT' in os.environ:
1063 # We don't want the currently configured NACL_SDK_ROOT to have any effect
1064 # of the build.
1065 del os.environ['NACL_SDK_ROOT']
1067 if platform == 'linux':
1068 # Linux-only: make sure the debian/stable sysroot image is installed
1069 install_script = os.path.join(SRC_DIR, 'build', 'linux', 'sysroot_scripts',
1070 'install-sysroot.py')
1072 buildbot_common.Run([sys.executable, install_script, '--arch=arm'])
1073 buildbot_common.Run([sys.executable, install_script, '--arch=i386'])
1074 buildbot_common.Run([sys.executable, install_script, '--arch=amd64'])
1076 if not options.skip_toolchain:
1077 BuildStepCleanPepperDirs(pepperdir, pepperdir_old)
1078 BuildStepMakePepperDirs(pepperdir, ['include', 'toolchain', 'tools'])
1079 BuildStepDownloadToolchains(toolchains)
1080 if options.nacl_tree_path:
1081 # Instead of untarring, copy the raw bionic toolchain
1082 not_bionic = [i for i in toolchains if i != 'arm_bionic']
1083 BuildStepUntarToolchains(pepperdir, not_bionic)
1084 tcname = GetToolchainDirName('arm_bionic')
1085 srcdir = os.path.join(toolchain_build, 'out', tcname)
1086 bionicdir = os.path.join(pepperdir, 'toolchain', tcname)
1087 oshelpers.Copy(['-r', srcdir, bionicdir])
1088 else:
1089 BuildStepUntarToolchains(pepperdir, toolchains)
1090 if platform == 'linux':
1091 buildbot_common.Move(os.path.join(pepperdir, 'toolchain', 'arm_trusted'),
1092 os.path.join(OUT_DIR, 'arm_trusted'))
1095 if platform == 'linux':
1096 # Linux-only: Copy arm libraries from the arm_trusted package. These are
1097 # needed to be able to run sel_ldr_arm under qemu.
1098 arm_libs = [
1099 'lib/arm-linux-gnueabihf/librt.so.1',
1100 'lib/arm-linux-gnueabihf/libpthread.so.0',
1101 'lib/arm-linux-gnueabihf/libgcc_s.so.1',
1102 'lib/arm-linux-gnueabihf/libc.so.6',
1103 'lib/arm-linux-gnueabihf/ld-linux-armhf.so.3',
1104 'lib/arm-linux-gnueabihf/libm.so.6',
1105 'usr/lib/arm-linux-gnueabihf/libstdc++.so.6'
1107 arm_lib_dir = os.path.join(pepperdir, 'tools', 'lib', 'arm_trusted', 'lib')
1108 buildbot_common.MakeDir(arm_lib_dir)
1109 for arm_lib in arm_libs:
1110 arm_lib = os.path.join(OUT_DIR, 'arm_trusted', arm_lib)
1111 buildbot_common.CopyFile(arm_lib, arm_lib_dir)
1112 buildbot_common.CopyFile(os.path.join(OUT_DIR, 'arm_trusted', 'qemu-arm'),
1113 os.path.join(pepperdir, 'tools'))
1116 BuildStepBuildToolchains(pepperdir, toolchains,
1117 not options.skip_toolchain,
1118 options.clean)
1120 BuildStepUpdateHelpers(pepperdir, True)
1121 BuildStepUpdateUserProjects(pepperdir, toolchains,
1122 options.build_experimental, True)
1124 BuildStepCopyTextFiles(pepperdir, pepper_ver, chrome_revision, nacl_revision)
1126 # Ship with libraries prebuilt, so run that first.
1127 BuildStepBuildLibraries(pepperdir, 'src')
1128 GenerateNotice(pepperdir)
1130 # Verify the SDK contains what we expect.
1131 if not options.bionic:
1132 BuildStepVerifyFilelist(pepperdir)
1134 if options.tar:
1135 BuildStepTarBundle(pepper_ver, tarfile)
1137 if platform == 'linux':
1138 BuildStepBuildPNaClComponent(pepper_ver, chrome_revision)
1140 if options.build_ports:
1141 ports_tarfile = os.path.join(OUT_DIR, 'naclports.tar.bz2')
1142 BuildStepSyncNaClPorts()
1143 BuildStepBuildNaClPorts(pepper_ver, pepperdir)
1144 if options.tar:
1145 BuildStepTarNaClPorts(pepper_ver, ports_tarfile)
1147 if options.build_app_engine and platform == 'linux':
1148 BuildStepBuildAppEngine(pepperdir, chrome_revision)
1150 if options.qemu:
1151 qemudir = os.path.join(NACL_DIR, 'toolchain', 'linux_arm-trusted')
1152 oshelpers.Copy(['-r', qemudir, pepperdir])
1154 # Archive the results on Google Cloud Storage.
1155 if options.archive:
1156 BuildStepArchiveBundle('build', pepper_ver, chrome_revision, nacl_revision,
1157 tarfile)
1158 # Only archive sdk_tools/naclport/pnacl_component on linux.
1159 if platform == 'linux':
1160 if options.build_ports:
1161 BuildStepArchiveBundle('naclports', pepper_ver, chrome_revision,
1162 nacl_revision, ports_tarfile)
1163 BuildStepArchiveSDKTools()
1164 BuildStepArchivePNaClComponent(chrome_revision)
1166 return 0
1169 if __name__ == '__main__':
1170 try:
1171 sys.exit(main(sys.argv[1:]))
1172 except KeyboardInterrupt:
1173 buildbot_common.ErrorExit('build_sdk: interrupted')