Search in sources :

Example 6 with BuildFSState

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);
    }
}
Also used : ProjectTimestamps(org.jetbrains.jps.incremental.storage.ProjectTimestamps) BuildTargetRegistryImpl(org.jetbrains.jps.builders.impl.BuildTargetRegistryImpl) BuildRootIndexImpl(org.jetbrains.jps.builders.impl.BuildRootIndexImpl) IgnoredFileIndexImpl(org.jetbrains.jps.indices.impl.IgnoredFileIndexImpl) BuildTargetIndexImpl(org.jetbrains.jps.builders.impl.BuildTargetIndexImpl) IOException(java.io.IOException) BuildTargetsState(org.jetbrains.jps.incremental.storage.BuildTargetsState) BuildFSState(org.jetbrains.jps.incremental.fs.BuildFSState) BuildDataPaths(org.jetbrains.jps.builders.storage.BuildDataPaths) ModuleExcludeIndex(org.jetbrains.jps.indices.ModuleExcludeIndex) ProjectDescriptor(org.jetbrains.jps.cmdline.ProjectDescriptor) ModuleExcludeIndexImpl(org.jetbrains.jps.indices.impl.ModuleExcludeIndexImpl) BuildDataPathsImpl(org.jetbrains.jps.builders.impl.BuildDataPathsImpl) BuildDataManager(org.jetbrains.jps.incremental.storage.BuildDataManager)

Example 7 with BuildFSState

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();
    }
}
Also used : BuildFSState(org.jetbrains.jps.incremental.fs.BuildFSState)

Example 8 with BuildFSState

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);
        }
    }
}
Also used : BuildFSState(org.jetbrains.jps.incremental.fs.BuildFSState) FilesDelta(org.jetbrains.jps.incremental.fs.FilesDelta) File(java.io.File) InvocationTargetException(java.lang.reflect.InvocationTargetException) BuildDataCorruptedException(org.jetbrains.jps.builders.storage.BuildDataCorruptedException) IOException(java.io.IOException) MappingFailedException(com.intellij.util.io.MappingFailedException)

Example 9 with BuildFSState

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;
        }
    }
}
Also used : BuildFSState(org.jetbrains.jps.incremental.fs.BuildFSState) ProjectDescriptor(org.jetbrains.jps.cmdline.ProjectDescriptor)

Example 10 with BuildFSState

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);
    }
}
Also used : BuildFSState(org.jetbrains.jps.incremental.fs.BuildFSState)

Aggregations

BuildFSState (org.jetbrains.jps.incremental.fs.BuildFSState)12 ProjectDescriptor (org.jetbrains.jps.cmdline.ProjectDescriptor)6 File (java.io.File)5 IOException (java.io.IOException)5 BuildTargetsState (org.jetbrains.jps.incremental.storage.BuildTargetsState)3 BuildRootDescriptor (org.jetbrains.jps.builders.BuildRootDescriptor)2 BuildDataPathsImpl (org.jetbrains.jps.builders.impl.BuildDataPathsImpl)2 BuildRootIndexImpl (org.jetbrains.jps.builders.impl.BuildRootIndexImpl)2 BuildTargetIndexImpl (org.jetbrains.jps.builders.impl.BuildTargetIndexImpl)2 BuildTargetRegistryImpl (org.jetbrains.jps.builders.impl.BuildTargetRegistryImpl)2 BuildDataCorruptedException (org.jetbrains.jps.builders.storage.BuildDataCorruptedException)2 BuildDataPaths (org.jetbrains.jps.builders.storage.BuildDataPaths)2 BuildDataManager (org.jetbrains.jps.incremental.storage.BuildDataManager)2 ProjectTimestamps (org.jetbrains.jps.incremental.storage.ProjectTimestamps)2 Timestamps (org.jetbrains.jps.incremental.storage.Timestamps)2 ModuleExcludeIndex (org.jetbrains.jps.indices.ModuleExcludeIndex)2 IgnoredFileIndexImpl (org.jetbrains.jps.indices.impl.IgnoredFileIndexImpl)2 ModuleExcludeIndexImpl (org.jetbrains.jps.indices.impl.ModuleExcludeIndexImpl)2 MultiMap (com.intellij.util.containers.MultiMap)1 MappingFailedException (com.intellij.util.io.MappingFailedException)1