class _JvmCompileWorkflowType(enum(['zinc-only', 'rsc-then-zinc'])): """Target classifications used to correctly schedule Zinc and Rsc jobs. There are some limitations we have to work around before we can compile everything through Rsc and followed by Zinc. - rsc is not able to outline all scala code just yet (this is also being addressed through automated rewrites). - javac is unable to consume rsc's jars just yet. - rsc is not able to outline all java code just yet (this is likely to *not* require rewrites, just some more work on rsc). As we work on improving our Rsc integration, we'll need to create more workflows to more closely map the supported features of Rsc. This enum class allows us to do that. - zinc-only: compiles targets just with Zinc and uses the Zinc products of their dependencies. - rsc-then-zinc: compiles targets with Rsc to create "header" jars, then runs Zinc against the Rsc products of their dependencies. The Rsc compile uses the Rsc products of Rsc compatible targets and the Zinc products of zinc-only targets. """ @classmethod def classify_target(cls, target): # NB: Java targets, Scala+Java targets, and some test targets are not currently supported for # compile with Rsc. # TODO: Rsc's produced header jars don't yet work with javac. Once this is resolved, we may add # additional workflow types. if target.has_sources('.java') or \ isinstance(target, JUnitTests) or \ (isinstance(target, ScalaLibrary) and tuple(target.java_sources)): target_type = _JvmCompileWorkflowType.zinc_only elif target.has_sources('.scala'): target_type = _JvmCompileWorkflowType.rsc_then_zinc else: target_type = None return target_type
class GlobExpansionConjunction(enum('conjunction', ['any_match', 'all_match'])): # NB: The `default_value` is automatically the first element of the value list, but can be # overridden or made more explicit in the body of the class. We want to be explicit here about # which behavior we have when merging globs, as that can affect performance. default_value = 'any_match'
class GlobMatchErrorBehavior(enum('failure_behavior', ['ignore', 'warn', 'error'])): """Describe the action to perform when matching globs in BUILD files to source files. NB: this object is interpreted from within Snapshot::lift_path_globs() -- that method will need to be aware of any changes to this object's definition. """ default_option_value = 'warn'
class DetailLevel(enum(['none', 'summary', 'nonmatching', 'all'])): """How much detail about validation to emit to the console. none: Emit nothing. summary: Emit a summary only. nonmatching: Emit details for source files that failed to match at least one required pattern. all: Emit details for all source files. """ pass
class Platform(enum(all_normalized_os_names())): # TODO: try to turn all of these accesses into v2 dependency injections! @memoized_classproperty def current(cls): return cls(get_normalized_os_name()) @memoized_property def runtime_lib_path_env_var(self): return self.resolve_for_enum_variant({ 'darwin': 'DYLD_LIBRARY_PATH', 'linux': 'LD_LIBRARY_PATH', })
class GlobExpansionConjunction(enum(['any_match', 'all_match'])): """Describe whether to require that only some or all glob strings match in a target's sources.
class Status(enum(['SUCCESS', 'FAILURE'])): pass
class HasAttrs(enum(['a', 'b'])): pass self.assertEqual(HasAttrs.a, HasAttrs('a'))
class _CompileWorkflowChoice(enum(['zinc-only', 'guess'])): """Enum covering the values for the default workflow option.
class SomeEnum(enum([1, 2])): pass class DatatypeTest(TestBase):
class ExecutionStrategy(enum([NAILGUN, SUBPROCESS, HERMETIC])): pass
class StrEnum(enum(['a'])): pass enum_instance = StrEnum('a')
class ToolchainVariant(enum(['gnu', 'llvm'])): pass class NativeBuildStep(CompilerOptionSetsMixin, MirroredTargetOptionMixin, Subsystem):
class StrEnum(enum(['a'])): pass
class PlatformConstraint(enum(list(all_normalized_os_names()) + ['none'])): @memoized_classproperty def local_platform(cls): return cls(Platform.current.value)
class HasAttrs(enum(['a', 'b'])): pass
class DuplicateAllowedValues(enum([1, 2, 3, 1])): pass
class SomeEnum(enum([1, 2])): pass
class DuplicateAllowedValues(enum([1, 2, 3, 1])): pass def test_enum_instance_creation(self):
class GlobMatchErrorBehavior(enum(['ignore', 'warn', 'error'])): """Describe the action to perform when matching globs in BUILD files to source files.
class OutOfOrderEnum(enum([2, 1, 3])): pass
class OutOfOrderEnum(enum([2, 1, 3])): pass two_out_of_order_instance = OutOfOrderEnum(2)
class ToolchainVariant(enum('descriptor', ['gnu', 'llvm'])): @property def is_gnu(self): return self.descriptor == 'gnu'
class ExpectedPlatformType(enum(['any', 'current'])): """Whether to check that the produced wheel has the 'any' platform, or the current one."""
class Platform(enum(all_normalized_os_names())): # TODO: try to turn all of these accesses into v2 dependency injections! @memoized_classproperty def current(cls): return cls(get_normalized_os_name())
class ToolchainVariant(enum(['gnu', 'llvm'])): pass
class JvmCompileWorkflowType( enum(['zinc-only', 'zinc-java', 'rsc-and-zinc'])): """Target classifications used to correctly schedule Zinc and Rsc jobs.
class SomeEnum(enum('x', [1, 2])): pass