From 21c6531bc0df1501cc9188f35b5d4ddedfa6d5fa Mon Sep 17 00:00:00 2001 From: Tony Lu Date: Thu, 15 Aug 2019 11:21:10 -0700 Subject: [PATCH] Added targets for other examples in objective-c examples --- examples/BUILD | 5 ++ examples/objective-c/BUILD | 58 +++++++++++++++++++ .../helloworld_macos/HelloWorld/Info.plist | 2 +- examples/objective-c/helloworld_macos/main.m | 4 ++ .../objective-c/route_guide/ViewControllers.m | 4 ++ test/build_test/BUILD | 2 +- 6 files changed, 73 insertions(+), 2 deletions(-) diff --git a/examples/BUILD b/examples/BUILD index aa9ed945849..6f801963c6e 100644 --- a/examples/BUILD +++ b/examples/BUILD @@ -238,3 +238,8 @@ cc_binary( "//:grpc++", ], ) + +proto_library( + name = "route_guide_proto", + srcs = ["protos/route_guide.proto"], +) diff --git a/examples/objective-c/BUILD b/examples/objective-c/BUILD index 9ceaaa9a8b4..4a5eafdf3fb 100644 --- a/examples/objective-c/BUILD +++ b/examples/objective-c/BUILD @@ -18,6 +18,7 @@ package(default_visibility = ["//visibility:public"]) load("@com_github_grpc_grpc//bazel:objc_grpc_library.bzl", "objc_grpc_library") load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application") +load("@build_bazel_rules_apple//apple:macos.bzl", "macos_application") objc_grpc_library( name = "HelloWorld_grpc_proto", @@ -59,3 +60,60 @@ ios_application( deps = [":HelloWorld-lib"], tags = ["manual"], ) + +objc_library( + name = "HelloWorldMacos-lib", + srcs = glob(["helloworld_macos/**/*.m",]), + hdrs = glob(["helloworld_macos/**/*.h"]), + data = glob([ + "helloworld_macos/HelloWorld/Base.lproj/**", + "helloworld_macos/HelloWorld/Images.xcassets/**", + ]), + includes = ["helloworld_macos/HelloWorld"], + deps = [":HelloWorld_grpc_proto"], + tags = ["manual"], +) + +macos_application( + name = "HelloWorldMacos", + bundle_id = "io.grpc.HelloWorld", + minimum_os_version = "10.13", + entitlements = "helloworld_macos/HelloWorld/Helloworld.entitlements", + infoplists = ["helloworld_macos/HelloWorld/Info.plist"], + deps = [":HelloWorldMacos-lib"], + tags = ["manual"], +) + +objc_grpc_library( + name = "RouteGuide", + srcs = ["//examples:protos/route_guide.proto"], + deps = ["//examples:route_guide_proto"], + tags = ["manual"], +) + +objc_library( + name = "RouteGuideClient-lib", + srcs = glob(["route_guide/**/*.m"]), + hdrs = glob(["route_guide/**/*.h"]), + data = glob([ + "route_guide/Misc/Base.lproj/**", + "route_guide/Misc/Images.xcassets/**", + "route_guide/route_guide_db.json", + ]), + includes = ["route_guide/Misc"], + deps = [":RouteGuide"], + tags = ["manual"], +) + +ios_application( + name = "RouteGuideClient", + bundle_id = "gRPC.RouteGuideClient", + families = [ + "iphone", + "ipad", + ], + minimum_os_version = "8.0", + infoplists = ["route_guide/Misc/Info.plist"], + deps = [":RouteGuideClient-lib"], + tags = ["manual"], +) diff --git a/examples/objective-c/helloworld_macos/HelloWorld/Info.plist b/examples/objective-c/helloworld_macos/HelloWorld/Info.plist index f7bfdac9d6f..c76261baef0 100644 --- a/examples/objective-c/helloworld_macos/HelloWorld/Info.plist +++ b/examples/objective-c/helloworld_macos/HelloWorld/Info.plist @@ -3,7 +3,7 @@ CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) + en CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIconFile diff --git a/examples/objective-c/helloworld_macos/main.m b/examples/objective-c/helloworld_macos/main.m index ce24a9b1466..c0e7ef3c9ab 100644 --- a/examples/objective-c/helloworld_macos/main.m +++ b/examples/objective-c/helloworld_macos/main.m @@ -20,7 +20,11 @@ #import #import +#if COCOAPODS #import +#else +#import "examples/protos/Helloworld.pbrpc.h" +#endif static NSString * const kHostAddress = @"localhost:50051"; diff --git a/examples/objective-c/route_guide/ViewControllers.m b/examples/objective-c/route_guide/ViewControllers.m index 43d2082f585..f36bfe607b5 100644 --- a/examples/objective-c/route_guide/ViewControllers.m +++ b/examples/objective-c/route_guide/ViewControllers.m @@ -17,7 +17,11 @@ */ #import +#if COCOAPODS #import +#else +#import "examples/protos/RouteGuide.pbrpc.h" +#endif static NSString * const kHostAddress = @"localhost:50051"; diff --git a/test/build_test/BUILD b/test/build_test/BUILD index 90777266a14..dd2030ccda6 100644 --- a/test/build_test/BUILD +++ b/test/build_test/BUILD @@ -25,4 +25,4 @@ build_test( "//examples/objective-c:HelloWorld", ], tags = ["manual"], -) \ No newline at end of file +)