Skip to content

Commit

Permalink
Add uses_swift flag to the providers exported by swift_library.
Browse files Browse the repository at this point in the history
* This eliminates the need to put "dummy.swift" into objc_binary targets that depend on swift_library.

--
MOS_MIGRATED_REVID=124015750
  • Loading branch information
Dmitry Shevchenko authored and meteorcloudy committed Jun 6, 2016
1 parent 91d3433 commit 696a4a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
24 changes: 5 additions & 19 deletions src/test/shell/bazel/bazel_apple_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ function make_app() {
rm -rf ios
mkdir -p ios

touch ios/dummy.swift

cat >ios/app.swift <<EOF
import UIKit
Expand Down Expand Up @@ -87,9 +85,7 @@ swift_library(name = "SwiftMain",
srcs = ["app.swift"])
objc_binary(name = "bin",
# TODO(b/28723643): This dummy is only here to trigger the
# USES_SWIFT flag on ObjcProvider and should not be necessary.
srcs = ['dummy.swift'],
srcs = ["//tools/objc:dummy.c"],
deps = [":SwiftMain"])
ios_application(name = "app",
Expand Down Expand Up @@ -118,8 +114,6 @@ function test_objc_depends_on_swift() {
rm -rf ios
mkdir -p ios

touch ios/dummy.swift

cat >ios/main.swift <<EOF
import Foundation
Expand Down Expand Up @@ -147,9 +141,7 @@ swift_library(name = "SwiftMain",
srcs = ["main.swift"])
objc_binary(name = "bin",
# TODO(b/28723643): This dummy is only here to trigger the
# USES_SWIFT flag on ObjcProvider and should not be necessary.
srcs = ['app.m', 'dummy.swift'],
srcs = ['app.m',],
deps = [":SwiftMain"])
EOF

Expand Down Expand Up @@ -210,8 +202,6 @@ function test_swift_import_objc_framework() {
# Copy the prebuilt framework into app's directory.
cp -RL "${BAZEL_RUNFILES}/tools/build_defs/apple/test/testdata/BlazeFramework.framework" ios

touch ios/dummy.swift

cat >ios/main.swift <<EOF
import UIKit
Expand All @@ -234,7 +224,7 @@ EOF
load("//tools/build_defs/apple:swift.bzl", "swift_library")
objc_binary(name = "bin",
srcs = ["dummy.swift"],
srcs = ["//tools/objc:dummy.c"],
deps = [":swift_lib"])
swift_library(name = "swift_lib",
Expand Down Expand Up @@ -287,7 +277,6 @@ int main() {
EOF

bazel build --verbose_failures //package:lipo_out \
--ios_sdk_version=$IOS_SDK_VERSION \
--ios_multi_cpus=i386,x86_64 || fail "should build apple_binary and obtain info via lipo"

cat bazel-genfiles/package/lipo_out | grep "i386 x86_64" \
Expand Down Expand Up @@ -325,7 +314,6 @@ EOF


bazel build --verbose_failures //package:extract_archives \
--ios_sdk_version=$IOS_SDK_VERSION \
--ios_multi_cpus=i386,x86_64 \
|| fail "should build multi-architecture archive"

Expand Down Expand Up @@ -388,9 +376,7 @@ swift_library(name = "SwiftMain",
srcs = ["app.swift"])
objc_binary(name = "bin",
# TODO(b/28723643): This dummy is only here to trigger the
# USES_SWIFT flag on ObjcProvider and should not be necessary.
srcs = ['dummy.swift'],
srcs = ["//tools/objc:dummy.c"],
deps = [":SwiftMain"])
ios_application(name = "app",
Expand All @@ -401,7 +387,7 @@ swift_library(name = "SwiftTest",
srcs = ["tests.swift"])
ios_test(name = "app_test",
srcs = ['dummy.swift'],
srcs = ["//tools/objc:dummy.c"],
deps = [":SwiftTest"],
xctest_app = "app")
EOF
Expand Down
3 changes: 2 additions & 1 deletion tools/build_defs/apple/swift.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ def _swift_library_impl(ctx):
objc_provider = apple_common.new_objc_provider(
library=set([output_lib] + dep_libs),
header=set([output_header]),
providers=objc_providers)
providers=objc_providers,
uses_swift=True)

return struct(
swift=struct(
Expand Down

0 comments on commit 696a4a7

Please sign in to comment.