1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 14:12:10 +02:00

Bug 434275 - Autotools configuration in subfolder not found

- add getProjectLocation() method
- fix getSourcePath() method to find the srcDir resource and then
  get its location
- fix all references in code to use getProjectLocation() and
  getSourcePath() where appropriate

Change-Id: I7d6d401a42213dbe9c4c2dee03aca306a4941683
Reviewed-on: https://git.eclipse.org/r/30466
Tested-by: Hudson CI
Reviewed-by: Jeff Johnston <jjohnstn@redhat.com>
Tested-by: Jeff Johnston <jjohnstn@redhat.com>
This commit is contained in:
Jeff Johnston 2014-07-24 17:26:47 -04:00
parent 86864c02fe
commit 49d1763a80

View file

@ -18,7 +18,6 @@ import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URI; import java.net.URI;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -145,7 +144,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
IPath buildDirectory = b.getBuildLocation(); IPath buildDirectory = b.getBuildLocation();
if (buildDirectory == null || buildDirectory.isEmpty()) { if (buildDirectory == null || buildDirectory.isEmpty()) {
// default build directory to project directory // default build directory to project directory
buildDirectory = project.getLocation(); buildDirectory = getProjectLocation();
} }
buildLocation = buildDirectory; buildLocation = buildDirectory;
buildDir = buildDirectory.toString(); buildDir = buildDirectory.toString();
@ -243,7 +242,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
IPath path = new Path(dirName); IPath path = new Path(dirName);
boolean rc = true; boolean rc = true;
if (dirName.length() == 0 || dirName.equals(".")) if (dirName.length() == 0 || dirName.equals("."))
path = project.getLocation().append(dirName); path = getProjectLocation().append(dirName);
File f = path.toFile(); File f = path.toFile();
if (!f.exists()) { if (!f.exists()) {
rc = f.mkdirs(); rc = f.mkdirs();
@ -387,9 +386,9 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
// to // to
// regenerate the makefile // regenerate the makefile
IPath configfile = buildLocation.append(CONFIG_STATUS); IPath configfile = buildLocation.append(CONFIG_STATUS);
IPath topConfigFile = project.getLocation().append(CONFIG_STATUS); IPath topConfigFile = getProjectLocation().append(CONFIG_STATUS);
IPath makefilePath = buildLocation.append(MAKEFILE); IPath makefilePath = buildLocation.append(MAKEFILE);
IPath topMakefilePath = project.getLocation().append(MAKEFILE); IPath topMakefilePath = getProjectLocation().append(MAKEFILE);
File configStatus = configfile.toFile(); File configStatus = configfile.toFile();
File topConfigStatus = topConfigFile.toFile(); File topConfigStatus = topConfigFile.toFile();
File makefile = makefilePath.toFile(); File makefile = makefilePath.toFile();
@ -419,7 +418,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
} }
makeargs[makeargs.length - 1] = target; makeargs[makeargs.length - 1] = target;
rc = runCommand(makeCmd, rc = runCommand(makeCmd,
project.getLocation(), getProjectLocation(),
makeargs, makeargs,
AutotoolsPlugin.getResourceString("MakeGenerator.clean.topdir"), //$NON-NLS-1$ AutotoolsPlugin.getResourceString("MakeGenerator.clean.topdir"), //$NON-NLS-1$
errMsg, console, consoleStart); errMsg, console, consoleStart);
@ -551,7 +550,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
IPath reconfCmdPath = new Path(reconfCmd); IPath reconfCmdPath = new Path(reconfCmd);
reconfArgs[0] = "-i"; //$NON-NLS-1$ reconfArgs[0] = "-i"; //$NON-NLS-1$
rc = runScript(reconfCmdPath, rc = runScript(reconfCmdPath,
project.getLocation().append(srcDir), getSourcePath(),
reconfArgs, reconfArgs,
AutotoolsPlugin.getFormattedString("MakeGenerator.autoreconf", new String[]{buildDir}), //$NON-NLS-1$ AutotoolsPlugin.getFormattedString("MakeGenerator.autoreconf", new String[]{buildDir}), //$NON-NLS-1$
errMsg, console, null, consoleStart); errMsg, console, null, consoleStart);
@ -584,13 +583,13 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
IPath makeCmd = builder.getBuildCommand(); IPath makeCmd = builder.getBuildCommand();
makeargs[0] = "-f" + getMakefileCVSPath().toOSString(); //$NON-NLS-1$ makeargs[0] = "-f" + getMakefileCVSPath().toOSString(); //$NON-NLS-1$
rc = runCommand(makeCmd, rc = runCommand(makeCmd,
project.getLocation().append(buildDir), getProjectLocation().append(buildDir),
makeargs, makeargs,
AutotoolsPlugin.getFormattedString("MakeGenerator.makefile.cvs", new String[]{buildDir}), //$NON-NLS-1$ AutotoolsPlugin.getFormattedString("MakeGenerator.makefile.cvs", new String[]{buildDir}), //$NON-NLS-1$
errMsg, console, consoleStart); errMsg, console, consoleStart);
consoleStart = false; consoleStart = false;
if (rc != IStatus.ERROR) { if (rc != IStatus.ERROR) {
File makefileFile = project.getLocation().append(buildDir) File makefileFile = getProjectLocation().append(buildDir)
.append(MAKEFILE).toFile(); .append(MAKEFILE).toFile();
addMakeTargetsToManager(makefileFile); addMakeTargetsToManager(makefileFile);
toolsCfg.setDirty(false); toolsCfg.setDirty(false);
@ -605,7 +604,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
IPath reconfCmdPath = new Path(reconfCmd); IPath reconfCmdPath = new Path(reconfCmd);
reconfArgs[0] = "-i"; //$NON-NLS-1$ reconfArgs[0] = "-i"; //$NON-NLS-1$
rc = runScript(reconfCmdPath, rc = runScript(reconfCmdPath,
project.getLocation().append(srcDir), getSourcePath(),
reconfArgs, reconfArgs,
AutotoolsPlugin.getFormattedString("MakeGenerator.autoreconf", new String[]{buildDir}), //$NON-NLS-1$ AutotoolsPlugin.getFormattedString("MakeGenerator.autoreconf", new String[]{buildDir}), //$NON-NLS-1$
errMsg, console, null, consoleStart); errMsg, console, null, consoleStart);
@ -754,6 +753,10 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
return str; return str;
} }
private IPath getProjectLocation() {
return project.getLocation();
}
private IPath getBuildPath(){ private IPath getBuildPath(){
return new Path(this.buildDir); return new Path(this.buildDir);
} }
@ -761,9 +764,14 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
private IPath getSourcePath(){ private IPath getSourcePath(){
IPath sourcePath; IPath sourcePath;
if (srcDir.equals("")) if (srcDir.equals(""))
sourcePath = project.getLocation(); sourcePath = getProjectLocation();
else else { // find location of source directory which may be a virtual folder
sourcePath = project.getLocation().append(srcDir); IResource sourceResource = project.findMember(srcDir);
if (sourceResource.exists() && sourceResource.getType() == IResource.FOLDER)
sourcePath = sourceResource.getLocation();
else // punt and let configure fail if directory is not found by then
sourcePath = getProjectLocation().append(srcDir);
}
return sourcePath; return sourcePath;
} }
@ -783,22 +791,14 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
if (Path.fromOSString(command).isAbsolute()) { if (Path.fromOSString(command).isAbsolute()) {
configPath = new Path(command); configPath = new Path(command);
} else { } else {
if (srcDir.equals("")) configPath = getSourcePath().append(command);
configPath = project.getLocation().append(command);
else
configPath = project.getLocation().append(srcDir)
.append(command);
} }
return configPath; return configPath;
} }
protected IPath getMakefileCVSPath() { protected IPath getMakefileCVSPath() {
IPath makefileCVSPath; IPath makefileCVSPath;
if (srcDir.equals("")) makefileCVSPath = getSourcePath().append(MAKEFILE_CVS);
makefileCVSPath = project.getLocation().append(MAKEFILE_CVS);
else
makefileCVSPath= project.getLocation().append(srcDir).append(
MAKEFILE_CVS);
return makefileCVSPath; return makefileCVSPath;
} }
@ -821,10 +821,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
cmdParms.add(tokens[i]); cmdParms.add(tokens[i]);
} }
if (srcDir.equals("")) autogenPath = getSourcePath().append(command);
autogenPath = project.getLocation().append(command);
else
autogenPath = project.getLocation().append(srcDir).append(command);
return autogenPath; return autogenPath;
} }