Skip to content

Commit

Permalink
Fix up for go
Browse files Browse the repository at this point in the history
  • Loading branch information
illicitonion committed Jun 20, 2018
1 parent 26dace8 commit c1115c6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class GoBinary(GoLocalSource):
"""A local Go main package."""

default_sources_globs = '*'
default_sources_exclude_globs = ('BUILD', 'BUILD.*')

@classmethod
def alias(cls):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class GoLibrary(GoLocalSource):
"""A local Go package."""

default_sources_globs = '*'
default_sources_exclude_globs = ('BUILD', 'BUILD.*')

@classmethod
def alias(cls):
Expand Down
17 changes: 0 additions & 17 deletions src/python/pants/engine/legacy/structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,23 +273,6 @@ def default_sources_globs(self):
return self.python_test_globs


class GoTargetAdaptor(TargetAdaptor):

@property
def default_sources(self):
# Go has always used implicit_sources: override to ignore the option.
return True

@property
def default_sources_globs(self):
# N.B. Go targets glob on `*` due to the way resources and .c companion files are handled.
return ('*',)

@property
def default_sources_exclude_globs(self):
return ('BUILD', 'BUILD.*')


class PantsPluginAdaptor(PythonTargetAdaptor):
def get_sources(self):
return ['register.py']
Expand Down
13 changes: 13 additions & 0 deletions src/python/pants/init/engine_initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ def __init__(self, build_file_aliases):
for alias, target_type in build_file_aliases.target_types.items()
}

for alias, factory in build_file_aliases.target_macro_factories.items():
# TargetMacro.Factory with more than one target type is deprecated.
# For default sources, this means that TargetMacro Factories with more than one target_type
# will not parse sources through the engine, and will fall back to the legacy python sources
# parsing.
# Conveniently, multi-target_type TargetMacro.Factory, and legacy python source parsing, are
# targeted to be removed in the same version of pants.
if len(factory.target_types) == 1:
self._table[alias] = self._make_target_adaptor(
TargetAdaptor,
tuple(factory.target_types)[0],
)

# TODO: The alias replacement here is to avoid elevating "TargetAdaptors" into the public
# API until after https://github.com/pantsbuild/pants/issues/3560 has been completed.
# These should likely move onto Target subclasses as the engine gets deeper into beta
Expand Down

0 comments on commit c1115c6

Please sign in to comment.