aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/build_defs/apple
diff options
context:
space:
mode:
authorGravatar Dmitry Shevchenko <dmishe@google.com>2016-09-06 20:34:02 +0000
committerGravatar Yue Gan <yueg@google.com>2016-09-07 10:38:57 +0000
commit8cb48f7ff32c3bf3f9c506438da09ad767a16145 (patch)
tree9f2a06fbe5a2c318c774f12e170735ec6cdd25d9 /tools/build_defs/apple
parent02211a6fc044e1a6bb8ffc8a0a8bf02766fe99ed (diff)
Re-add support for watchOS in swift_library.
RELNOTES: swift_library can be used to build watchOS apps. -- MOS_MIGRATED_REVID=132355955
Diffstat (limited to 'tools/build_defs/apple')
-rw-r--r--tools/build_defs/apple/shared.bzl10
-rw-r--r--tools/build_defs/apple/swift.bzl12
2 files changed, 18 insertions, 4 deletions
diff --git a/tools/build_defs/apple/shared.bzl b/tools/build_defs/apple/shared.bzl
index 97c567f18a..8ac34a6562 100644
--- a/tools/build_defs/apple/shared.bzl
+++ b/tools/build_defs/apple/shared.bzl
@@ -65,8 +65,14 @@ def xcrun_action(ctx, **kw):
This method takes the same keyword arguments as ctx.action, however you don't
need to specify the executable.
"""
- # TODO(dmishe): Use single_arch_platform() when available.
- platform = ctx.fragments.apple.ios_cpu_platform()
+
+ if (hasattr(ctx.fragments.apple, "single_arch_cpu")
+ and hasattr(ctx.fragments.apple, "single_arch_platform")):
+ platform = ctx.fragments.apple.single_arch_platform
+ else:
+ # TODO(dmishe): Remove this branch when single_arch_platform is available
+ # by default.
+ platform = ctx.fragments.apple.ios_cpu_platform()
action_env = ctx.fragments.apple.target_apple_env(platform) \
+ ctx.fragments.apple.apple_host_system_env()
diff --git a/tools/build_defs/apple/swift.bzl b/tools/build_defs/apple/swift.bzl
index 1a315a1930..fdae0fcf40 100644
--- a/tools/build_defs/apple/swift.bzl
+++ b/tools/build_defs/apple/swift.bzl
@@ -73,8 +73,15 @@ def _swift_library_impl(ctx):
apple_fm = ctx.fragments.apple
# TODO(dmishe): Use single_arch_cpu and single_arch_platform when available.
- cpu = apple_fm.ios_cpu()
- platform = apple_fm.ios_cpu_platform()
+ if (hasattr(apple_fm, "single_arch_cpu")
+ and hasattr(apple_fm, "single_arch_platform")):
+ cpu = apple_fm.single_arch_cpu
+ platform = apple_fm.single_arch_platform
+ else:
+ # TODO(dmishe): Remove this branch when single_arch_platform is available
+ # by default.
+ cpu = apple_fm.ios_cpu()
+ platform = apple_fm.ios_cpu_platform()
sdk_version = apple_fm.sdk_version_for_platform(platform)
target = _swift_target(cpu, platform, sdk_version)
@@ -127,6 +134,7 @@ def _swift_library_impl(ctx):
output_objs = []
for source in ctx.files.srcs:
obj = ctx.new_file(source.basename + ".o")
+ print(obj)
output_objs.append(obj)
output_map += struct(**{source.path: struct(object=obj.path)})