Skip to content

Commit f172068

Browse files
authored
Remove prints when toolchain is skipped (#1535)
If you have rules_swift in your dependency tree, but don't use swift anywhere in your build, this still warns is too noisy. Likely the most common case for this is because grpc depends on rules_apple.
1 parent ed87447 commit f172068

File tree

1 file changed

+4
-34
lines changed

1 file changed

+4
-34
lines changed

swift/internal/swift_autoconfiguration.bzl

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -200,21 +200,14 @@ def _normalized_linux_cpu(cpu):
200200
return "x86_64"
201201
return cpu
202202

203-
def _create_linux_toolchain(*, repository_ctx, warn_on_no_swiftc):
203+
def _create_linux_toolchain(*, repository_ctx):
204204
"""Creates BUILD targets for the Swift toolchain on Linux.
205205
206206
Args:
207207
repository_ctx: The repository rule context.
208-
warn_on_no_swiftc: If True, print a warning if 'swiftc' is not found in
209-
$PATH.
210208
"""
211209
path_to_swiftc = repository_ctx.which("swiftc")
212210
if not path_to_swiftc:
213-
if warn_on_no_swiftc:
214-
print("""\
215-
No 'swiftc' executable found in $PATH. Not auto-generating a Linux Swift \
216-
toolchain.
217-
""") # buildifier: disable=print
218211
return """\
219212
# No 'swiftc' executable found in $PATH. Not auto-generating a Linux Swift \
220213
toolchain.
@@ -314,21 +307,14 @@ def _get_python_bin(repository_ctx):
314307
return out
315308
return None
316309

317-
def _create_windows_toolchain(*, repository_ctx, warn_on_no_swiftc):
310+
def _create_windows_toolchain(*, repository_ctx):
318311
"""Creates BUILD targets for the Swift toolchain on Linux.
319312
320313
Args:
321314
repository_ctx: The repository rule context.
322-
warn_on_no_swiftc: If True, print a warning if 'swiftc.exe' is not found
323-
in $PATH.
324315
"""
325316
path_to_swiftc = repository_ctx.which("swiftc.exe")
326317
if not path_to_swiftc:
327-
if warn_on_no_swiftc:
328-
print("""\
329-
No 'swiftc.exe' executable found in $PATH. Not auto-generating a Windows Swift \
330-
toolchain.
331-
""") # buildifier: disable=print
332318
return """\
333319
# No 'swiftc.exe' executable found in $PATH. Not auto-generating a Windows \
334320
Swift toolchain.
@@ -394,16 +380,6 @@ toolchain(
394380
)
395381

396382
def _swift_autoconfiguration_impl(repository_ctx):
397-
os_name = repository_ctx.os.name.lower()
398-
is_linux = False
399-
is_windows = False
400-
if os_name.startswith("mac os"):
401-
pass
402-
elif os_name.startswith("windows"):
403-
is_windows = True
404-
else:
405-
is_linux = True
406-
407383
repository_ctx.file(
408384
"BUILD",
409385
"\n".join([
@@ -424,14 +400,8 @@ load(
424400
package(default_visibility = ["//visibility:public"])
425401
""",
426402
_create_xcode_toolchain(),
427-
_create_windows_toolchain(
428-
repository_ctx = repository_ctx,
429-
warn_on_no_swiftc = is_windows,
430-
),
431-
_create_linux_toolchain(
432-
repository_ctx = repository_ctx,
433-
warn_on_no_swiftc = is_linux,
434-
),
403+
_create_windows_toolchain(repository_ctx = repository_ctx),
404+
_create_linux_toolchain(repository_ctx = repository_ctx),
435405
]),
436406
)
437407

0 commit comments

Comments
 (0)