From e72d7a07d6f6e13feee87e16d48fee9dd3857eee Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Fri, 25 Nov 2016 12:47:29 +0000 Subject: Build protoc from source Use the provided sources to build the protoc binary instead of using the committed binaries. -- Change-Id: I3df01e9f400e3cebbd1fe3ce74c6142c93c58b6c Reviewed-on: https://cr.bazel.build/6732 MOS_MIGRATED_REVID=140192644 --- third_party/protobuf/3.0.0/BUILD | 25 ++++++---------- third_party/protobuf/README.md | 62 +--------------------------------------- 2 files changed, 9 insertions(+), 78 deletions(-) (limited to 'third_party/protobuf') diff --git a/third_party/protobuf/3.0.0/BUILD b/third_party/protobuf/3.0.0/BUILD index 2a22dbcfad..2e6f89401d 100644 --- a/third_party/protobuf/3.0.0/BUILD +++ b/third_party/protobuf/3.0.0/BUILD @@ -18,23 +18,6 @@ filegroup( visibility = ["//third_party/protobuf:__pkg__"], ) -filegroup( - name = "protoc", - srcs = select({ - # protoc-windows-x86_64.exe can't deal with long path(length > 260), - # so use protoc-mingw.exe instead. - "//third_party:windows_mingw": ["protoc-3.0.0-mingw.exe"], - "//third_party:windows_msys64_mingw64": ["protoc-3.0.0-mingw.exe"], - "//third_party:windows_msys64": ["protoc-3.0.0-mingw.exe"], - "//third_party:windows_clang": ["protoc-3.0.0-mingw.exe"], - "//third_party:darwin": ["protoc-3.0.0-osx-x86_32.exe"], - "//third_party:k8": ["protoc-3.0.0-linux-x86_64.exe"], - "//third_party:piii": ["protoc-3.0.0-linux-x86_32.exe"], - "//third_party:freebsd": ["protoc-3.0.0-linux-x86_32.exe"], - "//third_party:s390x": ["protoc-linux-s390x_64.exe"], - }), -) - java_import( name = "protobuf", jars = ["protobuf-java-3.0.0.jar"], @@ -318,3 +301,11 @@ proto_lang_toolchain( command_line = "--java_out=shared,immutable:$(OUT)", runtime = ":protobuf", ) + +cc_binary( + name = "protoc", + srcs = ["src/google/protobuf/compiler/main.cc"], + linkopts = LINK_OPTS, + visibility = ["//visibility:public"], + deps = [":protoc_lib"], +) diff --git a/third_party/protobuf/README.md b/third_party/protobuf/README.md index f9e73a9f75..367d542d06 100644 --- a/third_party/protobuf/README.md +++ b/third_party/protobuf/README.md @@ -1,68 +1,8 @@ -### Updating binaries other than the Linux 64-bit and MinGW ones +### Updating the jar binary 1. Go to http://search.maven.org/ 2. Search for g:"com.google.protobuf" 3. Download the "jar" link from protobuf-java and put them in `/third_party/protobuf/` -4. Download all binaries from "protoc" and put them in `/third_party/protobuf/` -5. Set executable bit: `chmod +x *.exe` - -* * * -### Updating the Linux 64-bit proto compiler -The 64-bit Linux version of the proto compiler is linked statically. To update it, do -the following steps on an x86_64 machine: - -1. `git clone http://github.com/google/protobuf.git` -2. `git checkout ` (e.g. `v3.0.0` or `e8ae137`) -3. `./autogen.sh` -4. `LDFLAGS=-static ./configure` -5. Change `LDFLAGS = -static` to `LDFLAGS = -all-static` in `src/Makefile`. -6. `make` -7. `cp src/protoc /third_party/protobuf//protoc--linux-x86_64.exe` . - -* * * -### Updating the MinGW proto compiler (64-bit) -Do this from a MinGW shell ([https://sourceforge.net/projects/msys2/files/]) on -a Windows machine. - -1. Clone the protobuf repo and check out the right commit - - ```sh - git clone http://github.com/google/protobuf.git - git checkout # e.g. `v3.0.0` or `e8ae137` - ``` - -2. Close all other MSYS/MinGW/Cygwin windows. Kill all running background jobs. - This step is optional, but if you have other terminal windows open the next - step may print some error messages (though it still seems to work). - -3. Install necessary MinGW packages - - ```sh - pacman -Syuu autoconf automake libtool curl make gcc unzip - ``` - -4. Configure for static linking and build like you would for Unix - - ```sh - ./autogen.sh - ./configure --disable-shared # takes about 2 minutes - ./make # takes about 11 minutes - ``` - -5. Copy resulting binary - - ```sh - cp src/protoc.exe /third_party/protobuf/protoc-mingw.exe - ``` - -* * * -### Updating the Linux s390x 64-bit proto compiler -To add 64-bit Linux s390x version of the statically linked proto compiler, use below steps: - -1. Build Protobuf compiler (v3.0.0-beta-2) from https://github.com/google/protobuf. -2. `cp src/protoc /third_party/protobuf/protoc-linux-s390x_64.exe` -3. `cp src/protoc /third_party/protobuf//protoc-linux-s390x_64.exe` - * * * ### Updating `protobuf.bzl` and the `src/` directory: -- cgit v1.2.3