diff options
author | Doug Schaefer | 2016-11-21 17:07:35 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2016-11-21 20:31:06 +0000 |
commit | 2e2431dd278a26d4a113f6c7e4875bf0b9a3a634 (patch) | |
tree | c3d8aadbb1b81f15924a68dbdbb419b2c7a62ae3 /build/org.eclipse.cdt.cmake.core | |
parent | 74e932af4f3d438e65fac70a2468213302342913 (diff) | |
download | org.eclipse.cdt-2e2431dd278a26d4a113f6c7e4875bf0b9a3a634.tar.gz org.eclipse.cdt-2e2431dd278a26d4a113f6c7e4875bf0b9a3a634.tar.xz org.eclipse.cdt-2e2431dd278a26d4a113f6c7e4875bf0b9a3a634.zip |
Fix NPE in CMake clean when generator not selected.
Change-Id: Id019a84aaffd597374bc3347229a554acf8d5dce
(cherry picked from commit cb14b447f82a5aea557008d2f63247ef638f8f8d)
Diffstat (limited to 'build/org.eclipse.cdt.cmake.core')
3 files changed, 47 insertions, 7 deletions
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 1b7fec99f3d..bfb56f58ca6 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 @@ -100,7 +100,7 @@ public class CMakeBuildConfiguration extends CBuildConfiguration { Path buildDir = getBuildDirectory(); - outStream.write(String.format("Building in: %s\n", buildDir.toString())); + outStream.write(String.format(Messages.CMakeBuildConfiguration_BuildingIn, buildDir.toString())); if (!Files.exists(buildDir.resolve("CMakeFiles"))) { //$NON-NLS-1$ List<String> command = new ArrayList<>(); @@ -168,7 +168,7 @@ public class CMakeBuildConfiguration extends CBuildConfiguration { return new IProject[] { project }; } catch (IOException e) { - throw new CoreException(Activator.errorStatus(String.format("Building %s", project.getName()), e)); + throw new CoreException(Activator.errorStatus(String.format(Messages.CMakeBuildConfiguration_Building, project.getName()), e)); } } @@ -186,13 +186,13 @@ public class CMakeBuildConfiguration extends CBuildConfiguration { Path buildDir = getBuildDirectory(); if (!Files.exists(buildDir.resolve("CMakeFiles"))) { //$NON-NLS-1$ - outStream.write("CMakeFiles not found. Assuming clean."); + outStream.write(Messages.CMakeBuildConfiguration_NotFound); return; } String cleanCommand = properties.get(CLEAN_COMMAND); if (cleanCommand == null) { - if (generator.equals("Ninja")) { //$NON-NLS-1$ + if (generator != null && generator.equals("Ninja")) { //$NON-NLS-1$ cleanCommand = "ninja clean"; //$NON-NLS-1$ } else { cleanCommand = "make clean"; //$NON-NLS-1$ @@ -212,7 +212,7 @@ public class CMakeBuildConfiguration extends CBuildConfiguration { project.refreshLocal(IResource.DEPTH_INFINITE, monitor); } catch (IOException e) { - throw new CoreException(Activator.errorStatus(String.format("Cleaning %s", project.getName()), e)); + throw new CoreException(Activator.errorStatus(String.format(Messages.CMakeBuildConfiguration_Cleaning, project.getName()), e)); } } @@ -220,7 +220,7 @@ public class CMakeBuildConfiguration extends CBuildConfiguration { IProject project = getProject(); Path commandsFile = getBuildDirectory().resolve("compile_commands.json"); //$NON-NLS-1$ if (Files.exists(commandsFile)) { - monitor.setTaskName("Processing compile_commands.json"); + monitor.setTaskName(Messages.CMakeBuildConfiguration_ProcCompJson); try (FileReader reader = new FileReader(commandsFile.toFile())) { Gson gson = new Gson(); CompileCommand[] commands = gson.fromJson(reader, CompileCommand[].class); @@ -230,7 +230,7 @@ public class CMakeBuildConfiguration extends CBuildConfiguration { shutdown(); } catch (IOException e) { throw new CoreException( - Activator.errorStatus(String.format("Processing compile commands %s", project.getName()), e)); + Activator.errorStatus(String.format(Messages.CMakeBuildConfiguration_ProcCompCmds, project.getName()), e)); } } } diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/Messages.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/Messages.java new file mode 100644 index 00000000000..e420dab906e --- /dev/null +++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/Messages.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2016 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.cmake.core.internal; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.cdt.cmake.core.internal.messages"; //$NON-NLS-1$ + public static String CMakeBuildConfiguration_Building; + public static String CMakeBuildConfiguration_BuildingIn; + public static String CMakeBuildConfiguration_Cleaning; + public static String CMakeBuildConfiguration_NotFound; + public static String CMakeBuildConfiguration_ProcCompCmds; + public static String CMakeBuildConfiguration_ProcCompJson; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/messages.properties b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/messages.properties new file mode 100644 index 00000000000..d4be3821762 --- /dev/null +++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/messages.properties @@ -0,0 +1,13 @@ +################################################################################ +# Copyright (c) 2016 QNX Software Systems and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +################################################################################ +CMakeBuildConfiguration_Building=Building %s +CMakeBuildConfiguration_BuildingIn=Building in: %s\n +CMakeBuildConfiguration_Cleaning=Cleaning %s +CMakeBuildConfiguration_NotFound=CMakeFiles not found. Assuming clean. +CMakeBuildConfiguration_ProcCompCmds=Processing compile commands %s +CMakeBuildConfiguration_ProcCompJson=Processing compile_commands.json |