From 9c8c3dea305b254b4854b56f850054958376e9ed Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Wed, 27 Apr 2022 10:40:01 -0700 Subject: [PATCH] Start reducing our reliance on autotools (#9824) Start reducing our reliance on autotools This commit updates a few of our CI scripts to build protoc using Bazel instead of autotools. I also updated the setuptools and Rake build configs to look for protoc under bazel-bin/ so that they will preferentially use a Bazel-built protoc binary. The goal is to start chipping away at our use of autotools in preparation for eventually dropping autotools support. --- kokoro/release/python/macos/config.sh | 13 +++++++------ kokoro/release/ruby/linux/ruby/ruby_build.sh | 9 ++++----- kokoro/release/ruby/macos/ruby/ruby_build.sh | 8 +++----- ruby/Rakefile | 8 +++++--- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/kokoro/release/python/macos/config.sh b/kokoro/release/python/macos/config.sh index 1b0a302e4c..91e62d6c79 100644 --- a/kokoro/release/python/macos/config.sh +++ b/kokoro/release/python/macos/config.sh @@ -25,12 +25,13 @@ function pre_build { # Runs in the root directory of this repository. pushd protobuf - # Build protoc - ./autogen.sh - ./configure - - CXXFLAGS="-std=c++14 -fPIC -g -O2" ./configure - make -j8 + # Build protoc and protobuf libraries + use_bazel.sh 5.1.1 + bazel build //:protoc + export PROTOC=$PWD/bazel-bin/protoc + mkdir src/.libs + ln -s $PWD/bazel-bin/libprotobuf.a src/.libs/libprotobuf.a + ln -s $PWD/bazel-bin/libprotobuf_lite.a src/.libs/libprotobuf-lite.a # Generate python dependencies. pushd python diff --git a/kokoro/release/ruby/linux/ruby/ruby_build.sh b/kokoro/release/ruby/linux/ruby/ruby_build.sh index f8ae9623f2..761b54fcaf 100755 --- a/kokoro/release/ruby/linux/ruby/ruby_build.sh +++ b/kokoro/release/ruby/linux/ruby/ruby_build.sh @@ -3,11 +3,10 @@ set -ex # Build protoc -if test ! -e src/protoc; then - ./autogen.sh - ./configure - make -j4 -fi +use_bazel.sh 5.1.1 +bazel build //:protoc +cp bazel-bin/protoc src/protoc +export PROTOC=$PWD/src/protoc umask 0022 pushd ruby diff --git a/kokoro/release/ruby/macos/ruby/ruby_build.sh b/kokoro/release/ruby/macos/ruby/ruby_build.sh index 7f6c18fe8e..55773b21a9 100755 --- a/kokoro/release/ruby/macos/ruby/ruby_build.sh +++ b/kokoro/release/ruby/macos/ruby/ruby_build.sh @@ -3,11 +3,9 @@ set -ex # Build protoc -if test ! -e src/protoc; then - ./autogen.sh - ./configure - make -j4 -fi +use_bazel.sh 5.1.1 +bazel build //:protoc +export PROTOC=$PWD/bazel-bin/protoc umask 0022 pushd ruby diff --git a/ruby/Rakefile b/ruby/Rakefile index 1892e6209f..8b5b68d855 100644 --- a/ruby/Rakefile +++ b/ruby/Rakefile @@ -37,10 +37,12 @@ proto2_protos = %w[ google/protobuf/compiler/plugin.proto ] -if system('../src/protoc --version') - protoc_command = '../src/protoc' +if !ENV['PROTOC'].nil? + protoc_command = ENV['PROTOC'] +elsif system('../src/protoc --version') + protoc_command = '../src/protoc' else - protoc_command = 'protoc' + protoc_command = 'protoc' end genproto_output = []