Skip to content

Commit e7b2d71

Browse files
committed
target.go
1 parent e74e8d4 commit e7b2d71

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

gazelle/python/target.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ type targetBuilder struct {
3030
pythonProjectRoot string
3131
bzlPackage string
3232
srcs *treeset.Set
33+
pyiSrcs *treeset.Set
3334
siblingSrcs *treeset.Set
3435
deps *treeset.Set
3536
resolvedDeps *treeset.Set
@@ -49,6 +50,7 @@ func newTargetBuilder(kind, name, pythonProjectRoot, bzlPackage string, siblingS
4950
pythonProjectRoot: pythonProjectRoot,
5051
bzlPackage: bzlPackage,
5152
srcs: treeset.NewWith(godsutils.StringComparator),
53+
pyiSrcs: treeset.NewWith(godsutils.StringComparator),
5254
siblingSrcs: siblingSrcs,
5355
deps: treeset.NewWith(moduleComparator),
5456
resolvedDeps: treeset.NewWith(godsutils.StringComparator),
@@ -73,6 +75,21 @@ func (t *targetBuilder) addSrcs(srcs *treeset.Set) *targetBuilder {
7375
return t
7476
}
7577

78+
// addPyiSrc adds a single pyi_src to the target.
79+
func (t *targetBuilder) addPyiSrc(pyiSrc string) *targetBuilder {
80+
t.pyiSrcs.Add(pyiSrc)
81+
return t
82+
}
83+
84+
// addPyiSrcs adds multiple pyi_srcs to the target.
85+
func (t *targetBuilder) addPyiSrcs(pyiSrcs *treeset.Set) *targetBuilder {
86+
it := pyiSrcs.Iterator()
87+
for it.Next() {
88+
t.pyiSrcs.Add(it.Value().(string))
89+
}
90+
return t
91+
}
92+
7693
// addModuleDependency adds a single module dep to the target.
7794
func (t *targetBuilder) addModuleDependency(dep Module) *targetBuilder {
7895
fileName := dep.Name + ".py"
@@ -165,6 +182,9 @@ func (t *targetBuilder) build() *rule.Rule {
165182
if !t.srcs.Empty() {
166183
r.SetAttr("srcs", t.srcs.Values())
167184
}
185+
if !t.pyiSrcs.Empty() {
186+
r.SetAttr("pyi_srcs", t.pyiSrcs.Values())
187+
}
168188
if !t.visibility.Empty() {
169189
r.SetAttr("visibility", t.visibility.Values())
170190
}

0 commit comments

Comments
 (0)