def BuildStepUpdateUserProjects(pepperdir, toolchains, build_experimental, clobber): buildbot_common.BuildStep('Update examples and libraries') filters = {} if not build_experimental: filters['EXPERIMENTAL'] = False if toolchains: toolchains = toolchains[:] # arm isn't a valid toolchain for build_projects if 'arm' in toolchains: toolchains.remove('arm') if 'host' in toolchains: toolchains.remove('host') toolchains.append(getos.GetPlatform()) filters['TOOLS'] = toolchains # Update examples and libraries filters['DEST'] = [ 'getting_started', 'examples/api', 'examples/demo', 'examples/tutorial', 'src' ] tree = parse_dsc.LoadProjectTree(SDK_SRC_DIR, include=filters) build_projects.UpdateProjects(pepperdir, tree, clobber=clobber, toolchains=toolchains)
def BuildStepUpdateUserProjects(pepperdir, toolchains, build_experimental, clobber): buildbot_common.BuildStep('Update examples and libraries') filters = {} if not build_experimental: filters['EXPERIMENTAL'] = False dsc_toolchains = [] for t in toolchains: if t.startswith('x86_') or t.startswith('arm_'): if t[4:] not in dsc_toolchains: dsc_toolchains.append(t[4:]) elif t == 'host': dsc_toolchains.append(getos.GetPlatform()) else: dsc_toolchains.append(t) filters['TOOLS'] = dsc_toolchains # Update examples and libraries filters['DEST'] = [ 'getting_started', 'examples/api', 'examples/demo', 'examples/tutorial', 'src' ] tree = parse_dsc.LoadProjectTree(SDK_SRC_DIR, include=filters) build_projects.UpdateProjects(pepperdir, tree, clobber=clobber, toolchains=dsc_toolchains)
def GetProjectTree(include): # Everything in src is a library, and cannot be run. exclude = {'DEST': 'src'} try: return parse_dsc.LoadProjectTree(SDK_SRC_DIR, include=include, exclude=exclude) except parse_dsc.ValidationError as e: buildbot_common.ErrorExit(str(e))
def StepRunSelLdrTests(pepperdir, sanitizer): filters = { 'SEL_LDR': True } tree = parse_dsc.LoadProjectTree(SDK_SRC_DIR, include=filters) def RunTest(test, toolchain, config, arch=None): args = ['STANDALONE=1', 'TOOLCHAIN=%s' % toolchain] args += GetSanitizerArgs(sanitizer) if arch is not None: args.append('NACL_ARCH=%s' % arch) build_projects.BuildProjectsBranch(pepperdir, test, clean=False, deps=False, config=config, args=args + ['run']) if getos.GetPlatform() == 'win': # On win32 we only support running on the system # arch archs = (getos.GetSystemArch('win'),) elif getos.GetPlatform() == 'mac': # We only ship 64-bit version of sel_ldr on mac. archs = ('x86_64',) else: # On linux we can run both 32 and 64-bit, and arm (via qemu) archs = ('x86_64', 'x86_32', 'arm') for root, projects in tree.iteritems(): for project in projects: if sanitizer: sanitizer_name = '[sanitizer=%s]' % sanitizer else: sanitizer_name = '' title = 'standalone test%s: %s' % (sanitizer_name, os.path.basename(project['NAME'])) location = os.path.join(root, project['NAME']) buildbot_common.BuildStep(title) configs = ('Debug', 'Release') # On linux we can run the standalone tests natively using the host # compiler. if getos.GetPlatform() == 'linux': if sanitizer: configs = ('Debug',) for config in configs: RunTest(location, 'linux', config) if sanitizer: continue for toolchain in ('clang-newlib', 'glibc', 'pnacl'): for arch in archs: for config in configs: RunTest(location, toolchain, config, arch)
def StepCopyTests(pepperdir, toolchains, build_experimental): buildbot_common.BuildStep('Copy Tests') # Update test libraries and test apps filters = {'DEST': ['tests']} if not build_experimental: filters['EXPERIMENTAL'] = False tree = parse_dsc.LoadProjectTree(SDK_SRC_DIR, include=filters) build_projects.UpdateHelpers(pepperdir, clobber=False) build_projects.UpdateProjects(pepperdir, tree, clobber=False, toolchains=toolchains)
def BuildStepCopyTests(pepperdir, toolchains, build_experimental, clobber): buildbot_common.BuildStep('Copy Tests') # Update test libraries and test apps filters = {'DEST': ['testlibs', 'tests']} if not build_experimental: filters['EXPERIMENTAL'] = False tree = parse_dsc.LoadProjectTree(SDK_SRC_DIR, filters=filters) platform = getos.GetPlatform() build_projects.UpdateHelpers(pepperdir, platform, clobber=clobber) build_projects.UpdateProjects(pepperdir, platform, tree, clobber=clobber, toolchains=toolchains)
def BuildStepUpdateUserProjects(pepperdir, platform, toolchains, build_experimental, clobber): buildbot_common.BuildStep('Update examples and libraries') filters = {} if not build_experimental: filters['EXPERIMENTAL'] = False if toolchains: filters['TOOLS'] = toolchains # Update examples and libraries filters['DEST'] = ['examples', 'src'] tree = parse_dsc.LoadProjectTree(SDK_SRC_DIR, filters=filters) build_projects.UpdateProjects(pepperdir, platform, tree, clobber=clobber, toolchains=toolchains)
def StepRunSelLdrTests(pepperdir, sanitizer): filters = {'SEL_LDR': True} tree = parse_dsc.LoadProjectTree(SDK_SRC_DIR, include=filters) def RunTest(test, toolchain, config, arch=None): args = ['STANDALONE=1', 'TOOLCHAIN=%s' % toolchain] if arch is not None: args.append('NACL_ARCH=%s' % arch) deps = False if sanitizer is not None: # For sanitizer builds we pass extra argument for make, and do # full clean build to make sure everything is rebuilt with the # correct flags deps = True if sanitizer == 'valgrind': args += ['RUN_UNDER=valgrind'] elif sanitizer == 'address': args += ['ASAN=1'] elif sanitizer == 'thread': args += ['TSAN=1'] build_projects.BuildProjectsBranch(pepperdir, test, clean=False, deps=deps, config=config, args=args + ['run']) if getos.GetPlatform() == 'win': # On win32 we only support running on the system # arch archs = (getos.GetSystemArch('win'), ) elif getos.GetPlatform() == 'mac': # We only ship 32-bit version of sel_ldr on mac. archs = ('x86_32', ) else: # On linux we can run both 32 and 64-bit archs = ('x86_64', 'x86_32') for root, projects in tree.iteritems(): for project in projects: if sanitizer: sanitizer_name = '[sanitizer=%s]' % sanitizer else: sanitizer_name = '' title = 'standalone test%s: %s' % ( sanitizer_name, os.path.basename(project['NAME'])) location = os.path.join(root, project['NAME']) buildbot_common.BuildStep(title) configs = ('Debug', 'Release') # On linux we can run the standalone tests natively using the host # compiler. if getos.GetPlatform() == 'linux': if sanitizer: configs = ('Debug', ) for config in configs: RunTest(location, 'linux', config) if sanitizer: continue for toolchain in ('clang-newlib', 'newlib', 'glibc', 'pnacl'): for arch in archs: for config in configs: RunTest(location, toolchain, config, arch)
def main(argv): parser = optparse.OptionParser() parser.add_option( '-c', '--clobber', help='Clobber project directories before copying new files', action='store_true', default=False) parser.add_option('-b', '--build', help='Build the projects.', action='store_true') parser.add_option( '--config', help='Choose configuration to build (Debug or Release). Builds both ' 'by default') parser.add_option('-x', '--experimental', help='Build experimental projects', action='store_true') parser.add_option( '-t', '--toolchain', help='Build using toolchain. Can be passed more than once.', action='append', default=[]) parser.add_option( '-d', '--dest', help='Select which build destinations (project types) are valid.', action='append') parser.add_option('-v', '--verbose', action='store_true') # To setup bash completion for this command first install optcomplete # and then add this line to your .bashrc: # complete -F _optcomplete build_projects.py try: import optcomplete optcomplete.autocomplete(parser) except ImportError: pass options, args = parser.parse_args(argv[1:]) if 'NACL_SDK_ROOT' in os.environ: # We don't want the currently configured NACL_SDK_ROOT to have any effect # on the build. del os.environ['NACL_SDK_ROOT'] pepper_ver = str(int(build_version.ChromeMajorVersion())) pepperdir = os.path.join(OUT_DIR, 'pepper_' + pepper_ver) if not options.toolchain: # Order matters here: the default toolchain for an example's Makefile will # be the first toolchain in this list that is available in the example. # e.g. If an example supports newlib and glibc, then the default will be # newlib. options.toolchain = ['pnacl', 'newlib', 'glibc', 'host'] if options.experimental: options.toolchain.append('bionic') if 'host' in options.toolchain: options.toolchain.remove('host') options.toolchain.append(getos.GetPlatform()) print 'Adding platform: ' + getos.GetPlatform() ValidateToolchains(options.toolchain) filters = {} if options.toolchain: filters['TOOLS'] = options.toolchain print 'Filter by toolchain: ' + str(options.toolchain) if not options.experimental: filters['EXPERIMENTAL'] = False if options.dest: filters['DEST'] = options.dest print 'Filter by type: ' + str(options.dest) if args: filters['NAME'] = args print 'Filter by name: ' + str(args) try: project_tree = parse_dsc.LoadProjectTree(SDK_SRC_DIR, include=filters) except parse_dsc.ValidationError as e: buildbot_common.ErrorExit(str(e)) parse_dsc.PrintProjectTree(project_tree) UpdateHelpers(pepperdir, clobber=options.clobber) UpdateProjects(pepperdir, project_tree, options.toolchain, clobber=options.clobber) if options.verbose: global verbose verbose = True if options.build: if options.config: configs = [options.config] else: configs = ['Debug', 'Release'] for config in configs: BuildProjects(pepperdir, project_tree, config=config) return 0
def main(args): parser = argparse.ArgumentParser() parser.add_argument('-c', '--channel', help='Channel to display in the name of the package.') # To setup bash completion for this command first install optcomplete # and then add this line to your .bashrc: # complete -F _optcomplete build_app.py try: import optcomplete optcomplete.autocomplete(parser) except ImportError: pass options = parser.parse_args(args) if options.channel: if options.channel not in ('Dev', 'Beta'): parser.error('Unknown channel: %s' % options.channel) toolchains = ['newlib', 'glibc'] pepper_ver = str(int(build_version.ChromeMajorVersion())) pepperdir = os.path.join(OUT_DIR, 'pepper_' + pepper_ver) app_dir = os.path.join(OUT_DIR, 'naclsdk_app') app_examples_dir = os.path.join(app_dir, 'examples') sdk_resources_dir = SDK_RESOURCE_DIR platform = getos.GetPlatform() buildbot_common.RemoveDir(app_dir) buildbot_common.MakeDir(app_dir) # Add some dummy directories so build_projects doesn't complain... buildbot_common.MakeDir(os.path.join(app_dir, 'tools')) buildbot_common.MakeDir(os.path.join(app_dir, 'toolchain')) config = 'Release' filters = {} filters['DISABLE_PACKAGE'] = False filters['EXPERIMENTAL'] = False filters['TOOLS'] = toolchains filters['DEST'] = [ 'examples/api', 'examples/getting_started', 'examples/demo', 'examples/tutorial' ] tree = parse_dsc.LoadProjectTree(SDK_SRC_DIR, include=filters) build_projects.UpdateHelpers(app_dir, clobber=True) build_projects.UpdateProjects(app_dir, tree, clobber=False, toolchains=toolchains, configs=[config], first_toolchain=True) # Collect permissions from each example, and aggregate them. def MergeLists(list1, list2): return list1 + [x for x in list2 if x not in list1] all_permissions = [] all_socket_permissions = [] all_filesystem_permissions = [] for _, project in parse_dsc.GenerateProjects(tree): permissions = project.get('PERMISSIONS', []) all_permissions = MergeLists(all_permissions, permissions) socket_permissions = project.get('SOCKET_PERMISSIONS', []) all_socket_permissions = MergeLists(all_socket_permissions, socket_permissions) filesystem_permissions = project.get('FILESYSTEM_PERMISSIONS', []) all_filesystem_permissions = MergeLists(all_filesystem_permissions, filesystem_permissions) if all_socket_permissions: all_permissions.append({'socket': all_socket_permissions}) if all_filesystem_permissions: all_permissions.append({'fileSystem': all_filesystem_permissions}) pretty_permissions = json.dumps(all_permissions, sort_keys=True, indent=4) for filename in ['background.js', 'icon128.png']: buildbot_common.CopyFile(os.path.join(sdk_resources_dir, filename), os.path.join(app_examples_dir, filename)) os.environ['NACL_SDK_ROOT'] = pepperdir build_projects.BuildProjects(app_dir, tree, deps=False, clean=False, config=config) RemoveBuildCruft(app_dir) StripNexes(app_dir, platform, pepperdir) # Add manifest.json after RemoveBuildCruft... that function removes the # manifest.json files for the individual examples. name = 'Native Client SDK' if options.channel: name += ' (%s)' % options.channel template_dict = { 'name': name, 'channel': options.channel, 'description': 'Native Client SDK examples, showing API use and key concepts.', 'key': False, # manifests with "key" are rejected when uploading to CWS. 'permissions': pretty_permissions, 'version': build_version.ChromeVersionNoTrunk() } easy_template.RunTemplateFile( os.path.join(sdk_resources_dir, 'manifest.json.template'), os.path.join(app_examples_dir, 'manifest.json'), template_dict) app_zip = os.path.join(app_dir, 'examples.zip') os.chdir(app_examples_dir) oshelpers.Zip([app_zip, '-r', '*']) return 0
def main(args): parser = optparse.OptionParser() _, args = parser.parse_args(args[1:]) toolchains = ['newlib', 'glibc'] pepper_ver = str(int(build_version.ChromeMajorVersion())) pepperdir = os.path.join(OUT_DIR, 'pepper_' + pepper_ver) app_dir = os.path.join(OUT_DIR, 'naclsdk_app') app_examples_dir = os.path.join(app_dir, 'examples') sdk_resources_dir = os.path.join(SDK_EXAMPLE_DIR, 'resources') platform = getos.GetPlatform() buildbot_common.RemoveDir(app_dir) buildbot_common.MakeDir(app_dir) # Add some dummy directories so build_projects doesn't complain... buildbot_common.MakeDir(os.path.join(app_dir, 'tools')) buildbot_common.MakeDir(os.path.join(app_dir, 'toolchain')) config = 'Release' filters = {} filters['DISABLE_PACKAGE'] = False filters['EXPERIMENTAL'] = False filters['TOOLS'] = toolchains filters['DEST'] = ['examples/api', 'examples/getting_started', 'examples/demo', 'examples/tutorial'] tree = parse_dsc.LoadProjectTree(SDK_SRC_DIR, filters=filters) build_projects.UpdateHelpers(app_dir, platform, clobber=True) build_projects.UpdateProjects(app_dir, platform, tree, clobber=False, toolchains=toolchains, configs=[config], first_toolchain=True) # Collect permissions from each example, and aggregate them. all_permissions = [] for _, project in parse_dsc.GenerateProjects(tree): all_permissions.extend(project.get('PERMISSIONS', [])) template_dict = { 'name': 'Native Client SDK', 'description': 'Native Client SDK examples, showing API use and key concepts.', 'key': False, # manifests with "key" are rejected when uploading to CWS. 'permissions': all_permissions, 'version': build_version.ChromeVersionNoTrunk() } easy_template.RunTemplateFile( os.path.join(sdk_resources_dir, 'manifest.json.template'), os.path.join(app_examples_dir, 'manifest.json'), template_dict) for filename in ['background.js', 'icon128.png']: buildbot_common.CopyFile(os.path.join(sdk_resources_dir, filename), os.path.join(app_examples_dir, filename)) os.environ['NACL_SDK_ROOT'] = pepperdir build_projects.BuildProjects(app_dir, platform, tree, deps=True, clean=False, config=config) RemoveBuildCruft(app_dir) StripNexes(app_dir, platform, pepperdir) app_zip = os.path.join(app_dir, 'examples.zip') os.chdir(app_examples_dir) oshelpers.Zip([app_zip, '-r', '*']) return 0
def main(args): parser = optparse.OptionParser() parser.add_option( '-c', '--clobber', help='Clobber project directories before copying new files', action='store_true', default=False) parser.add_option('-b', '--build', help='Build the projects.', action='store_true') parser.add_option( '--config', help='Choose configuration to build (Debug or Release). Builds both ' 'by default') parser.add_option('-x', '--experimental', help='Build experimental projects', action='store_true') parser.add_option( '-t', '--toolchain', help='Build using toolchain. Can be passed more than once.', action='append', default=[]) parser.add_option( '-d', '--dest', help='Select which build destinations (project types) are valid.', action='append') parser.add_option('-p', '--project', help='Select which projects are valid.', action='append') parser.add_option('-v', '--verbose', action='store_true') options, args = parser.parse_args(args[1:]) if args: parser.error('Not expecting any arguments.') if 'NACL_SDK_ROOT' in os.environ: # We don't want the currently configured NACL_SDK_ROOT to have any effect # on the build. del os.environ['NACL_SDK_ROOT'] pepper_ver = str(int(build_version.ChromeMajorVersion())) pepperdir = os.path.join(OUT_DIR, 'pepper_' + pepper_ver) platform = getos.GetPlatform() if not options.toolchain: options.toolchain = ['newlib', 'glibc', 'pnacl', 'host'] if 'host' in options.toolchain: options.toolchain.remove('host') options.toolchain.append(platform) print 'Adding platform: ' + platform ValidateToolchains(options.toolchain) filters = {} if options.toolchain: filters['TOOLS'] = options.toolchain print 'Filter by toolchain: ' + str(options.toolchain) if not options.experimental: filters['EXPERIMENTAL'] = False if options.dest: filters['DEST'] = options.dest print 'Filter by type: ' + str(options.dest) if options.project: filters['NAME'] = options.project print 'Filter by name: ' + str(options.project) project_tree = parse_dsc.LoadProjectTree(SDK_SRC_DIR, filters=filters) parse_dsc.PrintProjectTree(project_tree) UpdateHelpers(pepperdir, platform, clobber=options.clobber) UpdateProjects(pepperdir, platform, project_tree, options.toolchain, clobber=options.clobber) if options.build: if options.config: configs = [options.config] else: configs = ['Debug', 'Release'] for config in configs: BuildProjects(pepperdir, platform, project_tree, config=config) return 0
def main(args): parser = optparse.OptionParser() parser.add_option( '--clobber', help='Clobber project directories before copying new files', action='store_true', default=False) parser.add_option('-b', '--build', help='Build the projects.', action='store_true') parser.add_option('-x', '--experimental', help='Build experimental projects', action='store_true') parser.add_option( '-t', '--toolchain', help='Build using toolchain. Can be passed more than once.', action='append', default=[]) parser.add_option( '-d', '--dest', help='Select which build destinations (project types) are valid.', action='append') parser.add_option('-p', '--project', help='Select which projects are valid.', action='append') parser.add_option('-v', '--verbose', action='store_true') options, files = parser.parse_args(args[1:]) if len(files): parser.error('Not expecting files.') return 1 pepper_ver = str(int(build_version.ChromeMajorVersion())) pepperdir = os.path.join(OUT_DIR, 'pepper_' + pepper_ver) platform = getos.GetPlatform() if not options.toolchain: options.toolchain = ['newlib', 'glibc', 'pnacl', 'host'] if 'host' in options.toolchain: options.toolchain.append(platform) print 'Adding platform: ' + platform filters = {} if options.toolchain: filters['TOOLS'] = options.toolchain print 'Filter by toolchain: ' + str(options.toolchain) if not options.experimental: filters['EXPERIMENTAL'] = False if options.dest: filters['DEST'] = options.dest print 'Filter by type: ' + str(options.dest) if options.project: filters['NAME'] = options.project print 'Filter by name: ' + str(options.project) project_tree = parse_dsc.LoadProjectTree(SDK_SRC_DIR, verbose=options.verbose, filters=filters) parse_dsc.PrintProjectTree(project_tree) UpdateHelpers(pepperdir, platform, clobber=options.clobber) UpdateProjects(pepperdir, platform, project_tree, options.toolchain, clobber=options.clobber) if options.build: BuildProjects(pepperdir, platform, project_tree) return 0