From 174e02ae3e377e1cfc36a620a078d8046b0887c1 Mon Sep 17 00:00:00 2001 From: Ning Ren Date: Mon, 20 Nov 2017 15:24:21 -0800 Subject: Packs contents of WORKSPACE into a bzl function, so that it can be resued by other projects, and simplifies cares build. --- third_party/cares/BUILD | 9 +++++ third_party/cares/cares.BUILD | 38 ++++++++------------- third_party/cares/cares_local_files.BUILD | 57 ------------------------------- 3 files changed, 23 insertions(+), 81 deletions(-) create mode 100644 third_party/cares/BUILD delete mode 100644 third_party/cares/cares_local_files.BUILD (limited to 'third_party/cares') diff --git a/third_party/cares/BUILD b/third_party/cares/BUILD new file mode 100644 index 0000000000..ad27d93c0f --- /dev/null +++ b/third_party/cares/BUILD @@ -0,0 +1,9 @@ +exports_files([ + "ares_build.h", + "cares.BUILD", + "config_android/ares_config.h", + "config_darwin/ares_config.h", + "config_freebsd/ares_config.h", + "config_linux/ares_config.h", + "config_openbsd/ares_config.h", +]) diff --git a/third_party/cares/cares.BUILD b/third_party/cares/cares.BUILD index 85ca506ab0..3ac02875e6 100644 --- a/third_party/cares/cares.BUILD +++ b/third_party/cares/cares.BUILD @@ -35,33 +35,27 @@ config_setting( ) genrule( - name = "ares_build", - srcs = ["@cares_local_files//:ares_build_h"], + name = "ares_build_h", + srcs = ["@com_github_grpc_grpc//third_party/cares:ares_build.h"], outs = ["ares_build.h"], - cmd = "cat $(location @cares_local_files//:ares_build_h) > $@", + cmd = "cat $< > $@", ) -# cc_library( -# name = "ares_build_h", -# hdrs = ["ares_build.h"], -# data = [":ares_build"], -# includes = ["."], -# ) - genrule( - name = "ares_config", - srcs = ["@cares_local_files//:ares_config_h"], + name = "ares_config_h", + srcs = select({ + ":ios_x86_64": ["@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h"], + ":ios_armv7": ["@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h"], + ":ios_armv7s": ["@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h"], + ":ios_arm64": ["@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h"], + ":darwin": ["@com_github_grpc_grpc//third_party/cares:config_darwin/ares_config.h"], + ":android": ["@com_github_grpc_grpc//third_party/cares:config_android/ares_config.h"], + "//conditions:default": ["@com_github_grpc_grpc//third_party/cares:config_linux/ares_config.h"], + }), outs = ["ares_config.h"], - cmd = "cat $(location @cares_local_files//:ares_config_h) > $@", + cmd = "cat $< > $@", ) -# cc_library( -# name = "ares_config_h", -# hdrs = ["ares_config.h"], -# data = [":ares_config"], -# includes = ["."], -# ) - cc_library( name = "ares", srcs = [ @@ -147,10 +141,6 @@ cc_library( "-DNOMINMAX", "-DHAVE_CONFIG_H", ], - data = [ - ":ares_build", - ":ares_config", - ], includes = ["."], linkstatic = 1, visibility = [ diff --git a/third_party/cares/cares_local_files.BUILD b/third_party/cares/cares_local_files.BUILD deleted file mode 100644 index fe59447beb..0000000000 --- a/third_party/cares/cares_local_files.BUILD +++ /dev/null @@ -1,57 +0,0 @@ -package( - default_visibility = ["//visibility:public"], -) - -config_setting( - name = "darwin", - values = {"cpu": "darwin"}, -) - -# Android is not officially supported through C++. -# This just helps with the build for now. -config_setting( - name = "android", - values = { - "crosstool_top": "//external:android/crosstool", - }, -) - -# iOS is not officially supported through C++. -# This just helps with the build for now. -config_setting( - name = "ios_x86_64", - values = {"cpu": "ios_x86_64"}, -) - -config_setting( - name = "ios_armv7", - values = {"cpu": "ios_armv7"}, -) - -config_setting( - name = "ios_armv7s", - values = {"cpu": "ios_armv7s"}, -) - -config_setting( - name = "ios_arm64", - values = {"cpu": "ios_arm64"}, -) - -filegroup( - name = "ares_build_h", - srcs = ["ares_build.h"], -) - -filegroup( - name = "ares_config_h", - srcs = select({ - ":ios_x86_64": ["config_darwin/ares_config.h"], - ":ios_armv7": ["config_darwin/ares_config.h"], - ":ios_armv7s": ["config_darwin/ares_config.h"], - ":ios_arm64": ["config_darwin/ares_config.h"], - ":darwin": ["config_darwin/ares_config.h"], - ":android": ["config_android/ares_config.h"], - "//conditions:default": ["config_linux/ares_config.h"], - }), -) -- cgit v1.2.3