Эх сурвалжийг харах

Build ruby gem on kokoro (#4819)

* Install rake compiler

* Add kokoro config to build ruby gem on linux

* Rename from linix to linux

* Fix prepare_build.sh name

* Clean up

* Install bundler

* Install bundler

* Use c99 in order to build gem on mingw-32 on ruby 2.0.0

See https://github.com/rake-compiler/rake-compiler-dock/issues/4

* Move c99 config to extcofig.rb
Paul Yang 7 жил өмнө
parent
commit
f7ada1280f

+ 14 - 0
kokoro/release/linux/build_artifacts.sh

@@ -0,0 +1,14 @@
+#!/bin/bash
+
+set -ex
+
+# change to repo root
+cd $(dirname $0)/../../..
+
+source kokoro/release/linux/prepare_build.sh
+
+# ruby environment
+source kokoro/release/linux/ruby/ruby_build_environment.sh
+
+# build artifacts
+bash kokoro/release/linux/ruby/ruby_build.sh

+ 16 - 0
kokoro/release/linux/prepare_build.sh

@@ -0,0 +1,16 @@
+#!/bin/bash
+
+# Move docker's storage location to scratch disk so we don't run out of space.
+echo 'DOCKER_OPTS="${DOCKER_OPTS} --graph=/tmpfs/docker"' | sudo tee --append /etc/default/docker
+# Use container registry mirror for pulling docker images (should make downloads faster)
+# See https://cloud.google.com/container-registry/docs/using-dockerhub-mirroring
+echo 'DOCKER_OPTS="${DOCKER_OPTS} --registry-mirror=https://mirror.gcr.io"' | sudo tee --append /etc/default/docker
+sudo service docker restart
+
+# Download Docker images from DockerHub
+export DOCKERHUB_ORGANIZATION=grpctesting
+
+# All artifacts come here
+mkdir artifacts
+export ARTIFACT_DIR=$(pwd)/artifacts
+

+ 8 - 0
kokoro/release/linux/release.cfg

@@ -0,0 +1,8 @@
+# Configuration for Linux release builds
+build_file: "protobuf/kokoro/release/linux/build_artifacts.sh"
+
+action {
+  define_artifacts {
+    regex: "github/protobuf/artifacts/**"
+  }
+}

+ 15 - 0
kokoro/release/linux/ruby/ruby_build.sh

@@ -0,0 +1,15 @@
+#!/bin/bash
+
+# Build protoc
+if test ! -e src/protoc; then
+  ./autogen.sh
+  ./configure
+  make -j4
+fi
+
+umask 0022
+pushd ruby
+bundle install && bundle exec rake gem:native
+ls pkg
+mv pkg/* $ARTIFACT_DIR
+popd

+ 8 - 0
kokoro/release/linux/ruby/ruby_build_environment.sh

@@ -0,0 +1,8 @@
+#!/bin/bash
+
+set +ex
+[[ -s /etc/profile.d/rvm.sh ]] && . /etc/profile.d/rvm.sh
+set -e  # rvm commands are very verbose
+rvm --default use ruby-2.4.1
+gem install bundler --update
+set -ex

+ 1 - 0
kokoro/release/macos/ruby/ruby_build_environment.sh

@@ -7,6 +7,7 @@ source $HOME/.rvm/scripts/rvm
 set -e  # rvm commands are very verbose
 time rvm install 2.5.0
 rvm use 2.5.0 --default
+gem install rake-compiler --no-ri --no-doc
 gem install bundler --no-ri --no-doc
 rvm osx-ssl-certs status all
 rvm osx-ssl-certs update all

+ 3 - 1
ruby/ext/google/protobuf_c/extconf.rb

@@ -2,7 +2,9 @@
 
 require 'mkmf'
 
-$CFLAGS += " -std=c99 -O3 -DNDEBUG"
+unless RUBY_PLATFORM =~ /mswin|mingw/
+  $CFLAGS += " -std=c99 -O3 -DNDEBUG"
+end
 
 
 if RUBY_PLATFORM =~ /linux/