def main(args): parser = optparse.OptionParser() parser.add_option('-o', dest='out') parser.add_option('-c', '--config') parser.add_option('-t', '--template') parser.add_option('-k', '--key', action='store_true') options, args = parser.parse_args(args) if not options.out: parser.error('Need output file (-o)') if not options.template: parser.error('Need template (-t)') if not options.config: parser.error('Need config (-c)') template_dict = { 'config': options.config, 'resources': args } template_dict['key'] = options.key easy_template.RunTemplateFile(options.template, options.out, template_dict) return 0
def main(args): parser = optparse.OptionParser() _, args = parser.parse_args(args[1:]) toolchains = ['newlib', 'glibc'] pepper_ver = str(int(build_utils.ChromeMajorVersion())) pepperdir = os.path.join(build_sdk.OUT_DIR, 'pepper_' + pepper_ver) app_dir = os.path.join(build_sdk.OUT_DIR, 'naclsdk_app') app_examples_dir = os.path.join(app_dir, 'examples') sdk_resources_dir = os.path.join(build_sdk.SDK_EXAMPLE_DIR, 'resources') platform = getos.GetPlatform() buildbot_common.RemoveDir(app_dir) buildbot_common.MakeDir(app_dir) GenerateMake(app_dir, toolchains) easy_template.RunTemplateFile( os.path.join(sdk_resources_dir, 'manifest.json.template'), os.path.join(app_examples_dir, 'manifest.json'), {'version': build_utils.ChromeVersionNoTrunk()}) 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_sdk.BuildStepMakeAll(app_dir, platform, 'examples', 'Build Examples', False, False, 'Release') 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 = 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