Skip to content

Commit

Permalink
Fixups.
Browse files Browse the repository at this point in the history
  • Loading branch information
kwlzn committed Jul 10, 2018
1 parent 1cf722c commit f95c064
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
6 changes: 6 additions & 0 deletions src/python/pants/engine/BUILD
Expand Up @@ -185,6 +185,12 @@ python_library(
],
)


python_library(
name='console',
sources=['console.py']
)

resources(
name='native_engine_shared_library',
sources=['native_engine.so']
Expand Down
2 changes: 2 additions & 0 deletions src/python/pants/init/BUILD
Expand Up @@ -22,6 +22,7 @@ python_library(
'src/python/pants/engine/legacy:source_mapper',
'src/python/pants/engine/legacy:structs',
'src/python/pants/engine:build_files',
'src/python/pants/engine:console',
'src/python/pants/engine:mapper',
'src/python/pants/engine:native',
'src/python/pants/engine:parser',
Expand All @@ -30,6 +31,7 @@ python_library(
'src/python/pants/goal:run_tracker',
'src/python/pants/option',
'src/python/pants/process',
'src/python/pants/rules/core',
'src/python/pants/subsystem',
'src/python/pants/util:dirutil',
'src/python/pants/util:memo',
Expand Down
32 changes: 17 additions & 15 deletions src/python/pants/init/engine_initializer.py
Expand Up @@ -40,7 +40,6 @@
GlobMatchErrorBehavior)
from pants.option.options_bootstrapper import OptionsBootstrapper
from pants.rules.core.register import create_core_rules
from pants.util.collections import combined_dict
from pants.util.objects import datatype


Expand Down Expand Up @@ -225,22 +224,25 @@ def create_build_graph(self, target_roots, build_root=None):
return graph, address_mapper


def _make_goal_map_from_rules(rules):
goal_map = {}
goal_to_rule = [(rule.goal, rule) for rule in rules if getattr(rule, 'goal', None) is not None]
for goal, rule in goal_to_rule:
if goal in goal_map:
raise GoalMappingError(
'could not map goal `{}` to rule `{}`: already claimed by product `{}`'
.format(goal, rule, goal_map[goal])
)
goal_map[goal] = rule.output_type
return goal_map


class EngineInitializer(object):
"""Constructs the components necessary to run the v2 engine with v1 BuildGraph compatibility."""

class GoalMappingError(Exception):
"""Raised when a goal cannot be mapped to an @rule."""

@staticmethod
def _make_goal_map_from_rules(rules):
goal_map = {}
goal_to_rule = [(rule.goal, rule) for rule in rules if getattr(rule, 'goal', None) is not None]
for goal, rule in goal_to_rule:
if goal in goal_map:
raise EngineInitializer.GoalMappingError(
'could not map goal `{}` to rule `{}`: already claimed by product `{}`'
.format(goal, rule, goal_map[goal])
)
goal_map[goal] = rule.output_type
return goal_map

@staticmethod
def setup_legacy_graph(native, bootstrap_options, build_configuration):
"""Construct and return the components necessary for LegacyBuildGraph construction."""
Expand Down Expand Up @@ -345,7 +347,7 @@ def setup_legacy_graph_extended(
rules
)

goal_map = _make_goal_map_from_rules(rules)
goal_map = EngineInitializer._make_goal_map_from_rules(rules)

scheduler = Scheduler(
native,
Expand Down
2 changes: 0 additions & 2 deletions src/python/pants/pantsd/service/pailgun_service.py
Expand Up @@ -7,8 +7,6 @@

import logging
import select
import sys
import traceback
from contextlib import contextmanager

from pants.pantsd.pailgun_server import PailgunServer
Expand Down

0 comments on commit f95c064

Please sign in to comment.