Skip to content

Commit

Permalink
Deprecate CMakePropertiesController
Browse files Browse the repository at this point in the history
CMakePropertiesController was only used to create a new
CMakeProperties.  The load() method loads a YAML file
.settings/CDT-cmake.yaml which never existed, because the save()
method was never called.  There was no separate YAML file for Run and
Debug.

CMake properties are stored in the project preferences by the launch
config UI and these properties are used to construct the cmake command
line.
  • Loading branch information
ewaterlander committed Jun 7, 2024
1 parent d53715c commit 712f819
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
import org.eclipse.cdt.cmake.core.ICMakeToolChainManager;
import org.eclipse.cdt.cmake.core.ParsingConsoleOutputStream;
import org.eclipse.cdt.cmake.core.internal.CommandDescriptorBuilder.CommandDescriptor;
import org.eclipse.cdt.cmake.core.internal.properties.CMakePropertiesBean;
import org.eclipse.cdt.cmake.core.properties.CMakeGenerator;
import org.eclipse.cdt.cmake.core.properties.ICMakeProperties;
import org.eclipse.cdt.cmake.core.properties.ICMakePropertiesController;
import org.eclipse.cdt.cmake.core.properties.IOsOverrides;
import org.eclipse.cdt.core.CommandLauncherManager;
import org.eclipse.cdt.core.ConsoleOutputStream;
Expand Down Expand Up @@ -84,9 +84,6 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {

private ICMakeToolChainFile toolChainFile;

// lazily instantiated..
private CMakePropertiesController pc;

private Map<IResource, IScannerInfo> infoPerResource;
/**
* whether one of the CMakeLists.txt files in the project has been modified and saved by the
Expand Down Expand Up @@ -158,7 +155,7 @@ public IProject[] build(int kind, Map<String, String> args, IConsole console, IP
runCMake = true;
}

ICMakeProperties cmakeProperties = getPropertiesController().load();
ICMakeProperties cmakeProperties = new CMakePropertiesBean();
runCMake |= !Files.exists(buildDir.resolve("CMakeCache.txt")); //$NON-NLS-1$

final SimpleOsOverridesSelector overridesSelector = new SimpleOsOverridesSelector();
Expand Down Expand Up @@ -292,7 +289,7 @@ public void clean(IConsole console, IProgressMonitor monitor) throws CoreExcepti

project.deleteMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE);

ICMakeProperties cmakeProperties = getPropertiesController().load();
ICMakeProperties cmakeProperties = new CMakePropertiesBean();
CommandDescriptorBuilder cmdBuilder = new CommandDescriptorBuilder(cmakeProperties,
new SimpleOsOverridesSelector());
CommandDescriptor command = cmdBuilder.makeCMakeBuildCommandline(getCleanCommand());
Expand Down Expand Up @@ -375,27 +372,10 @@ public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOEx
}
}

/** Lazily creates the CMakePropertiesController for the project.
*/
private CMakePropertiesController getPropertiesController() {
if (pc == null) {
final Path filePath = Path.of(getProject().getFile(".settings/CDT-cmake.yaml").getLocationURI()); //$NON-NLS-1$
pc = new CMakePropertiesController(filePath, () -> {
deleteCMakeCache = true;
// TODO delete cache file here for the case a user restarts the workbench
// prior to running a new build
});
}
return pc;
}

// interface IAdaptable
@Override
@SuppressWarnings("unchecked")
public <T> T getAdapter(Class<T> adapter) {
if (ICMakePropertiesController.class.equals(adapter)) {
return (T) pc;
}
return super.getAdapter(adapter);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
* us to delete file CMakeCache.txt to avoid complaints by cmake.
* @author Martin Weber
*/
@Deprecated
class CMakePropertiesController implements ICMakePropertiesController {

private final Path storageFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ CommandDescriptor makeCMakeCommandline(Path toolChainFile) throws CoreException
args.add(file);
}
}
CommandDescriptorBuilder.appendCMakeArguments(args, cmakeProperties.getExtraArguments());

/* at last, add our requirements that override extra args specified by the user... */
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* @author Martin Weber
* @since 1.4
*/
@Deprecated
public interface ICMakePropertiesController {

/** Creates a new {@code ICMakeProperties} object, initialized from the persistence store.
Expand Down

0 comments on commit 712f819

Please sign in to comment.