Skip to content

Commit

Permalink
Revert previous commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewaterlander committed Jun 11, 2024
1 parent 712f819 commit a9fc3ed
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 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,6 +84,9 @@ 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 @@ -155,7 +158,7 @@ public IProject[] build(int kind, Map<String, String> args, IConsole console, IP
runCMake = true;
}

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

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

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

ICMakeProperties cmakeProperties = new CMakePropertiesBean();
ICMakeProperties cmakeProperties = getPropertiesController().load();
CommandDescriptorBuilder cmdBuilder = new CommandDescriptorBuilder(cmakeProperties,
new SimpleOsOverridesSelector());
CommandDescriptor command = cmdBuilder.makeCMakeBuildCommandline(getCleanCommand());
Expand Down Expand Up @@ -372,10 +375,27 @@ 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,7 +41,6 @@
* 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,6 +77,7 @@ 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,7 +19,6 @@
* @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 a9fc3ed

Please sign in to comment.