mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
external build manager: recalculating cached path variables after their change
This commit is contained in:
@@ -29,7 +29,10 @@ import com.intellij.execution.process.*;
|
||||
import com.intellij.execution.ui.RunContentDescriptor;
|
||||
import com.intellij.ide.PowerSaveMode;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.*;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.compiler.CompileContext;
|
||||
import com.intellij.openapi.components.ApplicationComponent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -212,6 +215,7 @@ public class BuildManager implements ApplicationComponent{
|
||||
private final BuildMessageDispatcher myMessageDispatcher = new BuildMessageDispatcher();
|
||||
private volatile int myListenPort = -1;
|
||||
private volatile CmdlineRemoteProto.Message.ControllerMessage.GlobalSettings myGlobals;
|
||||
private int myGlobalsStamp = -1;
|
||||
@Nullable
|
||||
private final Charset mySystemCharset;
|
||||
|
||||
@@ -534,11 +538,7 @@ public class BuildManager implements ApplicationComponent{
|
||||
return;
|
||||
}
|
||||
|
||||
CmdlineRemoteProto.Message.ControllerMessage.GlobalSettings globals = myGlobals;
|
||||
if (globals == null) {
|
||||
globals = buildGlobalSettings();
|
||||
myGlobals = globals;
|
||||
}
|
||||
final CmdlineRemoteProto.Message.ControllerMessage.GlobalSettings globals = buildGlobalSettings();
|
||||
CmdlineRemoteProto.Message.ControllerMessage.FSEvent currentFSChanges;
|
||||
final SequentialTaskExecutor projectTaskQueue;
|
||||
synchronized (myProjectDataMap) {
|
||||
@@ -687,14 +687,22 @@ public class BuildManager implements ApplicationComponent{
|
||||
return "com.intellij.compiler.server.BuildManager";
|
||||
}
|
||||
|
||||
private static CmdlineRemoteProto.Message.ControllerMessage.GlobalSettings buildGlobalSettings() {
|
||||
private CmdlineRemoteProto.Message.ControllerMessage.GlobalSettings buildGlobalSettings() {
|
||||
final PathMacrosImpl pathVars = PathMacrosImpl.getInstanceEx();
|
||||
|
||||
final CmdlineRemoteProto.Message.ControllerMessage.GlobalSettings cached = myGlobals;
|
||||
if (cached != null && myGlobalsStamp == pathVars.getModificationStamp()) {
|
||||
return cached;
|
||||
}
|
||||
myGlobals = null; // ensure the cache is cleared and stamp is current
|
||||
myGlobalsStamp = pathVars.getModificationStamp();
|
||||
|
||||
final Map<String, String> data = new HashMap<String, String>();
|
||||
|
||||
for (Map.Entry<String, String> entry : PathMacrosImpl.getGlobalSystemMacros().entrySet()) {
|
||||
data.put(entry.getKey(), FileUtil.toSystemIndependentName(entry.getValue()));
|
||||
}
|
||||
|
||||
final PathMacros pathVars = PathMacros.getInstance();
|
||||
for (String name : pathVars.getAllMacroNames()) {
|
||||
final String path = pathVars.getValue(name);
|
||||
if (path != null) {
|
||||
@@ -717,7 +725,7 @@ public class BuildManager implements ApplicationComponent{
|
||||
}
|
||||
}
|
||||
|
||||
return cmdBuilder.build();
|
||||
return myGlobals = cmdBuilder.build();
|
||||
}
|
||||
|
||||
private OSProcessHandler launchBuildProcess(Project project, final int port, final UUID sessionId) throws ExecutionException {
|
||||
|
||||
@@ -46,6 +46,7 @@ public class PathMacrosImpl extends PathMacros implements ApplicationComponent,
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.application.options.PathMacrosImpl");
|
||||
private final Map<String, String> myLegacyMacros = new HashMap<String, String>();
|
||||
private final Map<String, String> myMacros = new HashMap<String, String>();
|
||||
private int myModificationStamp = 0;
|
||||
private final ReentrantReadWriteLock myLock = new ReentrantReadWriteLock();
|
||||
private final List<String> myIgnoredMacros = ContainerUtil.createLockFreeCopyOnWriteList();
|
||||
|
||||
@@ -196,6 +197,16 @@ public class PathMacrosImpl extends PathMacros implements ApplicationComponent,
|
||||
if (!myIgnoredMacros.contains(name)) myIgnoredMacros.add(name);
|
||||
}
|
||||
|
||||
public int getModificationStamp() {
|
||||
myLock.readLock().lock();
|
||||
try {
|
||||
return myModificationStamp;
|
||||
}
|
||||
finally {
|
||||
myLock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, String> getGlobalSystemMacros() {
|
||||
final Map<String, String> map = new HashMap<String, String>();
|
||||
map.put(APPLICATION_HOME_MACRO_NAME, PathManager.getHomePath());
|
||||
@@ -236,6 +247,7 @@ public class PathMacrosImpl extends PathMacros implements ApplicationComponent,
|
||||
myMacros.clear();
|
||||
}
|
||||
finally {
|
||||
myModificationStamp++;
|
||||
myLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
@@ -259,6 +271,7 @@ public class PathMacrosImpl extends PathMacros implements ApplicationComponent,
|
||||
myMacros.put(name, value);
|
||||
}
|
||||
finally {
|
||||
myModificationStamp++;
|
||||
myLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
@@ -271,6 +284,7 @@ public class PathMacrosImpl extends PathMacros implements ApplicationComponent,
|
||||
myMacros.remove(name);
|
||||
}
|
||||
finally {
|
||||
myModificationStamp++;
|
||||
myLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
@@ -283,6 +297,7 @@ public class PathMacrosImpl extends PathMacros implements ApplicationComponent,
|
||||
LOG.assertTrue(value != null);
|
||||
}
|
||||
finally {
|
||||
myModificationStamp++;
|
||||
myLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
@@ -322,6 +337,7 @@ public class PathMacrosImpl extends PathMacros implements ApplicationComponent,
|
||||
}
|
||||
}
|
||||
finally {
|
||||
myModificationStamp++;
|
||||
myLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user