1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 17:26:01 +02:00

Fix NPE in CMake clean when generator not selected.

Change-Id: Id019a84aaffd597374bc3347229a554acf8d5dce
This commit is contained in:
Doug Schaefer 2016-11-21 12:07:35 -05:00 committed by Gerrit Code Review @ Eclipse.org
parent b7739323be
commit cb14b447f8
3 changed files with 47 additions and 7 deletions

View file

@ -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));
}
}
}

View file

@ -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() {
}
}

View file

@ -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