Skip to content

Commit

Permalink
Pass new test library directory to builds
Browse files Browse the repository at this point in the history
With Xcode 11 there is a new location where there are Swift specific
libraries and swiftmodules. Specifically they contain the new
`XCTUnwrap` function. This change passes these arguments to the compiler
and the linker.

For iOS tests this also requires bazelbuild/rules_apple#572

Fixes #266
  • Loading branch information
keith committed Aug 30, 2019
1 parent b50fab2 commit b0068d4
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion swift/internal/xcode_swift_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ toolchain, see `swift.bzl`.
load("@bazel_skylib//lib:collections.bzl", "collections")
load("@bazel_skylib//lib:dicts.bzl", "dicts")
load("@bazel_skylib//lib:partial.bzl", "partial")
load("@bazel_skylib//lib:paths.bzl", "paths")
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")
load(
":features.bzl",
Expand All @@ -35,6 +36,17 @@ load(
)
load(":providers.bzl", "SwiftToolchainInfo")

def _swift_developer_lib_dir(platform_framework_dir):
"""Returns the directory contain extra Swift specific developer libraries
Args:
platform_framework_dir: The developer platform framework directory for the current platform
Returns:
The directory containing Swift specific development libraries and swiftmodules
"""
return paths.join(paths.dirname(paths.dirname(platform_framework_dir)), "usr", "lib")

def _command_line_objc_copts(objc_fragment):
"""Returns copts that should be passed to `clang` from the `objc` fragment.
Expand Down Expand Up @@ -140,6 +152,7 @@ def _default_linker_opts(
# their rpaths.
if is_test:
linkopts.append("-Wl,-rpath,{}".format(platform_framework_dir))
linkopts.append("-L{}".format(_swift_developer_lib_dir(platform_framework_dir))

return linkopts

Expand All @@ -154,13 +167,16 @@ def _default_swiftc_copts(apple_fragment, apple_toolchain, target):
Returns:
A list of options that will be passed to any compile action created by this toolchain.
"""
platform_framework_dir = apple_toolchain.platform_developer_framework_dir(apple_fragment)
copts = [
"-target",
target,
"-sdk",
apple_toolchain.sdk_dir(),
"-F",
apple_toolchain.platform_developer_framework_dir(apple_fragment),
platform_framework_dir,
"-I",
_swift_developer_lib_dir(platform_framework_dir),
]

bitcode_mode = str(apple_fragment.bitcode_mode)
Expand Down

0 comments on commit b0068d4

Please sign in to comment.