mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 09:25:31 +02:00
Bug 515990 - Fix constant reindexing in CMake projects
There were issues with how the Core Build calculated whether reindexing was required due to compiler settings changes. Also if a source file was built more than once in a CMake build, it ended up always triggering a reindexing since the second instance looked like a settings change. We now only use the last compile command for a file. Change-Id: Icf2922e527ae20e0c3b0dae898d981d334013109
This commit is contained in:
parent
db6790d824
commit
582a7c10d5
3 changed files with 23 additions and 3 deletions
|
@ -15,6 +15,7 @@ import java.nio.file.Path;
|
|||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -231,7 +232,11 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
|
|||
try (FileReader reader = new FileReader(commandsFile.toFile())) {
|
||||
Gson gson = new Gson();
|
||||
CompileCommand[] commands = gson.fromJson(reader, CompileCommand[].class);
|
||||
Map<String, CompileCommand> dedupedCmds = new HashMap<>();
|
||||
for (CompileCommand command : commands) {
|
||||
dedupedCmds.put(command.getFile(), command);
|
||||
}
|
||||
for (CompileCommand command : dedupedCmds.values()) {
|
||||
processLine(command.getCommand());
|
||||
}
|
||||
shutdown();
|
||||
|
|
|
@ -633,15 +633,18 @@ public abstract class CBuildConfiguration extends PlatformObject
|
|||
for (IResource resource : resources) {
|
||||
loadScannerInfoCache();
|
||||
if (scannerInfoCache.hasCommand(commandStrings)) {
|
||||
scannerInfoCache.addResource(commandStrings, resource);
|
||||
if (!scannerInfoCache.hasResource(commandStrings, resource)) {
|
||||
scannerInfoCache.addResource(commandStrings, resource);
|
||||
infoChanged = true;
|
||||
}
|
||||
} else {
|
||||
Path commandPath = findCommand(command.get(0));
|
||||
command.set(0, commandPath.toString());
|
||||
IExtendedScannerInfo info = getToolChain().getScannerInfo(getBuildConfiguration(),
|
||||
command, null, resource, getBuildDirectoryURI());
|
||||
scannerInfoCache.addScannerInfo(commandStrings, info, resource);
|
||||
infoChanged = true;
|
||||
}
|
||||
infoChanged = true;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
|
|
|
@ -77,7 +77,7 @@ public class ScannerInfoCache {
|
|||
oldCommand.resourcePaths.remove(resourcePath);
|
||||
if (oldCommand.resourcePaths.isEmpty()) {
|
||||
// unused, remove
|
||||
commandMap.remove(commandStrings);
|
||||
commandMap.remove(oldCommand.command);
|
||||
commands.remove(oldCommand);
|
||||
resourceMap.remove(resourcePath);
|
||||
}
|
||||
|
@ -101,6 +101,18 @@ public class ScannerInfoCache {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 6.3
|
||||
*/
|
||||
public boolean hasResource(List<String> commandStrings, IResource resource) {
|
||||
String resourcePath = resource.getLocation().toOSString();
|
||||
Command command = commandMap.get(commandStrings);
|
||||
if (command == null) {
|
||||
return false;
|
||||
}
|
||||
return command.resourcePaths.contains(resourcePath);
|
||||
}
|
||||
|
||||
public void addResource(List<String> commandStrings, IResource resource) {
|
||||
String resourcePath = resource.getLocation().toOSString();
|
||||
Command command = commandMap.get(commandStrings);
|
||||
|
|
Loading…
Add table
Reference in a new issue