forked from pantsbuild/pants
-
Notifications
You must be signed in to change notification settings - Fork 0
/
additional_fields.py
38 lines (29 loc) · 1.4 KB
/
additional_fields.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).
from pants.backend.codegen.protobuf.target_types import (
ProtobufSourcesGeneratorTarget,
ProtobufSourceTarget,
)
from pants.backend.python.target_types import InterpreterConstraintsField, PythonResolveField
from pants.engine.target import StringField
class ProtobufPythonInterpreterConstraintsField(InterpreterConstraintsField):
alias = "python_interpreter_constraints"
class ProtobufPythonResolveField(PythonResolveField):
alias = "python_resolve"
class PythonSourceRootField(StringField):
alias = "python_source_root"
help = (
"The source root to generate Python sources under.\n\nIf unspecified, the source root the "
"`protobuf_sources` is under will be used."
)
def rules():
return [
ProtobufSourceTarget.register_plugin_field(ProtobufPythonInterpreterConstraintsField),
ProtobufSourcesGeneratorTarget.register_plugin_field(
ProtobufPythonInterpreterConstraintsField
),
ProtobufSourceTarget.register_plugin_field(ProtobufPythonResolveField),
ProtobufSourcesGeneratorTarget.register_plugin_field(ProtobufPythonResolveField),
ProtobufSourceTarget.register_plugin_field(PythonSourceRootField),
ProtobufSourcesGeneratorTarget.register_plugin_field(PythonSourceRootField),
]