From 5297be8dbdadf3d30f4e8f04570bb0f3a569144a Mon Sep 17 00:00:00 2001 From: Yi Cheng Date: Sat, 24 Oct 2015 12:43:18 -0700 Subject: [PATCH] Add --compile-zinc-debug-symbols option This standardizes providing debug-symbol flags, to help prevent going out of sync between cache population nodes and IDEs. Testing Done: CI: https://travis-ci.org/pantsbuild/pants/builds/87220079 Bugs closed: 2428 Reviewed at https://rbcommons.com/s/twitter/r/3013/ --- .../backend/jvm/tasks/jvm_compile/jvm_compile.py | 16 +++++++++++++--- .../zinc/test_zinc_compile_integration.py | 6 ++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/python/pants/backend/jvm/tasks/jvm_compile/jvm_compile.py b/src/python/pants/backend/jvm/tasks/jvm_compile/jvm_compile.py index b5dcffe41c2..f878181b48a 100644 --- a/src/python/pants/backend/jvm/tasks/jvm_compile/jvm_compile.py +++ b/src/python/pants/backend/jvm/tasks/jvm_compile/jvm_compile.py @@ -100,17 +100,24 @@ def register_options(cls, register): help='When set, any invalid/incompatible analysis files will be deleted ' 'automatically. When unset, an error is raised instead.') - register('--warnings', default=True, action='store_true', + register('--warnings', default=True, action='store_true', fingerprint=True, help='Compile with all configured warnings enabled.') - register('--warning-args', advanced=True, action='append', + register('--warning-args', advanced=True, action='append', fingerprint=True, default=list(cls.get_warning_args_default()), help='Extra compiler args to use when warnings are enabled.') - register('--no-warning-args', advanced=True, action='append', + register('--no-warning-args', advanced=True, action='append', fingerprint=True, default=list(cls.get_no_warning_args_default()), help='Extra compiler args to use when warnings are disabled.') + register('--debug-symbols', default=False, action='store_true', fingerprint=True, + help='Compile with debug symbol enabled.') + + register('--debug-symbol-args', advanced=True, action='append', fingerprint=True, + default=['-C-g:lines,source,vars'], + help='Extra args to enable debug symbol.') + register('--delete-scratch', advanced=True, default=True, action='store_true', help='Leave intermediate scratch files around, for debugging build problems.') @@ -257,6 +264,9 @@ def __init__(self, *args, **kwargs): else: self._args.extend(self.get_options().no_warning_args) + if self.get_options().debug_symbols: + self._args.extend(self.get_options().debug_symbol_args) + # The ivy confs for which we're building. self._confs = self.get_options().confs diff --git a/tests/python/pants_test/backend/jvm/tasks/jvm_compile/zinc/test_zinc_compile_integration.py b/tests/python/pants_test/backend/jvm/tasks/jvm_compile/zinc/test_zinc_compile_integration.py index b2129419736..4896d4f972f 100644 --- a/tests/python/pants_test/backend/jvm/tasks/jvm_compile/zinc/test_zinc_compile_integration.py +++ b/tests/python/pants_test/backend/jvm/tasks/jvm_compile/zinc/test_zinc_compile_integration.py @@ -79,6 +79,12 @@ def test_scalac_plugin_compile(self): self.assertEqual('org.pantsbuild.testproject.scalac.plugin.HelloScalac', root.find('classname').text) + def test_scalac_debug_symbol(self): + with self.do_test_compile('testprojects/src/scala/org/pantsbuild/testproject/scalac/plugin', + expected_files=['HelloScalac.class', 'scalac-plugin.xml'], + extra_args=['--compile-zinc-debug-symbols']) as found: + pass + def test_zinc_unsupported_option(self): with temporary_dir(root_dir=self.workdir_root()) as workdir: with temporary_dir(root_dir=self.workdir_root()) as cachedir: