def MakeBundle(major_version, revision=0, version=None, host_oses=None, stability='dev'): assert (version is None or version.split('.')[0] == 'trunk' or version.split('.')[0] == str(major_version)) if stability == CANARY: bundle_name = CANARY_BUNDLE_NAME else: bundle_name = 'pepper_' + str(major_version) bundle = manifest_util.Bundle(bundle_name) bundle.version = major_version bundle.revision = revision bundle.description = 'Chrome %s bundle, revision %s' % (major_version, revision) bundle.repath = 'pepper_' + str(major_version) bundle.recommended = 'no' bundle.stability = stability if host_oses: for host_os in host_oses: bundle.AddArchive(MakeArchive(host_os, version)) return bundle
def AddArchive(self, bundle, archive, add_json=True): path = GetPathFromHttpsUrl(archive.url) self[path] = 'My Dummy archive' if add_json: # add .json manifest snippet, it should look like a normal Bundle, but # only has one archive. new_bundle = manifest_util.Bundle('') new_bundle.CopyFrom(bundle) del new_bundle.archives[:] new_bundle.AddArchive(archive) self[path + '.json'] = new_bundle.GetDataAsString()
def _GetPlatformArchiveBundle(self, archive): """Downloads the manifest "snippet" for an archive, and reads it as a Bundle. Args: archive: The URL of a platform-specific archive. Returns: An object of type manifest_util.Bundle, read from a JSON file storing metadata for this archive. """ stdout = self.delegate.GsUtil_cat(GS_BUCKET_PATH + archive + '.json') bundle = manifest_util.Bundle('') bundle.LoadDataFromString(stdout) return bundle
def _AddDummyBundle(self, manifest, bundle_name): bundle = manifest_util.Bundle(bundle_name) bundle.revision = 1337 bundle.version = 23 bundle.description = bundle_name bundle.stability = 'beta' bundle.recommended = 'no' bundle.repath = bundle_name archive = self._MakeDummyArchive(bundle_name) bundle.AddArchive(archive) manifest.SetBundle(bundle) # Need to get the bundle from the manifest -- it doesn't use the one we # gave it. return manifest.GetBundle(bundle_name)
def MakeNonPepperBundle(name, with_archives=False): bundle = manifest_util.Bundle(name) bundle.version = 1 bundle.revision = 1 bundle.description = 'Dummy bundle' bundle.recommended = 'yes' bundle.stability = 'stable' if with_archives: for host_os in OS_MLW: archive = manifest_util.Archive(host_os) archive.url = 'http://example.com' archive.checksum = {'sha1': 'blah'} archive.size = 2 bundle.AddArchive(archive) return bundle
def MakeBundle(major_version, revision, version=None, host_oses=None): assert version is None or version.split('.')[0] == major_version bundle_name = 'pepper_' + major_version bundle = manifest_util.Bundle(bundle_name) bundle.version = int(major_version) bundle.revision = revision bundle.description = 'Chrome %s bundle, revision %s' % (major_version, revision) bundle.repath = bundle_name bundle.recommended = 'no' bundle.stability = 'dev' if host_oses: for host_os in host_oses: bundle.AddArchive(MakeArchive(host_os, version)) return bundle
def Add(self, bundle, add_archive_for_os=OS_MLW, add_json_for_os=OS_MLW): for archive in bundle.GetArchives(): if not archive.host_os in add_archive_for_os: continue # add a dummy file for each archive path = GetPathFromHttpsUrl(archive.url) self[path] = 'My Dummy Archive' if archive.host_os in add_json_for_os: # add .json manifest snippet, it should look like a normal Bundle, but # only has one archive. new_bundle = manifest_util.Bundle('') new_bundle.CopyFrom(bundle) del new_bundle.archives[:] new_bundle.AddArchive(archive) self[path + '.json'] = new_bundle.GetDataAsString()
def _GetPlatformArchiveBundle(self, archive): """Downloads the manifest "snippet" for an archive, and reads it as a Bundle. Args: archive: A full URL of a platform-specific archive, using the gs schema. Returns: An object of type manifest_util.Bundle, read from a JSON file storing metadata for this archive. """ stdout = self.delegate.GsUtil_cat(archive + '.json') bundle = manifest_util.Bundle('') bundle.LoadDataFromString(stdout) # Some snippets were uploaded with revisions and versions as strings. Fix # those here. bundle.revision = int(bundle.revision) bundle.version = int(bundle.version) return bundle
def MakePepperBundle(major_version, revision=0, version=None, stability='dev', bundle_name=None): assert (version is None or version.split('.')[0] == 'trunk' or version.split('.')[0] == str(major_version)) if not bundle_name: bundle_name = 'pepper_' + str(major_version) bundle = manifest_util.Bundle(bundle_name) bundle.version = major_version bundle.revision = revision bundle.description = 'Chrome %s bundle, revision %s' % (major_version, revision) bundle.repath = 'pepper_' + str(major_version) bundle.recommended = 'no' bundle.stability = stability return bundle
def GetManifestBundle(pepper_ver, revision, tarfile, archive_url): with open(tarfile, 'rb') as tarfile_stream: archive_sha1, archive_size = manifest_util.DownloadAndComputeHash( tarfile_stream) archive = manifest_util.Archive(manifest_util.GetHostOS()) archive.url = archive_url archive.size = archive_size archive.checksum = archive_sha1 bundle = manifest_util.Bundle('pepper_' + pepper_ver) bundle.revision = int(revision) bundle.repath = 'pepper_' + pepper_ver bundle.version = int(pepper_ver) bundle.description = 'Chrome %s bundle, revision %s' % (pepper_ver, revision) bundle.stability = 'dev' bundle.recommended = 'no' bundle.archives = [archive] return bundle
def _GetPlatformArchiveBundle(self, archive): """Downloads the manifest "snippet" for an archive, and reads it as a Bundle. Args: archive: A full URL of a platform-specific archive, using the gs schema. Returns: An object of type manifest_util.Bundle, read from a JSON file storing metadata for this archive. """ stdout = self.delegate.GsUtil_cat(archive + '.json') bundle = manifest_util.Bundle('') bundle.LoadDataFromString(stdout) # Some snippets were uploaded with revisions and versions as strings. Fix # those here. bundle.revision = int(bundle.revision) bundle.version = int(bundle.version) # HACK. The naclports archive specifies host_os as linux. Change it to all. for archive in bundle.GetArchives(): if NACLPORTS_ARCHIVE_NAME in archive.url: archive.host_os = 'all' return bundle
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