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);
}
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);
}
}
}
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);
}
}
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);
}
}
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);
}
Aggregations