// No need to check mkdirs result because an IOException will occur anyway
compilerWorkDir.mkdirs();
File precompilationFile = new File(compilerWorkDir, PRECOMPILE_FILENAME);
ModuleDef module = ModuleDefLoader.loadFromClassPath(logger, moduleName);
boolean generateOnShards = options.isEnabledGeneratingOnShards();
if (options.isValidateOnly()) {
// Don't bother running on shards for just a validation run
generateOnShards = false;
} else if (options.getDumpSignatureFile() != null) {
logger.log(TreeLogger.INFO,
"Precompiling on the start node, because a dump signature file was specified");
/*
* It would be possible to shard in this case, too. However, each
* permutation would have its own signatures dumped. Either the output
* would need to be multiple dump files, or those files would need to be
* combined back into one.
*/
generateOnShards = false;
}
if (generateOnShards) {
/*
* Pre-precompile. Count the permutations and plan to do a real
* precompile in the CompilePerms shards.
*/
TreeLogger branch = logger.branch(TreeLogger.INFO,
"Precompiling (minimal) module " + module.getName());
Util.writeObjectAsFile(logger, precompilationFile, options);
int numPermutations = module.getProperties().numPermutations();
Util.writeStringAsFile(logger, new File(compilerWorkDir,
PERM_COUNT_FILENAME), String.valueOf(numPermutations));
branch.log(TreeLogger.INFO,
"Precompilation (minimal) succeeded, number of permutations: "
+ numPermutations);
} else {
// TODO: All JDT checks now before even building TypeOracle?
module.getCompilationState(logger);
if (options.isValidateOnly()) {
TreeLogger branch = logger.branch(TreeLogger.INFO,
"Validating compilation " + module.getName());
if (!validate(branch, options, module, options.getGenDir(),
compilerWorkDir, options.getDumpSignatureFile())) {
branch.log(TreeLogger.ERROR, "Validation failed");
return false;
}
branch.log(TreeLogger.INFO, "Validation succeeded");
} else {
TreeLogger branch = logger.branch(TreeLogger.INFO,
"Precompiling module " + module.getName());
Precompilation precompilation = precompile(branch, options, module,
options.getGenDir(), compilerWorkDir,
options.getDumpSignatureFile());
if (precompilation == null) {