本文整理汇总了Python中pants.backend.jvm.subsystems.scala_platform.ScalaPlatform.global_instance方法的典型用法代码示例。如果您正苦于以下问题:Python ScalaPlatform.global_instance方法的具体用法?Python ScalaPlatform.global_instance怎么用?Python ScalaPlatform.global_instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pants.backend.jvm.subsystems.scala_platform.ScalaPlatform
的用法示例。
在下文中一共展示了ScalaPlatform.global_instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _language_platform_version_info
# 需要导入模块: from pants.backend.jvm.subsystems.scala_platform import ScalaPlatform [as 别名]
# 或者: from pants.backend.jvm.subsystems.scala_platform.ScalaPlatform import global_instance [as 别名]
def _language_platform_version_info(self):
ret = []
# Go through all the bootstrap tools required to compile.
targets = (ScalaPlatform.global_instance().tool_targets(self.context, 'scalac') +
self.tool_targets(self.context, 'zinc'))
for lib in (t for t in targets if isinstance(t, JarLibrary)):
for jar in lib.jar_dependencies:
ret.append(jar.cache_key())
# We must invalidate on the set of plugins and their settings.
ret.extend(self.plugin_args())
# Invalidate if any compiler args change.
# Note that while some args are obviously important for invalidation (e.g., the jvm target
# version), some might not be. However we must invalidated on all the args, because Zinc
# ignores analysis files if the compiler args they were created with are different from the
# current ones, and does a full recompile. So if we allow cached artifacts with those analysis
# files to be used, Zinc will do unnecessary full recompiles on subsequent edits.
ret.extend(self._args)
# Invalidate if use of name hashing changes.
ret.append('name-hashing-{0}'.format('on' if self.get_options().name_hashing else 'off'))
return ret
示例2: create_scaladoc_command
# 需要导入模块: from pants.backend.jvm.subsystems.scala_platform import ScalaPlatform [as 别名]
# 或者: from pants.backend.jvm.subsystems.scala_platform.ScalaPlatform import global_instance [as 别名]
def create_scaladoc_command(self, classpath, gendir, *targets):
sources = []
for target in targets:
sources.extend(target.sources_relative_to_buildroot())
# TODO(Tejal Desai): pantsbuild/pants/65: Remove java_sources attribute for ScalaLibrary
for java_target in target.java_sources:
sources.extend(java_target.sources_relative_to_buildroot())
if not sources:
return None
scala_platform = ScalaPlatform.global_instance()
tool_classpath = scala_platform.compiler_classpath(self.context.products)
args = ['-usejavacp',
'-classpath', ':'.join(classpath),
'-d', gendir]
args.extend(self.args)
args.extend(sources)
java_executor = SubprocessExecutor()
runner = java_executor.runner(jvm_options=self.jvm_options,
classpath=tool_classpath,
main='scala.tools.nsc.ScalaDoc',
args=args)
return runner.command
示例3: create_scaladoc_command
# 需要导入模块: from pants.backend.jvm.subsystems.scala_platform import ScalaPlatform [as 别名]
# 或者: from pants.backend.jvm.subsystems.scala_platform.ScalaPlatform import global_instance [as 别名]
def create_scaladoc_command(self, classpath, gendir, *targets):
sources = []
for target in targets:
sources.extend(target.sources_relative_to_buildroot())
# TODO(Tejal Desai): pantsbuild/pants/65: Remove java_sources attribute for ScalaLibrary
# A '.scala' owning target may not have java_sources, eg: junit_tests
if hasattr(target, 'java_sources'):
for java_target in target.java_sources:
sources.extend(java_target.sources_relative_to_buildroot())
if not sources:
return None
scala_platform = ScalaPlatform.global_instance()
tool_classpath = [cp_entry.path for cp_entry in scala_platform.compiler_classpath_entries(
self.context.products, self.context._scheduler)]
args = ['-usejavacp',
'-classpath', ':'.join(classpath),
'-d', gendir]
args.extend(self.args)
args.extend(sources)
java_executor = SubprocessExecutor(DistributionLocator.cached())
runner = java_executor.runner(jvm_options=self.jvm_options,
classpath=tool_classpath,
main='scala.tools.nsc.ScalaDoc',
args=args)
return runner.command
示例4: execute
# 需要导入模块: from pants.backend.jvm.subsystems.scala_platform import ScalaPlatform [as 别名]
# 或者: from pants.backend.jvm.subsystems.scala_platform.ScalaPlatform import global_instance [as 别名]
def execute(self):
"""Stages IDE project artifacts to a project directory and generates IDE configuration files."""
# Grab the targets in-play before the context is replaced by `self._prepare_project()` below.
targets = self.context.targets()
self._prepare_project()
if self.context.options.is_known_scope('compile.checkstyle'):
checkstyle_classpath = self.tool_classpath('checkstyle', scope='compile.checkstyle')
else: # Checkstyle not enabled.
checkstyle_classpath = []
if self.skip_scala:
scalac_classpath = []
else:
scalac_classpath = ScalaPlatform.global_instance().compiler_classpath(self.context.products)
self._project.set_tool_classpaths(checkstyle_classpath, scalac_classpath)
self.map_internal_jars(targets)
self.map_external_jars(targets)
idefile = self.generate_project(self._project)
if idefile:
try:
desktop.ui_open(idefile)
except desktop.OpenError as e:
raise TaskError(e)
示例5: setup_repl_session
# 需要导入模块: from pants.backend.jvm.subsystems.scala_platform import ScalaPlatform [as 别名]
# 或者: from pants.backend.jvm.subsystems.scala_platform.ScalaPlatform import global_instance [as 别名]
def setup_repl_session(self, targets):
repl_name = ScalaPlatform.global_instance().repl
return (
self.tool_classpath("pants-runner")
+ self.tool_classpath(repl_name, scope=ScalaPlatform.options_scope)
+ self.classpath(targets)
)
示例6: traversable_dependency_specs
# 需要导入模块: from pants.backend.jvm.subsystems.scala_platform import ScalaPlatform [as 别名]
# 或者: from pants.backend.jvm.subsystems.scala_platform.ScalaPlatform import global_instance [as 别名]
def traversable_dependency_specs(self):
for spec in super(ScalaLibrary, self).traversable_dependency_specs:
yield spec
# TODO(John Sirois): Targets should be able to set their scala platform version
# explicitly, and not have to conform to this global setting.
for library_spec in ScalaPlatform.global_instance().runtime:
yield library_spec
示例7: _fetch_tool_jar_from_scalac_classpath
# 需要导入模块: from pants.backend.jvm.subsystems.scala_platform import ScalaPlatform [as 别名]
# 或者: from pants.backend.jvm.subsystems.scala_platform.ScalaPlatform import global_instance [as 别名]
def _fetch_tool_jar_from_scalac_classpath(self, products, jar_name):
scala_version = ScalaPlatform.global_instance().version
classpath = self.tool_classpath_from_products(products,
ScalaPlatform.versioned_tool_name('scalac', scala_version),
scope=self.options_scope)
candidates = [jar for jar in classpath if jar_name in jar]
assert(len(candidates) == 1)
return candidates[0]
示例8: scalac_compiler_plugins_src
# 需要导入模块: from pants.backend.jvm.subsystems.scala_platform import ScalaPlatform [as 别名]
# 或者: from pants.backend.jvm.subsystems.scala_platform.ScalaPlatform import global_instance [as 别名]
def scalac_compiler_plugins_src(self, zinc_compile_instance=None):
"""Returns an instance of JvmToolMixin that should provide scalac compiler plugins.
TODO: Remove this method once the deprecation of `(scalac|javac)_plugins` on Zinc has
completed in `1.9.0.dev0`.
"""
return Zinc._select_jvm_tool_mixin(zinc_compile_instance,
ScalaPlatform.global_instance(),
['scalac_plugins', 'scalac_plugin_args', 'scalac_plugin_dep'])
示例9: test_scala_exclude
# 需要导入模块: from pants.backend.jvm.subsystems.scala_platform import ScalaPlatform [as 别名]
# 或者: from pants.backend.jvm.subsystems.scala_platform.ScalaPlatform import global_instance [as 别名]
def test_scala_exclude(self):
init_subsystem(ScalaPlatform)
name = 'foo_lib'
suffixed_name = ScalaPlatform.global_instance().suffix_version(name)
self.assertEqual(
suffixed_name,
ScalaExclude(org='example.com', name=name).name
)
示例10: _compiler_plugins_cp_entries
# 需要导入模块: from pants.backend.jvm.subsystems.scala_platform import ScalaPlatform [as 别名]
# 或者: from pants.backend.jvm.subsystems.scala_platform.ScalaPlatform import global_instance [as 别名]
def _compiler_plugins_cp_entries(self):
"""Any additional global compiletime classpath entries for compiler plugins."""
java_options_src = Java.global_instance()
scala_options_src = ScalaPlatform.global_instance()
def cp(instance, toolname):
scope = instance.options_scope
return instance.tool_classpath_from_products(self._products, toolname, scope=scope)
classpaths = (cp(java_options_src, 'javac-plugin-dep') +
cp(scala_options_src, 'scalac-plugin-dep'))
return [(conf, ClasspathEntry(jar)) for conf in self.DEFAULT_CONFS for jar in classpaths]
示例11: _compile_vts
# 需要导入模块: from pants.backend.jvm.subsystems.scala_platform import ScalaPlatform [as 别名]
# 或者: from pants.backend.jvm.subsystems.scala_platform.ScalaPlatform import global_instance [as 别名]
def _compile_vts(self, vts, ctx, upstream_analysis, classpath, progress_message, settings,
compiler_option_sets, zinc_file_manager, counter):
"""Compiles sources for the given vts into the given output dir.
:param vts: VersionedTargetSet with one entry for the target.
:param ctx: - A CompileContext instance for the target.
:param classpath: A list of classpath entries
May be invoked concurrently on independent target sets.
Postcondition: The individual targets in vts are up-to-date, as if each were
compiled individually.
"""
if not ctx.sources:
self.context.log.warn('Skipping {} compile for targets with no sources:\n {}'
.format(self.name(), vts.targets))
else:
counter_val = str(counter()).rjust(counter.format_length(), b' ')
counter_str = '[{}/{}] '.format(counter_val, counter.size)
# Do some reporting.
self.context.log.info(
counter_str,
'Compiling ',
items_to_report_element(ctx.sources, '{} source'.format(self.name())),
' in ',
items_to_report_element([t.address.reference() for t in vts.targets], 'target'),
' (',
progress_message,
').')
with self.context.new_workunit('compile', labels=[WorkUnitLabel.COMPILER]) as compile_workunit:
if self.get_options().capture_classpath:
self._record_compile_classpath(classpath, vts.targets, ctx.classes_dir)
try:
self.compile(
ctx,
self._args,
classpath,
upstream_analysis,
settings,
compiler_option_sets,
zinc_file_manager,
self._get_plugin_map('javac', Java.global_instance(), ctx.target),
self._get_plugin_map('scalac', ScalaPlatform.global_instance(), ctx.target),
)
self._capture_logs(compile_workunit, ctx.log_dir)
except TaskError:
if self.get_options().suggest_missing_deps:
logs = [path
for _, name, _, path in self._find_logs(compile_workunit)
if name == self.name()]
if logs:
self._find_missing_deps(logs, ctx.target)
raise
示例12: call
# 需要导入模块: from pants.backend.jvm.subsystems.scala_platform import ScalaPlatform [as 别名]
# 或者: from pants.backend.jvm.subsystems.scala_platform.ScalaPlatform import global_instance [as 别名]
def call(srcs):
def to_java_boolean(x):
return str(x).lower()
cp = ScalaPlatform.global_instance().style_classpath(self.context.products)
scalastyle_args = [
'-c', scalastyle_config,
'-v', to_java_boolean(scalastyle_verbose),
'-q', to_java_boolean(scalastyle_quiet),
]
return self.runjava(classpath=cp,
main=self._MAIN,
jvm_options=self.get_options().jvm_options,
args=scalastyle_args + srcs)
示例13: defaulted_property
# 需要导入模块: from pants.backend.jvm.subsystems.scala_platform import ScalaPlatform [as 别名]
# 或者: from pants.backend.jvm.subsystems.scala_platform.ScalaPlatform import global_instance [as 别名]
def defaulted_property(self, target, option_name):
"""Computes a language property setting for the given JvmTarget.
:param selector A function that takes a target or platform and returns the boolean value of the
property for that target or platform, or None if that target or platform does
not directly define the property.
If the target does not override the language property, returns true iff the property
is true for any of the matched languages for the target.
"""
if target.has_sources('.java'):
matching_subsystem = Java.global_instance()
elif target.has_sources('.scala'):
matching_subsystem = ScalaPlatform.global_instance()
else:
return getattr(target, option_name)
return matching_subsystem.get_scalar_mirrored_target_option(option_name, target)
示例14: defaulted_property
# 需要导入模块: from pants.backend.jvm.subsystems.scala_platform import ScalaPlatform [as 别名]
# 或者: from pants.backend.jvm.subsystems.scala_platform.ScalaPlatform import global_instance [as 别名]
def defaulted_property(self, target, selector):
"""Computes a language property setting for the given JvmTarget.
:param selector A function that takes a target or platform and returns the boolean value of the
property for that target or platform, or None if that target or platform does
not directly define the property.
If the target does not override the language property, returns true iff the property
is true for any of the matched languages for the target.
"""
if selector(target) is not None:
return selector(target)
prop = False
if target.has_sources('.java'):
prop |= selector(Java.global_instance())
if target.has_sources('.scala'):
prop |= selector(ScalaPlatform.global_instance())
return prop
示例15: _compute_language_property
# 需要导入模块: from pants.backend.jvm.subsystems.scala_platform import ScalaPlatform [as 别名]
# 或者: from pants.backend.jvm.subsystems.scala_platform.ScalaPlatform import global_instance [as 别名]
def _compute_language_property(self, target, selector):
"""Computes the a language property setting for the given target sources.
:param target The target whose language property will be calculated.
:param selector A function that takes a target or platform and returns the boolean value of the
property for that target or platform, or None if that target or platform does
not directly define the property.
If the target does not override the language property, returns true iff the property
is true for any of the matched languages for the target.
"""
if selector(target) is not None:
return selector(target)
property = False
if target.has_sources(".java"):
property |= selector(Java.global_instance())
if target.has_sources(".scala"):
property |= selector(ScalaPlatform.global_instance())
return property