示例#1
0
def GenerateManifest(srcroot, dstroot, desc):
    outdir = os.path.join(dstroot, desc['DEST'], desc['NAME'])
    srcpath = os.path.join(SDK_RESOURCE_DIR, 'manifest.json.template')
    dstpath = os.path.join(outdir, 'manifest.json')
    permissions = desc.get('PERMISSIONS', [])
    combined_permissions = list(permissions)
    socket_permissions = desc.get('SOCKET_PERMISSIONS', [])
    if socket_permissions:
        combined_permissions.append({'socket': socket_permissions})
    filesystem_permissions = desc.get('FILESYSTEM_PERMISSIONS', [])
    if filesystem_permissions:
        combined_permissions.append({'fileSystem': filesystem_permissions})
    pretty_permissions = json.dumps(combined_permissions,
                                    sort_keys=True,
                                    indent=4)
    replace = {
        'name': desc['TITLE'],
        'description': '%s Example' % desc['TITLE'],
        'key': True,
        'channel': None,
        'permissions': pretty_permissions,
        'multi_platform': desc.get('MULTI_PLATFORM', False),
        'version': build_version.ChromeVersionNoTrunk(),
        'min_chrome_version': desc.get('MIN_CHROME_VERSION')
    }
    RunTemplateFileIfChanged(srcpath, dstpath, replace)
示例#2
0
def ProcessProject(pepperdir,
                   srcroot,
                   dstroot,
                   desc,
                   toolchains,
                   configs=None,
                   first_toolchain=False):
    if not configs:
        configs = ['Debug', 'Release']

    name = desc['NAME']
    out_dir = os.path.join(dstroot, desc['DEST'], name)
    buildbot_common.MakeDir(out_dir)
    srcdirs = desc.get('SEARCH', ['.', '..', '../..'])
    srcdirs.append(os.path.join(SDK_EXAMPLE_DIR, 'resources'))

    # Copy sources to example directory
    sources = GenerateSourceCopyList(desc)
    FindAndCopyFiles(sources, srcroot, srcdirs, out_dir)

    # Copy public headers to the include directory.
    for headers_set in desc.get('HEADERS', []):
        headers = headers_set['FILES']
        header_out_dir = os.path.join(dstroot, headers_set['DEST'])
        FindAndCopyFiles(headers, srcroot, srcdirs, header_out_dir)

    make_path = os.path.join(out_dir, 'Makefile')

    if IsNexe(desc):
        template = os.path.join(SCRIPT_DIR, 'template.mk')
    else:
        template = os.path.join(SCRIPT_DIR, 'library.mk')

    # Ensure the order of |tools| is the same as toolchains; that way if
    # first_toolchain is set, it will choose based on the order of |toolchains|.
    tools = [tool for tool in toolchains if tool in desc['TOOLS']]
    if first_toolchain:
        tools = [tools[0]]
    template_dict = {
        'rel_sdk': '/'.join(['..'] * (len(desc['DEST'].split('/')) + 1)),
        'pre': desc.get('PRE', ''),
        'post': desc.get('POST', ''),
        'tools': tools,
        'targets': desc['TARGETS'],
    }
    RunTemplateFileIfChanged(template, make_path, template_dict)

    outdir = os.path.dirname(os.path.abspath(make_path))
    if getos.GetPlatform() == 'win':
        AddMakeBat(pepperdir, outdir)

    if IsExample(desc):
        ProcessHTML(srcroot, dstroot, desc, toolchains, configs,
                    first_toolchain)
        GenerateManifest(srcroot, dstroot, desc)

    return (name, desc['DEST'])
示例#3
0
def GenerateManifest(srcroot, dstroot, desc):
    outdir = os.path.join(dstroot, desc['DEST'], desc['NAME'])
    srcpath = os.path.join(SDK_EXAMPLE_DIR, 'resources',
                           'manifest.json.template')
    dstpath = os.path.join(outdir, 'manifest.json')
    replace = {
        'name': desc['TITLE'],
        'description': '%s Example' % desc['TITLE'],
        'key': True,
        'permissions': desc.get('PERMISSIONS', []),
        'version': build_version.ChromeVersionNoTrunk()
    }
    RunTemplateFileIfChanged(srcpath, dstpath, replace)
示例#4
0
def ProcessHTML(srcroot, dstroot, desc, toolchains, configs, first_toolchain):
  name = desc['NAME']
  nmf = desc['TARGETS'][0]['NAME']
  outdir = os.path.join(dstroot, desc['DEST'], name)
  srcpath = os.path.join(srcroot, 'index.html')
  dstpath = os.path.join(outdir, 'index.html')

  tools = GetPlatforms(toolchains, desc['TOOLS'], first_toolchain)

  path = "{tc}/{config}"
  replace = {
    'title': desc['TITLE'],
    'attrs':
        'data-name="%s" data-tools="%s" data-configs="%s" data-path="%s"' % (
        nmf, ' '.join(tools), ' '.join(configs), path),
  }
  RunTemplateFileIfChanged(srcpath, dstpath, replace)
示例#5
0
def GenerateMasterMakefile(out_path, targets, depth):
  """Generate a Master Makefile that builds all examples.

  Args:
    out_path: Root for output such that out_path+NAME = full path
    targets: List of targets names
    depth: How deep in from NACL_SDK_ROOT
  """
  in_path = os.path.join(SDK_EXAMPLE_DIR, 'Makefile')
  out_path = os.path.join(out_path, 'Makefile')
  template_dict = {
    'projects': targets,
    'rel_sdk' : '/'.join(['..'] * depth)
  }
  RunTemplateFileIfChanged(in_path, out_path, template_dict)
  outdir = os.path.dirname(os.path.abspath(out_path))
  pepperdir = os.path.dirname(outdir)
  AddMakeBat(pepperdir, outdir)
示例#6
0
def GenerateMasterMakefile(pepperdir, out_path, targets):
    """Generate a Master Makefile that builds all examples.

  Args:
    pepperdir: NACL_SDK_ROOT
    out_path: Root for output such that out_path+NAME = full path
    targets: List of targets names
  """
    in_path = os.path.join(SDK_EXAMPLE_DIR, 'Makefile')
    out_path = os.path.join(out_path, 'Makefile')
    rel_path = os.path.relpath(pepperdir, os.path.dirname(out_path))
    template_dict = {
        'projects': targets,
        'rel_sdk': rel_path,
    }
    RunTemplateFileIfChanged(in_path, out_path, template_dict)
    outdir = os.path.dirname(os.path.abspath(out_path))
    if getos.GetPlatform() == 'win':
        AddMakeBat(pepperdir, outdir)
示例#7
0
def GenerateManifest(srcroot, dstroot, desc):
    outdir = os.path.join(dstroot, desc['DEST'], desc['NAME'])
    srcpath = os.path.join(SDK_RESOURCE_DIR, 'manifest.json.template')
    dstpath = os.path.join(outdir, 'manifest.json')
    permissions = desc.get('PERMISSIONS', [])
    socket_permissions = desc.get('SOCKET_PERMISSIONS', [])
    combined_permissions = list(permissions)
    if socket_permissions:
        combined_permissions.append({'socket': socket_permissions})
    pretty_permissions = json.dumps(combined_permissions,
                                    sort_keys=True,
                                    indent=4)
    replace = {
        'name': desc['TITLE'],
        'description': '%s Example' % desc['TITLE'],
        'key': True,
        'channel': None,
        'permissions': pretty_permissions,
        'version': build_version.ChromeVersionNoTrunk()
    }
    RunTemplateFileIfChanged(srcpath, dstpath, replace)
def ProcessProject(pepperdir,
                   srcroot,
                   dstroot,
                   desc,
                   toolchains,
                   configs=None,
                   first_toolchain=False):
    if not configs:
        configs = ['Debug', 'Release']

    name = desc['NAME']
    out_dir = os.path.join(dstroot, desc['DEST'], name)
    buildbot_common.MakeDir(out_dir)
    srcdirs = desc.get('SEARCH', ['.', SDK_RESOURCE_DIR])

    # Copy sources to example directory
    sources = GenerateSourceCopyList(desc)
    FindAndCopyFiles(sources, srcroot, srcdirs, out_dir)

    # Copy public headers to the include directory.
    for headers_set in desc.get('HEADERS', []):
        headers = headers_set['FILES']
        header_out_dir = os.path.join(dstroot, headers_set['DEST'])
        FindAndCopyFiles(headers, srcroot, srcdirs, header_out_dir)

    make_path = os.path.join(out_dir, 'Makefile')

    outdir = os.path.dirname(os.path.abspath(make_path))
    if getos.GetPlatform() == 'win':
        AddMakeBat(pepperdir, outdir)

    # If this project has no TARGETS, then we don't need to generate anything.
    if 'TARGETS' not in desc:
        return (name, desc['DEST'])

    if IsNexe(desc):
        template = os.path.join(SDK_RESOURCE_DIR, 'Makefile.example.template')
    else:
        template = os.path.join(SDK_RESOURCE_DIR, 'Makefile.library.template')

    # Ensure the order of |tools| is the same as toolchains; that way if
    # first_toolchain is set, it will choose based on the order of |toolchains|.
    tools = [tool for tool in toolchains if tool in desc['TOOLS']]
    if first_toolchain:
        tools = [tools[0]]

    ModifyDescInPlace(desc)

    template_dict = {
        'desc': desc,
        'rel_sdk': '/'.join(['..'] * (len(desc['DEST'].split('/')) + 1)),
        'pre': desc.get('PRE', ''),
        'post': desc.get('POST', ''),
        'tools': tools,
        'sel_ldr': desc.get('SEL_LDR'),
        'targets': desc['TARGETS'],
        'multi_platform': desc.get('MULTI_PLATFORM', False),
    }
    RunTemplateFileIfChanged(template, make_path, template_dict)

    if IsExample(desc):
        ProcessHTML(srcroot, dstroot, desc, toolchains, configs,
                    first_toolchain)
        if not desc.get('NO_PACKAGE_FILES'):
            GenerateManifest(srcroot, dstroot, desc)

    return (name, desc['DEST'])