Search in sources :

Example 1 with Timestamps

use of org.jetbrains.jps.incremental.storage.Timestamps in project intellij-community by JetBrains.

the class BuildOperations method initTargetFSState.

private static void initTargetFSState(CompileContext context, BuildTarget<?> target, final boolean forceMarkDirty) throws IOException {
    final ProjectDescriptor pd = context.getProjectDescriptor();
    final Timestamps timestamps = pd.timestamps.getStorage();
    final THashSet<File> currentFiles = new THashSet<>(FileUtil.FILE_HASHING_STRATEGY);
    FSOperations.markDirtyFiles(context, target, CompilationRound.CURRENT, timestamps, forceMarkDirty, currentFiles, null);
    // handle deleted paths
    final BuildFSState fsState = pd.fsState;
    fsState.clearDeletedPaths(target);
    final SourceToOutputMapping sourceToOutputMap = pd.dataManager.getSourceToOutputMap(target);
    for (final Iterator<String> it = sourceToOutputMap.getSourcesIterator(); it.hasNext(); ) {
        final String path = it.next();
        // can check if the file exists
        final File file = new File(path);
        if (!currentFiles.contains(file)) {
            fsState.registerDeleted(context, target, file, timestamps);
        }
    }
    pd.fsState.markInitialScanPerformed(target);
}
Also used : Timestamps(org.jetbrains.jps.incremental.storage.Timestamps) BuildFSState(org.jetbrains.jps.incremental.fs.BuildFSState) SourceToOutputMapping(org.jetbrains.jps.builders.storage.SourceToOutputMapping) ProjectDescriptor(org.jetbrains.jps.cmdline.ProjectDescriptor) File(java.io.File) THashSet(gnu.trove.THashSet)

Example 2 with Timestamps

use of org.jetbrains.jps.incremental.storage.Timestamps in project intellij-community by JetBrains.

the class BuildOperations method markTargetsUpToDate.

public static void markTargetsUpToDate(CompileContext context, BuildTargetChunk chunk) throws IOException {
    final ProjectDescriptor pd = context.getProjectDescriptor();
    final BuildFSState fsState = pd.fsState;
    for (BuildTarget<?> target : chunk.getTargets()) {
        pd.getTargetsState().getTargetConfiguration(target).storeNonexistentOutputRoots(context);
    }
    if (!Utils.errorsDetected(context) && !context.getCancelStatus().isCanceled()) {
        boolean marked = dropRemovedPaths(context, chunk);
        for (BuildTarget<?> target : chunk.getTargets()) {
            if (target instanceof ModuleBuildTarget) {
                context.clearNonIncrementalMark((ModuleBuildTarget) target);
            }
            final Timestamps timestamps = pd.timestamps.getStorage();
            for (BuildRootDescriptor rd : pd.getBuildRootIndex().getTargetRoots(target, context)) {
                marked |= fsState.markAllUpToDate(context, rd, timestamps);
            }
        }
        if (marked) {
            context.processMessage(DoneSomethingNotification.INSTANCE);
        }
    }
}
Also used : Timestamps(org.jetbrains.jps.incremental.storage.Timestamps) BuildFSState(org.jetbrains.jps.incremental.fs.BuildFSState) ProjectDescriptor(org.jetbrains.jps.cmdline.ProjectDescriptor)

Example 3 with Timestamps

use of org.jetbrains.jps.incremental.storage.Timestamps in project intellij-community by JetBrains.

the class BuildOperations method ensureFSStateInitialized.

public static void ensureFSStateInitialized(CompileContext context, BuildTarget<?> target) throws IOException {
    final ProjectDescriptor pd = context.getProjectDescriptor();
    final Timestamps timestamps = pd.timestamps.getStorage();
    final BuildTargetConfiguration configuration = pd.getTargetsState().getTargetConfiguration(target);
    if (JavaBuilderUtil.isForcedRecompilationAllJavaModules(context)) {
        FSOperations.markDirtyFiles(context, target, CompilationRound.CURRENT, timestamps, true, null, null);
        pd.fsState.markInitialScanPerformed(target);
        configuration.save(context);
    } else if (context.getScope().isBuildForced(target) || configuration.isTargetDirty(context) || configuration.outputRootWasDeleted(context)) {
        initTargetFSState(context, target, true);
        if (!context.getScope().isBuildForced(target)) {
            // case when target build is forced, is handled separately
            IncProjectBuilder.clearOutputFiles(context, target);
        }
        pd.dataManager.cleanTargetStorages(target);
        configuration.save(context);
    } else if (!pd.fsState.isInitialScanPerformed(target)) {
        initTargetFSState(context, target, false);
    }
}
Also used : Timestamps(org.jetbrains.jps.incremental.storage.Timestamps) ProjectDescriptor(org.jetbrains.jps.cmdline.ProjectDescriptor) BuildTargetConfiguration(org.jetbrains.jps.incremental.storage.BuildTargetConfiguration)

Example 4 with Timestamps

use of org.jetbrains.jps.incremental.storage.Timestamps in project intellij-community by JetBrains.

the class FSOperations method markDirtyRecursively.

public static void markDirtyRecursively(CompileContext context, final CompilationRound round, ModuleChunk chunk, @Nullable FileFilter filter) throws IOException {
    Set<JpsModule> modules = chunk.getModules();
    Set<ModuleBuildTarget> targets = chunk.getTargets();
    final Set<ModuleBuildTarget> dirtyTargets = new HashSet<>(targets);
    // now mark all modules that depend on dirty modules
    final JpsJavaClasspathKind classpathKind = JpsJavaClasspathKind.compile(chunk.containsTests());
    boolean found = false;
    for (BuildTargetChunk targetChunk : context.getProjectDescriptor().getBuildTargetIndex().getSortedTargetChunks(context)) {
        if (!found) {
            if (targetChunk.getTargets().equals(chunk.getTargets())) {
                found = true;
            }
        } else {
            for (final BuildTarget<?> target : targetChunk.getTargets()) {
                if (target instanceof ModuleBuildTarget) {
                    final Set<JpsModule> deps = getDependentModulesRecursively(((ModuleBuildTarget) target).getModule(), classpathKind);
                    if (ContainerUtil.intersects(deps, modules)) {
                        for (BuildTarget<?> buildTarget : targetChunk.getTargets()) {
                            if (buildTarget instanceof ModuleBuildTarget) {
                                dirtyTargets.add((ModuleBuildTarget) buildTarget);
                            }
                        }
                        break;
                    }
                }
            }
        }
    }
    if (JavaBuilderUtil.isCompileJavaIncrementally(context)) {
        // mark as non-incremental only the module that triggered non-incremental change
        for (ModuleBuildTarget target : targets) {
            if (!isMarkedDirty(context, target)) {
                // if the target was marked dirty already, all its files were compiled, so
                // it makes no sense to mark it non-incremental
                context.markNonIncremental(target);
            }
        }
    }
    removeTargetsAlreadyMarkedDirty(context, dirtyTargets);
    final Timestamps timestamps = context.getProjectDescriptor().timestamps.getStorage();
    for (ModuleBuildTarget target : dirtyTargets) {
        markDirtyFiles(context, target, round, timestamps, true, null, filter);
    }
}
Also used : Timestamps(org.jetbrains.jps.incremental.storage.Timestamps) JpsModule(org.jetbrains.jps.model.module.JpsModule) BuildTargetChunk(org.jetbrains.jps.builders.impl.BuildTargetChunk) JpsJavaClasspathKind(org.jetbrains.jps.model.java.JpsJavaClasspathKind) THashSet(gnu.trove.THashSet) HashSet(java.util.HashSet)

Example 5 with Timestamps

use of org.jetbrains.jps.incremental.storage.Timestamps in project intellij-community by JetBrains.

the class BuildRunner method createCompilationScope.

private static CompileScope createCompilationScope(ProjectDescriptor pd, List<TargetTypeBuildScope> scopes, Collection<String> paths, final boolean forceClean, final boolean includeDependenciesToScope) throws Exception {
    Set<BuildTargetType<?>> targetTypes = new HashSet<>();
    Set<BuildTargetType<?>> targetTypesToForceBuild = new HashSet<>();
    Set<BuildTarget<?>> targets = new HashSet<>();
    Map<BuildTarget<?>, Set<File>> files;
    final TargetTypeRegistry typeRegistry = TargetTypeRegistry.getInstance();
    for (TargetTypeBuildScope scope : scopes) {
        final BuildTargetType<?> targetType = typeRegistry.getTargetType(scope.getTypeId());
        if (targetType == null) {
            LOG.info("Unknown target type: " + scope.getTypeId());
            continue;
        }
        if (scope.getForceBuild() || forceClean) {
            targetTypesToForceBuild.add(targetType);
        }
        if (scope.getAllTargets()) {
            targetTypes.add(targetType);
        } else {
            BuildTargetLoader<?> loader = targetType.createLoader(pd.getModel());
            for (String targetId : scope.getTargetIdList()) {
                BuildTarget<?> target = loader.createTarget(targetId);
                if (target != null) {
                    targets.add(target);
                } else {
                    LOG.info("Unknown " + targetType + " target id: " + targetId);
                }
            }
        }
    }
    if (includeDependenciesToScope) {
        includeDependenciesToScope(targetTypes, targets, targetTypesToForceBuild, pd);
    }
    final Timestamps timestamps = pd.timestamps.getStorage();
    if (!paths.isEmpty()) {
        boolean forceBuildAllModuleBasedTargets = false;
        for (BuildTargetType<?> type : targetTypesToForceBuild) {
            if (type instanceof JavaModuleBuildTargetType) {
                forceBuildAllModuleBasedTargets = true;
                break;
            }
        }
        files = new HashMap<>();
        for (String path : paths) {
            final File file = new File(path);
            final Collection<BuildRootDescriptor> descriptors = pd.getBuildRootIndex().findAllParentDescriptors(file, null);
            for (BuildRootDescriptor descriptor : descriptors) {
                Set<File> fileSet = files.get(descriptor.getTarget());
                if (fileSet == null) {
                    fileSet = new THashSet<>(FileUtil.FILE_HASHING_STRATEGY);
                    files.put(descriptor.getTarget(), fileSet);
                }
                final boolean added = fileSet.add(file);
                if (added) {
                    final BuildTargetType<?> targetType = descriptor.getTarget().getTargetType();
                    if (targetTypesToForceBuild.contains(targetType) || (forceBuildAllModuleBasedTargets && targetType instanceof ModuleBasedBuildTargetType)) {
                        pd.fsState.markDirty(null, file, descriptor, timestamps, false);
                    }
                }
            }
        }
    } else {
        files = Collections.emptyMap();
    }
    return new CompileScopeImpl(targetTypes, targetTypesToForceBuild, targets, files);
}
Also used : THashSet(gnu.trove.THashSet) ProjectTimestamps(org.jetbrains.jps.incremental.storage.ProjectTimestamps) Timestamps(org.jetbrains.jps.incremental.storage.Timestamps) JavaModuleBuildTargetType(org.jetbrains.jps.builders.java.JavaModuleBuildTargetType) File(java.io.File) TargetTypeBuildScope(org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.TargetTypeBuildScope) THashSet(gnu.trove.THashSet) JavaModuleBuildTargetType(org.jetbrains.jps.builders.java.JavaModuleBuildTargetType)

Aggregations

Timestamps (org.jetbrains.jps.incremental.storage.Timestamps)7 THashSet (gnu.trove.THashSet)3 File (java.io.File)3 ProjectDescriptor (org.jetbrains.jps.cmdline.ProjectDescriptor)3 BuildFSState (org.jetbrains.jps.incremental.fs.BuildFSState)2 HashSet (java.util.HashSet)1 TargetTypeBuildScope (org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.TargetTypeBuildScope)1 BuildRootIndex (org.jetbrains.jps.builders.BuildRootIndex)1 BuildTargetChunk (org.jetbrains.jps.builders.impl.BuildTargetChunk)1 JavaModuleBuildTargetType (org.jetbrains.jps.builders.java.JavaModuleBuildTargetType)1 SourceToOutputMapping (org.jetbrains.jps.builders.storage.SourceToOutputMapping)1 BuildTargetConfiguration (org.jetbrains.jps.incremental.storage.BuildTargetConfiguration)1 ProjectTimestamps (org.jetbrains.jps.incremental.storage.ProjectTimestamps)1 JpsJavaClasspathKind (org.jetbrains.jps.model.java.JpsJavaClasspathKind)1 JpsModule (org.jetbrains.jps.model.module.JpsModule)1