Skip to content

Commit

Permalink
Add build_root_singleton rule
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Arellano committed Nov 7, 2019
1 parent e7f410d commit 44f38b2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/python/pants/init/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ python_library(
'3rdparty/python/twitter/commons:twitter.common.collections',
'src/python/pants/backend/python/subsystems',
'src/python/pants/base:build_environment',
'src/python/pants/base:build_root',
'src/python/pants/base:exception_sink',
'src/python/pants/base:exceptions',
'src/python/pants/base:target_roots',
Expand Down
8 changes: 7 additions & 1 deletion src/python/pants/init/engine_initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from pants.backend.python.targets.python_library import PythonLibrary
from pants.backend.python.targets.python_tests import PythonTests
from pants.base.build_environment import get_buildroot
from pants.base.build_root import BuildRoot
from pants.base.exiter import PANTS_SUCCEEDED_EXIT_CODE
from pants.base.file_system_project_tree import FileSystemProjectTree
from pants.build_graph.build_configuration import BuildConfiguration
Expand Down Expand Up @@ -364,7 +365,11 @@ def symbol_table_singleton() -> SymbolTable:

@rule
def union_membership_singleton() -> UnionMembership:
return UnionMembership(build_configuration.union_rules())
return UnionMembership(build_configuration.union_rules())\

@rule
def build_root_singleton() -> BuildRoot:
return BuildRoot.instance

# Create a Scheduler containing graph and filesystem rules, with no installed goals. The
# LegacyBuildGraph will explicitly request the products it needs.
Expand All @@ -375,6 +380,7 @@ def union_membership_singleton() -> UnionMembership:
build_configuration_singleton,
symbol_table_singleton,
union_membership_singleton,
build_root_singleton,
] +
create_legacy_graph_tasks() +
create_fs_rules() +
Expand Down
1 change: 1 addition & 0 deletions src/python/pants/rules/core/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
python_library(
dependencies = [
'3rdparty/python:dataclasses',
'src/python/pants/base:build_root',
'src/python/pants/base:exiter',
'src/python/pants/build_graph',
'src/python/pants/engine:goal',
Expand Down
6 changes: 3 additions & 3 deletions src/python/pants/rules/core/filedeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from pathlib import Path

from pants.base.build_environment import get_buildroot
from pants.base.build_root import BuildRoot
from pants.engine.console import Console
from pants.engine.goal import Goal, LineOriented
from pants.engine.legacy.graph import TransitiveHydratedTargets
Expand Down Expand Up @@ -36,14 +36,14 @@ def register_options(cls, register):
def file_deps(
console: Console,
filedeps_options: Filedeps.Options,
build_root: BuildRoot,
transitive_hydrated_targets: TransitiveHydratedTargets
) -> Filedeps:

absolute = filedeps_options.values.absolute
globs = filedeps_options.values.globs

unique_rel_paths = set()
build_root = get_buildroot()

for hydrated_target in transitive_hydrated_targets.closure:
if hydrated_target.address.rel_path:
Expand All @@ -56,7 +56,7 @@ def file_deps(

with Filedeps.line_oriented(filedeps_options, console) as print_stdout:
for rel_path in sorted(unique_rel_paths):
final_path = str(Path(build_root, rel_path)) if absolute else rel_path
final_path = str(Path(build_root.path, rel_path)) if absolute else rel_path
print_stdout(final_path)

return Filedeps(exit_code=0)
Expand Down

0 comments on commit 44f38b2

Please sign in to comment.