/
build_all
executable file
·130 lines (111 loc) · 3.05 KB
/
build_all
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#! /usr/bin/env bash
#
# script to build gems for all relevant platforms:
# - MRI et al (standard gem)
# - windows (x86-mingw32 and x64-mingw32)
# - jruby
#
# here's what I recommend for building all the gems:
#
# set up a rake-compiler-dev-box as described here:
# https://github.com/tjschuck/rake-compiler-dev-box
# It is prepared with all the necessary build tools and environments.
#
# or alternatively do:
# 1. Setup a ubuntu 12.04+ machine
# 2. install rvm, and install 1.9.3, 2.0.0 and jruby.
# 3. `sudo apt-get install mingw32 gcc-mingw-w64-i686 gcc-mingw-w64-x86-64`
#
# as you build, you may run into these problems:
#
# - if you're using Virtualbox shared directories, you'll get a mingw
# "Protocol error" at linktime. Boo! Either use NFS or a
# locally-checked-out repository.
#
# - on ubuntus 11 and later, you may have issues with building
# rake-compiler's rubies against openssl v2. Just comment the lines
# out from ossl_ssl.c and you'll be fine.
#
# - you may have issues with Pathname conversion to String in
# bundler. Add this to the offending bundler file:
#
# class Pathname
# def to_str
# to_s
# end
# end
#
# - you may also have to hack rubygems.rb to eliminate a reference to
# RUBY_ENGINE (just comment it out)
#
DEFAULT_RUBY=2.0.0
HOST=
# Load RVM into a shell session *as a function*
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
source "$HOME/.rvm/scripts/rvm"
elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
source "/usr/local/rvm/scripts/rvm"
else
echo "ERROR: An RVM installation was not found.\n"
fi
rvm_use () {
current_ruby=$1
rvm use "${1}@nokogiri" --create || rvm -v
}
rvm_do () {
local ver=$1
shift
rvm "${ver}@nokogiri" do "$@"
}
cross_rubies () {
grep -v '#' .cross_rubies
}
ruby_vers () {
cross_rubies | while read -r line; do
echo "${line%%[-:]*}"
done | uniq
}
set -o errexit
for ver in `ruby_vers`; do
rvm_use $ver
gem install bundler --conservative
bundle install --quiet --local || bundle install
done
rvm_use $DEFAULT_RUBY
rm -rf tmp pkg
bundle exec rake clean
# holding pen
rm -rf gems
mkdir -p gems
# windows
for verspec in `cross_rubies`; do
version="${verspec%%:*}"
ver="${version%%-*}"
host="${verspec#*:}"
case $ver in
1.9.3)
# Parallel make does not work in 1.9.3, as it has a
# missing dependency problem with main.o.
make="make"
;;
*)
make="$MAKE"
esac
MAKE="$make" rvm_do $ver rake-compiler cross-ruby VERSION=$version HOST=$host debugflags="-g"
done
bundle exec rake gem:windows
cp -v pkg/nokogiri*{x86,x64}-mingw32*.gem gems
# MRI
bundle exec rake clean
bundle exec rake gem
cp -v pkg/nokogiri*.gem gems # should only be one at this point in the script
# jruby
rvm_use jruby
gem install bundler --conservative
bundle install --quiet --local || bundle install
bundle exec rake clean clobber
rvm_use $DEFAULT_RUBY
bundle exec rake generate
rvm_use jruby
bundle exec rake gem
cp -v pkg/nokogiri*java.gem gems