1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 09:25:31 +02:00

Fix bugs with emscripten and scannerInfo.

Change-Id: I54d3691426a48c2a6f71fee4188364e57eea402d
This commit is contained in:
Doug Schaefer 2017-10-19 12:51:21 -04:00
parent 8a45638df7
commit 50756f3f18
3 changed files with 27 additions and 21 deletions

View file

@ -13,6 +13,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
@ -255,12 +256,12 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
addDiscoveryOptions(commandLine);
commandLine.addAll(commandStrings.subList(1, commandStrings.size()));
// Strip quotes from the args on Windows
// Strip surrounding quotes from the args on Windows
if (Platform.OS_WIN32.equals(Platform.getOS())) {
for (int i = 0; i < commandLine.size(); i++) {
String arg = commandLine.get(i);
if (arg.contains("\"")) { //$NON-NLS-1$
commandLine.set(i, arg.replaceAll("\"", "")); //$NON-NLS-1$ //$NON-NLS-2$
if (arg.startsWith("\"") && arg.endsWith("\"")) { //$NON-NLS-1$ //$NON-NLS-2$
commandLine.set(i, arg.substring(1, arg.length() - 1));
}
}
}
@ -284,7 +285,12 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
for (int i = 1; i < commandLine.size(); ++i) {
if (!commandLine.get(i).startsWith("-")) { //$NON-NLS-1$
// TODO optimize by dealing with multi arg options like -o
Path filePath = buildDirectory.resolve(commandLine.get(i));
Path filePath;
try {
filePath = buildDirectory.resolve(commandLine.get(i));
} catch (InvalidPathException e) {
continue;
}
IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(filePath.toUri());
if (files.length > 0 && files[0].exists()) {
// replace it with a temp file
@ -479,6 +485,10 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
} else if (cCommand.contains("clang")) { //$NON-NLS-1$
cppCommand = cCommand.replace("clang", "clang++"); //$NON-NLS-1$ //$NON-NLS-2$
commands = new String[] { cCommand, cppCommand };
} else if (cCommand.contains("emcc")) { //$NON-NLS-1$
// TODO Hack for emscripten. Can we generalize?
cppCommand = cCommand.replace("emcc", "em++"); //$NON-NLS-1$ //$NON-NLS-2$
commands = new String[] { cCommand, cppCommand };
} else {
commands = new String[] { cCommand };
}

View file

@ -61,12 +61,7 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
} else {
toolChainFile = manager.getToolChainFileFor(getToolChain());
if (toolChainFile != null) {
settings.put(TOOLCHAIN_FILE, toolChainFile.getPath().toString());
try {
settings.flush();
} catch (BackingStoreException e) {
Activator.log(e);
}
saveToolChainFile();
}
}
}
@ -78,20 +73,20 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
public CMakeBuildConfiguration(IBuildConfiguration config, String name, IToolChain toolChain,
ICMakeToolChainFile toolChainFile, String launchMode) {
super(config, name, toolChain, launchMode);
this.toolChainFile = toolChainFile;
saveToolChainFile();
this.toolChainFile = toolChainFile;
if (toolChainFile != null) {
saveToolChainFile();
}
}
private void saveToolChainFile() {
if (toolChainFile != null) {
Preferences settings = getSettings();
settings.put(TOOLCHAIN_FILE, toolChainFile.getPath().toString());
try {
settings.flush();
} catch (BackingStoreException e) {
Activator.log(e);
}
Preferences settings = getSettings();
settings.put(TOOLCHAIN_FILE, toolChainFile.getPath().toString());
try {
settings.flush();
} catch (BackingStoreException e) {
Activator.log(e);
}
}

View file

@ -417,7 +417,8 @@ public abstract class CBuildConfiguration extends PlatformObject
}
protected Path findCommand(String command) {
if (Platform.getOS().equals(Platform.OS_WIN32) && !command.endsWith(".exe")) { //$NON-NLS-1$
if (Platform.getOS().equals(Platform.OS_WIN32)
&& !(command.endsWith(".exe") || command.endsWith(".bat"))) { //$NON-NLS-1$ //$NON-NLS-2$
command += ".exe"; //$NON-NLS-1$
}