|
1 | 1 | /*
|
2 |
| - * |
| 2 | + * |
3 | 3 | * Copyright 2002-2004 The Ant-Contrib project
|
4 | 4 | *
|
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License");
|
|
35 | 35 | /**
|
36 | 36 | * An abstract Compiler implementation which uses an external program to
|
37 | 37 | * perform the compile.
|
38 |
| - * |
| 38 | + * |
39 | 39 | * @author Adam Murdoch
|
40 | 40 | */
|
41 | 41 | public abstract class CommandLineCompiler extends AbstractCompiler {
|
@@ -68,11 +68,11 @@ abstract protected void addImpliedArgs(Vector args, boolean debug,
|
68 | 68 | Boolean rtti, OptimizationEnum optimization);
|
69 | 69 | /**
|
70 | 70 | * Adds command-line arguments for include directories.
|
71 |
| - * |
| 71 | + * |
72 | 72 | * If relativeArgs is not null will add corresponding relative paths
|
73 | 73 | * include switches to that vector (for use in building a configuration
|
74 | 74 | * identifier that is consistent between machines).
|
75 |
| - * |
| 75 | + * |
76 | 76 | * @param baseDirPath Base directory path.
|
77 | 77 | * @param includeDirs
|
78 | 78 | * Array of include directory paths
|
@@ -128,7 +128,7 @@ protected void buildDefineArguments(CompilerDef[] defs, Vector args) {
|
128 | 128 | }
|
129 | 129 | /**
|
130 | 130 | * Compiles a source file.
|
131 |
| - * |
| 131 | + * |
132 | 132 | */
|
133 | 133 | public void compile(CCTask task, File outputDir, String[] sourceFiles,
|
134 | 134 | String[] args, String[] endArgs, boolean relentless,
|
@@ -232,8 +232,8 @@ public void compile(CCTask task, File outputDir, String[] sourceFiles,
|
232 | 232 | }
|
233 | 233 | }
|
234 | 234 | protected CompilerConfiguration createConfiguration(final CCTask task,
|
235 |
| - final LinkType linkType, |
236 |
| - final ProcessorDef[] baseDefs, |
| 235 | + final LinkType linkType, |
| 236 | + final ProcessorDef[] baseDefs, |
237 | 237 | final CompilerDef specificDef,
|
238 | 238 | final TargetDef targetPlatform,
|
239 | 239 | final VersionInfo versionInfo) {
|
@@ -405,7 +405,7 @@ protected final boolean getLibtool() {
|
405 | 405 | }
|
406 | 406 | /**
|
407 | 407 | * Obtains the same compiler, but with libtool set
|
408 |
| - * |
| 408 | + * |
409 | 409 | * Default behavior is to ignore libtool
|
410 | 410 | */
|
411 | 411 | public final CommandLineCompiler getLibtoolCompiler() {
|
@@ -434,4 +434,54 @@ protected int runCommand(CCTask task, File workingDir, String[] cmdline)
|
434 | 434 | protected final void setCommand(String command) {
|
435 | 435 | this.command = command;
|
436 | 436 | }
|
| 437 | + |
| 438 | + /** |
| 439 | + * Build an make file buffer |
| 440 | + * |
| 441 | + */ |
| 442 | + protected String genMakefileBuffer(CCTask task, File outputDir, String[] sourceFiles, |
| 443 | + String[] args, String[] endArgs, boolean relentless, |
| 444 | + CommandLineCompilerConfiguration config, ProgressMonitor monitor) |
| 445 | + throws BuildException { |
| 446 | + String command = getCommand(); |
| 447 | + |
| 448 | + StringBuffer sb_opt_args = new StringBuffer(); |
| 449 | + sb_opt_args.append("OPT_ARGS := \\").append(System.getProperty("line.separator")); |
| 450 | + for (int j = 0; j < args.length; j++) { |
| 451 | + sb_opt_args.append("\t").append(args[j]).append("\\").append(System.getProperty("line.separator")); |
| 452 | + } |
| 453 | + sb_opt_args.append(System.getProperty("line.separator")); |
| 454 | + |
| 455 | + StringBuffer sb_opt_end_args = new StringBuffer(); |
| 456 | + sb_opt_end_args.append("OPT_END_ARGS := \\").append(System.getProperty("line.separator")); |
| 457 | + for (int j = 0; j < endArgs.length; j++) { |
| 458 | + sb_opt_end_args.append("\t").append(endArgs[j]).append("\\").append(System.getProperty("line.separator")); |
| 459 | + } |
| 460 | + sb_opt_end_args.append(System.getProperty("line.separator")); |
| 461 | + |
| 462 | + StringBuffer sb_src = new StringBuffer(); |
| 463 | + sb_src.append("SOURCES := \\").append(System.getProperty("line.separator")); |
| 464 | + for (int sourceIndex = 0; sourceIndex < sourceFiles.length; sourceIndex++) { |
| 465 | + String[] output = getOutputFileNames(sourceFiles[sourceIndex], null); |
| 466 | + |
| 467 | + if (output.length == 0) continue; |
| 468 | + |
| 469 | + sb_src.append(output[0]).append(":").append(sourceFiles[sourceIndex]) |
| 470 | + .append(System.getProperty("line.separator")) |
| 471 | + .append("\t") |
| 472 | + .append(libtool ? "libtool " : "") |
| 473 | + .append(command).append(" ") |
| 474 | + .append("$(OPT_ARGS) ") |
| 475 | + .append("-o $@ $< ") |
| 476 | + .append("$(OPT_END_ARGS)") |
| 477 | + .append(System.getProperty("line.separator")); |
| 478 | + } |
| 479 | + sb_src.append(System.getProperty("line.separator")); |
| 480 | + |
| 481 | + return new StringBuffer() |
| 482 | + .append(sb_opt_args).append(System.getProperty("line.separator")) |
| 483 | + .append(sb_opt_end_args).append(System.getProperty("line.separator")) |
| 484 | + .append(sb_src).append(System.getProperty("line.separator")) |
| 485 | + .toString(); |
| 486 | + } |
437 | 487 | }
|
0 commit comments