Exemplo n.º 1
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)
Exemplo 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)
Exemplo n.º 3
0
    def __init__(self, context):
        CodeGen.__init__(self, context)

        self.thrift_binary = select_binary(
            context.config.get('thrift-gen', 'supportdir'),
            (context.options.thrift_version
             or context.config.get('thrift-gen', 'version')), 'thrift')
        self.output_dir = (context.options.thrift_gen_create_outdir
                           or context.config.get('thrift-gen', 'workdir'))
        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 = OrderedSet()
            for dep in gen_info['deps']:
                deps.update(context.resolve(dep))
            return ThriftGen.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)
Exemplo n.º 4
0
    def __init__(self, context):
        CodeGen.__init__(self, context)

        self.protobuf_binary = select_binary(
            context.config.get('protobuf-gen', 'supportdir'),
            context.config.get('protobuf-gen', 'version'), 'protoc')

        self.output_dir = (context.options.protobuf_gen_create_outdir
                           or context.config.get('protobuf-gen', 'workdir'))

        def resolve_deps(key):
            deps = OrderedSet()
            for dep in context.config.getlist('protobuf-gen', key):
                deps.update(context.resolve(dep))
            return deps

        self.javadeps = resolve_deps('javadeps')
        self.java_out = os.path.join(self.output_dir, 'gen-java')

        self.pythondeps = resolve_deps('pythondeps')
        self.py_out = os.path.join(self.output_dir, 'gen-py')

        self.gen_langs = set(context.options.protobuf_gen_langs)
        for lang in ('java', 'python'):
            if self.context.products.isrequired(lang):
                self.gen_langs.add(lang)
Exemplo n.º 5
0
  def __init__(self, context):
    CodeGen.__init__(self, context)

    self.protobuf_binary = select_binary(
      context.config.get('protobuf-gen', 'supportdir'),
      context.config.get('protobuf-gen', 'version'),
      'protoc'
    )

    self.output_dir = (
      context.options.protobuf_gen_create_outdir
      or context.config.get('protobuf-gen', 'workdir')
    )

    def resolve_deps(key):
      deps = OrderedSet()
      for dep in context.config.getlist('protobuf-gen', 'javadeps'):
        deps.update(context.resolve(dep))
      return deps

    self.javadeps = resolve_deps('javadeps')
    self.java_out = os.path.join(self.output_dir, 'gen-java')

    self.pythondeps = resolve_deps('pythondeps')
    self.py_out = os.path.join(self.output_dir, 'gen-py')

    self.gen_langs = set(context.options.protobuf_gen_langs)
    for lang in ('java', 'python'):
      if self.context.products.isrequired(lang):
        self.gen_langs.add(lang)
Exemplo n.º 6
0
  def __init__(self, context):
    CodeGen.__init__(self, context)

    self.thrift_binary = select_binary(
      context.config.get('thrift-gen', 'supportdir'),
      context.config.get('thrift-gen', 'version'),
      'thrift'
    )
    self.output_dir = (
      context.options.thrift_gen_create_outdir
      or context.config.get('thrift-gen', 'workdir')
    )
    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 = OrderedSet()
      for dep in gen_info['deps']:
        deps.update(context.resolve(dep))
      return ThriftGen.GenInfo(gen, deps)

    self.gen_java = create_geninfo('java')
    self.gen_python = create_geninfo('python')
    self.gen_langs = set(context.options.thrift_gen_langs)
Exemplo n.º 7
0
    def __init__(self, context):
        CodeGen.__init__(self, context)
        self.thriftstore_admin = context.config.get('thriftstore-dml-gen',
                                                    'thriftstore-admin')

        self.output_dir = (context.options.thriftstore_gen_create_outdir
                           or context.config.get('thriftstore-dml-gen',
                                                 'workdir'))

        self.verbose = context.config.getbool('thriftstore-dml-gen', 'verbose')

        def create_javadeps():
            gen_info = context.config.getlist('thriftstore-dml-gen',
                                              'javadeps')
            deps = OrderedSet()
            for dep in gen_info:
                deps.update(context.resolve(dep))
            return deps

        def is_thriftstore_dml_instance(target):
            return isinstance(target, JavaThriftstoreDMLLibrary)

        # Resolved java library targets go in javadeps
        self.javadeps = create_javadeps()

        self.gen_thriftstore_java_dir = os.path.join(self.output_dir,
                                                     'gen-thriftstore-java')

        def insert_java_dml_targets():
            self.gen_dml_jls = {}
            # Create a synthetic java library for each dml target
            for dml_lib_target in context.targets(is_thriftstore_dml_instance):
                # Add one JavaThriftLibrary target
                thrift_dml_lib = self.context.add_new_target(
                    dml_lib_target.
                    target_base,  # Dir where sources are relative to
                    JavaThriftLibrary,
                    name=dml_lib_target.id,
                    sources=dml_lib_target.sources,
                    derived_from=dml_lib_target)
                # Add one generated JavaLibrary target (whose sources we will fill in later on)
                java_dml_lib = self.context.add_new_target(
                    self.gen_thriftstore_java_dir,
                    JavaLibrary,
                    name=dml_lib_target.id,
                    sources=[],
                    dependencies=self.javadeps,
                    derived_from=dml_lib_target)
                java_dml_lib.id = dml_lib_target.id + '.thriftstore_dml_gen'
                java_dml_lib.add_label('codegen')
                java_dml_lib.update_dependencies([thrift_dml_lib])
                self.gen_dml_jls[dml_lib_target] = java_dml_lib

            for dependee, dmls in context.dependents(
                    is_thriftstore_dml_instance).items():
                jls = map(lambda dml: self.gen_dml_jls[dml], dmls)
                dependee.update_dependencies(jls)

        insert_java_dml_targets()
Exemplo n.º 8
0
  def __init__(self, context):
    CodeGen.__init__(self, context)
    NailgunTask.__init__(self, context)

    # TODO(John Sirois): kill if not needed by prepare_gen
    self._classpath_by_compiler = {}

    active_compilers = set(map(lambda t: t.compiler, context.targets(predicate=self.is_gentarget)))
    for compiler, tools in self._all_possible_antlr_bootstrap_tools():
      if compiler in active_compilers:
        self._jvm_tool_bootstrapper.register_jvm_tool(compiler, tools)
Exemplo n.º 9
0
  def __init__(self, context):
    CodeGen.__init__(self, context)
    self.thriftstore_codegen = context.config.get('thriftstore-dml-gen', 'thriftstore-codegen')

    self.output_dir = (context.options.thriftstore_gen_create_outdir
      or context.config.get('thriftstore-dml-gen', 'workdir'))


    self.verbose = context.config.getbool('thriftstore-dml-gen', 'verbose')

    def create_javadeps():
      gen_info = context.config.getlist('thriftstore-dml-gen', 'javadeps')
      deps = OrderedSet()
      for dep in gen_info:
        deps.update(context.resolve(dep))
      return deps

    def is_thriftstore_dml_instance(target):
      return isinstance(target, JavaThriftstoreDMLLibrary)

    # Resolved java library targets go in javadeps
    self.javadeps = create_javadeps()

    self.gen_thriftstore_java_dir = os.path.join(self.output_dir, 'gen-thriftstore-java')

    def insert_java_dml_targets():
      self.gen_dml_jls = {}
      # Create a synthetic java library for each dml target
      for dml_lib_target in context.targets(is_thriftstore_dml_instance):
        # Add one JavaThriftLibrary target
        thrift_dml_lib = self.context.add_new_target(dml_lib_target.target_base, # Dir where sources are relative to
                                                     JavaThriftLibrary,
                                                     name=dml_lib_target.id,
                                                     sources=dml_lib_target.sources,
                                                     dependencies=dml_lib_target.dependencies,
                                                     derived_from=dml_lib_target)
        # Add one generated JavaLibrary target (whose sources we will fill in later on)
        java_dml_lib = self.context.add_new_target(self.gen_thriftstore_java_dir,
                                                   JavaLibrary,
                                                   name=dml_lib_target.id,
                                                   sources=[],
                                                   dependencies=self.javadeps,
                                                   derived_from=dml_lib_target)
        java_dml_lib.id = dml_lib_target.id + '.thriftstore_dml_gen'
        java_dml_lib.add_labels('synthetic')
        java_dml_lib.update_dependencies([thrift_dml_lib])
        self.gen_dml_jls[dml_lib_target] = java_dml_lib

      for dependee, dmls in context.dependents(is_thriftstore_dml_instance).items():
        jls = map(lambda dml: self.gen_dml_jls[dml], dmls)
        dependee.update_dependencies(jls)

    insert_java_dml_targets()
Exemplo n.º 10
0
    def __init__(self, context):
        CodeGen.__init__(self, context)
        NailgunTask.__init__(self, context)

        # TODO(John Sirois): kill if not needed by prepare_gen
        self._classpath_by_compiler = {}

        active_compilers = set(
            map(lambda t: t.compiler,
                context.targets(predicate=self.is_gentarget)))
        for compiler, tools in self._all_possible_antlr_bootstrap_tools():
            if compiler in active_compilers:
                self._jvm_tool_bootstrapper.register_jvm_tool(compiler, tools)
Exemplo n.º 11
0
  def __init__(self, context):
    CodeGen.__init__(self, context)
    NailgunTask.__init__(self, context)

    for compiler, tools in self._all_possible_antlr_bootstrap_tools():
      self._jvm_tool_bootstrapper.register_jvm_tool(compiler, tools)
Exemplo n.º 12
0
 def __init__(self, context):
     CodeGen.__init__(self, context)
     NailgunTask.__init__(self, context)
Exemplo n.º 13
0
 def __init__(self, context):
   CodeGen.__init__(self, context)
   NailgunTask.__init__(self, context)
Exemplo n.º 14
0
  def __init__(self, context):
    CodeGen.__init__(self, context)
    NailgunTask.__init__(self, context)

    for compiler, tools in self._all_possible_antlr_bootstrap_tools():
      self._bootstrap_utils.register_jvm_build_tools(compiler, tools)