Skip to content

Commit dfbf8b1

Browse files
authored
Remove split_srcs (#4019)
This should be identical and is much simpler. **What type of PR is this?** Code cleanup
1 parent 40aa3e7 commit dfbf8b1

File tree

2 files changed

+1
-36
lines changed

2 files changed

+1
-36
lines changed

go/private/common.bzl

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -76,40 +76,6 @@ syso_exts = [
7676
".syso",
7777
]
7878

79-
def split_srcs(srcs):
80-
"""Returns a struct of sources, divided by extension."""
81-
sources = struct(
82-
go = [],
83-
asm = [],
84-
headers = [],
85-
c = [],
86-
cxx = [],
87-
objc = [],
88-
syso = [],
89-
)
90-
ext_pairs = (
91-
(sources.go, go_exts),
92-
(sources.headers, hdr_exts),
93-
(sources.asm, asm_exts),
94-
(sources.c, c_exts),
95-
(sources.cxx, cxx_exts),
96-
(sources.objc, objc_exts),
97-
(sources.syso, syso_exts),
98-
)
99-
extmap = {}
100-
for outs, exts in ext_pairs:
101-
for ext in exts:
102-
ext = ext[1:] # strip the dot
103-
if ext in extmap:
104-
break
105-
extmap[ext] = outs
106-
for src in as_iterable(srcs):
107-
extouts = extmap.get(src.extension)
108-
if extouts == None:
109-
fail("Unknown source type {0}".format(src.basename))
110-
extouts.append(src)
111-
return sources
112-
11379
def os_path(ctx, path):
11480
path = str(path) # maybe convert from path type
11581
if ctx.os.name.startswith("windows"):

go/private/rules/test.bzl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ load(
2525
"asm_exts",
2626
"cgo_exts",
2727
"go_exts",
28-
"split_srcs",
2928
)
3029
load(
3130
"//go/private:context.bzl",
@@ -64,7 +63,7 @@ def _go_test_impl(ctx):
6463
internal_library = go.new_library(go, testfilter = "exclude")
6564
internal_source = go.library_to_source(go, ctx.attr, internal_library, ctx.coverage_instrumented())
6665
internal_archive = go.archive(go, internal_source)
67-
go_srcs = split_srcs(internal_source.srcs).go
66+
go_srcs = [src for src in internal_source.srcs if src.extension == "go"]
6867

6968
# Compile the library with the external black box tests
7069
external_library = go.new_library(

0 commit comments

Comments
 (0)