Beispiel #1
0
 def __init__(self, *args, **kwargs):
   super(JvmTask, self).__init__(*args, **kwargs)
   self.jvm = JVM.scoped_instance(self)
   self.jvm_options = self.jvm.get_jvm_options()
   self.args = self.jvm.get_program_args()
   self.confs = self.get_options().confs
   self.synthetic_classpath = self.jvm.get_options().synthetic_classpath
Beispiel #2
0
  def execute(self):
    indexable_targets = IndexableJavaTargets.get(self.context)
    targets_to_zinc_args = self.context.products.get_data('zinc_args')

    with self.invalidated(indexable_targets, invalidate_dependents=True) as invalidation_check:
      cp = self.tool_classpath('kythe-extractor')
      for vt in invalidation_check.invalid_vts:
        self.context.log.info('Kythe extracting from {}\n'.format(vt.target.address.spec))
        javac_args = self._get_javac_args_from_zinc_args(targets_to_zinc_args[vt.target])
        jvm_options = list(JVM.scoped_instance(self).get_jvm_options())
        jvm_options.extend([
          '-DKYTHE_CORPUS={}'.format(vt.target.address.spec),
          '-DKYTHE_ROOT_DIRECTORY={}'.format(vt.target.target_base),
          '-DKYTHE_OUTPUT_DIRECTORY={}'.format(vt.results_dir)
        ])

        result = self.dist.execute_java(
          classpath=cp, main=self._KYTHE_EXTRACTOR_MAIN,
          jvm_options=jvm_options, args=javac_args, workunit_name='kythe-extract')
        if result != 0:
          raise TaskError('java {main} ... exited non-zero ({result})'.format(
            main=self._KYTHE_EXTRACTOR_MAIN, result=result))

    for vt in invalidation_check.all_vts:
      created_files = os.listdir(vt.results_dir)
      if len(created_files) != 1:
        raise TaskError('Expected a single .kindex file in {}. Got: {}.'.format(
          vt.results_dir, ', '.join(created_files) if created_files else 'none'))
      kindex_files = self.context.products.get_data('kindex_files', dict)
      kindex_files[vt.target] = os.path.join(vt.results_dir, created_files[0])
Beispiel #3
0
  def __init__(self, *args, **kwargs):
    super(SquareIdea, self).__init__(*args, **kwargs)

    self.maven_style = self.get_options().maven_style
    self.intellij_output_dir = os.path.join(self.gen_project_workdir, 'out')
    self.nomerge = not self.get_options().merge
    self.open = self.get_options().open
    self.open_with = self.get_options().open_with
    self.bash = self.get_options().bash

    self.scala_language_level = _SCALA_VERSIONS.get(
      self.get_options().scala_language_level, None)
    self.scala_maximum_heap_size = self.get_options().scala_maximum_heap_size_mb

    self.fsc = self.get_options().fsc

    self.java_encoding = self.get_options().java_encoding
    self.java_maximum_heap_size = self.get_options().java_maximum_heap_size_mb

    idea_version = _VERSIONS[self.get_options().version]
    self.project_template = os.path.join(_TEMPLATE_BASEDIR,
                                         'project-{}.mustache'.format(idea_version))
    self.module_template = os.path.join(_TEMPLATE_BASEDIR,
                                        'module-{}.mustache'.format(idea_version))
    self.empty_module_file = os.path.join(_TEMPLATE_BASEDIR, 'empty-module.txt')

    self.project_filename = os.path.join(self.gen_project_workdir,
                                         '{}.ipr'.format(self.project_name))
    self.module_filename = os.path.join(self.gen_project_workdir,
                                        '{}.iml'.format(self.project_name))
    self.jvm = JVM.scoped_instance(self)
Beispiel #4
0
 def create_JVM(self, **kwargs):
   # Note: don't be confused by the fact that the JVM subsystem happens to have an option
   # named 'options', which we set in several tests below.  We name this method's arguments
   # kwargs instead of options to reduce this confusion.
   self.context(for_subsystems=[JVM], options={
     JVM.options_scope: kwargs
   })
   return JVM.global_instance()
Beispiel #5
0
 def create_JVM(self, **kwargs):
   # Note: don't be confused by the fact that the JVM subsystem happens to have an option
   # named 'options', which we set in several tests below.  We name this method's arguments
   # kwargs instead of options to reduce this confusion.
   self.context(for_subsystems=[JVM], options={
     JVM.options_scope: kwargs
   })
   return JVM.global_instance()
Beispiel #6
0
    def search_path():
      try:
        for location in JVM.global_instance().get_jdk_paths():
          yield cls._Location.from_home(location)
      except SubsystemError:
        logger.warning('Java distribution requested before JVM subsystem initialized.')
        pass

      yield env_home('JDK_HOME')
      yield env_home('JAVA_HOME')

      for location in cls._linux_java_homes():
        yield location

      for location in cls._osx_java_homes():
        yield location

      search_path = os.environ.get('PATH')
      if search_path:
        for bin_path in search_path.strip().split(os.pathsep):
          yield cls._Location.from_bin(bin_path)
Beispiel #7
0
        def search_path():
            try:
                for location in JVM.global_instance().get_jdk_paths():
                    yield cls._Location.from_home(location)
            except SubsystemError:
                logger.warning(
                    'Java distribution requested before JVM subsystem initialized.'
                )
                pass

            yield env_home('JDK_HOME')
            yield env_home('JAVA_HOME')

            for location in cls._linux_java_homes():
                yield location

            for location in cls._osx_java_homes():
                yield location

            search_path = os.environ.get('PATH')
            if search_path:
                for bin_path in search_path.strip().split(os.pathsep):
                    yield cls._Location.from_bin(bin_path)
Beispiel #8
0
 def subsystem_dependencies(cls):
     return super(JvmTask,
                  cls).subsystem_dependencies() + (JVM.scoped(cls), )
Beispiel #9
0
 def subsystem_dependencies(cls):
   return super(JvmTask, cls).subsystem_dependencies() + (JVM.scoped(cls),)
Beispiel #10
0
 def subsystem_dependencies(cls):
     return super().subsystem_dependencies() + (
         JVM.scoped(cls),
         DistributionLocator,
         JvmPlatform,
     )
Beispiel #11
0
 def subsystem_dependencies(cls):
   return super(ExtractJava, cls).subsystem_dependencies() + (JVM.scoped(cls),)
Beispiel #12
0
 def __init__(self, *args, **kwargs):
     super(JvmTask, self).__init__(*args, **kwargs)
     self.jvm = JVM.instance_for_task(self)
     self.jvm_options = self.jvm.get_jvm_options()
     self.args = self.jvm.get_program_args()
     self.confs = self.get_options().confs
Beispiel #13
0
 def __init__(self, *args, **kwargs):
   super(JvmTask, self).__init__(*args, **kwargs)
   self.jvm = JVM.instance_for_task(self)
   self.jvm_options = self.jvm.get_jvm_options()
   self.args = self.jvm.get_program_args()
   self.confs = self.get_options().confs