diff options
author | Dmitry Shevchenko <dmishe@google.com> | 2017-01-11 19:42:26 +0000 |
---|---|---|
committer | Marcel Hlopko <hlopko@google.com> | 2017-01-12 09:11:19 +0000 |
commit | 1b9ddda39af80292c2f0387bd300b06922696ccb (patch) | |
tree | c94bff9e73530b15e64349fa77fc479ae220aae1 | |
parent | f3874a48e5cc760303d5cc040691ce344c375f79 (diff) |
Add --swiftcopt support to swift_library
--
PiperOrigin-RevId: 144231300
MOS_MIGRATED_REVID=144231300
-rwxr-xr-x | src/test/shell/bazel/apple/bazel_apple_test.sh | 5 | ||||
-rw-r--r-- | tools/build_defs/apple/swift.bzl | 7 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/test/shell/bazel/apple/bazel_apple_test.sh b/src/test/shell/bazel/apple/bazel_apple_test.sh index a83bbe300a..94c4822524 100755 --- a/src/test/shell/bazel/apple/bazel_apple_test.sh +++ b/src/test/shell/bazel/apple/bazel_apple_test.sh @@ -627,6 +627,10 @@ public class SwiftClass { #if !FLAG let x: String = 1 // Invalid statement, should throw compiler error when FLAG is not set #endif + + #if !CMD_FLAG + let y: String = 1 // Invalid statement, should throw compiler error when CMD_FLAG is not set + #endif } } EOF @@ -640,6 +644,7 @@ swift_library(name = "swift_lib", EOF bazel build --verbose_failures --xcode_version=$XCODE_VERSION \ + --swiftcopt=-DCMD_FLAG \ //ios:swift_lib >$TEST_log 2>&1 || fail "should build" } diff --git a/tools/build_defs/apple/swift.bzl b/tools/build_defs/apple/swift.bzl index 60ed1bc26a..d5160f478a 100644 --- a/tools/build_defs/apple/swift.bzl +++ b/tools/build_defs/apple/swift.bzl @@ -309,6 +309,11 @@ def swiftc_args(ctx): args.extend(framework_args) args.extend(clang_args) args.extend(define_args) + + # TODO(b/33692249): Remove conditional once bazel is released. + if hasattr(ctx.fragments, "swift"): + args.extend(ctx.fragments.swift.copts()) + args.extend(ctx.attr.copts) return args @@ -459,7 +464,7 @@ SWIFT_LIBRARY_ATTRS = { swift_library = rule( _swift_library_impl, attrs = SWIFT_LIBRARY_ATTRS, - fragments = ["apple", "objc"], + fragments = ["apple", "objc", "swift"], output_to_genfiles=True, ) """ |