Skip to content

Commit

Permalink
Switch hasattr with our version check (#1152)
Browse files Browse the repository at this point in the history
If you mix hasattr with version checks you get the wrong behavior on
old dev builds, because in the case of fragments when it was supported
`ctx.fragments.swift` always existed, you just couldn't access it
without declaring the dependency, so on old commit releases they are
treated as not having this feature, even when the fragment API is still
there.
  • Loading branch information
keith committed Jan 18, 2024
1 parent 313ab73 commit 9ee82b8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion swift/internal/swift_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def _swift_toolchain_impl(ctx):
)

# TODO: Remove once we drop bazel 7.x support
if hasattr(ctx.fragments, "swift"):
if not bazel_features.cc.swift_fragment_removed:
swiftcopts = list(ctx.fragments.swift.copts())
else:
swiftcopts = []
Expand Down
2 changes: 1 addition & 1 deletion swift/internal/xcode_swift_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ def _xcode_swift_toolchain_impl(ctx):
xcode_config = ctx.attr._xcode_config[apple_common.XcodeVersionConfig]

# TODO: Remove once we drop bazel 7.x support
if hasattr(ctx.fragments, "swift"):
if not bazel_features.cc.swift_fragment_removed:
swiftcopts = list(ctx.fragments.swift.copts())
else:
swiftcopts = []
Expand Down

0 comments on commit 9ee82b8

Please sign in to comment.