Beispiel #1
0
def main(arguments):
    parser = optparse.OptionParser(
        description='Generates a struct from a JSON description.',
        usage='usage: %prog [option] -s schema -p platform description')
    parser.add_option('-b',
                      '--destbase',
                      help='base directory of generated files.')
    parser.add_option(
        '-d',
        '--destdir',
        help='directory to output generated files, relative to destbase.')
    parser.add_option(
        '-n',
        '--namespace',
        help='C++ namespace for generated files. e.g search_providers.')
    parser.add_option('-p',
                      '--platform',
                      action='append',
                      choices=_platforms,
                      help='target platform for the field trial, mandatory.')
    parser.add_option('-s',
                      '--schema',
                      help='path to the schema file, '
                      'mandatory.')
    parser.add_option('-o', '--output', help='output filename, ' 'mandatory.')
    parser.add_option('-y', '--year', help='year to put in the copy-right.')
    parser.add_option(
        '--invert_fieldtrials',
        action='store_true',
        help=
        "Inverts the enabled and disabled experiments for existing field trials."
    )

    (opts, args) = parser.parse_args(args=arguments)

    if not opts.schema:
        parser.error('You must specify a --schema.')

    if not opts.platform:
        parser.error('You must specify at least 1 --platform.')

    description_filename = os.path.normpath(args[0])
    shortroot = opts.output
    if opts.destdir:
        output_root = os.path.join(os.path.normpath(opts.destdir), shortroot)
    else:
        output_root = shortroot

    if opts.destbase:
        basepath = os.path.normpath(opts.destbase)
    else:
        basepath = ''

    schema = _Load(opts.schema)
    description = _LoadFieldTrialConfig(description_filename, opts.platform,
                                        opts.invert_fieldtrials)
    json_to_struct.GenerateStruct(basepath, output_root, opts.namespace,
                                  schema, description,
                                  os.path.split(description_filename)[1],
                                  os.path.split(opts.schema)[1], opts.year)
Beispiel #2
0
def main(arguments):
    parser = optparse.OptionParser(
        description='Generates a struct from a JSON description.',
        usage='usage: %prog [option] -s schema -p platform description')
    parser.add_option('-b',
                      '--destbase',
                      help='base directory of generated files.')
    parser.add_option(
        '-d',
        '--destdir',
        help='directory to output generated files, relative to destbase.')
    parser.add_option(
        '-n',
        '--namespace',
        help='C++ namespace for generated files. e.g search_providers.')
    parser.add_option('-p',
                      '--platform',
                      help='target platform for the field trial, mandatory.')
    parser.add_option('-s',
                      '--schema',
                      help='path to the schema file, '
                      'mandatory.')
    parser.add_option('-o', '--output', help='output filename, ' 'mandatory.')
    parser.add_option('-y', '--year', help='year to put in the copy-right.')
    (opts, args) = parser.parse_args(args=arguments)

    if not opts.schema:
        parser.error('You must specify a --schema.')

    if not opts.platform:
        parser.error('You must specify a --platform.')

    supported_platforms = [
        'android', 'chromeos', 'fuchsia', 'ios', 'linux', 'mac', 'win'
    ]
    if opts.platform not in supported_platforms:
        parser.error('\'%s\' is an unknown platform. Supported platforms: %s' %
                     (opts.platform, supported_platforms))

    description_filename = os.path.normpath(args[0])
    shortroot = opts.output
    if opts.destdir:
        output_root = os.path.join(os.path.normpath(opts.destdir), shortroot)
    else:
        output_root = shortroot

    if opts.destbase:
        basepath = os.path.normpath(opts.destbase)
    else:
        basepath = ''

    schema = _Load(opts.schema)
    description = _LoadFieldTrialConfig(description_filename, opts.platform)
    json_to_struct.GenerateStruct(basepath, output_root, opts.namespace,
                                  schema, description,
                                  os.path.split(description_filename)[1],
                                  os.path.split(opts.schema)[1], opts.year)
def main(arguments):
  parser = optparse.OptionParser(
      description='Generates an C++ array of struct from a JSON description.',
      usage='usage: %prog [option] -s schema description')
  parser.add_option('-b', '--destbase',
      help='base directory of generated files.')
  parser.add_option('-d', '--destdir',
      help='directory to output generated files, relative to destbase.')
  parser.add_option('-n', '--namespace',
      help='C++ namespace for generated files. e.g search_providers.')
  parser.add_option('-s', '--schema', help='path to the schema file, '
      'mandatory.')
  parser.add_option('-o', '--output', help='output filename, '
      'mandatory.')
  parser.add_option('-y', '--year',
      help='year to put in the copy-right.')
  (opts, args) = parser.parse_args(args=arguments)

  if not opts.schema:
    parser.error('You must specify a --schema.')

  description_filename = os.path.normpath(args[0])
  shortroot = opts.output
  if opts.destdir:
    output_root = os.path.join(os.path.normpath(opts.destdir), shortroot)
  else:
    output_root = shortroot

  if opts.destbase:
    basepath = os.path.normpath(opts.destbase)
  else:
    basepath = ''

  schema = _Load(opts.schema)
  description = _LoadFieldTrialConfig(description_filename)
  json_to_struct.GenerateStruct(
      basepath, output_root, opts.namespace, schema, description,
      os.path.split(description_filename)[1], os.path.split(opts.schema)[1],
      opts.year)