-
-
Notifications
You must be signed in to change notification settings - Fork 645
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow for codegen targets to be used directly by JVM compiler requests (
#14751) This amends `ClasspathEntryRequest.for_targets` to accept a codegen source request target and output a `ClasspathEntryRequest` that corresponds to a relevant JVM compilation request. With this approach, it seems that any `GenerateSourcesRequest` with `output` that is compatible with a `ClasspathEntryRequest` will Just Work™. To demonstrate this in action, there's backend registration support for the Java and Scala protobuf generators included in this PR too. The main current limitation is when multiple language backends are enabled for a given codegen source type. A solution for this would address #14041, and realistically needs to take multiple JVM languages into account.
- Loading branch information
Christopher Neugebauer
authored
Mar 11, 2022
1 parent
86d9183
commit 60c19d1
Showing
10 changed files
with
232 additions
and
57 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
src/python/pants/backend/codegen/protobuf/java/register.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright 2022 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
"""Generate Java sources from Protocol Buffers (Protobufs). | ||
See https://www.pantsbuild.org/docs/protobuf. | ||
""" | ||
|
||
from pants.backend.codegen import export_codegen_goal | ||
from pants.backend.codegen.protobuf import protobuf_dependency_inference | ||
from pants.backend.codegen.protobuf import tailor as protobuf_tailor | ||
from pants.backend.codegen.protobuf.java.rules import rules as java_rules | ||
from pants.backend.codegen.protobuf.target_types import ( | ||
ProtobufSourcesGeneratorTarget, | ||
ProtobufSourceTarget, | ||
) | ||
from pants.backend.codegen.protobuf.target_types import rules as protobuf_target_rules | ||
from pants.core.util_rules import stripped_source_files | ||
|
||
|
||
def rules(): | ||
return [ | ||
*java_rules(), | ||
*protobuf_dependency_inference.rules(), | ||
*protobuf_tailor.rules(), | ||
*export_codegen_goal.rules(), | ||
*protobuf_target_rules(), | ||
*stripped_source_files.rules(), | ||
] | ||
|
||
|
||
def target_types(): | ||
return [ProtobufSourcesGeneratorTarget, ProtobufSourceTarget] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/python/pants/backend/codegen/protobuf/scala/register.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright 2022 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
"""Generate Scala sources from Protocol Buffers (Protobufs). | ||
See https://www.pantsbuild.org/docs/protobuf. | ||
""" | ||
|
||
from pants.backend.codegen import export_codegen_goal | ||
from pants.backend.codegen.protobuf import protobuf_dependency_inference | ||
from pants.backend.codegen.protobuf import tailor as protobuf_tailor | ||
from pants.backend.codegen.protobuf.scala.rules import rules as scala_rules | ||
from pants.backend.codegen.protobuf.target_types import ( | ||
ProtobufSourcesGeneratorTarget, | ||
ProtobufSourceTarget, | ||
) | ||
from pants.backend.codegen.protobuf.target_types import rules as protobuf_target_rules | ||
from pants.core.util_rules import stripped_source_files | ||
|
||
|
||
def rules(): | ||
return [ | ||
*scala_rules(), | ||
*protobuf_dependency_inference.rules(), | ||
*protobuf_tailor.rules(), | ||
*export_codegen_goal.rules(), | ||
*protobuf_target_rules(), | ||
*stripped_source_files.rules(), | ||
] | ||
|
||
|
||
def target_types(): | ||
return [ProtobufSourcesGeneratorTarget, ProtobufSourceTarget] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.