def __init__(self, address=None, payload=None, sources=None, **kwargs): if not sources: # We grab all files in the current directory except BUILD files for 2 reasons: # 1. cgo: If a file imports "C" then it may rely on sibling .c, .cc, etc files that `go build` # will compile. # 2. resources: Even though go does not support them; ie by providing a protocol to embed them # in binaries, it does allow them to be placed in a directory where a test might use them # for example via plain old filesystem access. globs = Globs( ParseContext(rel_path=address.spec_path, type_aliases={})) sources = globs( '*', exclude=[ globs('BUILD*'), # This skips subdir content. globs('*/**') ]) payload = payload or Payload() payload.add_fields({ 'sources': self.create_sources_field(sources=sources, sources_rel_path=address.spec_path, key_arg='sources'), }) super(GoLocalSource, self).__init__(address=address, payload=payload, **kwargs)
def _globs(rel_path): pc = ParseContext(rel_path=rel_path, type_aliases={}) return Globs(pc)