Ejemplo n.º 1
0
    def _run_thrift(self, source, bases):
        thrift_file = source
        thrift_abs_path = os.path.abspath(os.path.join(self.root, thrift_file))

        args = [
            select_thrift_binary(self.config), '--gen', 'py:new_style',
            '-recurse', '-o', self.codegen_root
        ]

        # Add bases as include paths to try.  Note that include paths and compile targets
        # should be uniformly relative, or uniformly absolute (in this case the latter).
        for base in bases:
            args.extend(('-I', os.path.join(get_buildroot(), base)))
        args.append(thrift_abs_path)

        po = subprocess.Popen(args, cwd=self.chroot.path())
        rv = po.wait()
        if rv != 0:
            comm = po.communicate()
            print('thrift generation failed!', file=sys.stderr)
            print('STDOUT', file=sys.stderr)
            print(comm[0], file=sys.stderr)
            print('STDERR', file=sys.stderr)
            print(comm[1], file=sys.stderr)
        return rv == 0
Ejemplo n.º 2
0
  def __init__(self, context):
    CodeGen.__init__(self, context)

    output_dir = (
      context.options.thrift_gen_create_outdir
      or context.config.get('thrift-gen', 'workdir')
    )
    self.combined_dir = os.path.join(output_dir, 'combined')
    self.session_dir = os.path.join(output_dir, 'sessions')

    self.strict = context.config.getbool('thrift-gen', 'strict')
    self.verbose = context.config.getbool('thrift-gen', 'verbose')

    def create_geninfo(key):
      gen_info = context.config.getdict('thrift-gen', key)
      gen = gen_info['gen']
      deps = {}
      for category, depspecs in gen_info['deps'].items():
        dependencies = OrderedSet()
        deps[category] = dependencies
        for depspec in depspecs:
          dependencies.update(context.resolve(depspec))
      return self.GenInfo(gen, deps)

    self.gen_java = create_geninfo('java')
    self.gen_python = create_geninfo('python')

    self.gen_langs = set(context.options.thrift_gen_langs)
    for lang in ('java', 'python'):
      if self.context.products.isrequired(lang):
        self.gen_langs.add(lang)

    self.thrift_binary = select_thrift_binary(context.config,
                                              version=context.options.thrift_version)
Ejemplo n.º 3
0
  def _run_thrift(self, source, bases):
    thrift_file = source
    thrift_abs_path = os.path.join(self.root, thrift_file)
    thrift_abs_path = os.path.abspath(thrift_abs_path)

    args = [
      select_thrift_binary(self.config),
      '--gen',
      'py:new_style,utf8strings',
      '-recurse',
      '-o',
      os.path.join(self.chroot.path(), self.codegen_root)
    ]
    for base in bases:
      args.extend(('-I', base))
    args.append(thrift_abs_path)

    po = subprocess.Popen(args)
    rv = po.wait()
    if rv != 0:
      comm = po.communicate()
      print('thrift generation failed!', file=sys.stderr)
      print('STDOUT', file=sys.stderr)
      print(comm[0], file=sys.stderr)
      print('STDERR', file=sys.stderr)
      print(comm[1], file=sys.stderr)
    return rv == 0
Ejemplo n.º 4
0
    def __init__(self, context):
        CodeGen.__init__(self, context)

        output_dir = (context.options.thrift_gen_create_outdir
                      or context.config.get('thrift-gen', 'workdir'))
        self.combined_dir = os.path.join(output_dir, 'combined')
        self.session_dir = os.path.join(output_dir, 'sessions')

        self.strict = context.config.getbool('thrift-gen', 'strict')
        self.verbose = context.config.getbool('thrift-gen', 'verbose')

        def create_geninfo(key):
            gen_info = context.config.getdict('thrift-gen', key)
            gen = gen_info['gen']
            deps = {}
            for category, depspecs in gen_info['deps'].items():
                dependencies = OrderedSet()
                deps[category] = dependencies
                for depspec in depspecs:
                    dependencies.update(context.resolve(depspec))
            return self.GenInfo(gen, deps)

        self.gen_java = create_geninfo('java')
        self.gen_python = create_geninfo('python')

        self.gen_langs = set(context.options.thrift_gen_langs)
        for lang in ('java', 'python'):
            if self.context.products.isrequired(lang):
                self.gen_langs.add(lang)

        self.thrift_binary = select_thrift_binary(
            context.config, version=context.options.thrift_version)
Ejemplo n.º 5
0
  def _run_thrift(self, source, bases):
    thrift_file = source
    thrift_abs_path = os.path.abspath(os.path.join(self.root, thrift_file))

    args = [
      select_thrift_binary(self.config),
      '--gen',
      'py:new_style',
      '-recurse',
      '-o',
      self.codegen_root
    ]

    # Add bases as include paths to try.  Note that include paths and compile targets
    # should be uniformly relative, or uniformly absolute (in this case the latter).
    for base in bases:
      args.extend(('-I', os.path.join(get_buildroot(), base)))
    args.append(thrift_abs_path)

    po = subprocess.Popen(args, cwd=self.chroot.path())
    rv = po.wait()
    if rv != 0:
      comm = po.communicate()
      print('thrift generation failed!', file=sys.stderr)
      print('STDOUT', file=sys.stderr)
      print(comm[0], file=sys.stderr)
      print('STDERR', file=sys.stderr)
      print(comm[1], file=sys.stderr)
    return rv == 0
Ejemplo n.º 6
0
  def _run_thrift(self, source, bases):
    thrift_file = source
    thrift_abs_path = os.path.join(self.root, thrift_file)
    thrift_abs_path = os.path.abspath(thrift_abs_path)

    args = [
      select_thrift_binary(self.config),
      '--gen',
      'py:new_style',
      '-recurse',
      '-o',
      self.codegen_root
    ]
    for base in bases:
      args.extend(('-I', base))
    args.append(thrift_abs_path)

    cwd = os.getcwd()
    os.chdir(self.chroot.path())
    try:
      po = subprocess.Popen(args)
    finally:
      os.chdir(cwd)
    rv = po.wait()
    if rv != 0:
      comm = po.communicate()
      print('thrift generation failed!', file=sys.stderr)
      print('STDOUT', file=sys.stderr)
      print(comm[0], file=sys.stderr)
      print('STDERR', file=sys.stderr)
      print(comm[1], file=sys.stderr)
    return rv == 0
Ejemplo n.º 7
0
    def _run_thrift(self, source):
        args = [
            select_thrift_binary(self.config), '--gen', 'py:new_style', '-o',
            self.codegen_root, '-I', self._workdir,
            os.path.abspath(source)
        ]

        po = subprocess.Popen(args, cwd=self.chroot.path())
        rv = po.wait()
        if rv != 0:
            comm = po.communicate()
            print('thrift generation failed!', file=sys.stderr)
            print('STDOUT', file=sys.stderr)
            print(comm[0], file=sys.stderr)
            print('STDERR', file=sys.stderr)
            print(comm[1], file=sys.stderr)
        return rv == 0
Ejemplo n.º 8
0
  def _run_thrift(self, source):
    args = [
        select_thrift_binary(self.config),
        '--gen',
        'py:new_style',
        '-o', self.codegen_root,
        '-I', self._workdir,
        os.path.abspath(source)]

    po = subprocess.Popen(args, cwd=self.chroot.path())
    rv = po.wait()
    if rv != 0:
      comm = po.communicate()
      print('thrift generation failed!', file=sys.stderr)
      print('STDOUT', file=sys.stderr)
      print(comm[0], file=sys.stderr)
      print('STDERR', file=sys.stderr)
      print(comm[1], file=sys.stderr)
    return rv == 0
Ejemplo n.º 9
0
    def _run_thrift(self, source):
        args = [
            select_thrift_binary(self.config),
            "--gen",
            "py:new_style",
            "-o",
            self.codegen_root,
            "-I",
            self._workdir,
            os.path.abspath(source),
        ]

        po = subprocess.Popen(args, cwd=self.chroot.path())
        rv = po.wait()
        if rv != 0:
            comm = po.communicate()
            print("thrift generation failed!", file=sys.stderr)
            print("STDOUT", file=sys.stderr)
            print(comm[0], file=sys.stderr)
            print("STDERR", file=sys.stderr)
            print(comm[1], file=sys.stderr)
        return rv == 0