baidu / sofa-pbrpc

A light-weight RPC implement of google protobuf RPC framework.
Other
2.13k stars 655 forks source link

Bazel build #174

Closed teodor-pripoae closed 7 years ago

teodor-pripoae commented 7 years ago

Hi,

I've added Bazel config files to allow reproductible builds. I tested them on OS X and Linux (Ubuntu).

When building using Bazel, it will download all required dependencies and will compile static binaries for host platform.

To build sofa-pbrpc-client, run:

$ bazel build sofa-pbrpc-client

To build examples:

$ bazel build sample/compress_sample:server
$ bazel build sample/compress_sample:client

$ bazel-bin/sample/compress_sample/server
$ bazel-bin/sample/compress_sample/client
cyshi commented 7 years ago

@zd-double @qinzuoyan

cyshi commented 7 years ago

Thanks for your pr, very convenience.

teodor-pripoae commented 7 years ago

I'm still having a small problem with boost libs, it seems I can't include them as header only libs, I need to compile them into a static .a. I will fix it later today.

teodor-pripoae commented 7 years ago

Fixed compiling boost files.

zd-double commented 7 years ago

@teodor-pripoae Thanks very much for your code ! I build successfully on Ubuntu12.04, but failed on centos7.3

ERROR: /root/code/sofa-pbrpc/BUILD:34:1: C++ compilation of rule '//:sofa-pbrpc' failed: process-wrapper failed: error executing command /root/.cache/bazel/_bazel_root/4bb7f7aaaf8e6e59126eced3ac1ea215/execroot/sofa-pbrpc/_bin/process-wrapper -1 5 - - /usr/bin/gcc -U_FORTIFY_SOURCE '-D_FORTIFY_SOURCE=1' -fstack-protector -Wall ... (remaining 77 argument(s) skipped).
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/x86_64-redhat-linux/bits/os_defines.h:39:0,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/x86_64-redhat-linux/bits/c++config.h:2097,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/utility:68,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/algorithm:60,
                 from src/sofa/pbrpc/rpc_client_impl.cc:5:

gcc version: 4.8.5 kernel: 2.6.32

Thanks :)

teodor-pripoae commented 7 years ago

Can you send me the full output of bazel build please ?

I succesfully built it on centos 7.3 inside docker, using the following Dockerfile for bazel:

FROM centos:7.3.1611

# Build tools
RUN yum install gcc gcc-c++ kernel-devel wget unzip zlib-devel zip \
    git automake cmake patch libtool which glibc-static libstdc++-static \
    java-1.8.0-openjdk-devel

# Bazel
RUN wget -O /tmp/bazel.sh https://github.com/bazelbuild/bazel/releases/download/0.4.2/bazel-0.4.2-installer-linux-x86_64.sh && \
    chmod +x /tmp/bazel.sh && \
    /tmp/bazel.sh
zd-double commented 7 years ago

@teodor-pripoae I found it's something wrong with my build environment and I succesfully built now. Thanks. I find there's no bazel BUILD file in unit-test and test, would you mind adding these in this pr? :)

teodor-pripoae commented 7 years ago

I've added build file for unit-test, for test I will try in the following days. I tried using cc_test macros from bazel but there is an issue with protobuf beeing registered multiple times, so I've made a script to build and run the tests.

I will try to find a solution later this week.

cyshi commented 7 years ago

Can we merge this pull request first? @zd-double @qinzuoyan @bluebore