1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-08 08:45:44 +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.io.InputStreamReader;
import java.net.URI; import java.net.URI;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
@ -255,12 +256,12 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
addDiscoveryOptions(commandLine); addDiscoveryOptions(commandLine);
commandLine.addAll(commandStrings.subList(1, commandStrings.size())); 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())) { if (Platform.OS_WIN32.equals(Platform.getOS())) {
for (int i = 0; i < commandLine.size(); i++) { for (int i = 0; i < commandLine.size(); i++) {
String arg = commandLine.get(i); String arg = commandLine.get(i);
if (arg.contains("\"")) { //$NON-NLS-1$ if (arg.startsWith("\"") && arg.endsWith("\"")) { //$NON-NLS-1$ //$NON-NLS-2$
commandLine.set(i, arg.replaceAll("\"", "")); //$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) { for (int i = 1; i < commandLine.size(); ++i) {
if (!commandLine.get(i).startsWith("-")) { //$NON-NLS-1$ if (!commandLine.get(i).startsWith("-")) { //$NON-NLS-1$
// TODO optimize by dealing with multi arg options like -o // 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()); IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(filePath.toUri());
if (files.length > 0 && files[0].exists()) { if (files.length > 0 && files[0].exists()) {
// replace it with a temp file // 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$ } else if (cCommand.contains("clang")) { //$NON-NLS-1$
cppCommand = cCommand.replace("clang", "clang++"); //$NON-NLS-1$ //$NON-NLS-2$ cppCommand = cCommand.replace("clang", "clang++"); //$NON-NLS-1$ //$NON-NLS-2$
commands = new String[] { cCommand, cppCommand }; 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 { } else {
commands = new String[] { cCommand }; commands = new String[] { cCommand };
} }

View file

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

View file

@ -417,7 +417,8 @@ public abstract class CBuildConfiguration extends PlatformObject
} }
protected Path findCommand(String command) { 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$ command += ".exe"; //$NON-NLS-1$
} }