use of org.jetbrains.jps.incremental.fs.BuildFSState in project intellij-community by JetBrains.
the class JpsBuildTestCase method createProjectDescriptor.
protected ProjectDescriptor createProjectDescriptor(final BuildLoggingManager buildLoggingManager) {
try {
BuildTargetRegistryImpl targetRegistry = new BuildTargetRegistryImpl(myModel);
ModuleExcludeIndex index = new ModuleExcludeIndexImpl(myModel);
IgnoredFileIndexImpl ignoredFileIndex = new IgnoredFileIndexImpl(myModel);
BuildDataPaths dataPaths = new BuildDataPathsImpl(myDataStorageRoot);
BuildRootIndexImpl buildRootIndex = new BuildRootIndexImpl(targetRegistry, myModel, index, dataPaths, ignoredFileIndex);
BuildTargetIndexImpl targetIndex = new BuildTargetIndexImpl(targetRegistry, buildRootIndex);
BuildTargetsState targetsState = new BuildTargetsState(dataPaths, myModel, buildRootIndex);
ProjectTimestamps timestamps = new ProjectTimestamps(myDataStorageRoot, targetsState);
BuildDataManager dataManager = new BuildDataManager(dataPaths, targetsState, true);
return new ProjectDescriptor(myModel, new BuildFSState(true), timestamps, dataManager, buildLoggingManager, index, targetsState, targetIndex, buildRootIndex, ignoredFileIndex);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of org.jetbrains.jps.incremental.fs.BuildFSState in project intellij-community by JetBrains.
the class Standalone method runBuild.
public static void runBuild(JpsModelLoader loader, File dataStorageRoot, MessageHandler messageHandler, List<TargetTypeBuildScope> scopes, boolean includeDependenciesToScope) throws Exception {
final BuildRunner buildRunner = new BuildRunner(loader);
ProjectDescriptor descriptor = buildRunner.load(messageHandler, dataStorageRoot, new BuildFSState(true));
try {
buildRunner.runBuild(descriptor, CanceledStatus.NULL, null, messageHandler, BuildType.BUILD, scopes, includeDependenciesToScope);
} finally {
descriptor.release();
}
}
use of org.jetbrains.jps.incremental.fs.BuildFSState in project intellij-community by JetBrains.
the class IncProjectBuilder method checkUpToDate.
public void checkUpToDate(CompileScope scope) {
CompileContextImpl context = null;
try {
context = createContext(scope);
final BuildFSState fsState = myProjectDescriptor.fsState;
for (BuildTarget<?> target : myProjectDescriptor.getBuildTargetIndex().getAllTargets()) {
if (scope.isAffected(target)) {
BuildOperations.ensureFSStateInitialized(context, target);
final FilesDelta delta = fsState.getEffectiveFilesDelta(context, target);
delta.lockData();
try {
for (Set<File> files : delta.getSourcesToRecompile().values()) {
for (File file : files) {
if (scope.isAffected(target, file)) {
// this will serve as a marker that compiler has work to do
myMessageDispatcher.processMessage(DoneSomethingNotification.INSTANCE);
return;
}
}
}
} finally {
delta.unlockData();
}
}
}
} catch (Exception e) {
LOG.info(e);
// this will serve as a marker that compiler has work to do
myMessageDispatcher.processMessage(DoneSomethingNotification.INSTANCE);
} finally {
if (context != null) {
flushContext(context);
}
}
}
use of org.jetbrains.jps.incremental.fs.BuildFSState in project intellij-community by JetBrains.
the class IncProjectBuilder method reportUnprocessedChanges.
private static void reportUnprocessedChanges(CompileContextImpl context) {
final ProjectDescriptor pd = context.getProjectDescriptor();
final BuildFSState fsState = pd.fsState;
for (BuildTarget<?> target : pd.getBuildTargetIndex().getAllTargets()) {
if (fsState.hasUnprocessedChanges(context, target)) {
context.processMessage(new UnprocessedFSChangesNotification());
break;
}
}
}
use of org.jetbrains.jps.incremental.fs.BuildFSState in project intellij-community by JetBrains.
the class BuildSession method runBuild.
private void runBuild(final MessageHandler msgHandler, CanceledStatus cs) throws Throwable {
final File dataStorageRoot = Utils.getDataStorageRoot(myProjectPath);
if (dataStorageRoot == null) {
msgHandler.processMessage(new CompilerMessage("build", BuildMessage.Kind.ERROR, "Cannot determine build data storage root for project " + myProjectPath));
return;
}
final boolean storageFilesAbsent = !dataStorageRoot.exists() || !new File(dataStorageRoot, FS_STATE_FILE).exists();
if (storageFilesAbsent) {
// invoked the very first time for this project
myBuildRunner.setForceCleanCaches(true);
}
final ProjectDescriptor preloadedProject = myPreloadedData != null ? myPreloadedData.getProjectDescriptor() : null;
final DataInputStream fsStateStream = storageFilesAbsent || preloadedProject != null || myInitialFSDelta == null ? /*this will force FS rescan*/
null : createFSDataStream(dataStorageRoot, myInitialFSDelta.getOrdinal());
if (fsStateStream != null || myPreloadedData != null) {
// optimization: check whether we can skip the build
final boolean hasWorkFlag = fsStateStream != null ? fsStateStream.readBoolean() : myPreloadedData.hasWorkToDo();
final boolean hasWorkToDoWithModules = hasWorkFlag || myInitialFSDelta == null;
if (!myForceModelLoading && (myBuildType == BuildType.BUILD || myBuildType == BuildType.UP_TO_DATE_CHECK) && !hasWorkToDoWithModules && scopeContainsModulesOnlyForIncrementalMake(myScopes) && !containsChanges(myInitialFSDelta)) {
final DataInputStream storedFsData;
if (myPreloadedData != null) {
storedFsData = createFSDataStream(dataStorageRoot, myInitialFSDelta.getOrdinal());
if (storedFsData != null) {
// skip hasWorkToDo flag
storedFsData.readBoolean();
}
} else {
storedFsData = fsStateStream;
}
if (storedFsData != null) {
updateFsStateOnDisk(dataStorageRoot, storedFsData, myInitialFSDelta.getOrdinal());
LOG.info("No changes found since last build. Exiting.");
if (preloadedProject != null) {
preloadedProject.release();
}
return;
}
}
}
final BuildFSState fsState = preloadedProject != null ? preloadedProject.fsState : new BuildFSState(false);
try {
final ProjectDescriptor pd;
if (preloadedProject != null) {
pd = preloadedProject;
final List<BuildMessage> preloadMessages = myPreloadedData.getLoadMessages();
if (!preloadMessages.isEmpty()) {
// replay preload-time messages, so that they are delivered to the IDE
for (BuildMessage message : preloadMessages) {
msgHandler.processMessage(message);
}
}
if (myInitialFSDelta == null || myPreloadedData.getFsEventOrdinal() + 1L != myInitialFSDelta.getOrdinal()) {
// FS rescan was forced
fsState.clearAll();
} else {
// apply events to already loaded state
try {
applyFSEvent(pd, myInitialFSDelta, false);
} catch (Throwable e) {
LOG.error(e);
fsState.clearAll();
}
}
} else {
// standard case
pd = myBuildRunner.load(msgHandler, dataStorageRoot, fsState);
TimingLog.LOG.debug("Project descriptor loaded");
if (fsStateStream != null) {
try {
try {
fsState.load(fsStateStream, pd.getModel(), pd.getBuildRootIndex());
applyFSEvent(pd, myInitialFSDelta, false);
TimingLog.LOG.debug("FS Delta loaded");
} finally {
fsStateStream.close();
}
} catch (Throwable e) {
LOG.error(e);
fsState.clearAll();
}
}
}
myProjectDescriptor = pd;
myLastEventOrdinal = myInitialFSDelta != null ? myInitialFSDelta.getOrdinal() : 0L;
// free memory
myInitialFSDelta = null;
// ensure events from controller are processed after FSState initialization
myEventsProcessor.startProcessing();
myBuildRunner.runBuild(pd, cs, myConstantSearch, msgHandler, myBuildType, myScopes, false);
TimingLog.LOG.debug("Build finished");
} finally {
saveData(fsState, dataStorageRoot);
}
}
Aggregations