From f0437d6ed695b048eaca8fd0fd88907332eba772 Mon Sep 17 00:00:00 2001 From: Liangliang He Date: Tue, 29 Aug 2017 22:31:38 +0800 Subject: [PATCH] Fix android build --- WORKSPACE | 14 +++++++------- mace/core/BUILD | 1 + mace/examples/BUILD | 5 +---- mace/ops/BUILD | 10 +++++++++- mace/proto/BUILD | 2 +- mace/third_party/gtest.BUILD | 35 ++++++++++++++++++++++------------- 6 files changed, 41 insertions(+), 26 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index b2322988..247e552b 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -5,24 +5,24 @@ workspace(name = "mace") # This statement defines the @com_google_protobuf repo. http_archive( name = "com_google_protobuf", - urls = ["http://v9.git.n.xiaomi.com/deep-learning/protobuf/repository/archive.zip?ref=b4b0e304be5a68de3d0ee1af9b286f958750f5e4"], - strip_prefix = "protobuf-b4b0e304be5a68de3d0ee1af9b286f958750f5e4-b4b0e304be5a68de3d0ee1af9b286f958750f5e4", - sha256 = "11087b7d623d066e9b58acf22e3d8f8433e2f3ce1248123bd61da4e109a3f30a", + urls = ["http://v9.git.n.xiaomi.com/deep-learning/protobuf/repository/archive.zip?ref=c7457ef65a7a8584b1e3bd396c401ccf8e275ffa"], + strip_prefix = "protobuf-c7457ef65a7a8584b1e3bd396c401ccf8e275ffa-c7457ef65a7a8584b1e3bd396c401ccf8e275ffa", + sha256 = "0a54cae83b77f4b54b7db4eaebadd81fbe91655e84a1ef3f6d29116d75f3a45f", ) # cc_proto_library rules implicitly depend on @com_google_protobuf_cc//:cc_toolchain, # which is the C++ proto runtime (base classes and common utilities). http_archive( name = "com_google_protobuf_cc", - urls = ["http://v9.git.n.xiaomi.com/deep-learning/protobuf/repository/archive.zip?ref=b4b0e304be5a68de3d0ee1af9b286f958750f5e4"], - strip_prefix = "protobuf-b4b0e304be5a68de3d0ee1af9b286f958750f5e4-b4b0e304be5a68de3d0ee1af9b286f958750f5e4", - sha256 = "11087b7d623d066e9b58acf22e3d8f8433e2f3ce1248123bd61da4e109a3f30a", + urls = ["http://v9.git.n.xiaomi.com/deep-learning/protobuf/repository/archive.zip?ref=c7457ef65a7a8584b1e3bd396c401ccf8e275ffa"], + strip_prefix = "protobuf-c7457ef65a7a8584b1e3bd396c401ccf8e275ffa-c7457ef65a7a8584b1e3bd396c401ccf8e275ffa", + sha256 = "0a54cae83b77f4b54b7db4eaebadd81fbe91655e84a1ef3f6d29116d75f3a45f", ) new_http_archive( name = "gtest", url = "http://v9.git.n.xiaomi.com/deep-learning/googletest/repository/archive.zip?ref=release-1.8.0", - strip_prefix = "googletest-release-1.8.0-ec44c6c1675c25b9827aacd08c02433cccde7780/googletest", + strip_prefix = "googletest-release-1.8.0-ec44c6c1675c25b9827aacd08c02433cccde7780", sha256 = "a0b43a0a43cda0cc401a46d75519d961ef27f6674d4126366e47d9c946c4bbcd", build_file = "mace/third_party/gtest.BUILD", ) diff --git a/mace/core/BUILD b/mace/core/BUILD index 8b63a4b1..2da78ebb 100644 --- a/mace/core/BUILD +++ b/mace/core/BUILD @@ -15,5 +15,6 @@ cc_library( deps = [ "//mace/proto:cc_proto", ], + copts = ['-std=c++11'], ) diff --git a/mace/examples/BUILD b/mace/examples/BUILD index e932dd38..55cb535c 100644 --- a/mace/examples/BUILD +++ b/mace/examples/BUILD @@ -1,8 +1,5 @@ # Examples -load( - "//mace:mace.bzl", - "if_android", - ) +load("//mace:mace.bzl", "if_android") cc_binary( name = "helloworld", diff --git a/mace/ops/BUILD b/mace/ops/BUILD index 9443f7a3..f6fede34 100644 --- a/mace/ops/BUILD +++ b/mace/ops/BUILD @@ -8,6 +8,8 @@ package( licenses(["notice"]) # Apache 2.0 +load("//mace:mace.bzl", "if_android") + cc_library( name = "ops", srcs = ["relu.cc"], @@ -16,14 +18,20 @@ cc_library( "//mace/proto:cc_proto", "//mace/core:core", ], + copts = ['-std=c++11'], ) cc_test( name = "relu_test", srcs = ["relu_test.cc",], deps = [ - "@gtest//:gtest", + "@gtest//:gtest_main", ":ops", ], + copts = ['-std=c++11'], + linkopts = if_android([ + "-pie", + "-llog", + ]) ) diff --git a/mace/proto/BUILD b/mace/proto/BUILD index bb2512bc..c0ed8820 100644 --- a/mace/proto/BUILD +++ b/mace/proto/BUILD @@ -13,4 +13,4 @@ proto_library( cc_proto_library( name = "cc_proto", deps = [":proto"], -) \ No newline at end of file +) diff --git a/mace/third_party/gtest.BUILD b/mace/third_party/gtest.BUILD index be8010ba..b1ae15a9 100644 --- a/mace/third_party/gtest.BUILD +++ b/mace/third_party/gtest.BUILD @@ -1,19 +1,28 @@ -# Description: -# Google test - -licenses(["notice"]) - cc_library( name = "gtest", - srcs = glob( - ["src/*.cc"], - exclude = ["src/gtest-all.cc"] - ), + srcs = [ + "googletest/src/gtest-all.cc", + "googlemock/src/gmock-all.cc", + ], hdrs = glob([ - "include/**/*.h", - "src/*.h" + "**/*.h", + "googletest/src/*.cc", + "googlemock/src/*.cc", ]), - copts = ["-Iexternal/gtest/include"], + includes = [ + "googlemock", + "googletest", + "googletest/include", + "googlemock/include", + ], + linkopts = ["-pthread"], + visibility = ["//visibility:public"], +) + +cc_library( + name = "gtest_main", + srcs = ["googlemock/src/gmock_main.cc"], linkopts = ["-pthread"], visibility = ["//visibility:public"], -) \ No newline at end of file + deps = [":gtest"], +) -- GitLab