Skip to content

Commit

Permalink
Bump to latest zinc and remove the extractor. (pantsbuild#8246)
Browse files Browse the repository at this point in the history
### Problem

pantsbuild#8239 uses a nailgun API to avoid exiting: we need to incorporate it. Additionally, the zinc-extractor is no longer used after pantsbuild#8125.

### Solution

Remove the `zinc-extractor` code, and bump to latest `zinc-compiler`.
  • Loading branch information
stuhood authored Sep 22, 2019
1 parent 9568087 commit 608e7a5
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 292 deletions.
18 changes: 2 additions & 16 deletions src/python/pants/backend/jvm/subsystems/zinc.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,18 @@
from pants.util.memo import memoized_method, memoized_property


_ZINC_COMPILER_VERSION = '0.0.14'
_ZINC_COMPILER_VERSION = '0.0.17'


class Zinc:
"""Configuration for Pants' zinc wrapper tool."""

ZINC_COMPILE_MAIN = 'org.pantsbuild.zinc.compiler.Main'
ZINC_BOOTSTRAPER_MAIN = 'org.pantsbuild.zinc.bootstrapper.Main'
ZINC_EXTRACT_MAIN = 'org.pantsbuild.zinc.extractor.Main'
DEFAULT_CONFS = ['default']

ZINC_COMPILER_TOOL_NAME = 'zinc'
ZINC_BOOTSTRAPPER_TOOL_NAME = 'zinc-bootstrapper'
ZINC_EXTRACTOR_TOOL_NAME = 'zinc-extractor'

_lock = Lock()

Expand Down Expand Up @@ -82,7 +80,7 @@ def register_options(cls, register):
cls.register_jvm_tool(register,
Zinc.ZINC_BOOTSTRAPPER_TOOL_NAME,
classpath=[
JarDependency('org.pantsbuild', 'zinc-bootstrapper_2.12', '0.0.11'),
JarDependency('org.pantsbuild', 'zinc-bootstrapper_2.12', '0.0.12'),
],
main=Zinc.ZINC_BOOTSTRAPER_MAIN,
custom_rules=shader_rules,
Expand Down Expand Up @@ -119,12 +117,6 @@ def register_options(cls, register):
main='no.such.main.Main',
custom_rules=shader_rules)

cls.register_jvm_tool(register,
Zinc.ZINC_EXTRACTOR_TOOL_NAME,
classpath=[
JarDependency('org.pantsbuild', 'zinc-extractor_2.12', '0.0.12')
])

# Register scalac for fixed versions of Scala, 2.10, 2.11 and 2.12.
# Relies on ScalaPlatform to get the revision version from the major.minor version.
# The tool with the correct scala version will be retrieved later,
Expand Down Expand Up @@ -398,12 +390,6 @@ def cp(instance, toolname):
cp(scala_options_src, 'scalac-plugin-dep'))
return [(conf, jar) for conf in self.DEFAULT_CONFS for jar in classpaths]

@memoized_property
def extractor(self):
return self._zinc_factory.tool_classpath_from_products(self._products,
self.ZINC_EXTRACTOR_TOOL_NAME,
scope=self._zinc_factory.options_scope)

def compile_classpath_entries(self, classpath_product_key, target, extra_cp_entries=None):
classpath_product = self._products.get_data(classpath_product_key)
dependencies = DependencyContext.global_instance().dependencies_respecting_strict_deps(target)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ def register_options(cls, register):
'This is unset by default, because it is generally a good precaution to cache '
'only clean/cold builds.')

register('--use-barebones-logger', advanced=True, type=bool, default=False,
help='Use our own implementation of the SBT logger in the Zinc compiler. '
'This is experimental, but it provides great speedups in native-images of Zinc.')

@classmethod
def subsystem_dependencies(cls):
return super().subsystem_dependencies() + (Zinc.Factory, JvmPlatform,)
Expand Down Expand Up @@ -290,6 +294,9 @@ def relative_to_exec_root(path):
post_compile_merge_dir = relative_to_exec_root(ctx.post_compile_merge_dir)
zinc_args.extend(['--post-compile-merge-dir', post_compile_merge_dir])

if self.get_options().use_barebones_logger:
zinc_args.append('--use-barebones-logger')

compiler_bridge_classpath_entry = self._zinc.compile_compiler_bridge(self.context)
zinc_args.extend(['-compiled-bridge-jar', relative_to_exec_root(compiler_bridge_classpath_entry.path)])
zinc_args.extend(['-scala-path', ':'.join(scala_path)])
Expand Down
21 changes: 0 additions & 21 deletions src/scala/org/pantsbuild/zinc/extractor/BUILD

This file was deleted.

78 changes: 0 additions & 78 deletions src/scala/org/pantsbuild/zinc/extractor/Extractor.scala

This file was deleted.

103 changes: 0 additions & 103 deletions src/scala/org/pantsbuild/zinc/extractor/Main.scala

This file was deleted.

46 changes: 0 additions & 46 deletions src/scala/org/pantsbuild/zinc/extractor/Settings.scala

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -251,30 +251,49 @@ def test_combination(target, expect_success, extra_args=[]):
test_combination('fatal', expect_success=False,
extra_args=['--compile-rsc-compiler-option-sets-disabled-args={"fatal_warnings": ["-S-Xfatal-warnings"]}'])

def test_zinc_logs_warnings_properly(self):
"""Test that the zinc logger emits warnings correctly."""
# TODO(#8306) When the new zinc-compiler version is published (0.0.17), add the test linked in the issue here.
def _compile_unused_import(self, use_barebones_logger=False):
# Compile a target that we expect will raise an "Unused import" warning.
with self.temporary_workdir() as workdir:
with self.temporary_cachedir() as cachedir:
# Compile a target that we expect will raise an "Unused import" warning.
args = [
'--compile-rsc-args=+["-S-Ywarn-unused:_"]',
'-ldebug',
] + (['--compile-rsc-use-barebones-logger'] if use_barebones_logger else [])
pants_run = self.run_test_compile(
workdir,
cachedir,
'testprojects/src/scala/org/pantsbuild/testproject/compilation_warnings/unused_import_warning:unused_import',
extra_args=[
'--compile-rsc-args=+["-S-Ywarn-unused:_"]'
])
workdir,
cachedir,
'testprojects/src/scala/org/pantsbuild/testproject/compilation_warnings/unused_import_warning:unused_import',
extra_args=args
)
self.assert_success(pants_run)
return pants_run

# Confirm that we were warned in the expected format.
expected_strings =[
"/testprojects/src/scala/org/pantsbuild/testproject/compilation_warnings/unused_import_warning/UnusedImportWarning.scala:2:14: Unused import",
"[warn] import scala.List // Unused import warning",
"[warn] one warning found"
]

for expected in expected_strings:
self.assertIn(expected, pants_run.stdout_data)
def test_zinc_logs_warnings_properly(self):
"""Test that, with the standard logger, we log the warning in the expected format."""
pants_run = self._compile_unused_import()
# Confirm that we were warned in the expected format.
expected_strings =[
"/testprojects/src/scala/org/pantsbuild/testproject/compilation_warnings/unused_import_warning/UnusedImportWarning.scala:2:14: Unused import",
"[warn] import scala.List // Unused import warning",
"[warn] one warning found"
]

for expected in expected_strings:
self.assertIn(expected, pants_run.stdout_data)

def test_barebones_logger_works(self):
"""
Test that the barebones logger logs the expected warning.
TODO(#8312): this should be synced up with the normal logging output in order to use native-image zinc!
"""
pants_run = self._compile_unused_import(use_barebones_logger=True)
expected_strings =[
"/testprojects/src/scala/org/pantsbuild/testproject/compilation_warnings/unused_import_warning/UnusedImportWarning.scala",
"[warn] one warning found"
]

for expected in expected_strings:
self.assertIn(expected, pants_run.stdout_data)

@unittest.expectedFailure
def test_soft_excludes_at_compiletime(self):
Expand Down
Loading

0 comments on commit 608e7a5

Please sign in to comment.