diff --git a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java index 1425a4f0da8..86af92019d3 100644 --- a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java +++ b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java @@ -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 }; } diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java index 1308426d97d..14d9fae4f0b 100644 --- a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java +++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java @@ -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); } } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java index f9222e48b46..2c2e14cd68c 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java @@ -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$ }