Lines 417-430
Link Here
|
417 |
/** |
417 |
/** |
418 |
* Do the compile with the specified arguments. |
418 |
* Do the compile with the specified arguments. |
419 |
* @param args - arguments to pass to process on command line |
419 |
* @param args - arguments to pass to process on command line |
420 |
* @param firstFileName - index of the first source file in args, |
420 |
* @param separableArgIndex - index of the first source file in args, |
421 |
* if the index is negative, no temporary file will ever be |
421 |
* if the index is negative, no temporary file will ever be |
422 |
* created, but this may hit the command line length limit on your |
422 |
* created, but this may hit the command line length limit on your |
423 |
* system. |
423 |
* system. |
424 |
* @return the exit code of the compilation |
424 |
* @return the exit code of the compilation |
425 |
*/ |
425 |
*/ |
426 |
protected int executeExternalCompile(String[] args, int firstFileName) { |
426 |
protected int executeExternalCompile(String[] args, int separableArgIndex) { |
427 |
return executeExternalCompile(args, firstFileName, true); |
427 |
return executeExternalCompile(args, separableArgIndex, true); |
428 |
} |
428 |
} |
429 |
|
429 |
|
430 |
/** |
430 |
/** |
Lines 434-443
Link Here
|
434 |
* project's base directory.</p> |
434 |
* project's base directory.</p> |
435 |
* |
435 |
* |
436 |
* @param args - arguments to pass to process on command line |
436 |
* @param args - arguments to pass to process on command line |
437 |
* @param firstFileName - index of the first source file in args, |
437 |
* @param separableArgIndex - index of the first argument which could be |
438 |
* if the index is negative, no temporary file will ever be |
438 |
* placed in a separate file, if the total command line size exceeds some |
439 |
* created, but this may hit the command line length limit on your |
439 |
* platform-dependent threshold (typically 4Kb). This and subsequent |
440 |
* system. |
440 |
* arguments will be replaced with {@code @that-file-location}. May be |
|
|
441 |
* {@code -1} to suppress this feature entirely. Use {@code 0} to replace |
442 |
* all arguments, which is suitable for all modern compilers. Some very old |
443 |
* compilers require this to be the index of the first actual source file, |
444 |
* in case compiler options cannot be included. |
441 |
* @param quoteFiles - if set to true, filenames containing |
445 |
* @param quoteFiles - if set to true, filenames containing |
442 |
* spaces will be quoted when they appear in the external file. |
446 |
* spaces will be quoted when they appear in the external file. |
443 |
* This is necessary when running JDK 1.4's javac and probably |
447 |
* This is necessary when running JDK 1.4's javac and probably |
Lines 446-452
Link Here
|
446 |
* |
450 |
* |
447 |
* @since Ant 1.6 |
451 |
* @since Ant 1.6 |
448 |
*/ |
452 |
*/ |
449 |
protected int executeExternalCompile(String[] args, int firstFileName, |
453 |
protected int executeExternalCompile(String[] args, int separableArgIndex, |
450 |
boolean quoteFiles) { |
454 |
boolean quoteFiles) { |
451 |
String[] commandArray = null; |
455 |
String[] commandArray = null; |
452 |
File tmpFile = null; |
456 |
File tmpFile = null; |
Lines 460-472
Link Here
|
460 |
* file if the total length of the command line exceeds this limit. |
464 |
* file if the total length of the command line exceeds this limit. |
461 |
*/ |
465 |
*/ |
462 |
if (Commandline.toString(args).length() > COMMAND_LINE_LIMIT |
466 |
if (Commandline.toString(args).length() > COMMAND_LINE_LIMIT |
463 |
&& firstFileName >= 0) { |
467 |
&& separableArgIndex >= 0) { |
464 |
BufferedWriter out = null; |
468 |
BufferedWriter out = null; |
465 |
try { |
469 |
try { |
466 |
tmpFile = FILE_UTILS.createTempFile( |
470 |
tmpFile = FILE_UTILS.createTempFile( |
467 |
"files", "", getJavac().getTempdir(), true, true); |
471 |
"files", "", getJavac().getTempdir(), true, true); |
468 |
out = new BufferedWriter(new FileWriter(tmpFile)); |
472 |
out = new BufferedWriter(new FileWriter(tmpFile)); |
469 |
for (int i = firstFileName; i < args.length; i++) { |
473 |
for (int i = separableArgIndex; i < args.length; i++) { |
470 |
if (quoteFiles && args[i].indexOf(" ") > -1) { |
474 |
if (quoteFiles && args[i].indexOf(" ") > -1) { |
471 |
args[i] = args[i].replace(File.separatorChar, '/'); |
475 |
args[i] = args[i].replace(File.separatorChar, '/'); |
472 |
out.write("\"" + args[i] + "\""); |
476 |
out.write("\"" + args[i] + "\""); |
Lines 476-484
Link Here
|
476 |
out.newLine(); |
480 |
out.newLine(); |
477 |
} |
481 |
} |
478 |
out.flush(); |
482 |
out.flush(); |
479 |
commandArray = new String[firstFileName + 1]; |
483 |
commandArray = new String[separableArgIndex + 1]; |
480 |
System.arraycopy(args, 0, commandArray, 0, firstFileName); |
484 |
System.arraycopy(args, 0, commandArray, 0, separableArgIndex); |
481 |
commandArray[firstFileName] = "@" + tmpFile; |
485 |
commandArray[separableArgIndex] = "@" + tmpFile; |
482 |
} catch (IOException e) { |
486 |
} catch (IOException e) { |
483 |
throw new BuildException("Error creating temporary file", |
487 |
throw new BuildException("Error creating temporary file", |
484 |
e, location); |
488 |
e, location); |