Пример #1
0
    def execute(self):
        archive = self.get_options().archive
        if archive == 'none':
            return

        indexable_targets = IndexableJavaTargets.global_instance().get(
            self.context)
        for tgt in indexable_targets:
            entries = self.context.products.get_data('kythe_entries_files',
                                                     dict)[tgt]
            kythe_distdir = os.path.join(self.get_options().pants_distdir,
                                         'kythe')
            safe_mkdir(kythe_distdir)
            uncompressed_kythe_distpath = os.path.join(
                kythe_distdir, '{}.entries'.format(tgt.address.path_safe_spec))
            if archive == 'uncompressed':
                kythe_distpath = uncompressed_kythe_distpath
                shutil.copy(entries, kythe_distpath)
            else:
                kythe_distpath = shutil.make_archive(
                    base_name=uncompressed_kythe_distpath,
                    format=archive,
                    root_dir=os.path.dirname(entries),
                    base_dir=os.path.basename(entries))
            self.context.log.info(
                'Copied entries to {}'.format(kythe_distpath))
Пример #2
0
  def execute(self):
    indexable_targets = IndexableJavaTargets.global_instance().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:
      extractor_cp = self.tool_classpath('kythe-java-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])
        # Kythe jars embed a copy of Java 9's com.sun.tools.javac and javax.tools, for use on JDK8.
        # We must put these jars on the bootclasspath, ahead of any others, to ensure that we load
        # the Java 9 versions, and not the runtime's versions.
        jvm_options = ['-Xbootclasspath/p:{}'.format(':'.join(extractor_cp))]
        jvm_options.extend(self.get_options().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=extractor_cp, main=self._KYTHE_JAVA_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_JAVA_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])
    def execute(self):
        indexable_targets = IndexableJavaTargets.global_instance().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:
            extractor_cp = self.tool_classpath('kythe-java-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 = []
                if self.dist.version < Revision.lenient('9'):
                    # When run on JDK8, Kythe requires javac9 on the bootclasspath.
                    javac9_cp = self.tool_classpath('javac9')
                    jvm_options.append('-Xbootclasspath/p:{}'.format(
                        ':'.join(javac9_cp)))
                jvm_options.extend(self.get_options().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=extractor_cp,
                    main=self._KYTHE_JAVA_EXTRACTOR_MAIN,
                    jvm_options=jvm_options,
                    args=javac_args,
                    create_synthetic_jar=False,
                    workunit_factory=self.context.new_workunit,
                    workunit_name='kythe-extract')
                if result != 0:
                    raise TaskError(
                        'java {main} ... exited non-zero ({result})'.format(
                            main=self._KYTHE_JAVA_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 .kzip file in {}. Got: {}.'.format(
                        vt.results_dir,
                        ', '.join(created_files) if created_files else 'none'))
            kzip_files = self.context.products.get_data('kzip_files', dict)
            kzip_files[vt.target] = os.path.join(vt.results_dir,
                                                 created_files[0])
Пример #4
0
    def execute(self):
        indexable_targets = IndexableJavaTargets.global_instance().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:
            extractor_cp = self.tool_classpath('kythe-java-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])
                # Kythe jars embed a copy of Java 9's com.sun.tools.javac and javax.tools, for use on JDK8.
                # We must put these jars on the bootclasspath, ahead of any others, to ensure that we load
                # the Java 9 versions, and not the runtime's versions.
                jvm_options = [
                    '-Xbootclasspath/p:{}'.format(':'.join(extractor_cp))
                ]
                jvm_options.extend(self.get_options().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=extractor_cp,
                    main=self._KYTHE_JAVA_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_JAVA_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])
Пример #5
0
  def execute(self):
    indexable_targets = IndexableJavaTargets.global_instance().get(self.context)

    with self.invalidated(indexable_targets, invalidate_dependents=True) as invalidation_check:
      if invalidation_check.invalid_vts:
        indexer_cp = self.tool_classpath('kythe-java-indexer')
        # Kythe jars embed a copy of Java 9's com.sun.tools.javac and javax.tools, for use on JDK8.
        # We must put these jars on the bootclasspath, ahead of any others, to ensure that we load
        # the Java 9 versions, and not the runtime's versions.
        jvm_options = ['-Xbootclasspath/p:{}'.format(':'.join(indexer_cp))]
        jvm_options.extend(self.get_options().jvm_options)

        for vt in invalidation_check.invalid_vts:
          self._index(vt, indexer_cp, jvm_options)

    for vt in invalidation_check.all_vts:
      entries = self._entries_file(vt)
      self.context.products.get_data('kythe_entries_files', dict)[vt.target] = entries
Пример #6
0
  def execute(self):
    indexable_targets = IndexableJavaTargets.global_instance().get(self.context)

    with self.invalidated(indexable_targets, invalidate_dependents=True) as invalidation_check:
      if invalidation_check.invalid_vts:
        indexer_cp = self.tool_classpath('kythe-java-indexer')
        jvm_options = []
        if self.dist.version < Revision.lenient('9'):
          # When run on JDK8, Kythe requires javac9 on the bootclasspath.
          javac9_cp = self.tool_classpath('javac9')
          jvm_options.append('-Xbootclasspath/p:{}'.format(':'.join(javac9_cp)))
        jvm_options.extend(self.get_options().jvm_options)

        for vt in invalidation_check.invalid_vts:
          self._index(vt, indexer_cp, jvm_options)

    for vt in invalidation_check.all_vts:
      entries = self._entries_file(vt)
      self.context.products.get_data('kythe_entries_files', dict)[vt.target] = entries
Пример #7
0
    def execute(self):
        indexable_targets = IndexableJavaTargets.global_instance().get(self.context)

        with self.invalidated(indexable_targets, invalidate_dependents=True) as invalidation_check:
            if invalidation_check.invalid_vts:
                indexer_cp = self.tool_classpath("kythe-java-indexer")
                jvm_options = []
                if self.dist.version < Revision.lenient("9"):
                    # When run on JDK8, Kythe requires javac9 on the bootclasspath.
                    javac9_cp = self.tool_classpath("javac9")
                    jvm_options.append("-Xbootclasspath/p:{}".format(":".join(javac9_cp)))
                jvm_options.extend(self.get_options().jvm_options)

                for vt in invalidation_check.invalid_vts:
                    self._index(vt, indexer_cp, jvm_options)

        for vt in invalidation_check.all_vts:
            entries = self._entries_file(vt)
            self.context.products.get_data("kythe_entries_files", dict)[vt.target] = entries
Пример #8
0
  def execute(self):
    indexable_targets = IndexableJavaTargets.global_instance().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:
      extractor_cp = self.tool_classpath('kythe-java-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 = []
        if self.dist.version < Revision.lenient('9'):
          # When run on JDK8, Kythe requires javac9 on the bootclasspath.
          javac9_cp = self.tool_classpath('javac9')
          jvm_options.append('-Xbootclasspath/p:{}'.format(':'.join(javac9_cp)))
        jvm_options.extend(self.get_options().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=extractor_cp, main=self._KYTHE_JAVA_EXTRACTOR_MAIN,
          jvm_options=jvm_options, args=javac_args, create_synthetic_jar=False,
          workunit_factory=self.context.new_workunit, workunit_name='kythe-extract')
        if result != 0:
          raise TaskError('java {main} ... exited non-zero ({result})'.format(
            main=self._KYTHE_JAVA_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 .kzip file in {}. Got: {}.'.format(
          vt.results_dir, ', '.join(created_files) if created_files else 'none'))
      kzip_files = self.context.products.get_data('kzip_files', dict)
      kzip_files[vt.target] = os.path.join(vt.results_dir, created_files[0])
Пример #9
0
    def execute(self):
        indexable_targets = IndexableJavaTargets.global_instance().get(
            self.context)

        with self.invalidated(
                indexable_targets,
                invalidate_dependents=True) as invalidation_check:
            if invalidation_check.invalid_vts:
                indexer_cp = self.tool_classpath('kythe-java-indexer')
                # Kythe jars embed a copy of Java 9's com.sun.tools.javac and javax.tools, for use on JDK8.
                # We must put these jars on the bootclasspath, ahead of any others, to ensure that we load
                # the Java 9 versions, and not the runtime's versions.
                jvm_options = [
                    '-Xbootclasspath/p:{}'.format(':'.join(indexer_cp))
                ]
                jvm_options.extend(self.get_options().jvm_options)

                for vt in invalidation_check.invalid_vts:
                    self._index(vt, indexer_cp, jvm_options)

        for vt in invalidation_check.all_vts:
            entries = self._entries_file(vt)
            self.context.products.get_data('kythe_entries_files',
                                           dict)[vt.target] = entries