forked from ruby/ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild
More file actions
executable file
·82 lines (70 loc) · 1.75 KB
/
build
File metadata and controls
executable file
·82 lines (70 loc) · 1.75 KB
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
#!/bin/bash
set -euo pipefail
debug=
release=
if [[ $# = 0 ]]; then
debug=true
release=true
fi
for target do
case $target in
(debug) debug=true;;
(release) release=true;;
(*) >&2 echo "unknown target: $target"; exit 1;;
esac
done
git config alias.build >/dev/null || git config alias.build '!f(){ git show origin/HEAD:build | bash -s - "$@";};f'
mkdir -p target
git check-ignore -q target || echo '/target/' >> "$(git rev-parse --git-common-dir)/info/exclude"
fail() {
set +x
>&2 echo "[$1] $2 failed"
return 1
}
trap -- exit INT
set -x
declare -a configure_args=(\
--cache-file="config.cache"
--disable-shared
--disable-install-doc
--with-ext="openssl,psych,json,+"
cflags="-march=native"
)
if [[ $(uname -s) = Darwin ]]; then
brew install autoconf openssl@3 libyaml gmp
configure_args+=(
--with-libyaml-dir="$(brew --prefix libyaml)"
--with-openssl-dir="$(brew --prefix openssl@3)"
--with-gmp-dir="$(brew --prefix gmp)"
)
else
sudo apt-get install --yes --no-install-recommends autoconf openssl libyaml-dev libgmp-dev zlib1g-dev
fi
./autogen.sh
nproc=$(getconf _NPROCESSORS_ONLN)
if [[ $debug ]]; then
mkdir -p target/debug
cd target/debug
./config.status --recheck ||
../../configure \
--prefix="$HOME/.ruby/debug" \
"${configure_args[@]}" \
--enable-devel \
--enable-debug-env \
cppflags="-DRUBY_DEBUG=1 -DUSE_RUBY_DEBUG_LOG=1" \
optflags="-O0 -fno-omit-frame-pointer" \
|| fail debug configure
make -j "$nproc" || fail debug make
cd -
fi
if [[ $release ]]; then
mkdir -p target/release
cd target/release
./config.status --recheck ||
../../configure \
--prefix="$HOME/.ruby/head" \
"${configure_args[@]}" \
|| fail release configure
make -j "$nproc" || fail release make
make install || fail release make install
fi