Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bazel import brpc build failed #1378

Closed
FightingMan opened this issue Apr 13, 2021 · 2 comments
Closed

bazel import brpc build failed #1378

FightingMan opened this issue Apr 13, 2021 · 2 comments

Comments

@FightingMan
Copy link

Describe the bug (描述bug)
bazel 引入brpc失败
单独在brpc项目里面 bazel build ...编译成功
但是在单独的项目里面通过workspace引入brpc失败

To Reproduce (复现方法)
见附件

Expected behavior (期望行为)
bazel能通过workspace引入brpc

Versions (各种版本)
OS: centos7
Compiler: gcc version 7.3.1 20180303 (Red Hat 7.3.1-6) (GCC)
brpc: master
protobuf: libprotoc 3.12.3
bazel:bazel 1.1.0

Additional context/screenshots (更多上下文/截图)

(base) [ /tmp/test_brpc]$ cat test.cpp
#include

int main() {
return 0;
}
(base) [ /tmp/test_brpc]$ cat BUILD
package(default_visibility = ["//visibility:public"])

cc_binary(
name = "test_server",
linkopts = [
"-ldl",
],
deps = [
":test_service",
],
)

cc_library(
name = "test_service",
srcs = [“test.cpp”],
visibility = [
"//visibility:public",
],
deps = [
"@brpc_cpp//:brpc",
],
)

(base) [ /tmp/test_brpc]$ cat WORKSPACE
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load('@bazel_tools//tools/build_defs/repo:git.bzl', 'git_repository')
git_repository(
name = "brpc_cpp",
remote = "https://github.com/apache/incubator-brpc.git",
branch = "master",
)
(base) [ /tmp/test_brpc]$ bazel build ...
INFO: Writing tracer profile to '/.../4bbabbdb1156dfbb9355920322dd01b1/command.profile.gz'
DEBUG: Rule 'brpc_cpp' indicated that a canonical reproducible form can be obtained by modifying arguments commit = "b3a948c9dca29632b3367529488e070852e31f11", shallow_since = "1617642087 +0200" and dropping ["branch"]
DEBUG: Call stack for the definition of repository 'brpc_cpp' which is a git_repository (rule definition at /.../4bbabbdb1156dfbb9355920322dd01b1/external/bazel_tools/tools/build_defs/repo/git.bzl:195:18):

  • /tmp/test_brpc/WORKSPACE:3:1
    ERROR: /tmp/test_brpc/BUILD:13:1: error loading package '@brpc_cpp//': in /.../4bbabbdb1156dfbb9355920322dd01b1/external/brpc_cpp/bazel/brpc.bzl: Unable to find package for @com_google_protobuf//:protobuf.bzl: The repository '@com_google_protobuf' could not be resolved. and referenced by '//:test_service'
    ERROR: Analysis of target '//:test_server' failed; build aborted: error loading package '@brpc_cpp//': in /.../4bbabbdb1156dfbb9355920322dd01b1/external/brpc_cpp/bazel/brpc.bzl: Unable to find package for @com_google_protobuf//:protobuf.bzl: The repository '@com_google_protobuf' could not be resolved.
    INFO: Elapsed time: 0.101s
    INFO: 0 processes.
    FAILED: Build did NOT complete successfully (1 packages loaded, 0 targets configured)
    (base) [/tmp/test_brpc]$ ls
    BUILD WORKSPACE test.cpp
@FightingMan
Copy link
Author

update:
copy全部buildfile到本地,以及修改本地WORKSPACE文件能解决
期待提供一共fucntion,load一下即可

(base) [ /tmp/test_brpc]$ ls
BUILD WORKSPACE bazel-bin bazel-out bazel-test_brpc bazel-testlogs glog.BUILD leveldb.BUILD openssl.BUILD test.cpp zlib.BUILD
(base) [/tmp/test_brpc]$ !cat
cat WORKSPACE
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load('@bazel_tools//tools/build_defs/repo:git.bzl', 'git_repository')
git_repository(
name = "brpc_cpp",
remote = "https://github.com/apache/incubator-brpc.git",
branch = "master",
)

skylib_version = "0.8.0"
http_archive(
name = "bazel_skylib",
type = "tar.gz",
url = "https://github.com/bazelbuild/bazel-skylib/releases/download/{}/bazel-skylib.{}.tar.gz".format (skylib_version, skylib_version),
sha256 = "2ef429f5d7ce7111263289644d233707dba35e39696377ebab8b0bc701f7818e",
)

http_archive(
name = "com_google_protobuf",
strip_prefix = "protobuf-3.6.1.3",
sha256 = "9510dd2afc29e7245e9e884336f848c8a6600a14ae726adb6befdb4f786f0be2",
type = "zip",
url = "https://github.com/protocolbuffers/protobuf/archive/v3.6.1.3.zip",
)

http_archive(
name = "com_github_gflags_gflags",
strip_prefix = "gflags-46f73f88b18aee341538c0dfc22b1710a6abedef",
url = "https://github.com/gflags/gflags/archive/46f73f88b18aee341538c0dfc22b1710a6abedef.tar.gz",
)

bind(
name = "gflags",
actual = "@com_github_gflags_gflags//:gflags",
)

http_archive(
name = "com_github_google_leveldb",
build_file = "//:leveldb.BUILD",
strip_prefix = "leveldb-a53934a3ae1244679f812d998a4f16f2c7f309a6",
url = "https://github.com/google/leveldb/archive/a53934a3ae1244679f812d998a4f16f2c7f309a6.tar.gz"
)

http_archive(
name = "com_github_google_glog",
build_file = "//:glog.BUILD",
strip_prefix = "glog-a6a166db069520dbbd653c97c2e5b12e08a8bb26",
url = "https://github.com/google/glog/archive/a6a166db069520dbbd653c97c2e5b12e08a8bb26.tar.gz"
)

http_archive(
name = "com_google_googletest",
strip_prefix = "googletest-0fe96607d85cf3a25ac40da369db62bbee2939a5",
url = "https://github.com/google/googletest/archive/0fe96607d85cf3a25ac40da369db62bbee2939a5.tar.gz",
)

new_local_repository(
name = "openssl",
path = "/usr",
build_file = "//:openssl.BUILD",
)

new_local_repository(
name = "openssl_macos",
build_file = "//:openssl.BUILD",
path = "/usr/lib/openssl",
)

bind(
name = "ssl",
actual = "@openssl//:ssl"
)

bind(
name = "ssl_macos",
actual = "@openssl_macos//:ssl"
)

new_local_repository(
name = "zlib",
build_file = "//:zlib.BUILD",
path = "/usr",
)

@serverglen
Copy link
Contributor

closed, reopen if you have further ideas.
Thank you for your contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants