external compiler: fixed scope for standalone build

This commit is contained in:
nik
2012-09-20 09:02:29 +04:00
parent 5fd86e11be
commit c8f6c6c24d
4 changed files with 19 additions and 21 deletions
@@ -54,7 +54,7 @@ public class CmdlineProtoUtil {
);
}
private static TargetTypeBuildScope createAllTargetsScope(BuildTargetType type) {
public static TargetTypeBuildScope createAllTargetsScope(BuildTargetType type) {
return TargetTypeBuildScope.newBuilder()
.setTypeId(type.getTypeId())
.setAllTargets(true)
@@ -6,7 +6,6 @@ import gnu.trove.THashSet;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.api.BuildType;
import org.jetbrains.jps.api.CanceledStatus;
import org.jetbrains.jps.api.CmdlineRemoteProto;
import org.jetbrains.jps.api.GlobalOptions;
import org.jetbrains.jps.builders.BuildTarget;
import org.jetbrains.jps.builders.BuildTargetType;
@@ -37,12 +36,12 @@ public class BuildRunner {
public static final boolean PARALLEL_BUILD_ENABLED = Boolean.parseBoolean(System.getProperty(GlobalOptions.COMPILE_PARALLEL_OPTION, "false"));
private static final boolean STORE_TEMP_CACHES_IN_MEMORY = PARALLEL_BUILD_ENABLED || System.getProperty(GlobalOptions.USE_MEMORY_TEMP_CACHE_OPTION) != null;
private final JpsModelLoader myModelLoader;
private final List<CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.TargetTypeBuildScope> myScopes;
private final List<TargetTypeBuildScope> myScopes;
private final List<String> myFilePaths;
private final Map<String, String> myBuilderParams;
private boolean myForceCleanCaches;
public BuildRunner(JpsModelLoader modelLoader, List<CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.TargetTypeBuildScope> scopes, List<String> filePaths, Map<String, String> builderParams) {
public BuildRunner(JpsModelLoader modelLoader, List<TargetTypeBuildScope> scopes, List<String> filePaths, Map<String, String> builderParams) {
myModelLoader = modelLoader;
myScopes = scopes;
myFilePaths = filePaths;
@@ -88,14 +87,14 @@ public class BuildRunner {
}
public void runBuild(ProjectDescriptor pd, CanceledStatus cs, @Nullable Callbacks.ConstantAffectionResolver constantSearch,
MessageHandler msgHandler, final boolean includeTests, BuildType buildType) throws Exception {
MessageHandler msgHandler, BuildType buildType) throws Exception {
for (int attempt = 0; attempt < 2; attempt++) {
if (myForceCleanCaches && myScopes.isEmpty() && myFilePaths.isEmpty()) {
// if compilation scope is the whole project and cache rebuild is forced, use PROJECT_REBUILD for faster compilation
buildType = BuildType.PROJECT_REBUILD;
}
final CompileScope compileScope = createCompilationScope(buildType, pd, myScopes, myFilePaths, includeTests);
final CompileScope compileScope = createCompilationScope(buildType, pd, myScopes, myFilePaths);
final IncProjectBuilder builder = new IncProjectBuilder(pd, BuilderRegistry.getInstance(), myBuilderParams, cs, constantSearch);
builder.addMessageHandler(msgHandler);
try {
@@ -131,10 +130,8 @@ public class BuildRunner {
}
}
private static CompileScope createCompilationScope(BuildType buildType,
ProjectDescriptor pd,
List<TargetTypeBuildScope> scopes,
Collection<String> paths, boolean includeTests) throws Exception {
private static CompileScope createCompilationScope(BuildType buildType, ProjectDescriptor pd, List<TargetTypeBuildScope> scopes,
Collection<String> paths) throws Exception {
Set<BuildTargetType> targetTypes = new HashSet<BuildTargetType>();
Set<BuildTarget> targets = new HashSet<BuildTarget>();
Map<BuildTarget, Set<File>> files;
@@ -184,7 +184,7 @@ final class BuildSession implements Runnable, CanceledStatus {
// ensure events from controller are processed after FSState initialization
myEventsProcessor.startProcessing();
myBuildRunner.runBuild(pd, cs, myConstantSearch, msgHandler, true, myBuildType);
myBuildRunner.runBuild(pd, cs, myConstantSearch, msgHandler, myBuildType);
}
finally {
saveData(fsState, dataStorageRoot);
@@ -6,7 +6,6 @@ import com.sampullara.cli.Args;
import com.sampullara.cli.Argument;
import org.jetbrains.jps.api.BuildType;
import org.jetbrains.jps.api.CanceledStatus;
import org.jetbrains.jps.api.CmdlineProtoUtil;
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType;
import org.jetbrains.jps.cmdline.BuildRunner;
import org.jetbrains.jps.cmdline.JpsModelLoader;
@@ -123,23 +122,25 @@ public class Standalone {
public static void runBuild(JpsModelLoader loader, final File dataStorageRoot, BuildType buildType, Set<String> modulesSet,
List<String> artifactsList, final boolean includeTests, final MessageHandler messageHandler) throws Exception {
List<TargetTypeBuildScope> scopes = new ArrayList<TargetTypeBuildScope>();
if (modulesSet.isEmpty()) {
scopes.addAll(CmdlineProtoUtil.createAllModulesScopes());
}
else {
for (JavaModuleBuildTargetType type : JavaModuleBuildTargetType.ALL_TYPES) {
if (includeTests || !type.isTests()) {
scopes.add(TargetTypeBuildScope.newBuilder().setTypeId(type.getTypeId()).addAllTargetId(modulesSet).build());
for (JavaModuleBuildTargetType type : JavaModuleBuildTargetType.ALL_TYPES) {
if (includeTests || !type.isTests()) {
TargetTypeBuildScope.Builder builder = TargetTypeBuildScope.newBuilder().setTypeId(type.getTypeId());
if (modulesSet.isEmpty()) {
builder.setAllTargets(true);
}
else {
builder.addAllTargetId(modulesSet);
}
scopes.add(builder.build());
}
}
if (artifactsList.isEmpty()) {
if (!artifactsList.isEmpty()) {
scopes.add(TargetTypeBuildScope.newBuilder().setTypeId(ArtifactBuildTargetType.INSTANCE.getTypeId()).addAllTargetId(artifactsList).build());
}
final BuildRunner buildRunner = new BuildRunner(loader, scopes, Collections.<String>emptyList(), Collections.<String, String>emptyMap());
ProjectDescriptor descriptor = buildRunner.load(messageHandler, dataStorageRoot, new BuildFSState(true));
try {
buildRunner.runBuild(descriptor, CanceledStatus.NULL, null, messageHandler, includeTests, buildType);
buildRunner.runBuild(descriptor, CanceledStatus.NULL, null, messageHandler, buildType);
}
finally {
descriptor.release();