jruby-launcher 1.0.15-java → 1.0.16-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Makefile +2 -2
- data/argparser.cpp +12 -4
- data/inc/Makefile-conf.mk +1 -1
- data/jvmlauncher.cpp +16 -14
- data/jvmlauncher.h +1 -1
- data/lib/jruby-launcher.rb +1 -1
- data/ng.c +172 -84
- data/platformlauncher.cpp +4 -4
- data/resources/jruby.ico +0 -0
- data/spec/launcher_spec.rb +6 -6
- data/version.h +1 -1
- metadata +35 -80
- data/pkg/jruby-launcher-1.0.15-java/extconf.rb +0 -7
- data/pkg/jruby-launcher-1.0.15-java/lib/jruby-launcher.rb +0 -3
- data/pkg/jruby-launcher-1.0.15-java/lib/rubygems/defaults/jruby_native.rb +0 -4
- data/pkg/jruby-launcher-1.0.15-java/spec/launcher_spec.rb +0 -258
- data/pkg/jruby-launcher-1.0.15-java/spec/spec_helper.rb +0 -81
data/Makefile
CHANGED
@@ -27,10 +27,10 @@ jruby.res: resources/jruby.rc
|
|
27
27
|
windres $^ -O coff -o $@
|
28
28
|
|
29
29
|
jruby.exe: jrubyexe.cpp nbexecloader.h utilsfuncs.cpp utilsfuncswin.cpp jruby.res
|
30
|
-
g++ $(CXXFLAGS) $^ -s -o $@ $(LDLIBSOPTIONS)
|
30
|
+
g++ $(CXXFLAGS) $^ -s -o $@ $(LDLIBSOPTIONS) -static
|
31
31
|
|
32
32
|
jrubyw.exe: jrubyexe.cpp nbexecloader.h utilsfuncs.cpp utilsfuncswin.cpp jruby.res
|
33
|
-
g++ $(CXXFLAGS) -DJRUBYW -mwindows $^ -s -o $@ $(LDLIBSOPTIONS)
|
33
|
+
g++ $(CXXFLAGS) -DJRUBYW -mwindows $^ -s -o $@ $(LDLIBSOPTIONS) -static
|
34
34
|
|
35
35
|
install:
|
36
36
|
@if [ ! -f ./jruby ]; then echo "Please run 'make' first."; exit 1; fi
|
data/argparser.cpp
CHANGED
@@ -391,12 +391,14 @@ void ArgParser::prepareOptions() {
|
|
391
391
|
|
392
392
|
option = OPT_JFFI_PATH;
|
393
393
|
#ifdef WIN32
|
394
|
-
option += (platformDir + "\\lib\\native
|
394
|
+
option += (platformDir + "\\lib\\native;"
|
395
|
+
+ platformDir + "\\lib\\native\\i386-Windows;"
|
395
396
|
+ platformDir + "\\lib\\native\\x86_64-Windows");
|
396
397
|
#else
|
397
398
|
struct utsname name;
|
398
399
|
if (uname(&name) == 0) {
|
399
|
-
string
|
400
|
+
string ffiBase(platformDir + "/lib/native");
|
401
|
+
string ffiPath = ffiBase;
|
400
402
|
DIR* dir = opendir(ffiBase.c_str());
|
401
403
|
struct dirent* ent;
|
402
404
|
if (dir != NULL) {
|
@@ -476,8 +478,6 @@ void ArgParser::setupMaxHeapAndStack(list<string> userOptions) {
|
|
476
478
|
if (!maxStack) {
|
477
479
|
javaOptions.push_back("-Xss" + stackSize);
|
478
480
|
}
|
479
|
-
javaOptions.push_back("-Djruby.memory.max=" + heapSize);
|
480
|
-
javaOptions.push_back("-Djruby.stack.max=" + stackSize);
|
481
481
|
}
|
482
482
|
|
483
483
|
void ArgParser::constructBootClassPath() {
|
@@ -498,6 +498,14 @@ void ArgParser::constructBootClassPath() {
|
|
498
498
|
addToBootClassPath(jruby_complete_jar.c_str());
|
499
499
|
}
|
500
500
|
|
501
|
+
#ifdef DISTRO_BOOT_CLASS_PATH
|
502
|
+
// hack converting macro to string
|
503
|
+
#define STR_HACK2(x) #x
|
504
|
+
#define STR_HACK(x) STR_HACK2(x)
|
505
|
+
addToBootClassPath(STR_HACK(DISTRO_BOOT_CLASS_PATH));
|
506
|
+
#endif
|
507
|
+
|
508
|
+
|
501
509
|
logMsg("BootclassPath: %s", bootClassPath.c_str());
|
502
510
|
}
|
503
511
|
|
data/inc/Makefile-conf.mk
CHANGED
@@ -64,7 +64,7 @@ WINDRES = windres
|
|
64
64
|
LDLIBSOPTIONS = -lstdc++
|
65
65
|
|
66
66
|
ifdef MINGW
|
67
|
-
LDLIBSOPTIONS += -lws2_32 -static-libgcc -Wl,--enable-auto-import -Wl,-Bstatic -Wl,-Bdynamic
|
67
|
+
LDLIBSOPTIONS += -lws2_32 -static-libgcc -Wl,--enable-auto-import -Wl,-Bstatic -Wl,-Bdynamic -static
|
68
68
|
PROGRAM = jruby.dll
|
69
69
|
else
|
70
70
|
PROGRAM = jruby
|
data/jvmlauncher.cpp
CHANGED
@@ -78,34 +78,33 @@ void JvmLauncher::setJavaCmd(const string cmdPath) {
|
|
78
78
|
javaServerDllPath = javaPath;
|
79
79
|
}
|
80
80
|
|
81
|
-
bool JvmLauncher::checkJava(
|
82
|
-
assert(path);
|
81
|
+
bool JvmLauncher::checkJava(std::string &path, const char *prefix) {
|
83
82
|
assert(prefix);
|
84
|
-
logMsg("checkJava(%s)", path);
|
85
|
-
|
86
|
-
if (*
|
87
|
-
|
83
|
+
logMsg("checkJava('%s', '%s')", path.c_str(), prefix);
|
84
|
+
|
85
|
+
if (*path.rbegin() == '\\') {
|
86
|
+
path.erase(path.length() - 1, 1);
|
88
87
|
}
|
89
|
-
javaExePath =
|
90
|
-
javawExePath =
|
91
|
-
javaClientDllPath =
|
92
|
-
javaServerDllPath =
|
88
|
+
javaExePath = path + prefix + JAVA_EXE_FILE;
|
89
|
+
javawExePath = path + prefix + JAVAW_EXE_FILE;
|
90
|
+
javaClientDllPath = path + prefix + JAVA_CLIENT_DLL_FILE;
|
91
|
+
javaServerDllPath = path + prefix + JAVA_SERVER_DLL_FILE;
|
93
92
|
if (!fileExists(javaClientDllPath.c_str())) {
|
94
93
|
javaClientDllPath = "";
|
95
94
|
}
|
96
95
|
if (!fileExists(javaServerDllPath.c_str())) {
|
97
96
|
javaServerDllPath = "";
|
98
97
|
}
|
99
|
-
javaBinPath =
|
98
|
+
javaBinPath = path + prefix + JAVA_BIN_DIR;
|
100
99
|
if (fileExists(javaExePath.c_str()) || !javaClientDllPath.empty() || !javaServerDllPath.empty()) {
|
101
100
|
if (!fileExists(javawExePath.c_str())) {
|
102
101
|
logMsg("javaw.exe not exists, forcing java.exe");
|
103
102
|
javawExePath = javaExePath;
|
104
103
|
}
|
104
|
+
javaPath = path;
|
105
105
|
return true;
|
106
106
|
}
|
107
107
|
|
108
|
-
javaPath.clear();
|
109
108
|
javaBinPath.clear();
|
110
109
|
javaExePath.clear();
|
111
110
|
javawExePath.clear();
|
@@ -117,10 +116,13 @@ bool JvmLauncher::checkJava(const char *path, const char *prefix) {
|
|
117
116
|
bool JvmLauncher::initialize(const char *javaPathOrMinVersion) {
|
118
117
|
logMsg("JvmLauncher::initialize()\n\tjavaPathOrMinVersion: %s", javaPathOrMinVersion);
|
119
118
|
assert(javaPathOrMinVersion);
|
119
|
+
|
120
|
+
std::string pathOrVersion(javaPathOrMinVersion);
|
121
|
+
|
120
122
|
if (isVersionString(javaPathOrMinVersion)) {
|
121
123
|
return findJava(javaPathOrMinVersion);
|
122
124
|
} else {
|
123
|
-
return (checkJava(
|
125
|
+
return (checkJava(pathOrVersion, JAVA_JRE_PREFIX) || checkJava(pathOrVersion, ""));
|
124
126
|
}
|
125
127
|
}
|
126
128
|
|
@@ -444,7 +446,7 @@ bool JvmLauncher::findJava(const char *javaKey, const char *prefix, const char *
|
|
444
446
|
if (*path.rbegin() == '\\') {
|
445
447
|
path.erase(path.length() - 1, 1);
|
446
448
|
}
|
447
|
-
return checkJava(path
|
449
|
+
return checkJava(path, prefix);
|
448
450
|
}
|
449
451
|
}
|
450
452
|
}
|
data/jvmlauncher.h
CHANGED
@@ -82,7 +82,7 @@ public:
|
|
82
82
|
private:
|
83
83
|
JvmLauncher(const JvmLauncher& orig);
|
84
84
|
|
85
|
-
bool checkJava(
|
85
|
+
bool checkJava(std::string &javaPath, const char *version);
|
86
86
|
bool findJava(const char *minJavaVersion);
|
87
87
|
bool findJava(const char *javaKey, const char *prefix, const char *minJavaVersion);
|
88
88
|
bool startOutProcJvm(const char *mainClassName, std::list<std::string> args, std::list<std::string> options, DWORD *retCode);
|
data/lib/jruby-launcher.rb
CHANGED
data/ng.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
|
3
|
-
Copyright 2004,
|
3
|
+
Copyright 2004-2012, Martian Software, Inc.
|
4
4
|
|
5
5
|
Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
you may not use this file except in compliance with the License.
|
@@ -36,8 +36,9 @@
|
|
36
36
|
#include <stdlib.h>
|
37
37
|
#include <string.h>
|
38
38
|
#include <unistd.h>
|
39
|
+
#include <fcntl.h>
|
39
40
|
|
40
|
-
#define NAILGUN_VERSION "0.
|
41
|
+
#define NAILGUN_VERSION "0.9.0"
|
41
42
|
|
42
43
|
#define BUFSIZE (2048)
|
43
44
|
|
@@ -62,10 +63,6 @@
|
|
62
63
|
#define MIN(a,b) ((a<b)?(a):(b))
|
63
64
|
#endif
|
64
65
|
|
65
|
-
#ifndef MSG_WAITALL
|
66
|
-
#define MSG_WAITALL 0x40 /* wait for full request or error */
|
67
|
-
#endif
|
68
|
-
|
69
66
|
#ifdef WIN32
|
70
67
|
#define NAILGUN_FILESEPARATOR "NAILGUN_FILESEPARATOR=\\"
|
71
68
|
#define NAILGUN_PATHSEPARATOR "NAILGUN_PATHSEPARATOR=;"
|
@@ -80,27 +77,45 @@
|
|
80
77
|
#define NAILGUN_CLIENT_NAME "ng"
|
81
78
|
#define CHUNK_HEADER_LEN (5)
|
82
79
|
|
83
|
-
#define NAILGUN_SOCKET_FAILED (
|
84
|
-
#define NAILGUN_CONNECT_FAILED (
|
85
|
-
#define NAILGUN_UNEXPECTED_CHUNKTYPE (
|
86
|
-
#define NAILGUN_EXCEPTION_ON_SERVER (
|
87
|
-
#define NAILGUN_CONNECTION_BROKEN (
|
88
|
-
#define NAILGUN_BAD_ARGUMENTS (
|
80
|
+
#define NAILGUN_SOCKET_FAILED (231)
|
81
|
+
#define NAILGUN_CONNECT_FAILED (230)
|
82
|
+
#define NAILGUN_UNEXPECTED_CHUNKTYPE (229)
|
83
|
+
#define NAILGUN_EXCEPTION_ON_SERVER (228)
|
84
|
+
#define NAILGUN_CONNECTION_BROKEN (227)
|
85
|
+
#define NAILGUN_BAD_ARGUMENTS (226)
|
89
86
|
|
90
87
|
#define CHUNKTYPE_STDIN '0'
|
91
88
|
#define CHUNKTYPE_STDOUT '1'
|
92
89
|
#define CHUNKTYPE_STDERR '2'
|
93
90
|
#define CHUNKTYPE_STDIN_EOF '.'
|
94
91
|
#define CHUNKTYPE_ARG 'A'
|
92
|
+
#define CHUNKTYPE_LONGARG 'L'
|
95
93
|
#define CHUNKTYPE_ENV 'E'
|
96
94
|
#define CHUNKTYPE_DIR 'D'
|
97
95
|
#define CHUNKTYPE_CMD 'C'
|
98
96
|
#define CHUNKTYPE_EXIT 'X'
|
97
|
+
#define CHUNKTYPE_STARTINPUT 'S'
|
99
98
|
|
99
|
+
// jruby-launcher specific constant
|
100
|
+
#define JRUBY_EXIT_EXCEPTION (1)
|
101
|
+
|
102
|
+
/*
|
103
|
+
the following is required to compile for hp-ux
|
104
|
+
originally posted at http://jira.codehaus.org/browse/JRUBY-2346
|
105
|
+
*/
|
106
|
+
#ifndef MSG_WAITALL
|
107
|
+
#define MSG_WAITALL 0x40 /* wait for full request or error */
|
108
|
+
#endif
|
100
109
|
|
101
110
|
/* the socket connected to the nailgun server */
|
102
111
|
int nailgunsocket = 0;
|
103
112
|
|
113
|
+
/* buffer used for receiving and writing nail output chunks */
|
114
|
+
char buf[BUFSIZE];
|
115
|
+
|
116
|
+
/* track whether or not we've been told to send stdin to server */
|
117
|
+
int startedInput = 0;
|
118
|
+
|
104
119
|
/**
|
105
120
|
* Clean up the application.
|
106
121
|
*/
|
@@ -198,6 +213,38 @@ void sendHeader(unsigned int size, char chunkType) {
|
|
198
213
|
sendAll(nailgunsocket, header, CHUNK_HEADER_LEN);
|
199
214
|
}
|
200
215
|
|
216
|
+
/**
|
217
|
+
* Sends the contents of the specified file as a long argument (--nailgun-filearg)
|
218
|
+
* This is sent as one or more chunks of type CHUNK_LONGARG. The end of the argument
|
219
|
+
* is indicated by an empty chunk.
|
220
|
+
*
|
221
|
+
* @param filename the name of the file to send.
|
222
|
+
* @return nonzero on failure
|
223
|
+
*/
|
224
|
+
int sendFileArg(char *filename) {
|
225
|
+
int i, f;
|
226
|
+
|
227
|
+
if ((f = open(filename, O_RDONLY)) < 0) {
|
228
|
+
perror("--nailgun-filearg");
|
229
|
+
return 1;
|
230
|
+
}
|
231
|
+
|
232
|
+
i = read(f, buf, BUFSIZE);
|
233
|
+
while (i > 0) {
|
234
|
+
sendHeader(i, CHUNKTYPE_LONGARG);
|
235
|
+
sendAll(nailgunsocket, buf, i);
|
236
|
+
i = read(f, buf, BUFSIZE);
|
237
|
+
}
|
238
|
+
if (i < 0) {
|
239
|
+
perror("--nailgun-filearg");
|
240
|
+
return 1;
|
241
|
+
}
|
242
|
+
sendHeader(0, CHUNKTYPE_LONGARG);
|
243
|
+
|
244
|
+
close(f);
|
245
|
+
return 0;
|
246
|
+
}
|
247
|
+
|
201
248
|
/**
|
202
249
|
* Sends a null-terminated string with the specified chunk type.
|
203
250
|
*
|
@@ -205,7 +252,7 @@ void sendHeader(unsigned int size, char chunkType) {
|
|
205
252
|
* @param text the null-terminated string to send
|
206
253
|
*/
|
207
254
|
void sendText(char chunkType, char *text) {
|
208
|
-
int len = strlen(text);
|
255
|
+
int len = text ? strlen(text) : 0;
|
209
256
|
sendHeader(len, chunkType);
|
210
257
|
sendAll(nailgunsocket, text, len);
|
211
258
|
}
|
@@ -234,6 +281,8 @@ void recvToFD(HANDLE destFD, char *buf, unsigned long len) {
|
|
234
281
|
int thisPass = 0;
|
235
282
|
|
236
283
|
thisPass = recv(nailgunsocket, buf, bytesToRead, MSG_WAITALL);
|
284
|
+
if (thisPass < bytesToRead) handleSocketClose();
|
285
|
+
|
237
286
|
|
238
287
|
bytesRead += thisPass;
|
239
288
|
|
@@ -278,47 +327,13 @@ void processExit(char *buf, unsigned long len) {
|
|
278
327
|
buf[bytesRead] = 0;
|
279
328
|
|
280
329
|
exitcode = atoi(buf);
|
330
|
+
if (exitcode != 0) {
|
331
|
+
exitcode = JRUBY_EXIT_EXCEPTION;
|
332
|
+
}
|
281
333
|
|
282
334
|
cleanUpAndExit(exitcode);
|
283
335
|
}
|
284
336
|
|
285
|
-
/**
|
286
|
-
* Processes data from the nailgun server.
|
287
|
-
*/
|
288
|
-
void processnailgunstream() {
|
289
|
-
/* buffer used for receiving and writing nail output chunks */
|
290
|
-
char buf[BUFSIZE];
|
291
|
-
|
292
|
-
/*for (;;) {*/
|
293
|
-
int bytesRead = 0;
|
294
|
-
unsigned long len;
|
295
|
-
char chunkType;
|
296
|
-
|
297
|
-
bytesRead = recv(nailgunsocket, buf, CHUNK_HEADER_LEN, 0);
|
298
|
-
|
299
|
-
if (bytesRead < CHUNK_HEADER_LEN) {
|
300
|
-
handleSocketClose();
|
301
|
-
}
|
302
|
-
|
303
|
-
len = ((buf[0] << 24) & 0xff000000)
|
304
|
-
| ((buf[1] << 16) & 0x00ff0000)
|
305
|
-
| ((buf[2] << 8) & 0x0000ff00)
|
306
|
-
| ((buf[3]) & 0x000000ff);
|
307
|
-
|
308
|
-
chunkType = buf[4];
|
309
|
-
|
310
|
-
switch(chunkType) {
|
311
|
-
case CHUNKTYPE_STDOUT: recvToFD(NG_STDOUT_FILENO, buf, len);
|
312
|
-
break;
|
313
|
-
case CHUNKTYPE_STDERR: recvToFD(NG_STDERR_FILENO, buf, len);
|
314
|
-
break;
|
315
|
-
case CHUNKTYPE_EXIT: processExit(buf, len);
|
316
|
-
break;
|
317
|
-
default: fprintf(stdout, "Unexpected chunk type %d ('%c')\n", chunkType, chunkType);
|
318
|
-
cleanUpAndExit(NAILGUN_UNEXPECTED_CHUNKTYPE);
|
319
|
-
}
|
320
|
-
/*}*/
|
321
|
-
}
|
322
337
|
|
323
338
|
/**
|
324
339
|
* Sends len bytes from buf to the nailgun server in a stdin chunk.
|
@@ -345,19 +360,19 @@ void processEof() {
|
|
345
360
|
*/
|
346
361
|
DWORD WINAPI processStdin (LPVOID lpParameter) {
|
347
362
|
/* buffer used for reading and sending stdin chunks */
|
348
|
-
char
|
363
|
+
char wbuf[BUFSIZE];
|
349
364
|
|
350
365
|
for (;;) {
|
351
366
|
DWORD numberOfBytes = 0;
|
352
367
|
|
353
|
-
if (!ReadFile(NG_STDIN_FILENO,
|
368
|
+
if (!ReadFile(NG_STDIN_FILENO, wbuf, BUFSIZE, &numberOfBytes, NULL)) {
|
354
369
|
if (numberOfBytes != 0) {
|
355
370
|
handleError();
|
356
371
|
}
|
357
372
|
}
|
358
373
|
|
359
374
|
if (numberOfBytes > 0) {
|
360
|
-
sendStdin(
|
375
|
+
sendStdin(wbuf, numberOfBytes);
|
361
376
|
} else {
|
362
377
|
processEof();
|
363
378
|
break;
|
@@ -400,26 +415,77 @@ void initSockets () {
|
|
400
415
|
* Initialise the asynchronous io.
|
401
416
|
*/
|
402
417
|
void initIo () {
|
403
|
-
SECURITY_ATTRIBUTES securityAttributes;
|
404
|
-
DWORD threadId = 0;
|
405
|
-
|
406
418
|
/* create non-blocking console io */
|
407
419
|
AllocConsole();
|
420
|
+
|
421
|
+
NG_STDIN_FILENO = GetStdHandle(STD_INPUT_HANDLE);
|
422
|
+
NG_STDOUT_FILENO = GetStdHandle(STD_OUTPUT_HANDLE);
|
423
|
+
NG_STDERR_FILENO = GetStdHandle(STD_ERROR_HANDLE);
|
424
|
+
}
|
425
|
+
#endif
|
426
|
+
|
427
|
+
#ifdef WIN32
|
428
|
+
/**
|
429
|
+
* Initialise the asynchronous io.
|
430
|
+
*/
|
431
|
+
void winStartInput () {
|
432
|
+
SECURITY_ATTRIBUTES securityAttributes;
|
433
|
+
DWORD threadId = 0;
|
408
434
|
|
409
435
|
securityAttributes.bInheritHandle = TRUE;
|
410
436
|
securityAttributes.lpSecurityDescriptor = NULL;
|
411
437
|
securityAttributes.nLength = 0;
|
412
438
|
|
413
|
-
NG_STDIN_FILENO = GetStdHandle(STD_INPUT_HANDLE);
|
414
|
-
NG_STDOUT_FILENO = GetStdHandle(STD_OUTPUT_HANDLE);
|
415
|
-
NG_STDERR_FILENO = GetStdHandle(STD_ERROR_HANDLE);
|
416
|
-
|
417
439
|
if (!CreateThread(&securityAttributes, 0, &processStdin, NULL, 0, &threadId)) {
|
418
440
|
handleError();
|
419
441
|
}
|
420
442
|
}
|
421
443
|
#endif
|
422
444
|
|
445
|
+
/**
|
446
|
+
* Processes data from the nailgun server.
|
447
|
+
*/
|
448
|
+
void processnailgunstream() {
|
449
|
+
|
450
|
+
/*for (;;) {*/
|
451
|
+
int bytesRead = 0;
|
452
|
+
unsigned long len;
|
453
|
+
char chunkType;
|
454
|
+
|
455
|
+
bytesRead = recv(nailgunsocket, buf, CHUNK_HEADER_LEN, MSG_WAITALL);
|
456
|
+
|
457
|
+
if (bytesRead < CHUNK_HEADER_LEN) {
|
458
|
+
handleSocketClose();
|
459
|
+
}
|
460
|
+
|
461
|
+
len = ((buf[0] << 24) & 0xff000000)
|
462
|
+
| ((buf[1] << 16) & 0x00ff0000)
|
463
|
+
| ((buf[2] << 8) & 0x0000ff00)
|
464
|
+
| ((buf[3]) & 0x000000ff);
|
465
|
+
|
466
|
+
chunkType = buf[4];
|
467
|
+
|
468
|
+
switch(chunkType) {
|
469
|
+
case CHUNKTYPE_STDOUT: recvToFD(NG_STDOUT_FILENO, buf, len);
|
470
|
+
break;
|
471
|
+
case CHUNKTYPE_STDERR: recvToFD(NG_STDERR_FILENO, buf, len);
|
472
|
+
break;
|
473
|
+
case CHUNKTYPE_EXIT: processExit(buf, len);
|
474
|
+
break;
|
475
|
+
case CHUNKTYPE_STARTINPUT:
|
476
|
+
if (!startedInput) {
|
477
|
+
#ifdef WIN32
|
478
|
+
winStartInput();
|
479
|
+
#endif
|
480
|
+
startedInput = 1;
|
481
|
+
}
|
482
|
+
break;
|
483
|
+
default: fprintf(stderr, "Unexpected chunk type %d ('%c')\n", chunkType, chunkType);
|
484
|
+
cleanUpAndExit(NAILGUN_UNEXPECTED_CHUNKTYPE);
|
485
|
+
}
|
486
|
+
/*}*/
|
487
|
+
}
|
488
|
+
|
423
489
|
/**
|
424
490
|
* Trims any path info from the beginning of argv[0] to determine
|
425
491
|
* the name used to launch the client.
|
@@ -450,25 +516,31 @@ int isNailgunClientName(char *s) {
|
|
450
516
|
* Displays usage info and bails
|
451
517
|
*/
|
452
518
|
void usage(int exitcode) {
|
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(
|
519
|
+
fprintf(stderr, "NailGun v%s\n\n", NAILGUN_VERSION);
|
520
|
+
fprintf(stderr, "Usage: ng class [--nailgun-options] [args]\n");
|
521
|
+
fprintf(stderr, " (to execute a class)\n");
|
522
|
+
fprintf(stderr, " or: ng alias [--nailgun-options] [args]\n");
|
523
|
+
fprintf(stderr, " (to execute an aliased class)\n");
|
524
|
+
fprintf(stderr, " or: alias [--nailgun-options] [args]\n");
|
525
|
+
fprintf(stderr, " (to execute an aliased class, where \"alias\"\n");
|
526
|
+
fprintf(stderr, " is both the alias for the class and a symbolic\n");
|
527
|
+
fprintf(stderr, " link to the ng client)\n\n");
|
528
|
+
|
529
|
+
fprintf(stderr, "where options include:\n");
|
530
|
+
fprintf(stderr, " --nailgun-D<name>=<value> set/override a client environment variable\n");
|
531
|
+
fprintf(stderr, " --nailgun-version print product version and exit\n");
|
532
|
+
fprintf(stderr, " --nailgun-showversion print product version and continue\n");
|
533
|
+
fprintf(stderr, " --nailgun-server to specify the address of the nailgun server\n");
|
534
|
+
fprintf(stderr, " (default is NAILGUN_SERVER environment variable\n");
|
535
|
+
fprintf(stderr, " if set, otherwise localhost)\n");
|
536
|
+
fprintf(stderr, " --nailgun-port to specify the port of the nailgun server\n");
|
537
|
+
fprintf(stderr, " (default is NAILGUN_PORT environment variable\n");
|
538
|
+
fprintf(stderr, " if set, otherwise 2113)\n");
|
539
|
+
fprintf(stderr, " --nailgun-filearg FILE places the entire contents of FILE into the\n");
|
540
|
+
fprintf(stderr, " next argument, which is interpreted as a string\n");
|
541
|
+
fprintf(stderr, " using the server's default character set. May be\n");
|
542
|
+
fprintf(stderr, " specified more than once.\n");
|
543
|
+
fprintf(stderr, " --nailgun-help print this message and exit\n");
|
472
544
|
|
473
545
|
cleanUpAndExit(exitcode);
|
474
546
|
}
|
@@ -515,6 +587,15 @@ int nailgunClientMain(int argc, char *argv[], char *env[]) {
|
|
515
587
|
cmd = NULL;
|
516
588
|
}
|
517
589
|
|
590
|
+
/* if executing just the ng client with no arguments or -h|--help, then
|
591
|
+
display usage and exit. Don't handle -h|--help if a command other than
|
592
|
+
ng or ng.exe was used, since the appropriate nail should then handle
|
593
|
+
--help. */
|
594
|
+
if (cmd == NULL &&
|
595
|
+
(argc == 1 ||
|
596
|
+
(argc == 2 && strcmp("--help", argv[1]) == 0) ||
|
597
|
+
(argc == 2 && strcmp("-h", argv[1]) == 0))) usage(0);
|
598
|
+
|
518
599
|
firstArgIndex = 1;
|
519
600
|
|
520
601
|
/* quite possibly the lamest commandline parsing ever.
|
@@ -533,6 +614,9 @@ int nailgunClientMain(int argc, char *argv[], char *env[]) {
|
|
533
614
|
nailgun_port = argv[i + 1];
|
534
615
|
argv[i] = argv[i + 1]= NULL;
|
535
616
|
++i;
|
617
|
+
} else if (!strcmp("--nailgun-filearg", argv[i])) {
|
618
|
+
/* just verify usage here. do the rest when sending args. */
|
619
|
+
if (i == argc - 1) usage (NAILGUN_BAD_ARGUMENTS);
|
536
620
|
} else if (!strcmp("--nailgun-version", argv[i])) {
|
537
621
|
printf("NailGun client version %s\n", NAILGUN_VERSION);
|
538
622
|
cleanUpAndExit(0);
|
@@ -557,7 +641,7 @@ int nailgunClientMain(int argc, char *argv[], char *env[]) {
|
|
557
641
|
hostinfo = gethostbyname(nailgun_server);
|
558
642
|
|
559
643
|
if (hostinfo == NULL) {
|
560
|
-
fprintf(
|
644
|
+
fprintf(stderr, "Unknown host: %s\n", nailgun_server);
|
561
645
|
cleanUpAndExit(NAILGUN_CONNECT_FAILED);
|
562
646
|
}
|
563
647
|
|
@@ -576,7 +660,7 @@ int nailgunClientMain(int argc, char *argv[], char *env[]) {
|
|
576
660
|
|
577
661
|
if (connect(nailgunsocket, (struct sockaddr *)&server_addr,
|
578
662
|
sizeof(struct sockaddr)) == -1) {
|
579
|
-
perror("connect
|
663
|
+
perror("connect");
|
580
664
|
cleanUpAndExit(NAILGUN_CONNECT_FAILED);
|
581
665
|
}
|
582
666
|
|
@@ -585,7 +669,11 @@ int nailgunClientMain(int argc, char *argv[], char *env[]) {
|
|
585
669
|
marked some arguments NULL if we read them to specify the
|
586
670
|
nailgun server and/or port */
|
587
671
|
for(i = firstArgIndex; i < argc; ++i) {
|
588
|
-
if (argv[i] != NULL)
|
672
|
+
if (argv[i] != NULL) {
|
673
|
+
if (!strcmp("--nailgun-filearg", argv[i])) {
|
674
|
+
sendFileArg(argv[++i]);
|
675
|
+
} else sendText(CHUNKTYPE_ARG, argv[i]);
|
676
|
+
}
|
589
677
|
}
|
590
678
|
|
591
679
|
/* now send environment */
|
@@ -596,7 +684,7 @@ int nailgunClientMain(int argc, char *argv[], char *env[]) {
|
|
596
684
|
}
|
597
685
|
|
598
686
|
/* now send the working directory */
|
599
|
-
cwd = getcwd(NULL,
|
687
|
+
cwd = getcwd(NULL, 0);
|
600
688
|
sendText(CHUNKTYPE_DIR, cwd);
|
601
689
|
free(cwd);
|
602
690
|
|
@@ -616,7 +704,7 @@ int nailgunClientMain(int argc, char *argv[], char *env[]) {
|
|
616
704
|
FD_ZERO(&readfds);
|
617
705
|
|
618
706
|
/* don't select on stdin if we've already reached its end */
|
619
|
-
if (!eof) {
|
707
|
+
if (startedInput && !eof) {
|
620
708
|
FD_SET(NG_STDIN_FILENO, &readfds);
|
621
709
|
}
|
622
710
|
|
data/platformlauncher.cpp
CHANGED
@@ -220,10 +220,10 @@ bool PlatformLauncher::checkJDKHome() {
|
|
220
220
|
logMsg("-Xjdkhome is not set, checking for %%JAVA_HOME%%...");
|
221
221
|
char *origJavaHome = getenv("JAVA_HOME");
|
222
222
|
if (origJavaHome) {
|
223
|
-
|
224
|
-
logMsg("%%JAVA_HOME%% is set: %s", javaHome);
|
225
|
-
if (!jvmLauncher.initialize(javaHome)) {
|
226
|
-
logMsg("ERROR: Cannot locate java installation, specified by JAVA_HOME: %s", javaHome);
|
223
|
+
string javaHome = trimTrailingBackslashes(origJavaHome);
|
224
|
+
logMsg("%%JAVA_HOME%% is set: %s", javaHome.c_str());
|
225
|
+
if (!jvmLauncher.initialize(javaHome.c_str())) {
|
226
|
+
logMsg("ERROR: Cannot locate java installation, specified by JAVA_HOME: %s", javaHome.c_str());
|
227
227
|
string errMsg = "Cannot locate Java installation, specified by JAVA_HOME:\n";
|
228
228
|
errMsg += javaHome;
|
229
229
|
string errMsgFull = errMsg + "\nDo you want to try to use default version?";
|
data/resources/jruby.ico
CHANGED
Binary file
|
data/spec/launcher_spec.rb
CHANGED
@@ -95,19 +95,19 @@ describe "JRuby native launcher" do
|
|
95
95
|
end
|
96
96
|
|
97
97
|
it "should default to 500m max heap" do
|
98
|
-
jruby_launcher_args("").should include("-Xmx500m"
|
98
|
+
jruby_launcher_args("").should include("-Xmx500m")
|
99
99
|
end
|
100
100
|
|
101
101
|
it "should allow max heap to be overridden" do
|
102
|
-
jruby_launcher_args("-J-Xmx256m").should include("-Xmx256m"
|
102
|
+
jruby_launcher_args("-J-Xmx256m").should include("-Xmx256m")
|
103
103
|
end
|
104
104
|
|
105
105
|
it "should default to 2048k max stack" do
|
106
|
-
jruby_launcher_args("").should include("-Xss2048k"
|
106
|
+
jruby_launcher_args("").should include("-Xss2048k")
|
107
107
|
end
|
108
108
|
|
109
109
|
it "should allow max stack to be overridden" do
|
110
|
-
jruby_launcher_args("-J-Xss512k").should include("-Xss512k"
|
110
|
+
jruby_launcher_args("-J-Xss512k").should include("-Xss512k")
|
111
111
|
end
|
112
112
|
|
113
113
|
it "should add the contents of the CLASSPATH environment variable" do
|
@@ -209,13 +209,13 @@ describe "JRuby native launcher" do
|
|
209
209
|
# JRUBY-6016
|
210
210
|
it "should honor JAVA_MEM" do
|
211
211
|
with_environment "JAVA_MEM" => "-Xmx768m" do
|
212
|
-
jruby_launcher_args("").should include("-Xmx768m"
|
212
|
+
jruby_launcher_args("").should include("-Xmx768m")
|
213
213
|
end
|
214
214
|
end
|
215
215
|
|
216
216
|
it "should honor JAVA_STACK" do
|
217
217
|
with_environment "JAVA_STACK" => "-Xss3072k" do
|
218
|
-
jruby_launcher_args("").should include("-Xss3072k"
|
218
|
+
jruby_launcher_args("").should include("-Xss3072k")
|
219
219
|
end
|
220
220
|
end
|
221
221
|
|
data/version.h
CHANGED
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jruby-launcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.16
|
4
5
|
prerelease:
|
5
|
-
version: 1.0.15
|
6
6
|
platform: java
|
7
7
|
authors:
|
8
8
|
- Nick Sieger
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2013-05-21 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: Builds and installs a native launcher for JRuby on your system
|
16
16
|
email:
|
@@ -25,78 +25,35 @@ files:
|
|
25
25
|
- README.txt
|
26
26
|
- Makefile
|
27
27
|
- Rakefile
|
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
|
-
cGxhdGZvcm1sYXVuY2hlci5o
|
58
|
-
- !binary |-
|
59
|
-
cmJfdzMyX2NtZHZlY3Rvci5o
|
60
|
-
- !binary |-
|
61
|
-
dW5peGxhdW5jaGVyLmg=
|
62
|
-
- !binary |-
|
63
|
-
dXRpbHNmdW5jcy5o
|
64
|
-
- !binary |-
|
65
|
-
dmVyc2lvbi5o
|
66
|
-
- !binary |-
|
67
|
-
aW5jL01ha2VmaWxlLWNvbmYubWs=
|
68
|
-
- !binary |-
|
69
|
-
aW5jL01ha2VmaWxlLWltcGwubWs=
|
70
|
-
- !binary |-
|
71
|
-
aW5jL01ha2VmaWxlLXJ1bGVzLm1r
|
72
|
-
- !binary |-
|
73
|
-
ZXh0Y29uZi5yYg==
|
74
|
-
- !binary |-
|
75
|
-
bGliL2pydWJ5LWxhdW5jaGVyLnJi
|
76
|
-
- !binary |-
|
77
|
-
bGliL3J1YnlnZW1zL2RlZmF1bHRzL2pydWJ5X25hdGl2ZS5yYg==
|
78
|
-
- !binary |-
|
79
|
-
cGtnL2pydWJ5LWxhdW5jaGVyLTEuMC4xNS1qYXZhL2V4dGNvbmYucmI=
|
80
|
-
- !binary |-
|
81
|
-
cGtnL2pydWJ5LWxhdW5jaGVyLTEuMC4xNS1qYXZhL2xpYi9qcnVieS1sYXVu
|
82
|
-
Y2hlci5yYg==
|
83
|
-
- !binary |-
|
84
|
-
cGtnL2pydWJ5LWxhdW5jaGVyLTEuMC4xNS1qYXZhL2xpYi9ydWJ5Z2Vtcy9k
|
85
|
-
ZWZhdWx0cy9qcnVieV9uYXRpdmUucmI=
|
86
|
-
- !binary |-
|
87
|
-
cGtnL2pydWJ5LWxhdW5jaGVyLTEuMC4xNS1qYXZhL3NwZWMvbGF1bmNoZXJf
|
88
|
-
c3BlYy5yYg==
|
89
|
-
- !binary |-
|
90
|
-
cGtnL2pydWJ5LWxhdW5jaGVyLTEuMC4xNS1qYXZhL3NwZWMvc3BlY19oZWxw
|
91
|
-
ZXIucmI=
|
92
|
-
- !binary |-
|
93
|
-
c3BlYy9sYXVuY2hlcl9zcGVjLnJi
|
94
|
-
- !binary |-
|
95
|
-
c3BlYy9zcGVjX2hlbHBlci5yYg==
|
96
|
-
- !binary |-
|
97
|
-
cmVzb3VyY2VzL2pydWJ5Lmljbw==
|
98
|
-
- !binary |-
|
99
|
-
cmVzb3VyY2VzL2pydWJ5LnJj
|
28
|
+
- ng.c
|
29
|
+
- strlcpy.c
|
30
|
+
- argparser.cpp
|
31
|
+
- jruby.cpp
|
32
|
+
- jrubyexe.cpp
|
33
|
+
- jvmlauncher.cpp
|
34
|
+
- platformlauncher.cpp
|
35
|
+
- unixlauncher.cpp
|
36
|
+
- utilsfuncs.cpp
|
37
|
+
- utilsfuncswin.cpp
|
38
|
+
- argnames.h
|
39
|
+
- argparser.h
|
40
|
+
- jvmlauncher.h
|
41
|
+
- nbexecloader.h
|
42
|
+
- platformlauncher.h
|
43
|
+
- rb_w32_cmdvector.h
|
44
|
+
- unixlauncher.h
|
45
|
+
- utilsfuncs.h
|
46
|
+
- version.h
|
47
|
+
- inc/Makefile-conf.mk
|
48
|
+
- inc/Makefile-impl.mk
|
49
|
+
- inc/Makefile-rules.mk
|
50
|
+
- extconf.rb
|
51
|
+
- lib/jruby-launcher.rb
|
52
|
+
- lib/rubygems/defaults/jruby_native.rb
|
53
|
+
- spec/launcher_spec.rb
|
54
|
+
- spec/spec_helper.rb
|
55
|
+
- resources/jruby.ico
|
56
|
+
- resources/jruby.rc
|
100
57
|
homepage: http://jruby.org
|
101
58
|
licenses: []
|
102
59
|
post_install_message:
|
@@ -105,17 +62,15 @@ require_paths:
|
|
105
62
|
- lib
|
106
63
|
required_ruby_version: !ruby/object:Gem::Requirement
|
107
64
|
requirements:
|
108
|
-
- -
|
65
|
+
- - '>='
|
109
66
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
111
|
-
MA==
|
67
|
+
version: '0'
|
112
68
|
none: false
|
113
69
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
70
|
requirements:
|
115
|
-
- -
|
71
|
+
- - '>='
|
116
72
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
118
|
-
MA==
|
73
|
+
version: '0'
|
119
74
|
none: false
|
120
75
|
requirements: []
|
121
76
|
rubyforge_project: jruby-extras
|
@@ -1,258 +0,0 @@
|
|
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 drop the backslashes at the end of JAVA_HOME" do
|
53
|
-
with_environment "JAVA_HOME" => File.join("some", "java", "home\\\\") do
|
54
|
-
if windows?
|
55
|
-
jruby_launcher_args("").join.should =~ %r{some/java/home}
|
56
|
-
else
|
57
|
-
jruby_launcher_args("").first.should == File.join("some", "java", "home", "bin", "java")
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should complain about a missing log argument" do
|
63
|
-
jruby_launcher("-Xtrace 2>&1").should =~ /Argument is missing for "-Xtrace"/
|
64
|
-
jruby_launcher("-Xtrace -- 2>&1").should =~ /Argument is missing for "-Xtrace"/
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should complain about a missing jdkhome argument" do
|
68
|
-
jruby_launcher("-Xjdkhome 2>&1").should =~ /Argument is missing/
|
69
|
-
jruby_launcher("-Xjdkhome -- 2>&1").should =~ /Argument is missing/
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should complain about a missing classpath append argument" do
|
73
|
-
jruby_launcher("-Xcp:a 2>&1").should =~ /Argument is missing/
|
74
|
-
jruby_launcher("-Xcp:a -- 2>&1").should =~ /Argument is missing/
|
75
|
-
end
|
76
|
-
|
77
|
-
it "should run nailgun server with --ng-server option" do
|
78
|
-
jruby_launcher_args("--ng-server").last.should == "com/martiansoftware/nailgun/NGServer"
|
79
|
-
end
|
80
|
-
|
81
|
-
it "should run nailgun client with --ng option" do
|
82
|
-
jruby_launcher_args('--ng -e "puts 1"').should == ["org.jruby.util.NailMain", "-e", "puts 1"]
|
83
|
-
end
|
84
|
-
|
85
|
-
it "should handle -J JVM options" do
|
86
|
-
jruby_launcher_args("-J-Darg1=value1 -J-Darg2=value2").should include("-Darg1=value1", "-Darg2=value2")
|
87
|
-
end
|
88
|
-
|
89
|
-
it "should pass -Xprop.erty=value as -J-Djruby.prop.erty=value" do
|
90
|
-
jruby_launcher_args("-Xprop.erty=value").should include("-Djruby.prop.erty=value")
|
91
|
-
end
|
92
|
-
|
93
|
-
it "should pass -Xproperties as --properties" do
|
94
|
-
jruby_launcher_args("-Xproperties").should include("--properties")
|
95
|
-
end
|
96
|
-
|
97
|
-
it "should default to 500m max heap" do
|
98
|
-
jruby_launcher_args("").should include("-Xmx500m", "-Djruby.memory.max=500m")
|
99
|
-
end
|
100
|
-
|
101
|
-
it "should allow max heap to be overridden" do
|
102
|
-
jruby_launcher_args("-J-Xmx256m").should include("-Xmx256m", "-Djruby.memory.max=256m")
|
103
|
-
end
|
104
|
-
|
105
|
-
it "should default to 2048k max stack" do
|
106
|
-
jruby_launcher_args("").should include("-Xss2048k", "-Djruby.stack.max=2048k")
|
107
|
-
end
|
108
|
-
|
109
|
-
it "should allow max stack to be overridden" do
|
110
|
-
jruby_launcher_args("-J-Xss512k").should include("-Xss512k", "-Djruby.stack.max=512k")
|
111
|
-
end
|
112
|
-
|
113
|
-
it "should add the contents of the CLASSPATH environment variable" do
|
114
|
-
with_environment "CLASSPATH" => "some.jar" do
|
115
|
-
classpath_arg(jruby_launcher_args("")).should =~ /some.jar/
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
it "should add the classpath elements in proper order" do
|
120
|
-
s = File::PATH_SEPARATOR
|
121
|
-
with_environment "CLASSPATH" => "some-env.jar" do
|
122
|
-
args = jruby_launcher_args("-Xcp:a some-other.jar -Xcp:p some.jar")
|
123
|
-
classpath_arg(args).should =~ /some.jar.*#{s}some-env.jar#{s}some-other.jar/
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
it "should use the --server compiler" do
|
128
|
-
jruby_launcher_args("--server").should include("-server")
|
129
|
-
end
|
130
|
-
|
131
|
-
it "should use the --client compiler" do
|
132
|
-
jruby_launcher_args("--client").should include("-client")
|
133
|
-
end
|
134
|
-
|
135
|
-
it "should set the JMX settings when --manage is present" do
|
136
|
-
jruby_launcher_args("--manage").should include("-Dcom.sun.management.jmxremote", "-Djruby.management.enabled=true")
|
137
|
-
end
|
138
|
-
|
139
|
-
it "should set the headless flag when --headless is present" do
|
140
|
-
jruby_launcher_args("--headless").should include("-Djava.awt.headless=true")
|
141
|
-
end
|
142
|
-
|
143
|
-
it "should pass -Xprof when --sample is present" do
|
144
|
-
jruby_launcher_args("--sample").should include("-Xprof")
|
145
|
-
end
|
146
|
-
|
147
|
-
it "should stop argument processing when a -- is seen" do
|
148
|
-
jruby_launcher_args("-- -Xhelp -Xtrace --headless").should include("-Xhelp", "-Xtrace", "--headless")
|
149
|
-
end
|
150
|
-
|
151
|
-
# JRUBY-4151
|
152
|
-
it "should properly handle single quotes" do
|
153
|
-
jruby_launcher_args("-e 'ABC DEF'").should include("ABC DEF")
|
154
|
-
end
|
155
|
-
|
156
|
-
# JRUBY-4581
|
157
|
-
it "should prepend JRUBY_OPTS to the start of the argument list to process" do
|
158
|
-
with_environment "JRUBY_OPTS" => "--server -J-Dsome.key=val -rubygems" do
|
159
|
-
jruby_launcher_args("-e 'ABC DEF'").should include("-server", "-Dsome.key=val", "-rubygems", "-e", "ABC DEF")
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
# JRUBY-4611
|
164
|
-
it "stops argument processing on first non-option argument" do
|
165
|
-
jruby_launcher_args("foo.rb --sample")[-2..-1].should == ["foo.rb", "--sample"]
|
166
|
-
end
|
167
|
-
|
168
|
-
# JRUBY-4608
|
169
|
-
if RbConfig::CONFIG['target_os'] =~ /darwin/i
|
170
|
-
it "includes file.encoding=UTF-8 on Mac if JAVA_ENCODING is not set" do
|
171
|
-
jruby_launcher_args("-e true").should include("-Dfile.encoding=UTF-8")
|
172
|
-
with_environment "JAVA_ENCODING" => "MacRoman" do
|
173
|
-
jruby_launcher_args("-e true").should_not include("-Dfile.encoding=UTF-8")
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
it "does not crash on empty args" do
|
179
|
-
jruby_launcher_args("-e ''").should include("-e")
|
180
|
-
jruby_launcher("-Xtrace '' 2>&1").should =~ /-Xtrace/
|
181
|
-
jruby_launcher("-Xjdkhome '' 2>&1").should =~ /-Xjdkhome/
|
182
|
-
end
|
183
|
-
|
184
|
-
# JRUBY-4706
|
185
|
-
it "should put JRuby on regular classpath when -Xnobootclasspath is used" do
|
186
|
-
args = jruby_launcher_args("-e true")
|
187
|
-
args.grep(/Xbootclasspath/).should_not be_empty
|
188
|
-
args = jruby_launcher_args("-Xnobootclasspath -e true")
|
189
|
-
args.grep(/Xbootclasspath/).should be_empty
|
190
|
-
end
|
191
|
-
|
192
|
-
it "should put JRuby on regular classpath when VERIFY_JRUBY is set" do
|
193
|
-
with_environment "VERIFY_JRUBY" => "true" do
|
194
|
-
args = jruby_launcher_args("-e true")
|
195
|
-
args.grep(/Xbootclasspath/).should be_empty
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
# JRUBY-4709
|
200
|
-
it "should include a bare : or ; at the end of the classpath, to include PWD in the path" do
|
201
|
-
classpath_arg(jruby_launcher_args("-Xnobootclasspath -e true")).should =~
|
202
|
-
if windows?
|
203
|
-
/;$/
|
204
|
-
else
|
205
|
-
/:$/
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
# JRUBY-6016
|
210
|
-
it "should honor JAVA_MEM" do
|
211
|
-
with_environment "JAVA_MEM" => "-Xmx768m" do
|
212
|
-
jruby_launcher_args("").should include("-Xmx768m", "-Djruby.memory.max=768m")
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
it "should honor JAVA_STACK" do
|
217
|
-
with_environment "JAVA_STACK" => "-Xss3072k" do
|
218
|
-
jruby_launcher_args("").should include("-Xss3072k", "-Djruby.stack.max=3072k")
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
it "should honor JRUBY_HOME" do
|
223
|
-
with_environment "JRUBY_HOME" => "/tmp" do
|
224
|
-
jruby_launcher_args("").should include("-Djruby.home=/tmp")
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
context "JRUBY_HOME set and JRUBY_HOME/lib/jruby.jar exists" do
|
229
|
-
let(:jruby_home) do
|
230
|
-
require 'tempfile'
|
231
|
-
t = Tempfile.new("jruby_home")
|
232
|
-
t.path.tap { t.close! }
|
233
|
-
end
|
234
|
-
|
235
|
-
before do
|
236
|
-
FileUtils.mkdir_p(File.join(jruby_home, "lib"))
|
237
|
-
FileUtils.touch(File.join(jruby_home, "lib", "jruby.jar"))
|
238
|
-
end
|
239
|
-
after { FileUtils.rm_rf jruby_home }
|
240
|
-
|
241
|
-
it "should add jruby.jar to the bootclasspath" do
|
242
|
-
with_environment "JRUBY_HOME" => jruby_home do
|
243
|
-
jruby_launcher_args("").should include("-Xbootclasspath/a:#{jruby_home}/lib/jruby.jar")
|
244
|
-
end
|
245
|
-
end
|
246
|
-
end
|
247
|
-
|
248
|
-
it "should place user-supplied options after default options" do
|
249
|
-
args = jruby_launcher_args("-J-Djruby.home=/tmp")
|
250
|
-
home_args = args.select {|x| x =~ /^-Djruby\.home/ }
|
251
|
-
home_args.length.should == 2
|
252
|
-
home_args.last.should == "-Djruby.home=/tmp"
|
253
|
-
end
|
254
|
-
|
255
|
-
it "should print the version" do
|
256
|
-
jruby_launcher("-Xversion 2>&1").should =~ /Launcher Version #{JRubyLauncher::VERSION}/
|
257
|
-
end
|
258
|
-
end
|
@@ -1,81 +0,0 @@
|
|
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 = RbConfig::CONFIG['target_os'] =~ /mswin/
|
13
|
-
|
14
|
-
def self.check_executable_built
|
15
|
-
exe = File.expand_path("../../jruby", __FILE__) + RbConfig::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 classpath_arg(args)
|
49
|
-
index = args.index("-cp")
|
50
|
-
index.should > 0
|
51
|
-
args[index + 1]
|
52
|
-
end
|
53
|
-
|
54
|
-
def with_environment(pairs = {})
|
55
|
-
prev_env = {}
|
56
|
-
pairs.each_pair do |k,v|
|
57
|
-
prev_env[k] = ENV[k] if ENV.has_key?(k)
|
58
|
-
ENV[k] = v
|
59
|
-
end
|
60
|
-
begin
|
61
|
-
yield
|
62
|
-
ensure
|
63
|
-
pairs.keys.each {|k| ENV.delete(k)}
|
64
|
-
ENV.update(prev_env)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
RSpec.configure do |config|
|
70
|
-
config.before(:all) do
|
71
|
-
JRubyLauncherHelper.check_executable_built
|
72
|
-
# clear environment for better control
|
73
|
-
ENV.delete("JAVA_HOME")
|
74
|
-
ENV.delete("JRUBY_HOME")
|
75
|
-
ENV.delete("JAVA_OPTS")
|
76
|
-
ENV.delete("JRUBY_OPTS")
|
77
|
-
ENV.delete("CLASSPATH")
|
78
|
-
ENV.delete("JAVA_ENCODING")
|
79
|
-
end
|
80
|
-
config.include(JRubyLauncherHelper)
|
81
|
-
end
|