def BuildStepUntarToolchains(pepperdir, platform, arch, toolchains): buildbot_common.BuildStep('Untar Toolchains') tcname = platform + '_' + arch tmpdir = os.path.join(SRC_DIR, 'out', 'tc_temp') buildbot_common.RemoveDir(tmpdir) buildbot_common.MakeDir(tmpdir) if 'newlib' in toolchains: # Untar the newlib toolchains tarfile = GetNewlibToolchain(platform, arch) buildbot_common.Run([sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile], cwd=NACL_DIR) # Then rename/move it to the pepper toolchain directory srcdir = os.path.join(tmpdir, 'sdk', 'nacl-sdk') newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib') buildbot_common.Move(srcdir, newlibdir) if 'glibc' in toolchains: # Untar the glibc toolchains tarfile = GetGlibcToolchain(platform, arch) buildbot_common.Run([sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile], cwd=NACL_DIR) # Then rename/move it to the pepper toolchain directory srcdir = os.path.join(tmpdir, 'toolchain', tcname) glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc') buildbot_common.Move(srcdir, glibcdir) # Untar the pnacl toolchains if 'pnacl' in toolchains: tmpdir = os.path.join(tmpdir, 'pnacl') buildbot_common.RemoveDir(tmpdir) buildbot_common.MakeDir(tmpdir) tarfile = GetPNaClToolchain(platform, arch) buildbot_common.Run([sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile], cwd=NACL_DIR) # Then rename/move it to the pepper toolchain directory pnacldir = os.path.join(pepperdir, 'toolchain', tcname + '_pnacl') buildbot_common.Move(tmpdir, pnacldir) if options.gyp and sys.platform not in ['cygwin', 'win32']: # If the gyp options is specified we install a toolchain # wrapper so that gyp can switch toolchains via a commandline # option. bindir = os.path.join(pepperdir, 'toolchain', tcname, 'bin') wrapper = os.path.join(SDK_SRC_DIR, 'tools', 'compiler-wrapper.py') buildbot_common.MakeDir(bindir) buildbot_common.CopyFile(wrapper, bindir) # Module 'os' has no 'symlink' member (on Windows). # pylint: disable=E1101 os.symlink('compiler-wrapper.py', os.path.join(bindir, 'i686-nacl-g++')) os.symlink('compiler-wrapper.py', os.path.join(bindir, 'i686-nacl-gcc')) os.symlink('compiler-wrapper.py', os.path.join(bindir, 'i686-nacl-ar'))
def BuildStepBuildNaClPorts(pepper_ver, pepperdir): """Build selected naclports in all configurations.""" # TODO(sbc): currently naclports doesn't know anything about # Debug builds so the Debug subfolders are all empty. bundle_dir = os.path.join(NACLPORTS_DIR, 'out', 'sdk_bundle') env = dict(os.environ) env['NACL_SDK_ROOT'] = pepperdir env['NACLPORTS_NO_ANNOTATE'] = "1" build_script = 'build_tools/bots/linux/nacl-linux-sdk-bundle.sh' buildbot_common.BuildStep('Build naclports') buildbot_common.Run([build_script], env=env, cwd=NACLPORTS_DIR) out_dir = os.path.join(bundle_dir, 'pepper_XX') out_dir_final = os.path.join(bundle_dir, 'pepper_%s' % pepper_ver) buildbot_common.RemoveDir(out_dir_final) buildbot_common.Move(out_dir, out_dir_final) # Some naclports do not include a standalone LICENSE/COPYING file # so we explicitly list those here for inclusion. extra_licenses = ('tinyxml/readme.txt', 'jpeg-8d/README', 'zlib-1.2.3/README') src_root = os.path.join(NACLPORTS_DIR, 'out', 'repository-i686') output_license = os.path.join(out_dir_final, 'ports', 'LICENSE') GenerateNotice(src_root , output_license, extra_licenses) readme = os.path.join(out_dir_final, 'ports', 'README') oshelpers.Copy(['-v', os.path.join(SDK_SRC_DIR, 'README.naclports'), readme])
def UntarToolchains(pepperdir, platform, arch, toolchains): buildbot_common.BuildStep('Untar Toolchains') tcname = platform + '_' + arch tmpdir = os.path.join(SRC_DIR, 'out', 'tc_temp') buildbot_common.RemoveDir(tmpdir) buildbot_common.MakeDir(tmpdir) if 'newlib' in toolchains: # Untar the newlib toolchains tarfile = GetNewlibToolchain(platform, arch) buildbot_common.Run( [sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile], cwd=NACL_DIR) # Then rename/move it to the pepper toolchain directory srcdir = os.path.join(tmpdir, 'sdk', 'nacl-sdk') newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib') buildbot_common.Move(srcdir, newlibdir) if 'glibc' in toolchains: # Untar the glibc toolchains tarfile = GetGlibcToolchain(platform, arch) buildbot_common.Run( [sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile], cwd=NACL_DIR) # Then rename/move it to the pepper toolchain directory srcdir = os.path.join(tmpdir, 'toolchain', tcname) glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc') buildbot_common.Move(srcdir, glibcdir) # Untar the pnacl toolchains if 'pnacl' in toolchains: tmpdir = os.path.join(tmpdir, 'pnacl') buildbot_common.RemoveDir(tmpdir) buildbot_common.MakeDir(tmpdir) tarfile = GetPNaClToolchain(platform, arch) buildbot_common.Run( [sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile], cwd=NACL_DIR) # Then rename/move it to the pepper toolchain directory pnacldir = os.path.join(pepperdir, 'toolchain', tcname + '_pnacl') buildbot_common.Move(tmpdir, pnacldir)
def BuildToolchains(pepperdir, platform, arch, pepper_ver, toolchains): buildbot_common.BuildStep('SDK Items') tcname = platform + '_' + arch newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib') glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc') pnacldir = os.path.join(pepperdir, 'toolchain', tcname + '_pnacl') # Run scons TC build steps if arch == 'x86': if 'newlib' in toolchains: buildbot_common.Run(GetBuildArgs('newlib', newlibdir, pepperdir, 'x86', '32'), cwd=NACL_DIR, shell=(platform == 'win')) buildbot_common.Run(GetBuildArgs('newlib', newlibdir, pepperdir, 'x86', '64'), cwd=NACL_DIR, shell=(platform == 'win')) InstallHeaders(GetToolchainNaClInclude('newlib', newlibdir, 'x86'), pepper_ver, 'newlib') if 'glibc' in toolchains: buildbot_common.Run(GetBuildArgs('glibc', glibcdir, pepperdir, 'x86', '32'), cwd=NACL_DIR, shell=(platform == 'win')) buildbot_common.Run(GetBuildArgs('glibc', glibcdir, pepperdir, 'x86', '64'), cwd=NACL_DIR, shell=(platform == 'win')) InstallHeaders(GetToolchainNaClInclude('glibc', glibcdir, 'x86'), pepper_ver, 'glibc') if 'pnacl' in toolchains: buildbot_common.Run(GetBuildArgs('pnacl', pnacldir, pepperdir, 'x86', '32'), cwd=NACL_DIR, shell=(platform == 'win')) buildbot_common.Run(GetBuildArgs('pnacl', pnacldir, pepperdir, 'x86', '64'), cwd=NACL_DIR, shell=(platform == 'win')) # Pnacl libraries are typically bitcode, but some are native and # will be looked up in the native library directory. buildbot_common.Move( os.path.join( GetToolchainNaClLib('pnacl', pnacldir, 'x86', '64'), 'libpnacl_irt_shim.a'), GetPNaClNativeLib(pnacldir, 'x86-64')) InstallHeaders(GetToolchainNaClInclude('pnacl', pnacldir, 'x86'), pepper_ver, 'newlib') else: buildbot_common.ErrorExit('Missing arch %s' % arch)
def BuildStepUntarToolchains(pepperdir, toolchains): buildbot_common.BuildStep('Untar Toolchains') platform = getos.GetPlatform() build_platform = '%s_x86' % platform tmpdir = os.path.join(OUT_DIR, 'tc_temp') buildbot_common.RemoveDir(tmpdir) buildbot_common.MakeDir(tmpdir) # Create a list of extract packages tuples, the first part should be # "$PACKAGE_TARGET/$PACKAGE". The second part should be the destination # directory relative to pepperdir/toolchain. extract_packages = [] for toolchain in toolchains: toolchain_map = TOOLCHAIN_PACKAGE_MAP.get(toolchain, None) if toolchain_map: package_name, tcdir, _ = toolchain_map package_tuple = (os.path.join(build_platform, package_name), tcdir % { 'platform': platform }) extract_packages.append(package_tuple) # On linux we also want to extract the arm_trusted package which contains # the ARM libraries we ship in support of sel_ldr_arm. if platform == 'linux': extract_packages.append((os.path.join(build_platform, 'arm_trusted'), 'arm_trusted')) if extract_packages: # Extract all of the packages into the temp directory. package_names = [ package_tuple[0] for package_tuple in extract_packages ] buildbot_common.Run([ sys.executable, PKGVER, '--packages', ','.join(package_names), '--tar-dir', NACL_TOOLCHAINTARS_DIR, '--dest-dir', tmpdir, 'extract' ]) # Move all the packages we extracted to the correct destination. for package_name, dest_dir in extract_packages: full_src_dir = os.path.join(tmpdir, package_name) full_dst_dir = os.path.join(pepperdir, 'toolchain', dest_dir) buildbot_common.Move(full_src_dir, full_dst_dir) # Cleanup the temporary directory we are no longer using. buildbot_common.RemoveDir(tmpdir)
def BuildStepUntarToolchains(pepperdir, toolchains): buildbot_common.BuildStep('Untar Toolchains') platform = getos.GetPlatform() tmpdir = os.path.join(OUT_DIR, 'tc_temp') buildbot_common.RemoveDir(tmpdir) buildbot_common.MakeDir(tmpdir) if 'newlib' in toolchains: # Untar the newlib toolchains tarfile = GetNewlibToolchain() buildbot_common.Run([sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile], cwd=NACL_DIR) # Then rename/move it to the pepper toolchain directory srcdir = os.path.join(tmpdir, 'sdk', 'nacl-sdk') tcname = platform + '_x86_newlib' newlibdir = os.path.join(pepperdir, 'toolchain', tcname) buildbot_common.Move(srcdir, newlibdir) if 'arm' in toolchains: # Copy the existing arm toolchain from native_client tree tcname = platform + '_arm_newlib' arm_toolchain = os.path.join(NACL_DIR, 'toolchain', tcname) arm_toolchain_sdk = os.path.join(pepperdir, 'toolchain', os.path.basename(arm_toolchain)) buildbot_common.CopyDir(arm_toolchain, arm_toolchain_sdk) if 'glibc' in toolchains: # Untar the glibc toolchains tarfile = GetGlibcToolchain() tcname = platform + '_x86_glibc' buildbot_common.Run([sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile], cwd=NACL_DIR) # Then rename/move it to the pepper toolchain directory srcdir = os.path.join(tmpdir, 'toolchain', platform + '_x86') glibcdir = os.path.join(pepperdir, 'toolchain', tcname) buildbot_common.Move(srcdir, glibcdir) # Untar the pnacl toolchains if 'pnacl' in toolchains: tmpdir = os.path.join(tmpdir, 'pnacl') buildbot_common.RemoveDir(tmpdir) buildbot_common.MakeDir(tmpdir) tarfile = GetPNaClToolchain() tcname = platform + '_pnacl' buildbot_common.Run([sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile], cwd=NACL_DIR) # Then rename/move it to the pepper toolchain directory pnacldir = os.path.join(pepperdir, 'toolchain', tcname) buildbot_common.Move(tmpdir, pnacldir) PrunePNaClToolchain(pnacldir) buildbot_common.RemoveDir(tmpdir) if options.gyp and platform != 'win': # If the gyp options is specified we install a toolchain # wrapper so that gyp can switch toolchains via a commandline # option. bindir = os.path.join(pepperdir, 'toolchain', tcname, 'bin') wrapper = os.path.join(SDK_SRC_DIR, 'tools', 'compiler-wrapper.py') buildbot_common.MakeDir(bindir) buildbot_common.CopyFile(wrapper, bindir) # Module 'os' has no 'symlink' member (on Windows). # pylint: disable=E1101 os.symlink('compiler-wrapper.py', os.path.join(bindir, 'i686-nacl-g++')) os.symlink('compiler-wrapper.py', os.path.join(bindir, 'i686-nacl-gcc')) os.symlink('compiler-wrapper.py', os.path.join(bindir, 'i686-nacl-ar'))
def main(args): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('--qemu', help='Add qemu for ARM.', action='store_true') parser.add_argument('--tar', help='Force the tar step.', action='store_true') parser.add_argument('--archive', help='Force the archive step.', action='store_true') parser.add_argument('--release', help='PPAPI release version.', dest='release', default=None) parser.add_argument('--build-app-engine', help='Build AppEngine demos.', action='store_true') parser.add_argument('--experimental', help='build experimental examples and libraries', action='store_true', dest='build_experimental') parser.add_argument('--skip-toolchain', help='Skip toolchain untar', action='store_true') parser.add_argument('--no-clean', dest='clean', action='store_false', help="Don't clean gn build directories") parser.add_argument( '--mac-sdk', help='Set the mac-sdk (e.g. 10.6) to use when building with ninja.') parser.add_argument( '--no-arm-trusted', action='store_true', help='Disable building of ARM trusted components (sel_ldr, etc).') parser.add_argument('--no-use-sysroot', action='store_true', help='Disable building against sysroot.') # To setup bash completion for this command first install optcomplete # and then add this line to your .bashrc: # complete -F _optcomplete build_sdk.py try: import optcomplete optcomplete.autocomplete(parser) except ImportError: pass global options options = parser.parse_args(args) buildbot_common.BuildStep('build_sdk') if buildbot_common.IsSDKBuilder(): options.archive = True # TODO(binji): re-enable app_engine build when the linux builder stops # breaking when trying to git clone from github. # See http://crbug.com/412969. options.build_app_engine = False options.tar = True # NOTE: order matters here. This will be the order that is specified in the # Makefiles; the first toolchain will be the default. toolchains = ['pnacl', 'x86_glibc', 'arm_glibc', 'clang-newlib', 'host'] print 'Building: ' + ' '.join(toolchains) platform = getos.GetPlatform() if options.archive and not options.tar: parser.error('Incompatible arguments with archive.') chrome_version = int(build_version.ChromeMajorVersion()) chrome_revision = build_version.ChromeRevision() nacl_revision = build_version.NaClRevision() pepper_ver = str(chrome_version) pepper_old = str(chrome_version - 1) pepperdir = os.path.join(OUT_DIR, 'pepper_' + pepper_ver) pepperdir_old = os.path.join(OUT_DIR, 'pepper_' + pepper_old) tarname = 'naclsdk_%s.tar.bz2' % platform tarfile = os.path.join(OUT_DIR, tarname) if options.release: pepper_ver = options.release print 'Building PEPPER %s at %s' % (pepper_ver, chrome_revision) if 'NACL_SDK_ROOT' in os.environ: # We don't want the currently configured NACL_SDK_ROOT to have any effect # of the build. del os.environ['NACL_SDK_ROOT'] if platform == 'linux': # Linux-only: make sure the debian/stable sysroot image is installed install_script = os.path.join(SRC_DIR, 'build', 'linux', 'sysroot_scripts', 'install-sysroot.py') buildbot_common.Run([sys.executable, install_script, '--arch=arm']) buildbot_common.Run([sys.executable, install_script, '--arch=i386']) buildbot_common.Run([sys.executable, install_script, '--arch=amd64']) if not options.skip_toolchain: BuildStepCleanPepperDirs(pepperdir, pepperdir_old) BuildStepMakePepperDirs(pepperdir, ['include', 'toolchain', 'tools']) BuildStepDownloadToolchains(toolchains) BuildStepUntarToolchains(pepperdir, toolchains) if platform == 'linux': buildbot_common.Move( os.path.join(pepperdir, 'toolchain', 'arm_trusted'), os.path.join(OUT_DIR, 'arm_trusted')) if platform == 'linux': # Linux-only: Copy arm libraries from the arm_trusted package. These are # needed to be able to run sel_ldr_arm under qemu. arm_libs = [ 'lib/arm-linux-gnueabihf/librt.so.1', 'lib/arm-linux-gnueabihf/libpthread.so.0', 'lib/arm-linux-gnueabihf/libgcc_s.so.1', 'lib/arm-linux-gnueabihf/libc.so.6', 'lib/arm-linux-gnueabihf/ld-linux-armhf.so.3', 'lib/arm-linux-gnueabihf/libm.so.6', 'usr/lib/arm-linux-gnueabihf/libstdc++.so.6' ] arm_lib_dir = os.path.join(pepperdir, 'tools', 'lib', 'arm_trusted', 'lib') buildbot_common.MakeDir(arm_lib_dir) for arm_lib in arm_libs: arm_lib = os.path.join(OUT_DIR, 'arm_trusted', arm_lib) buildbot_common.CopyFile(arm_lib, arm_lib_dir) buildbot_common.CopyFile( os.path.join(OUT_DIR, 'arm_trusted', 'qemu-arm'), os.path.join(pepperdir, 'tools')) BuildStepBuildToolchains(pepperdir, toolchains, not options.skip_toolchain, options.clean) BuildStepUpdateHelpers(pepperdir, True) BuildStepUpdateUserProjects(pepperdir, toolchains, options.build_experimental, True) BuildStepCopyTextFiles(pepperdir, pepper_ver, chrome_revision, nacl_revision) # Ship with libraries prebuilt, so run that first. BuildStepBuildLibraries(pepperdir) GenerateNotice(pepperdir) # Verify the SDK contains what we expect. BuildStepVerifyFilelist(pepperdir) if options.tar: BuildStepTarBundle(pepper_ver, tarfile) if platform == 'linux': BuildStepBuildPNaClComponent(pepper_ver, chrome_revision) if options.build_app_engine and platform == 'linux': BuildStepBuildAppEngine(pepperdir, chrome_revision) if options.qemu: qemudir = os.path.join(NACL_DIR, 'toolchain', 'linux_arm-trusted') oshelpers.Copy(['-r', qemudir, pepperdir]) # Archive the results on Google Cloud Storage. if options.archive: BuildStepArchiveBundle('build', pepper_ver, chrome_revision, nacl_revision, tarfile) # Only archive sdk_tools/naclport/pnacl_component on linux. if platform == 'linux': BuildStepArchiveSDKTools() BuildStepArchivePNaClComponent(chrome_revision) return 0
def main(args): parser = optparse.OptionParser() parser.add_option('--pnacl', help='Enable pnacl build.', action='store_true', dest='pnacl', default=False) parser.add_option('--examples', help='Only build the examples.', action='store_true', dest='only_examples', default=False) parser.add_option('--update', help='Only build the updater.', action='store_true', dest='only_updater', default=False) parser.add_option('--skip-tar', help='Skip generating a tarball.', action='store_true', dest='skip_tar', default=False) parser.add_option('--archive', help='Force the archive step.', action='store_true', dest='archive', default=False) parser.add_option('--release', help='PPAPI release version.', dest='release', default=None) options, args = parser.parse_args(args[1:]) platform = getos.GetPlatform() arch = 'x86' builder_name = os.getenv('BUILDBOT_BUILDERNAME', '') if builder_name.find('pnacl') >= 0 and builder_name.find('sdk') >= 0: options.pnacl = True if options.pnacl: toolchains = ['pnacl'] else: toolchains = ['newlib', 'glibc'] print 'Building: ' + ' '.join(toolchains) skip = options.only_examples or options.only_updater skip_examples = skip and not options.only_examples skip_update = skip and not options.only_updater skip_untar = skip skip_build = skip skip_test_updater = skip skip_tar = skip or options.skip_tar if options.archive and (options.only_examples or options.skip_tar): parser.error('Incompatible arguments with archive.') pepper_ver = str(int(build_utils.ChromeMajorVersion())) pepper_old = str(int(build_utils.ChromeMajorVersion()) - 1) clnumber = build_utils.ChromeRevision() if options.release: pepper_ver = options.release print 'Building PEPPER %s at %s' % (pepper_ver, clnumber) if not skip_build: buildbot_common.BuildStep('Rerun hooks to get toolchains') buildbot_common.Run(['gclient', 'runhooks'], cwd=SRC_DIR, shell=(platform == 'win')) buildbot_common.BuildStep('Clean Pepper Dirs') pepperdir = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_ver) pepperold = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_old) buildbot_common.RemoveDir(pepperold) if not skip_untar: buildbot_common.RemoveDir(pepperdir) buildbot_common.MakeDir(os.path.join(pepperdir, 'libraries')) buildbot_common.MakeDir(os.path.join(pepperdir, 'toolchain')) buildbot_common.MakeDir(os.path.join(pepperdir, 'tools')) else: buildbot_common.MakeDir(pepperdir) if not skip_build: buildbot_common.BuildStep('Add Text Files') files = ['AUTHORS', 'COPYING', 'LICENSE', 'NOTICE', 'README'] files = [os.path.join(SDK_SRC_DIR, filename) for filename in files] oshelpers.Copy(['-v'] + files + [pepperdir]) # Clean out the temporary toolchain untar directory if not skip_untar: UntarToolchains(pepperdir, platform, arch, toolchains) if not skip_build: BuildToolchains(pepperdir, platform, arch, pepper_ver, toolchains) InstallHeaders(os.path.join(pepperdir, 'libraries'), pepper_ver, 'libs') if not skip_build: buildbot_common.BuildStep('Copy make OS helpers') buildbot_common.CopyDir(os.path.join(SDK_SRC_DIR, 'tools', '*.py'), os.path.join(pepperdir, 'tools')) if platform == 'win': buildbot_common.BuildStep('Add MAKE') http_download.HttpDownload( GSTORE + MAKE, os.path.join(pepperdir, 'tools', 'make.exe')) rename_list = [ 'ncval_x86_32', 'ncval_x86_64', 'sel_ldr_x86_32', 'sel_ldr_x86_64' ] tools = os.path.join(pepperdir, 'tools') for name in rename_list: src = os.path.join(pepperdir, 'tools', name) dst = os.path.join(pepperdir, 'tools', name + '.exe') buildbot_common.Move(src, dst) if not skip_examples: CopyExamples(pepperdir, toolchains) tarname = 'naclsdk_' + platform + '.bz2' if 'pnacl' in toolchains: tarname = 'p' + tarname tarfile = os.path.join(OUT_DIR, tarname) if not skip_tar: buildbot_common.BuildStep('Tar Pepper Bundle') buildbot_common.Run([ sys.executable, CYGTAR, '-C', OUT_DIR, '-cjf', tarfile, 'pepper_' + pepper_ver ], cwd=NACL_DIR) # Run build tests buildbot_common.BuildStep('Run build_tools tests') buildbot_common.Run([ sys.executable, os.path.join(SDK_SRC_DIR, 'build_tools', 'tests', 'test_all.py') ]) # build sdk update if not skip_update: build_updater.BuildUpdater(OUT_DIR) # start local server sharing a manifest + the new bundle if not skip_test_updater and not skip_tar: buildbot_common.BuildStep('Move bundle to localserver dir') buildbot_common.MakeDir(SERVER_DIR) buildbot_common.Move(tarfile, SERVER_DIR) tarfile = os.path.join(SERVER_DIR, tarname) server = None try: buildbot_common.BuildStep('Run local server') server = test_server.LocalHTTPServer(SERVER_DIR) buildbot_common.BuildStep('Generate manifest') with open(tarfile, 'rb') as tarfile_stream: archive_sha1, archive_size = manifest_util.DownloadAndComputeHash( tarfile_stream) archive = manifest_util.Archive(manifest_util.GetHostOS()) archive.CopyFrom({ 'url': server.GetURL(tarname), 'size': archive_size, 'checksum': { 'sha1': archive_sha1 } }) bundle = manifest_util.Bundle('pepper_' + pepper_ver) bundle.CopyFrom({ 'revision': int(clnumber), 'repath': 'pepper_' + pepper_ver, 'version': int(pepper_ver), 'description': 'Chrome %s bundle, revision %s' % (pepper_ver, clnumber), 'stability': 'dev', 'recommended': 'no', 'archives': [archive] }) manifest = manifest_util.SDKManifest() manifest.SetBundle(bundle) manifest_name = 'naclsdk_manifest2.json' with open(os.path.join(SERVER_DIR, manifest_name), 'wb') as \ manifest_stream: manifest_stream.write(manifest.GetDataAsString()) # use newly built sdk updater to pull this bundle buildbot_common.BuildStep('Update from local server') naclsdk_sh = os.path.join(OUT_DIR, 'nacl_sdk', 'naclsdk') if platform == 'win': naclsdk_sh += '.bat' buildbot_common.Run([ naclsdk_sh, '-U', server.GetURL(manifest_name), 'update', 'pepper_' + pepper_ver ]) # If we are testing examples, do it in the newly pulled directory. pepperdir = os.path.join(OUT_DIR, 'nacl_sdk', 'pepper_' + pepper_ver) # kill server finally: if server: server.Shutdown() # build examples. if not skip_examples: buildbot_common.BuildStep('Test Build Examples') example_dir = os.path.join(pepperdir, 'examples') makefile = os.path.join(example_dir, 'Makefile') if os.path.isfile(makefile): print "\n\nMake: " + example_dir buildbot_common.Run(['make', '-j8'], cwd=os.path.abspath(example_dir), shell=True) # Archive on non-trybots. buildername = os.environ.get('BUILDBOT_BUILDERNAME', '') if options.archive or '-sdk' in buildername: buildbot_common.BuildStep('Archive build') bucket_path = 'nativeclient-mirror/nacl/nacl_sdk/%s' % \ build_utils.ChromeVersion() buildbot_common.Archive(tarname, bucket_path, os.path.dirname(tarfile)) if not skip_update: # Only push up sdk_tools.tgz on the linux buildbot. if buildername == 'linux-sdk-multi': sdk_tools = os.path.join(OUT_DIR, 'sdk_tools.tgz') buildbot_common.Archive('sdk_tools.tgz', bucket_path, OUT_DIR, step_link=False) # generate "manifest snippet" for this archive. if not skip_test_updater: archive = bundle.GetArchive(manifest_util.GetHostOS()) archive.url = 'https://commondatastorage.googleapis.com/' \ 'nativeclient-mirror/nacl/nacl_sdk/%s/%s' % ( build_utils.ChromeVersion(), tarname) manifest_snippet_file = os.path.join(OUT_DIR, tarname + '.json') with open(manifest_snippet_file, 'wb') as manifest_snippet_stream: manifest_snippet_stream.write(bundle.GetDataAsString()) buildbot_common.Archive(tarname + '.json', bucket_path, OUT_DIR, step_link=False) return 0
def main(args): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('--nacl-tree-path', help='Path to native client tree for bionic build.', dest='nacl_tree_path') parser.add_argument('--qemu', help='Add qemu for ARM.', action='store_true') parser.add_argument('--bionic', help='Add bionic build.', action='store_true') parser.add_argument('--tar', help='Force the tar step.', action='store_true') parser.add_argument('--archive', help='Force the archive step.', action='store_true') parser.add_argument('--release', help='PPAPI release version.', dest='release', default=None) parser.add_argument('--build-ports', help='Build naclport bundle.', action='store_true') parser.add_argument('--build-app-engine', help='Build AppEngine demos.', action='store_true') parser.add_argument('--experimental', help='build experimental examples and libraries', action='store_true', dest='build_experimental') parser.add_argument('--skip-toolchain', help='Skip toolchain untar', action='store_true') parser.add_argument('--no-clean', dest='clean', action='store_false', help="Don't clean gypbuild directories") parser.add_argument( '--mac-sdk', help='Set the mac-sdk (e.g. 10.6) to use when building with ninja.') parser.add_argument( '--no-arm-trusted', action='store_true', help='Disable building of ARM trusted components (sel_ldr, etc).') # To setup bash completion for this command first install optcomplete # and then add this line to your .bashrc: # complete -F _optcomplete build_sdk.py try: import optcomplete optcomplete.autocomplete(parser) except ImportError: pass global options options = parser.parse_args(args) buildbot_common.BuildStep('build_sdk') if options.nacl_tree_path: options.bionic = True toolchain_build = os.path.join(options.nacl_tree_path, 'toolchain_build') print 'WARNING: Building bionic toolchain from NaCl checkout.' print 'This option builds bionic from the sources currently in the' print 'provided NativeClient checkout, and the results instead of ' print 'downloading a toolchain from the builder. This may result in a' print 'NaCl SDK that can not run on ToT chrome.' print 'NOTE: To clobber you will need to run toolchain_build_bionic.py' print 'directly from the NativeClient checkout.' print '' response = raw_input("Type 'y' and hit enter to continue.\n") if response != 'y' and response != 'Y': print 'Aborting.' return 1 # Get head version of NativeClient tree buildbot_common.BuildStep('Build bionic toolchain.') buildbot_common.Run( [sys.executable, 'toolchain_build_bionic.py', '-f'], cwd=toolchain_build) else: toolchain_build = None if buildbot_common.IsSDKBuilder(): options.archive = True options.build_ports = True # TODO(binji): re-enable app_engine build when the linux builder stops # breaking when trying to git clone from github. # See http://crbug.com/412969. options.build_app_engine = False options.tar = True # NOTE: order matters here. This will be the order that is specified in the # Makefiles; the first toolchain will be the default. toolchains = ['pnacl', 'newlib', 'glibc', 'arm', 'clang-newlib', 'host'] # Changes for experimental bionic builder if options.bionic: toolchains.append('bionic') options.build_ports = False options.build_app_engine = False print 'Building: ' + ' '.join(toolchains) platform = getos.GetPlatform() if options.archive and not options.tar: parser.error('Incompatible arguments with archive.') chrome_version = int(build_version.ChromeMajorVersion()) chrome_revision = build_version.ChromeRevision() nacl_revision = build_version.NaClRevision() pepper_ver = str(chrome_version) pepper_old = str(chrome_version - 1) pepperdir = os.path.join(OUT_DIR, 'pepper_' + pepper_ver) pepperdir_old = os.path.join(OUT_DIR, 'pepper_' + pepper_old) if options.bionic: tarname = 'naclsdk_bionic.tar.bz2' else: tarname = 'naclsdk_%s.tar.bz2' % platform tarfile = os.path.join(OUT_DIR, tarname) if options.release: pepper_ver = options.release print 'Building PEPPER %s at %s' % (pepper_ver, chrome_revision) if 'NACL_SDK_ROOT' in os.environ: # We don't want the currently configured NACL_SDK_ROOT to have any effect # of the build. del os.environ['NACL_SDK_ROOT'] if platform == 'linux': # Linux-only: make sure the debian/stable sysroot image is installed install_script = os.path.join(SRC_DIR, 'chrome', 'installer', 'linux', 'sysroot_scripts', 'install-debian.wheezy.sysroot.py') buildbot_common.Run([sys.executable, install_script, '--arch=arm']) buildbot_common.Run([sys.executable, install_script, '--arch=i386']) buildbot_common.Run([sys.executable, install_script, '--arch=amd64']) if not options.skip_toolchain: BuildStepCleanPepperDirs(pepperdir, pepperdir_old) BuildStepMakePepperDirs(pepperdir, ['include', 'toolchain', 'tools']) BuildStepDownloadToolchains(toolchains) if options.nacl_tree_path: # Instead of untarring, copy the raw bionic toolchain not_bionic = [i for i in toolchains if i != 'bionic'] BuildStepUntarToolchains(pepperdir, not_bionic) tcname = GetToolchainDirName('bionic', 'arm') srcdir = os.path.join(toolchain_build, 'out', tcname) bionicdir = os.path.join(pepperdir, 'toolchain', tcname) oshelpers.Copy(['-r', srcdir, bionicdir]) else: BuildStepUntarToolchains(pepperdir, toolchains) if platform == 'linux': buildbot_common.Move( os.path.join(pepperdir, 'toolchain', 'arm_trusted'), os.path.join(OUT_DIR, 'arm_trusted')) if platform == 'linux': # Linux-only: Copy arm libraries from the arm_trusted package. These are # needed to be able to run sel_ldr_arm under qemu. arm_libs = [ 'lib/arm-linux-gnueabihf/librt.so.1', 'lib/arm-linux-gnueabihf/libpthread.so.0', 'lib/arm-linux-gnueabihf/libgcc_s.so.1', 'lib/arm-linux-gnueabihf/libc.so.6', 'lib/arm-linux-gnueabihf/ld-linux-armhf.so.3', 'lib/arm-linux-gnueabihf/libm.so.6', 'usr/lib/arm-linux-gnueabihf/libstdc++.so.6' ] arm_lib_dir = os.path.join(pepperdir, 'tools', 'lib', 'arm_trusted', 'lib') buildbot_common.MakeDir(arm_lib_dir) for arm_lib in arm_libs: arm_lib = os.path.join(OUT_DIR, 'arm_trusted', arm_lib) buildbot_common.CopyFile(arm_lib, arm_lib_dir) buildbot_common.CopyFile( os.path.join(OUT_DIR, 'arm_trusted', 'qemu-arm'), os.path.join(pepperdir, 'tools')) BuildStepBuildToolchains(pepperdir, toolchains, not options.skip_toolchain, options.clean) BuildStepUpdateHelpers(pepperdir, True) BuildStepUpdateUserProjects(pepperdir, toolchains, options.build_experimental, True) BuildStepCopyTextFiles(pepperdir, pepper_ver, chrome_revision, nacl_revision) # Ship with libraries prebuilt, so run that first. BuildStepBuildLibraries(pepperdir, 'src') GenerateNotice(pepperdir) # Verify the SDK contains what we expect. if not options.bionic: BuildStepVerifyFilelist(pepperdir) if options.tar: BuildStepTarBundle(pepper_ver, tarfile) if platform == 'linux': BuildStepBuildPNaClComponent(pepper_ver, chrome_revision) if options.build_ports: ports_tarfile = os.path.join(OUT_DIR, 'naclports.tar.bz2') BuildStepSyncNaClPorts() BuildStepBuildNaClPorts(pepper_ver, pepperdir) if options.tar: BuildStepTarNaClPorts(pepper_ver, ports_tarfile) if options.build_app_engine and platform == 'linux': BuildStepBuildAppEngine(pepperdir, chrome_revision) if options.qemu: qemudir = os.path.join(NACL_DIR, 'toolchain', 'linux_arm-trusted') oshelpers.Copy(['-r', qemudir, pepperdir]) # Archive the results on Google Cloud Storage. if options.archive: BuildStepArchiveBundle('build', pepper_ver, chrome_revision, nacl_revision, tarfile) # Only archive sdk_tools/naclport/pnacl_component on linux. if platform == 'linux': if options.build_ports: BuildStepArchiveBundle('naclports', pepper_ver, chrome_revision, nacl_revision, ports_tarfile) BuildStepArchiveSDKTools() BuildStepArchivePNaClComponent() return 0