Ejemplo n.º 1
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
Ejemplo n.º 2
0
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
Ejemplo n.º 3
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