}
public boolean run(TreeLogger logger) throws UnableToCompleteException {
for (String moduleName : options.getModuleNames()) {
File compilerWorkDir = options.getCompilerWorkDir(moduleName);
ModuleDef module = ModuleDefLoader.loadFromClassPath(logger, moduleName);
File precompilationFile = new File(compilerWorkDir,
Precompile.PRECOMPILATION_FILENAME);
if (!precompilationFile.exists()) {
logger.log(TreeLogger.ERROR, "File not found '"
+ precompilationFile.getAbsolutePath()
+ "'; please run Precompile first");
return false;
}
Precompilation precompilation;
try {
precompilation = Util.readFileAsObject(precompilationFile,
Precompilation.class);
} catch (ClassNotFoundException e) {
logger.log(TreeLogger.ERROR, "Unable to deserialize '"
+ precompilationFile.getAbsolutePath() + "'", e);
return false;
}
Permutation[] perms = precompilation.getPermutations();
File[] resultFiles = new File[perms.length];
for (int i = 0; i < perms.length; ++i) {
resultFiles[i] = CompilePerms.makePermFilename(compilerWorkDir,
perms[i].getId());
if (!resultFiles[i].exists()) {
logger.log(TreeLogger.ERROR, "File not found '"
+ precompilationFile.getAbsolutePath()
+ "'; please compile all permutations");
return false;
}
}
TreeLogger branch = logger.branch(TreeLogger.INFO, "Linking module "
+ module.getName());
StandardLinkerContext linkerContext = new StandardLinkerContext(branch,
module, precompilation.getUnifiedAst().getOptions());
ArtifactSet artifacts = doLink(branch, linkerContext, precompilation,
resultFiles);