本文整理匯總了Python中pants.backend.jvm.tasks.jvm_compile.jvm_dependency_analyzer.JvmDependencyAnalyzer.check方法的典型用法代碼示例。如果您正苦於以下問題:Python JvmDependencyAnalyzer.check方法的具體用法?Python JvmDependencyAnalyzer.check怎麽用?Python JvmDependencyAnalyzer.check使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pants.backend.jvm.tasks.jvm_compile.jvm_dependency_analyzer.JvmDependencyAnalyzer
的用法示例。
在下文中一共展示了JvmDependencyAnalyzer.check方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: JvmCompileGlobalStrategy
# 需要導入模塊: from pants.backend.jvm.tasks.jvm_compile.jvm_dependency_analyzer import JvmDependencyAnalyzer [as 別名]
# 或者: from pants.backend.jvm.tasks.jvm_compile.jvm_dependency_analyzer.JvmDependencyAnalyzer import check [as 別名]
class JvmCompileGlobalStrategy(JvmCompileStrategy):
"""A strategy for JVM compilation that uses a global classpath and analysis."""
class InternalTargetPartitioningError(Exception):
"""Error partitioning targets by jvm platform settings."""
@classmethod
def register_options(cls, register, compile_task_name, supports_concurrent_execution):
register('--missing-deps', advanced=True, choices=['off', 'warn', 'fatal'], default='warn',
fingerprint=True,
help='Check for missing dependencies in code compiled with {0}. Reports actual '
'dependencies A -> B where there is no transitive BUILD file dependency path '
'from A to B. If fatal, missing deps are treated as a build error.'.format(
compile_task_name))
register('--missing-direct-deps', advanced=True, choices=['off', 'warn', 'fatal'],
default='off',
fingerprint=True,
help='Check for missing direct dependencies in code compiled with {0}. Reports actual '
'dependencies A -> B where there is no direct BUILD file dependency path from '
'A to B. This is a very strict check; In practice it is common to rely on '
'transitive, indirect dependencies, e.g., due to type inference or when the main '
'target in a BUILD file is modified to depend on other targets in the same BUILD '
'file, as an implementation detail. However it may still be useful to use this '
'on occasion. '.format(compile_task_name))
register('--missing-deps-whitelist', advanced=True, type=list_option,
fingerprint=True,
help="Don't report these targets even if they have missing deps.")
register('--unnecessary-deps', advanced=True, choices=['off', 'warn', 'fatal'], default='off',
fingerprint=True,
help='Check for declared dependencies in code compiled with {0} that are not needed. '
'This is a very strict check. For example, generated code will often '
'legitimately have BUILD dependencies that are unused in practice.'.format(
compile_task_name))
register('--changed-targets-heuristic-limit', advanced=True, type=int, default=0,
help='If non-zero, and we have fewer than this number of locally-changed targets, '
'partition them separately, to preserve stability when compiling repeatedly.')
def __init__(self, context, options, workdir, analysis_tools, compile_task_name,
sources_predicate):
super(JvmCompileGlobalStrategy, self).__init__(context, options, workdir, analysis_tools,
compile_task_name, sources_predicate)
# Various working directories.
# NB: These are grandfathered in with non-strategy-specific names, but to prevent
# collisions within the buildcache, strategies should use strategy-specific subdirectories.
self._analysis_dir = os.path.join(workdir, 'analysis')
self._classes_dir = os.path.join(workdir, 'classes')
self._analysis_file = os.path.join(self._analysis_dir, 'global_analysis.valid')
self._invalid_analysis_file = os.path.join(self._analysis_dir, 'global_analysis.invalid')
self._target_sources_dir = os.path.join(workdir, 'target_sources')
# The rough number of source files to build in each compiler pass.
self._partition_size_hint = options.partition_size_hint
# Set up dep checking if needed.
def munge_flag(flag):
flag_value = getattr(options, flag, None)
return None if flag_value == 'off' else flag_value
check_missing_deps = munge_flag('missing_deps')
check_missing_direct_deps = munge_flag('missing_direct_deps')
check_unnecessary_deps = munge_flag('unnecessary_deps')
if check_missing_deps or check_missing_direct_deps or check_unnecessary_deps:
target_whitelist = options.missing_deps_whitelist
# Must init it here, so it can set requirements on the context.
self._dep_analyzer = JvmDependencyAnalyzer(self.context,
check_missing_deps,
check_missing_direct_deps,
check_unnecessary_deps,
target_whitelist)
else:
self._dep_analyzer = None
# Computed lazily as needed.
self._upstream_class_to_path = None
# If non-zero, and we have fewer than this number of locally-changed targets,
# then we partition them separately, to preserve stability in the face of repeated
# compilations.
self._changed_targets_heuristic_limit = options.changed_targets_heuristic_limit
# Sources (relative to buildroot) present in the last analysis that have since been deleted.
# Populated in prepare_compile().
self._deleted_sources = None
def name(self):
return 'global'
def compile_context(self, target):
"""Returns the default/stable compile context for the given target.
Temporary compile contexts are private to the strategy.
"""
#.........這裏部分代碼省略.........
示例2: JvmCompile
# 需要導入模塊: from pants.backend.jvm.tasks.jvm_compile.jvm_dependency_analyzer import JvmDependencyAnalyzer [as 別名]
# 或者: from pants.backend.jvm.tasks.jvm_compile.jvm_dependency_analyzer.JvmDependencyAnalyzer import check [as 別名]
class JvmCompile(NailgunTaskBase, GroupMember, JvmToolTaskMixin):
"""A common framework for JVM compilation.
To subclass for a specific JVM language, implement the static values and methods
mentioned below under "Subclasses must implement".
"""
@classmethod
def setup_parser(cls, option_group, args, mkflag):
super(JvmCompile, cls).setup_parser(option_group, args, mkflag)
option_group.add_option(
mkflag("warnings"),
mkflag("warnings", negate=True),
dest=cls._language + "_compile_warnings",
default=True,
action="callback",
callback=mkflag.set_bool,
help="[%default] Compile with all configured warnings enabled.",
)
option_group.add_option(
mkflag("partition-size-hint"),
dest=cls._language + "_partition_size_hint",
action="store",
type="int",
default=-1,
help="Roughly how many source files to attempt to compile together. "
"Set to a large number to compile all sources together. Set this "
"to 0 to compile target-by-target. Default is set in pants.ini.",
)
option_group.add_option(
mkflag("missing-deps"),
dest=cls._language + "_missing_deps",
choices=["off", "warn", "fatal"],
default="warn",
help="[%default] One of off, warn, fatal. "
"Check for missing dependencies in " + cls._language + "code. "
"Reports actual dependencies A -> B where there is no "
"transitive BUILD file dependency path from A to B."
"If fatal, missing deps are treated as a build error.",
)
option_group.add_option(
mkflag("missing-direct-deps"),
dest=cls._language + "_missing_direct_deps",
choices=["off", "warn", "fatal"],
default="off",
help="[%default] One of off, warn, fatal. "
"Check for missing direct dependencies in "
+ cls._language
+ " code. Reports actual dependencies A -> B where there is no "
"direct BUILD file dependency path from A to B. This is a very "
"strict check, as in practice it is common to rely on transitive, "
"non-direct dependencies, e.g., due to type inference or when the "
"main target in a BUILD file is modified to depend on other "
"targets in the same BUILD file as an implementation detail. It "
"may still be useful to set it to fatal temorarily, to detect "
"these.",
)
option_group.add_option(
mkflag("unnecessary-deps"),
dest=cls._language + "_unnecessary_deps",
choices=["off", "warn", "fatal"],
default="off",
help="[%default] One of off, warn, fatal. Check for declared "
"dependencies in " + cls._language + " code that are not "
"needed. This is a very strict check. For example, generated code "
"will often legitimately have BUILD dependencies that are unused "
"in practice.",
)
option_group.add_option(
mkflag("delete-scratch"),
mkflag("delete-scratch", negate=True),
dest=cls._language + "_delete_scratch",
default=True,
action="callback",
callback=mkflag.set_bool,
help="[%default] Leave intermediate scratch files around, " "for debugging build problems.",
)
# Subclasses must implement.
# --------------------------
_language = None
_file_suffix = None
_config_section = None
@classmethod
def name(cls):
return cls._language
@classmethod
def product_types(cls):
return ["classes_by_target", "classes_by_source"]
def select(self, target):
return target.has_sources(self._file_suffix)
#.........這裏部分代碼省略.........
示例3: JvmCompile
# 需要導入模塊: from pants.backend.jvm.tasks.jvm_compile.jvm_dependency_analyzer import JvmDependencyAnalyzer [as 別名]
# 或者: from pants.backend.jvm.tasks.jvm_compile.jvm_dependency_analyzer.JvmDependencyAnalyzer import check [as 別名]
class JvmCompile(NailgunTaskBase, GroupMember):
"""A common framework for JVM compilation.
To subclass for a specific JVM language, implement the static values and methods
mentioned below under "Subclasses must implement".
"""
@classmethod
def register_options(cls, register):
super(JvmCompile, cls).register_options(register)
register('--partition-size-hint', type=int, default=sys.maxint, metavar='<# source files>',
help='Roughly how many source files to attempt to compile together. Set to a large '
'number to compile all sources together. Set to 0 to compile target-by-target.')
register('--jvm-options', type=Options.list,
help='Run the compiler with these JVM options.')
register('--args', action='append', default=list(cls.get_args_default(register.bootstrap)),
help='Pass these args to the compiler.')
register('--confs', type=Options.list, default=['default'],
help='Compile for these Ivy confs.')
register('--warnings', default=True, action='store_true',
help='Compile with all configured warnings enabled.')
register('--warning-args', action='append', default=list(cls.get_warning_args_default()),
help='Extra compiler args to use when warnings are enabled.')
register('--no-warning-args', action='append', default=list(cls.get_no_warning_args_default()),
help='Extra compiler args to use when warnings are disabled.')
register('--missing-deps', choices=['off', 'warn', 'fatal'], default='warn',
help='Check for missing dependencies in {0} code. Reports actual dependencies A -> B '
'where there is no transitive BUILD file dependency path from A to B. If fatal, '
'missing deps are treated as a build error.'.format(cls._language))
register('--missing-direct-deps', choices=['off', 'warn', 'fatal'], default='off',
help='Check for missing direct dependencies in {0} code. Reports actual dependencies '
'A -> B where there is no direct BUILD file dependency path from A to B. This is '
'a very strict check; In practice it is common to rely on transitive, indirect '
'dependencies, e.g., due to type inference or when the main target in a BUILD '
'file is modified to depend on other targets in the same BUILD file, as an '
'implementation detail. However it may still be useful to use this on '
'occasion. '.format(cls._language))
register('--missing-deps-whitelist', type=Options.list,
help="Don't report these targets even if they have missing deps.")
register('--unnecessary-deps', choices=['off', 'warn', 'fatal'], default='off',
help='Check for declared dependencies in {0} code that are not needed. This is a very '
'strict check. For example, generated code will often legitimately have BUILD '
'dependencies that are unused in practice.'.format(cls._language))
register('--changed-targets-heuristic-limit', type=int, default=0,
help='If non-zero, and we have fewer than this number of locally-changed targets, '
'partition them separately, to preserve stability when compiling repeatedly.')
register('--delete-scratch', default=True, action='store_true',
help='Leave intermediate scratch files around, for debugging build problems.')
@classmethod
def product_types(cls):
return ['classes_by_target', 'classes_by_source', 'resources_by_target']
@classmethod
def prepare(cls, options, round_manager):
super(JvmCompile, cls).prepare(options, round_manager)
# This task uses JvmDependencyAnalyzer as a helper, get its product needs
JvmDependencyAnalyzer.prepare(options, round_manager)
round_manager.require_data('compile_classpath')
round_manager.require_data('ivy_cache_dir')
round_manager.require_data('ivy_resolve_symlink_map')
# Require codegen we care about
# TODO(John Sirois): roll this up in Task - if the list of labels we care about for a target
# predicate to filter the full build graph is exposed, the requirement can be made automatic
# and in turn codegen tasks could denote the labels they produce automating wiring of the
# produce side
round_manager.require_data('java')
round_manager.require_data('scala')
# Allow the deferred_sources_mapping to take place first
round_manager.require_data('deferred_sources')
# Subclasses must implement.
# --------------------------
_language = None
_file_suffix = None
@classmethod
def name(cls):
return cls._language
@classmethod
def get_args_default(cls, bootstrap_option_values):
"""Override to set default for --args option.
#.........這裏部分代碼省略.........