Skip to content

Commit bfc14e6

Browse files
authored
Merge pull request #8875 from headius/simpler_bin_ruby
Pregenerate bin/ruby and bin/ruby.bat
2 parents 52f4469 + 8bbeec6 commit bfc14e6

File tree

8 files changed

+293
-128
lines changed

8 files changed

+293
-128
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ rubyspec_temp
142142
!bin/gem
143143
!bin/update_rubygems
144144
!bin/bundle
145-
!bin/jruby.bash
146145
!bin/jruby.bat
147146
!bin/jrubyc
148147
!bin/jrubyc.bat
@@ -157,6 +156,7 @@ rubyspec_temp
157156
!bin/jgem
158157
!bin/jirb
159158
!bin/jirb_swing
159+
!bin/jruby
160160
!bin/jruby.bash
161161
!bin/jruby.bat
162162
!bin/jruby.dll

bin/jruby

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
#!/bin/sh
2+
# -----------------------------------------------------------------------------
3+
# jruby - Relaunches as jruby.sh from the same path.
4+
#
5+
# See jruby.sh for more information.
6+
# -----------------------------------------------------------------------------
7+
8+
# Pure shell dirname
9+
dir_name() {
10+
local filename="$1" trail=
11+
case $filename in
12+
*/*[!/]*)
13+
trail=${filename##*[!/]}
14+
filename=${filename%%"$trail"}
15+
REPLY=${filename%/*}
16+
;;
17+
*[!/]*)
18+
trail=${filename##*[!/]}
19+
REPLY="."
20+
;;
21+
*)
22+
REPLY="/"
23+
;;
24+
esac
25+
}
26+
27+
# Pure shell basename
28+
base_name() {
29+
local filename="$1" trail=
30+
case $filename in
31+
*/*[!/]*)
32+
trail=${filename##*[!/]}
33+
filename=${filename%%"$trail"}
34+
REPLY=${filename##*/}
35+
;;
36+
*[!/]*)
37+
trail=${filename##*[!/]}
38+
REPLY=${filename%%"$trail"}
39+
;;
40+
*)
41+
REPLY="/"
42+
;;
43+
esac
44+
}
45+
46+
# Determine whether path is absolute and contains no relative segments or symlinks
47+
path_is_canonical() {
48+
local path=
49+
for path; do
50+
case $path in
51+
([!/]*) return 1 ;;
52+
(./*|../*) return 1 ;;
53+
(*/.|*/..) return 1 ;;
54+
(*/./*|*/../*) return 1 ;;
55+
esac
56+
while [ "$path" ]; do
57+
[ -h "$path" ] && return 1
58+
path="${path%/*}"
59+
done
60+
done
61+
return 0
62+
}
63+
64+
# Resolve directory to its canonical value
65+
resolve_dir() {
66+
# Some shells (dash, ksh) resolve relative paths by default before cd'ing, i.e.
67+
# cd /foo/bar/../baz = cd /foo/baz
68+
# This is fine unless bar is a symlink, in which case the second form is
69+
# invalid. Passing -P to cd fixes this behaviour.
70+
REPLY="$(cd -P -- "$1" && pwd)"
71+
}
72+
73+
# Resolve symlink until it's not a symlink
74+
resolve_file() {
75+
local current="$1" target=
76+
77+
while [ -h "$current" ]; do
78+
target="$(readlink "$current")" || return
79+
case $target in
80+
(/*) current="$target" ;;
81+
# handle relative symlinks
82+
(*) dir_name "$current"; current="$REPLY/$target" ;;
83+
esac
84+
done
85+
REPLY="$current"
86+
}
87+
88+
# Resolve path to its canonical value
89+
resolve() {
90+
local target="$1" base=
91+
REPLY=
92+
93+
# Verify target actually exists (and isn't too deep in symlinks)
94+
if ! [ -e "$target" ]; then
95+
echo >&2 "Error: No such file or directory: $target"
96+
return 1
97+
fi
98+
99+
# Realpath is way faster than repeatedly calling readlink, so use it if possible
100+
if command -v realpath >/dev/null; then
101+
REPLY="$(realpath "$target")" && return
102+
fi
103+
104+
# Take shortcut for directories
105+
if [ -d "$target" ]; then
106+
resolve_dir "$target" && return
107+
fi
108+
109+
# Ensure $target is not a symlink
110+
resolve_file "$target" || return
111+
target="$REPLY"
112+
113+
# Resolve parent directory if it's not absolute
114+
if ! path_is_canonical "$target"; then
115+
dir_name "$target"
116+
resolve_dir "$REPLY" || return
117+
base="$REPLY"
118+
119+
base_name "$target"
120+
target="$base/$REPLY"
121+
fi
122+
REPLY="$target"
123+
}
124+
125+
# ----- Find JRuby launcher based on this executable's path -------------------
126+
127+
# Get the absolute path of the executable
128+
if [ "${BASH-}" ]; then
129+
# shellcheck disable=2128,3028
130+
script_src=${BASH_SOURCE-}
131+
else
132+
script_src=$0
133+
fi
134+
dir_name "$script_src"
135+
base_dir=$(cd -P -- "$REPLY" >/dev/null && pwd -P)
136+
base_name "$script_src"
137+
resolve "$base_dir/$REPLY"
138+
self_path=$REPLY
139+
140+
# Get the directory of the target script
141+
dir_name "$self_path"
142+
jruby_bin=$REPLY
143+
144+
# Run the launcher (in the current shell as an optimization)
145+
. "$jruby_bin/jruby.sh"

bin/ruby

Lines changed: 0 additions & 1 deletion
This file was deleted.

bin/ruby

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
#!/bin/sh
2+
# -----------------------------------------------------------------------------
3+
# ruby - Relaunches as jruby.sh from the same path.
4+
#
5+
# See jruby.sh for more information.
6+
# -----------------------------------------------------------------------------
7+
8+
# Pure shell dirname
9+
dir_name() {
10+
local filename="$1" trail=
11+
case $filename in
12+
*/*[!/]*)
13+
trail=${filename##*[!/]}
14+
filename=${filename%%"$trail"}
15+
REPLY=${filename%/*}
16+
;;
17+
*[!/]*)
18+
trail=${filename##*[!/]}
19+
REPLY="."
20+
;;
21+
*)
22+
REPLY="/"
23+
;;
24+
esac
25+
}
26+
27+
# Pure shell basename
28+
base_name() {
29+
local filename="$1" trail=
30+
case $filename in
31+
*/*[!/]*)
32+
trail=${filename##*[!/]}
33+
filename=${filename%%"$trail"}
34+
REPLY=${filename##*/}
35+
;;
36+
*[!/]*)
37+
trail=${filename##*[!/]}
38+
REPLY=${filename%%"$trail"}
39+
;;
40+
*)
41+
REPLY="/"
42+
;;
43+
esac
44+
}
45+
46+
# Determine whether path is absolute and contains no relative segments or symlinks
47+
path_is_canonical() {
48+
local path=
49+
for path; do
50+
case $path in
51+
([!/]*) return 1 ;;
52+
(./*|../*) return 1 ;;
53+
(*/.|*/..) return 1 ;;
54+
(*/./*|*/../*) return 1 ;;
55+
esac
56+
while [ "$path" ]; do
57+
[ -h "$path" ] && return 1
58+
path="${path%/*}"
59+
done
60+
done
61+
return 0
62+
}
63+
64+
# Resolve directory to its canonical value
65+
resolve_dir() {
66+
# Some shells (dash, ksh) resolve relative paths by default before cd'ing, i.e.
67+
# cd /foo/bar/../baz = cd /foo/baz
68+
# This is fine unless bar is a symlink, in which case the second form is
69+
# invalid. Passing -P to cd fixes this behaviour.
70+
REPLY="$(cd -P -- "$1" && pwd)"
71+
}
72+
73+
# Resolve symlink until it's not a symlink
74+
resolve_file() {
75+
local current="$1" target=
76+
77+
while [ -h "$current" ]; do
78+
target="$(readlink "$current")" || return
79+
case $target in
80+
(/*) current="$target" ;;
81+
# handle relative symlinks
82+
(*) dir_name "$current"; current="$REPLY/$target" ;;
83+
esac
84+
done
85+
REPLY="$current"
86+
}
87+
88+
# Resolve path to its canonical value
89+
resolve() {
90+
local target="$1" base=
91+
REPLY=
92+
93+
# Verify target actually exists (and isn't too deep in symlinks)
94+
if ! [ -e "$target" ]; then
95+
echo >&2 "Error: No such file or directory: $target"
96+
return 1
97+
fi
98+
99+
# Realpath is way faster than repeatedly calling readlink, so use it if possible
100+
if command -v realpath >/dev/null; then
101+
REPLY="$(realpath "$target")" && return
102+
fi
103+
104+
# Take shortcut for directories
105+
if [ -d "$target" ]; then
106+
resolve_dir "$target" && return
107+
fi
108+
109+
# Ensure $target is not a symlink
110+
resolve_file "$target" || return
111+
target="$REPLY"
112+
113+
# Resolve parent directory if it's not absolute
114+
if ! path_is_canonical "$target"; then
115+
dir_name "$target"
116+
resolve_dir "$REPLY" || return
117+
base="$REPLY"
118+
119+
base_name "$target"
120+
target="$base/$REPLY"
121+
fi
122+
REPLY="$target"
123+
}
124+
125+
# ----- Find JRuby launcher based on this executable's path -------------------
126+
127+
# Get the absolute path of the executable
128+
if [ "${BASH-}" ]; then
129+
# shellcheck disable=2128,3028
130+
script_src=${BASH_SOURCE-}
131+
else
132+
script_src=$0
133+
fi
134+
dir_name "$script_src"
135+
base_dir=$(cd -P -- "$REPLY" >/dev/null && pwd -P)
136+
base_name "$script_src"
137+
resolve "$base_dir/$REPLY"
138+
self_path=$REPLY
139+
140+
# Get the directory of the target script
141+
dir_name "$self_path"
142+
jruby_bin=$REPLY
143+
144+
# Run the launcher (in the current shell as an optimization)
145+
. "$jruby_bin/jruby.sh"

bin/ruby.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@ECHO OFF
2+
@"%~dp0jruby.exe" %*

core/pom.rb

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,6 @@
234234
:phase => 'clean',
235235
'filesets' => [ { 'directory' => '${project.build.sourceDirectory}',
236236
'includes' => [ '${Constants.java}' ] },
237-
{ 'directory' => '${project.basedir}/..',
238-
'includes' => [ 'bin/jruby' ] },
239237
{ 'directory' => '${project.basedir}/..',
240238
'includes' => [ 'lib/jni/**' ] } ],
241239
'failOnError' => 'false' )
@@ -295,23 +293,6 @@
295293
])
296294
end
297295

298-
copy_goal = [:exec, :executable => '/bin/sh', :arguments => ['-c', 'cp ${jruby.basedir}/bin/jruby.sh ${jruby.basedir}/bin/jruby']]
299-
300-
profile :clean do
301-
activation do
302-
# hack to get the os triggeer into the model
303-
os = org.apache.maven.model.ActivationOS.new
304-
os.family = 'unix'
305-
@current.os = os
306-
end
307-
308-
phase :clean do
309-
plugin 'org.codehaus.mojo:exec-maven-plugin' do
310-
execute_goals( *copy_goal )
311-
end
312-
end
313-
end
314-
315296
profile 'error-prone' do
316297
activation do
317298
jdk('11') # even an older (2.10.0) version of error-prone would need an adjusted setup on Java 8
@@ -346,26 +327,6 @@
346327
end
347328
end
348329

349-
profile 'jruby.sh' do
350-
351-
activation do
352-
file( :missing => '../bin/jruby' )
353-
end
354-
activation do
355-
# hack to get the os triggeer into the model
356-
os = org.apache.maven.model.ActivationOS.new
357-
os.family = 'unix'
358-
@current.os = os
359-
end
360-
361-
phase :initialize do
362-
plugin 'org.codehaus.mojo:exec-maven-plugin' do
363-
execute_goals *copy_goal
364-
end
365-
end
366-
367-
end
368-
369330
jni_config = [ 'unpack', { :id => 'unzip native',
370331
'excludes' => 'META-INF,META-INF/*',
371332
'artifactItems' => [ { 'groupId' => 'com.github.jnr',

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy