use of org.jetbrains.jps.builders.impl.BuildTargetChunk in project intellij-community by JetBrains.
the class IncProjectBuilder method runBuildersForChunk.
private boolean runBuildersForChunk(final CompileContext context, final BuildTargetChunk chunk) throws ProjectBuildException, IOException {
Set<? extends BuildTarget<?>> targets = chunk.getTargets();
if (targets.size() > 1) {
Set<ModuleBuildTarget> moduleTargets = new LinkedHashSet<>();
for (BuildTarget<?> target : targets) {
if (target instanceof ModuleBuildTarget) {
moduleTargets.add((ModuleBuildTarget) target);
} else {
String targetsString = StringUtil.join(targets, (Function<BuildTarget<?>, String>) target1 -> StringUtil.decapitalize(target1.getPresentableName()), ", ");
context.processMessage(new CompilerMessage("", BuildMessage.Kind.ERROR, "Cannot build " + StringUtil.decapitalize(target.getPresentableName()) + " because it is included into a circular dependency (" + targetsString + ")"));
return false;
}
}
return runModuleLevelBuilders(context, new ModuleChunk(moduleTargets));
}
final BuildTarget<?> target = targets.iterator().next();
if (target instanceof ModuleBuildTarget) {
return runModuleLevelBuilders(context, new ModuleChunk(Collections.singleton((ModuleBuildTarget) target)));
}
// In general the set of files corresponding to changed source file may be different
// Need this for example, to keep up with case changes in file names for case-insensitive OSes:
// deleting the output before copying is the only way to ensure the case of the output file's name is exactly the same as source file's case
cleanOldOutputs(context, target);
final List<TargetBuilder<?, ?>> builders = BuilderRegistry.getInstance().getTargetBuilders();
final float builderProgressDelta = 1.0f / builders.size();
for (TargetBuilder<?, ?> builder : builders) {
buildTarget(target, context, builder);
updateDoneFraction(context, builderProgressDelta);
}
return true;
}
use of org.jetbrains.jps.builders.impl.BuildTargetChunk 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.builders.impl.BuildTargetChunk in project intellij-community by JetBrains.
the class IncProjectBuilder method buildChunks.
private void buildChunks(final CompileContextImpl context) throws ProjectBuildException {
try {
final CompileScope scope = context.getScope();
final ProjectDescriptor pd = context.getProjectDescriptor();
final BuildTargetIndex targetIndex = pd.getBuildTargetIndex();
// for better progress dynamics consider only actually affected chunks
int totalAffected = 0;
for (BuildTargetChunk chunk : targetIndex.getSortedTargetChunks(context)) {
if (isAffected(context.getScope(), chunk)) {
totalAffected += chunk.getTargets().size();
}
}
myTotalTargetsWork = totalAffected;
boolean compileInParallel = BuildRunner.PARALLEL_BUILD_ENABLED;
if (compileInParallel && MAX_BUILDER_THREADS <= 1) {
LOG.info("Switched off parallel compilation because maximum number of builder threads is less than 2. Set '" + GlobalOptions.COMPILE_PARALLEL_MAX_THREADS_OPTION + "' system property to a value greater than 1 to really enable parallel compilation.");
compileInParallel = false;
}
if (compileInParallel) {
new BuildParallelizer(context).buildInParallel();
} else {
// non-parallel build
for (BuildTargetChunk chunk : targetIndex.getSortedTargetChunks(context)) {
try {
buildChunkIfAffected(context, scope, chunk);
} finally {
pd.dataManager.closeSourceToOutputStorages(Collections.singleton(chunk));
pd.dataManager.flush(true);
}
}
}
} catch (IOException e) {
throw new ProjectBuildException(e);
}
}
Aggregations