jruby-launcher 1.0.12-java → 1.0.13-java
Sign up to get free protection for your applications and to get access to all the features.
- data/argparser.cpp +38 -27
- data/lib/jruby-launcher.rb +1 -1
- data/ng.c +20 -20
- data/pkg/jruby-launcher-1.0.12-java/extconf.rb +7 -0
- data/pkg/jruby-launcher-1.0.12-java/lib/jruby-launcher.rb +3 -0
- data/pkg/jruby-launcher-1.0.12-java/lib/rubygems/defaults/jruby_native.rb +4 -0
- data/pkg/jruby-launcher-1.0.12-java/spec/launcher_spec.rb +223 -0
- data/pkg/jruby-launcher-1.0.12-java/spec/spec_helper.rb +75 -0
- data/platformlauncher.cpp +3 -3
- data/spec/launcher_spec.rb +26 -0
- data/unixlauncher.cpp +1 -0
- data/utilsfuncs.cpp +3 -2
- data/version.h +1 -1
- metadata +8 -3
data/argparser.cpp
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
#include <cstdlib>
|
7
7
|
#include <memory>
|
8
8
|
#include <string>
|
9
|
+
#include <unistd.h>
|
9
10
|
#include "utilsfuncs.h"
|
10
11
|
#include "argparser.h"
|
11
12
|
#include "argnames.h"
|
@@ -29,7 +30,6 @@ Options:\n\
|
|
29
30
|
-Xversion print launcher's version\n\
|
30
31
|
\nJvm Management:\n\
|
31
32
|
-Xjdkhome <path> set path to JDK\n\
|
32
|
-
-Xfork-java run java in separate process\n\
|
33
33
|
-J<jvm_option> pass <jvm_option> to JVM\n\
|
34
34
|
\nClasspath Management:\n\
|
35
35
|
-Xcp <classpath> set the classpath\n\
|
@@ -42,7 +42,9 @@ Options:\n\
|
|
42
42
|
-Xprop.erty[=value] equivalent to -J-Djruby.<prop.erty>[=value]\n\
|
43
43
|
-Xproperties list supported properties (omit \"jruby.\" with -X)\n"
|
44
44
|
#ifdef WIN32
|
45
|
-
"
|
45
|
+
"\
|
46
|
+
-Xfork-java run java in separate process\n\
|
47
|
+
-Xconsole <mode> jrubyw console attach mode (new|attach|suppress)\n"
|
46
48
|
#endif
|
47
49
|
"\n"
|
48
50
|
;
|
@@ -114,21 +116,42 @@ void ArgParser::addEnvVarToOptions(std::list<std::string> & optionsList, const c
|
|
114
116
|
#include <mach-o/dyld.h>
|
115
117
|
#endif
|
116
118
|
|
119
|
+
#ifndef PATH_MAX
|
120
|
+
#define PATH_MAX MAX_PATH
|
121
|
+
#endif
|
122
|
+
|
117
123
|
bool ArgParser::initPlatformDir() {
|
118
|
-
#ifdef WIN32
|
119
|
-
char path[MAX_PATH] = "";
|
120
|
-
getCurrentModulePath(path, MAX_PATH);
|
121
|
-
#else
|
122
|
-
char path[PATH_MAX] = "";
|
123
124
|
bool found = false;
|
125
|
+
char path[PATH_MAX] = "";
|
126
|
+
|
127
|
+
if (getenv("JRUBY_HOME") != NULL) {
|
128
|
+
logMsg("initPlatformDir: using JRUBY_HOME environment variable");
|
129
|
+
char sep[2] = { FILE_SEP, NULL };
|
130
|
+
strncpy(path, getenv("JRUBY_HOME"), PATH_MAX - 11);
|
131
|
+
strncpy(path + strlen(path), sep, 1);
|
132
|
+
strncpy(path + strlen(path), "bin", 3);
|
133
|
+
strncpy(path + strlen(path), sep, 1);
|
134
|
+
strncpy(path + strlen(path), "jruby", 5);
|
135
|
+
found = true;
|
136
|
+
}
|
124
137
|
|
125
|
-
|
126
|
-
|
127
|
-
|
138
|
+
#ifdef WIN32
|
139
|
+
|
140
|
+
if (!found) {
|
141
|
+
getCurrentModulePath(path, PATH_MAX);
|
142
|
+
}
|
143
|
+
|
144
|
+
#else // !WIN32
|
145
|
+
|
146
|
+
if (!found) {
|
147
|
+
// first try via linux /proc/self/exe
|
148
|
+
logMsg("initPlatformDir: trying /proc/self/exe");
|
149
|
+
found = readlink("/proc/self/exe", path, PATH_MAX) != -1;
|
150
|
+
}
|
128
151
|
|
129
152
|
#ifdef __MACH__
|
130
153
|
uint32_t sz = PATH_MAX;
|
131
|
-
if (_NSGetExecutablePath(path, &sz) == 0) { // OSX-specific
|
154
|
+
if (!found && _NSGetExecutablePath(path, &sz) == 0) { // OSX-specific
|
132
155
|
logMsg("initPlatformDir: using _NSGetExecutablePath");
|
133
156
|
string tmpPath(path);
|
134
157
|
realpath(tmpPath.c_str(), path);
|
@@ -138,7 +161,7 @@ bool ArgParser::initPlatformDir() {
|
|
138
161
|
|
139
162
|
#ifdef __SUNOS__
|
140
163
|
const char* execname = getexecname();
|
141
|
-
if (execname) {
|
164
|
+
if (!found && execname) {
|
142
165
|
logMsg("initPlatformDir: using getexecname");
|
143
166
|
char * dst = path;
|
144
167
|
if (execname[0] != '/') {
|
@@ -164,6 +187,7 @@ bool ArgParser::initPlatformDir() {
|
|
164
187
|
strncpy(path + strlen(path), platformDir.c_str(), platformDir.length());
|
165
188
|
found = true;
|
166
189
|
}
|
190
|
+
#endif // WIN32
|
167
191
|
|
168
192
|
if (!found) { // try via PATH search
|
169
193
|
logMsg("initPlatformDir: trying to find executable on PATH");
|
@@ -172,21 +196,8 @@ bool ArgParser::initPlatformDir() {
|
|
172
196
|
found = true;
|
173
197
|
}
|
174
198
|
|
175
|
-
if
|
176
|
-
|
177
|
-
logMsg("initPlatformDir: trying JRUBY_HOME environment variable");
|
178
|
-
strncpy(path, getenv("JRUBY_HOME"), PATH_MAX - 11);
|
179
|
-
strncpy(path + strlen(path), "/bin/jruby", 10);
|
180
|
-
found = true;
|
181
|
-
}
|
182
|
-
}
|
183
|
-
|
184
|
-
if (!fileExists(path)) {
|
185
|
-
printToConsole("Could not figure out a proper location for JRuby.\n"
|
186
|
-
"Try `jruby -Xtrace trace.log ...` and view trace.log for details.");
|
187
|
-
return false;
|
188
|
-
}
|
189
|
-
#endif
|
199
|
+
// Check if bin/jruby file exists; this logs a message if not found
|
200
|
+
fileExists(path);
|
190
201
|
|
191
202
|
logMsg("Module: %s", path);
|
192
203
|
char *bslash = strrchr(path, FILE_SEP);
|
data/lib/jruby-launcher.rb
CHANGED
data/ng.c
CHANGED
@@ -314,7 +314,7 @@ void processnailgunstream() {
|
|
314
314
|
break;
|
315
315
|
case CHUNKTYPE_EXIT: processExit(buf, len);
|
316
316
|
break;
|
317
|
-
default: fprintf(
|
317
|
+
default: fprintf(stdout, "Unexpected chunk type %d ('%c')\n", chunkType, chunkType);
|
318
318
|
cleanUpAndExit(NAILGUN_UNEXPECTED_CHUNKTYPE);
|
319
319
|
}
|
320
320
|
/*}*/
|
@@ -451,24 +451,24 @@ int isNailgunClientName(char *s) {
|
|
451
451
|
*/
|
452
452
|
void usage(int exitcode) {
|
453
453
|
|
454
|
-
fprintf(
|
455
|
-
fprintf(
|
456
|
-
fprintf(
|
457
|
-
fprintf(
|
458
|
-
fprintf(
|
459
|
-
fprintf(
|
460
|
-
fprintf(
|
461
|
-
fprintf(
|
462
|
-
|
463
|
-
fprintf(
|
464
|
-
fprintf(
|
465
|
-
fprintf(
|
466
|
-
fprintf(
|
467
|
-
fprintf(
|
468
|
-
fprintf(
|
469
|
-
fprintf(
|
470
|
-
fprintf(
|
471
|
-
fprintf(
|
454
|
+
fprintf(stdout, "Usage: ng class [--nailgun-options] [args]\n");
|
455
|
+
fprintf(stdout, " (to execute a class)\n");
|
456
|
+
fprintf(stdout, " or: ng alias [--nailgun-options] [args]\n");
|
457
|
+
fprintf(stdout, " (to execute an aliased class)\n");
|
458
|
+
fprintf(stdout, " or: alias [--nailgun-options] [args]\n");
|
459
|
+
fprintf(stdout, " (to execute an aliased class, where \"alias\"\n");
|
460
|
+
fprintf(stdout, " is both the alias for the class and a symbolic\n");
|
461
|
+
fprintf(stdout, " link to the ng client)\n\n");
|
462
|
+
|
463
|
+
fprintf(stdout, "where options include:\n");
|
464
|
+
fprintf(stdout, " --nailgun-D<name>=<value> set/override a client environment variable\n");
|
465
|
+
fprintf(stdout, " --nailgun-version print product version and exit\n");
|
466
|
+
fprintf(stdout, " --nailgun-showversion print product version and continue\n");
|
467
|
+
fprintf(stdout, " --nailgun-server to specify the address of the nailgun server\n");
|
468
|
+
fprintf(stdout, " (default is localhost)\n");
|
469
|
+
fprintf(stdout, " --nailgun-port to specify the port of the nailgun server\n");
|
470
|
+
fprintf(stdout, " (default is 2113)\n");
|
471
|
+
fprintf(stdout, " --nailgun-help print this message and exit\n");
|
472
472
|
|
473
473
|
cleanUpAndExit(exitcode);
|
474
474
|
}
|
@@ -557,7 +557,7 @@ int nailgunClientMain(int argc, char *argv[], char *env[]) {
|
|
557
557
|
hostinfo = gethostbyname(nailgun_server);
|
558
558
|
|
559
559
|
if (hostinfo == NULL) {
|
560
|
-
fprintf(
|
560
|
+
fprintf(stdout, "Unknown host: %s\n", nailgun_server);
|
561
561
|
cleanUpAndExit(NAILGUN_CONNECT_FAILED);
|
562
562
|
}
|
563
563
|
|
@@ -0,0 +1,223 @@
|
|
1
|
+
require File.expand_path('../spec_helper.rb', __FILE__)
|
2
|
+
load File.expand_path('../../lib/jruby-launcher.rb', __FILE__)
|
3
|
+
|
4
|
+
describe "JRuby native launcher" do
|
5
|
+
it "should run org.jruby.Main" do
|
6
|
+
jruby_launcher_args("").last.should == "org/jruby/Main"
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should pass unrecognized arguments to JRuby" do
|
10
|
+
jruby_launcher_args("-J-Dsome.option -v --help")[-3..-1].should == ["org/jruby/Main", "-v", "--help"]
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should print help message" do
|
14
|
+
args = jruby_launcher_args("-Xhelp 2>&1")
|
15
|
+
args.detect{|l| l =~ /JRuby Launcher usage/}.should be_true
|
16
|
+
args.should include("-X")
|
17
|
+
args = jruby_launcher_args("-X 2>&1")
|
18
|
+
args.detect{|l| l =~ /JRuby Launcher usage/}.should be_true
|
19
|
+
args.should include("-X")
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should use $JAVACMD when JAVACMD is specified" do
|
23
|
+
with_environment "JAVACMD" => File.join("jato") do
|
24
|
+
if windows?
|
25
|
+
jruby_launcher_args("-v 2>&1").join.should =~ %r{jato}
|
26
|
+
else
|
27
|
+
jruby_launcher_args("-v").first.should == File.join("jato")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should use $JAVA_HOME/bin/java when JAVA_HOME is specified" do
|
33
|
+
with_environment "JAVA_HOME" => File.join("some", "java", "home") do
|
34
|
+
if windows?
|
35
|
+
jruby_launcher_args("-v 2>&1").join.should =~ %r{some/java/home}
|
36
|
+
else
|
37
|
+
jruby_launcher_args("-v").first.should == File.join("some", "java", "home", "bin", "java")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should use -Xjdkhome argument above JAVA_HOME" do
|
43
|
+
with_environment "JAVA_HOME" => File.join("env", "java", "home") do
|
44
|
+
if windows?
|
45
|
+
jruby_launcher_args("-Xjdkhome some/java/home 2>&1").join.should =~ %r{some/java/home}
|
46
|
+
else
|
47
|
+
jruby_launcher_args("-Xjdkhome some/java/home").first.should == File.join("some", "java", "home", "bin", "java")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should complain about a missing log argument" do
|
53
|
+
jruby_launcher("-Xtrace 2>&1").should =~ /Argument is missing for "-Xtrace"/
|
54
|
+
jruby_launcher("-Xtrace -- 2>&1").should =~ /Argument is missing for "-Xtrace"/
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should complain about a missing jdkhome argument" do
|
58
|
+
jruby_launcher("-Xjdkhome 2>&1").should =~ /Argument is missing/
|
59
|
+
jruby_launcher("-Xjdkhome -- 2>&1").should =~ /Argument is missing/
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should complain about a missing classpath append argument" do
|
63
|
+
jruby_launcher("-Xcp:a 2>&1").should =~ /Argument is missing/
|
64
|
+
jruby_launcher("-Xcp:a -- 2>&1").should =~ /Argument is missing/
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should run nailgun server with --ng-server option" do
|
68
|
+
jruby_launcher_args("--ng-server").last.should == "com/martiansoftware/nailgun/NGServer"
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should run nailgun client with --ng option" do
|
72
|
+
jruby_launcher_args('--ng -e "puts 1"').should == ["org.jruby.util.NailMain", "-e", "puts 1"]
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should handle -J JVM options" do
|
76
|
+
jruby_launcher_args("-J-Darg1=value1 -J-Darg2=value2").should include("-Darg1=value1", "-Darg2=value2")
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should pass -Xprop.erty=value as -J-Djruby.prop.erty=value" do
|
80
|
+
jruby_launcher_args("-Xprop.erty=value").should include("-Djruby.prop.erty=value")
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should pass -Xproperties as --properties" do
|
84
|
+
jruby_launcher_args("-Xproperties").should include("--properties")
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should default to 500m max heap" do
|
88
|
+
jruby_launcher_args("").should include("-Xmx500m", "-Djruby.memory.max=500m")
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should allow max heap to be overridden" do
|
92
|
+
jruby_launcher_args("-J-Xmx256m").should include("-Xmx256m", "-Djruby.memory.max=256m")
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should default to 2048k max stack" do
|
96
|
+
jruby_launcher_args("").should include("-Xss2048k", "-Djruby.stack.max=2048k")
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should allow max stack to be overridden" do
|
100
|
+
jruby_launcher_args("-J-Xss512k").should include("-Xss512k", "-Djruby.stack.max=512k")
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should add the contents of the CLASSPATH environment variable" do
|
104
|
+
with_environment "CLASSPATH" => "some.jar" do
|
105
|
+
classpath_arg = jruby_launcher_args("").detect{|a| a =~ /java\.class\.path/}
|
106
|
+
classpath_arg.should =~ /-Djava.class.path=.*some.jar/
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should add the classpath elements in proper order" do
|
111
|
+
s = File::PATH_SEPARATOR
|
112
|
+
with_environment "CLASSPATH" => "some-env.jar" do
|
113
|
+
classpath_arg = jruby_launcher_args("-Xcp:a some-other.jar -Xcp:p some.jar").detect{|a| a =~ /java\.class\.path/}
|
114
|
+
classpath_arg.should =~ /-Djava.class.path=some.jar.*#{s}some-env.jar#{s}some-other.jar/
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should use the --server compiler" do
|
119
|
+
jruby_launcher_args("--server").should include("-server")
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should use the --client compiler" do
|
123
|
+
jruby_launcher_args("--client").should include("-client")
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should set the JMX settings when --manage is present" do
|
127
|
+
jruby_launcher_args("--manage").should include("-Dcom.sun.management.jmxremote", "-Djruby.management.enabled=true")
|
128
|
+
end
|
129
|
+
|
130
|
+
it "should set the headless flag when --headless is present" do
|
131
|
+
jruby_launcher_args("--headless").should include("-Djava.awt.headless=true")
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should pass -Xprof when --sample is present" do
|
135
|
+
jruby_launcher_args("--sample").should include("-Xprof")
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should stop argument processing when a -- is seen" do
|
139
|
+
jruby_launcher_args("-- -Xhelp -Xtrace --headless").should include("-Xhelp", "-Xtrace", "--headless")
|
140
|
+
end
|
141
|
+
|
142
|
+
# JRUBY-4151
|
143
|
+
it "should properly handle single quotes" do
|
144
|
+
jruby_launcher_args("-e 'ABC DEF'").should include("ABC DEF")
|
145
|
+
end
|
146
|
+
|
147
|
+
# JRUBY-4581
|
148
|
+
it "should prepend JRUBY_OPTS to the start of the argument list to process" do
|
149
|
+
with_environment "JRUBY_OPTS" => "--server -J-Dsome.key=val -rubygems" do
|
150
|
+
jruby_launcher_args("-e 'ABC DEF'").should include("-server", "-Dsome.key=val", "-rubygems", "-e", "ABC DEF")
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
# JRUBY-4611
|
155
|
+
it "stops argument processing on first non-option argument" do
|
156
|
+
jruby_launcher_args("foo.rb --sample")[-2..-1].should == ["foo.rb", "--sample"]
|
157
|
+
end
|
158
|
+
|
159
|
+
# JRUBY-4608
|
160
|
+
if Config::CONFIG['target_os'] =~ /darwin/i
|
161
|
+
it "includes file.encoding=UTF-8 on Mac if JAVA_ENCODING is not set" do
|
162
|
+
jruby_launcher_args("-e true").should include("-Dfile.encoding=UTF-8")
|
163
|
+
with_environment "JAVA_ENCODING" => "MacRoman" do
|
164
|
+
jruby_launcher_args("-e true").should_not include("-Dfile.encoding=UTF-8")
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
it "does not crash on empty args" do
|
170
|
+
jruby_launcher_args("-e ''").should include("-e")
|
171
|
+
jruby_launcher("-Xtrace '' 2>&1").should =~ /-Xtrace/
|
172
|
+
jruby_launcher("-Xjdkhome '' 2>&1").should =~ /-Xjdkhome/
|
173
|
+
end
|
174
|
+
|
175
|
+
# JRUBY-4706
|
176
|
+
it "should put JRuby on regular classpath when -Xnobootclasspath is used" do
|
177
|
+
args = jruby_launcher_args("-e true")
|
178
|
+
args.grep(/Xbootclasspath/).should_not be_empty
|
179
|
+
args = jruby_launcher_args("-Xnobootclasspath -e true")
|
180
|
+
args.grep(/Xbootclasspath/).should be_empty
|
181
|
+
end
|
182
|
+
|
183
|
+
it "should put JRuby on regular classpath when VERIFY_JRUBY is set" do
|
184
|
+
with_environment "VERIFY_JRUBY" => "true" do
|
185
|
+
args = jruby_launcher_args("-e true")
|
186
|
+
args.grep(/Xbootclasspath/).should be_empty
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
# JRUBY-4709
|
191
|
+
it "should include a bare : or ; at the end of the classpath, to include PWD in the path" do
|
192
|
+
jruby_launcher_args("-Xnobootclasspath -e true").grep(/java\.class\.path/).first.should =~
|
193
|
+
if windows?
|
194
|
+
/;$/
|
195
|
+
else
|
196
|
+
/:$/
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
# JRUBY-6016
|
201
|
+
it "should honor JAVA_MEM" do
|
202
|
+
with_environment "JAVA_MEM" => "-Xmx768m" do
|
203
|
+
jruby_launcher_args("").should include("-Xmx768m", "-Djruby.memory.max=768m")
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
it "should honor JAVA_STACK" do
|
208
|
+
with_environment "JAVA_STACK" => "-Xss3072k" do
|
209
|
+
jruby_launcher_args("").should include("-Xss3072k", "-Djruby.stack.max=3072k")
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
it "should place user-supplied options after default options" do
|
214
|
+
args = jruby_launcher_args("-J-Djruby.home=/tmp")
|
215
|
+
home_args = args.select {|x| x =~ /^-Djruby\.home/ }
|
216
|
+
home_args.length.should == 2
|
217
|
+
home_args.last.should == "-Djruby.home=/tmp"
|
218
|
+
end
|
219
|
+
|
220
|
+
it "should print the version" do
|
221
|
+
jruby_launcher("-Xversion 2>&1").should =~ /Launcher Version #{JRubyLauncher::VERSION}/
|
222
|
+
end
|
223
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'rbconfig'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
if defined?(JRUBY_VERSION)
|
6
|
+
require 'jruby'
|
7
|
+
JRuby.runtime.instance_config.run_ruby_in_process = false
|
8
|
+
end
|
9
|
+
|
10
|
+
module JRubyLauncherHelper
|
11
|
+
JRUBY_EXE = ''
|
12
|
+
WINDOWS = Config::CONFIG['target_os'] =~ /mswin/
|
13
|
+
|
14
|
+
def self.check_executable_built
|
15
|
+
exe = File.expand_path("../../jruby", __FILE__) + Config::CONFIG['EXEEXT']
|
16
|
+
unless File.executable?(exe)
|
17
|
+
raise "Error: launcher executable not built; type `make' before continuing."
|
18
|
+
end
|
19
|
+
top = File.dirname(exe)
|
20
|
+
name = File.basename(exe)
|
21
|
+
home = File.join(top, "build/home")
|
22
|
+
FileUtils.mkdir_p(File.join(home, "bin"))
|
23
|
+
FileUtils.cp(exe, File.join(home, "bin"))
|
24
|
+
if JRubyLauncherHelper::WINDOWS
|
25
|
+
FileUtils.cp(exe.sub(/exe/, 'dll'), File.join(home, "bin"))
|
26
|
+
end
|
27
|
+
FileUtils.mkdir_p(File.join(home, "lib"))
|
28
|
+
FileUtils.touch(File.join(home, "lib/jruby.jar"))
|
29
|
+
JRUBY_EXE.concat File.join(home, "bin", name)
|
30
|
+
end
|
31
|
+
|
32
|
+
def jruby_launcher(args)
|
33
|
+
`#{JRUBY_EXE} #{args}`
|
34
|
+
end
|
35
|
+
|
36
|
+
def jruby_launcher_args(args)
|
37
|
+
jruby_launcher("-Xcommand #{args}").split("\n")
|
38
|
+
end
|
39
|
+
|
40
|
+
def last_exit_code
|
41
|
+
$?.exitstatus
|
42
|
+
end
|
43
|
+
|
44
|
+
def windows?
|
45
|
+
WINDOWS
|
46
|
+
end
|
47
|
+
|
48
|
+
def with_environment(pairs = {})
|
49
|
+
prev_env = {}
|
50
|
+
pairs.each_pair do |k,v|
|
51
|
+
prev_env[k] = ENV[k] if ENV.has_key?(k)
|
52
|
+
ENV[k] = v
|
53
|
+
end
|
54
|
+
begin
|
55
|
+
yield
|
56
|
+
ensure
|
57
|
+
pairs.keys.each {|k| ENV.delete(k)}
|
58
|
+
ENV.update(prev_env)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
RSpec.configure do |config|
|
64
|
+
config.before(:all) do
|
65
|
+
JRubyLauncherHelper.check_executable_built
|
66
|
+
# clear environment for better control
|
67
|
+
ENV.delete("JAVA_HOME")
|
68
|
+
ENV.delete("JRUBY_HOME")
|
69
|
+
ENV.delete("JAVA_OPTS")
|
70
|
+
ENV.delete("JRUBY_OPTS")
|
71
|
+
ENV.delete("CLASSPATH")
|
72
|
+
ENV.delete("JAVA_ENCODING")
|
73
|
+
end
|
74
|
+
config.include(JRubyLauncherHelper)
|
75
|
+
end
|
data/platformlauncher.cpp
CHANGED
@@ -98,7 +98,7 @@ bool PlatformLauncher::start(char* argv[], int argc, DWORD *retCode, const char*
|
|
98
98
|
progArgs.push_front("org.jruby.util.NailMain");
|
99
99
|
char ** nailArgv = convertToArgvArray(progArgs);
|
100
100
|
if (printCommandLine) {
|
101
|
-
|
101
|
+
printListToConsole(progArgs);
|
102
102
|
return true;
|
103
103
|
}
|
104
104
|
|
@@ -210,7 +210,7 @@ bool PlatformLauncher::checkJDKHome() {
|
|
210
210
|
return false;
|
211
211
|
}
|
212
212
|
} else {
|
213
|
-
fprintf(
|
213
|
+
fprintf(stdout, "%s\n", errMsg.c_str());
|
214
214
|
return false;
|
215
215
|
}
|
216
216
|
}
|
@@ -233,7 +233,7 @@ bool PlatformLauncher::checkJDKHome() {
|
|
233
233
|
return false;
|
234
234
|
}
|
235
235
|
} else {
|
236
|
-
fprintf(
|
236
|
+
fprintf(stdout, "%s\n", errMsg.c_str());
|
237
237
|
return false;
|
238
238
|
}
|
239
239
|
} else {
|
data/spec/launcher_spec.rb
CHANGED
@@ -210,6 +210,32 @@ describe "JRuby native launcher" do
|
|
210
210
|
end
|
211
211
|
end
|
212
212
|
|
213
|
+
it "should honor JRUBY_HOME" do
|
214
|
+
with_environment "JRUBY_HOME" => "/tmp" do
|
215
|
+
jruby_launcher_args("").should include("-Djruby.home=/tmp")
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
context "JRUBY_HOME set and JRUBY_HOME/lib/jruby.jar exists" do
|
220
|
+
let(:jruby_home) do
|
221
|
+
require 'tempfile'
|
222
|
+
t = Tempfile.new("jruby_home")
|
223
|
+
t.path.tap { t.close! }
|
224
|
+
end
|
225
|
+
|
226
|
+
before do
|
227
|
+
FileUtils.mkdir_p(File.join(jruby_home, "lib"))
|
228
|
+
FileUtils.touch(File.join(jruby_home, "lib", "jruby.jar"))
|
229
|
+
end
|
230
|
+
after { FileUtils.rm_rf jruby_home }
|
231
|
+
|
232
|
+
it "should add jruby.jar to the bootclasspath" do
|
233
|
+
with_environment "JRUBY_HOME" => jruby_home do
|
234
|
+
jruby_launcher_args("").should include("-Xbootclasspath/a:#{jruby_home}/lib/jruby.jar")
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
213
239
|
it "should place user-supplied options after default options" do
|
214
240
|
args = jruby_launcher_args("-J-Djruby.home=/tmp")
|
215
241
|
home_args = args.select {|x| x =~ /^-Djruby\.home/ }
|
data/unixlauncher.cpp
CHANGED
data/utilsfuncs.cpp
CHANGED
@@ -51,6 +51,7 @@
|
|
51
51
|
#include <algorithm>
|
52
52
|
#include <iterator>
|
53
53
|
#include <iostream>
|
54
|
+
#include <unistd.h>
|
54
55
|
#include "utilsfuncs.h"
|
55
56
|
#include "argnames.h"
|
56
57
|
|
@@ -202,7 +203,7 @@ void logV(bool appendSysError, bool showMsgBox, const char *format, va_list args
|
|
202
203
|
::MessageBox(NULL, msg, "JRuby Error", MB_OK | MB_ICONSTOP);
|
203
204
|
}
|
204
205
|
#endif
|
205
|
-
fprintf(
|
206
|
+
fprintf(stdout, "%s\n", msg);
|
206
207
|
}
|
207
208
|
}
|
208
209
|
|
@@ -242,7 +243,7 @@ bool checkLoggingArg(int argc, char *argv[], bool delFile) {
|
|
242
243
|
}
|
243
244
|
|
244
245
|
bool printToConsole(const char *msg) {
|
245
|
-
fprintf(
|
246
|
+
fprintf(stdout, "%s", msg);
|
246
247
|
return false;
|
247
248
|
}
|
248
249
|
|
data/version.h
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: jruby-launcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.0.
|
5
|
+
version: 1.0.13
|
6
6
|
platform: java
|
7
7
|
authors:
|
8
8
|
- Nick Sieger
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2012-
|
14
|
+
date: 2012-04-18 00:00:00 Z
|
15
15
|
dependencies: []
|
16
16
|
|
17
17
|
description: Builds and installs a native launcher for JRuby on your system
|
@@ -54,6 +54,11 @@ files:
|
|
54
54
|
- extconf.rb
|
55
55
|
- lib/jruby-launcher.rb
|
56
56
|
- lib/rubygems/defaults/jruby_native.rb
|
57
|
+
- pkg/jruby-launcher-1.0.12-java/extconf.rb
|
58
|
+
- pkg/jruby-launcher-1.0.12-java/lib/jruby-launcher.rb
|
59
|
+
- pkg/jruby-launcher-1.0.12-java/lib/rubygems/defaults/jruby_native.rb
|
60
|
+
- pkg/jruby-launcher-1.0.12-java/spec/launcher_spec.rb
|
61
|
+
- pkg/jruby-launcher-1.0.12-java/spec/spec_helper.rb
|
57
62
|
- spec/launcher_spec.rb
|
58
63
|
- spec/spec_helper.rb
|
59
64
|
- resources/jruby.ico
|
@@ -81,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
86
|
requirements: []
|
82
87
|
|
83
88
|
rubyforge_project: jruby-extras
|
84
|
-
rubygems_version: 1.8.
|
89
|
+
rubygems_version: 1.8.15
|
85
90
|
signing_key:
|
86
91
|
specification_version: 3
|
87
92
|
summary: Native launcher for JRuby
|