options.setWorkDir(Utility.makeTemporaryDirectory(null, "gwtc"));
tempWorkDir = true;
}
for (String moduleName : options.getModuleNames()) {
ModuleDef module = ModuleDefLoader.loadFromClassPath(logger,
moduleName, true);
File compilerWorkDir = options.getCompilerWorkDir(moduleName);
if (options.isValidateOnly()) {
if (!Precompile.validate(logger, options, module,
options.getGenDir(), compilerWorkDir,
options.getDumpSignatureFile())) {
return false;
}
} else {
long compileStart = System.currentTimeMillis();
TreeLogger branch = logger.branch(TreeLogger.INFO,
"Compiling module " + moduleName);
// Optimize early since permutation compiles will run in process.
options.setOptimizePrecompile(true);
Precompilation precompilation = Precompile.precompile(branch,
options, module, options.getGenDir(), compilerWorkDir,
options.getDumpSignatureFile());
if (precompilation == null) {
return false;
}
Permutation[] allPerms = precompilation.getPermutations();
List<FileBackedObject<PermutationResult>> resultFiles = CompilePerms.makeResultFiles(
options.getCompilerWorkDir(moduleName), allPerms);
CompilePerms.compile(branch, precompilation, allPerms,
options.getLocalWorkers(), resultFiles);
ArtifactSet generatedArtifacts = precompilation.getGeneratedArtifacts();
JJSOptions precompileOptions = precompilation.getUnifiedAst().getOptions();
precompilation = null; // No longer needed, so save the memory
File absPath = new File(options.getWarDir(), module.getName());
absPath = absPath.getAbsoluteFile();
String logMessage = "Linking into " + absPath + ".";
if (options.getExtraDir() != null) {
File absExtrasPath = new File(options.getExtraDir(), module.getName());
absExtrasPath = absExtrasPath.getAbsoluteFile();
logMessage += " Writing extras to " + absExtrasPath;
}
Link.link(logger.branch(TreeLogger.TRACE, logMessage),
module, generatedArtifacts, allPerms, resultFiles,