}
Transcoder[] transcoders = WebTierAPI.getTranscoders(tempOEMConfiguration.configuration);
SubCompiler[] compilers = WebTierAPI.getCompilers(compilerConfig, mappings, transcoders);
CompilerSwcContext swcContext = new CompilerSwcContext(true);
try
{
swcContext.load( compilerConfig.getLibraryPath(),
compilerConfig.getExternalLibraryPath(),
null,
compilerConfig.getIncludeLibraries(),
mappings,
I18nUtils.getTranslationFormat(compilerConfig),
data.swcCache );
}
catch (SwcException ex)
{
if (Trace.error)
{
ex.printStackTrace();
}
clean(false /* cleanData */, false /* cleanCache */, false /* cleanOutput */);
return FAIL;
}
// save the generated swcCache if the class has a libraryCache.
if (libraryCache != null)
{
libraryCache.setSwcCache(data.swcCache);
}
// If checksum is different, rebuild.
if (OEMUtil.isRecompilationNeeded(data, swcContext, tempOEMConfiguration))
{
if (benchmark != null)
{
benchmark.benchmark2("Starting full compile for " + getOutput(), true);
}
clean(true /* cleanData */,
false /* cleanCache */,
false /* cleanOutput */,
true /* cleanConfig */,
false /* cleanMessages */,
false /* cleanThreadLocals */);
int returnValue = recompile(true, licenseMap, tempOEMConfiguration);
if (benchmark != null)
{
benchmark.benchmark2("Ending full compile for " + getOutput(), true);
}
clean(returnValue != OK, false, false);
return returnValue;
}
// If --include-sources is different, rebuild.
Set<VirtualFile> fileSet = null;
if ((fileSet = processSources(compilerConfig)) == null)
{
clean(false /* cleanData */, false /* cleanCache */, false /* cleanOutput */);
return FAIL;
}
// If --include-stylesheets is different, rebuild.
fileSet.addAll(processStylesheets());
boolean isFileSpecDifferent = isDifferent(data.fileSet, fileSet);
if (isFileSpecDifferent)
{
if (benchmark != null)
{
benchmark.benchmark2("Starting full compile for " + getOutput(), true);
}
clean(true /* cleanData */,
false /* cleanCache */,
false /* cleanOutput */,
true /* cleanConfig */,
false /* cleanMessages */,
false /* cleanThreadLocals */);
int returnValue = recompile(true, licenseMap, tempOEMConfiguration);
if (benchmark != null)
{
benchmark.benchmark2("Ending full compile for " + getOutput(), true);
}
clean(returnValue != OK, false, false);
return returnValue;
}
if (benchmark != null)
{
// We aren't really starting the compile here, but it's
// the earliest that we know that it's going to be an
// active compilation.
benchmark.benchmark2("Starting active compile for " + getOutput(), true);
}
data.includes = new HashSet<String>(swcContext.getIncludes());
data.excludes = new HashSet<String>(swcContext.getExterns());
tempOEMConfiguration.configuration.addExterns( swcContext.getExterns() );
tempOEMConfiguration.configuration.addIncludes( swcContext.getIncludes() );
data.swcArchiveFiles = new HashMap<String, VirtualFile>(swcContext.getIncludeFiles());
// The ToolsConfiguration expects class names in QName format.
Set<String> qNameClasses = new HashSet<String>();
for (String className : classes)
{
qNameClasses.add(NameFormatter.toColon(className));
}
// Allow -include-classes to override the -external-library-path.
tempOEMConfiguration.configuration.removeExterns(qNameClasses);
// If we want only inheritance dependencies of -include-classes then
// add the classes to the includes list. When
// -include-inheritance-dependencies-only is turned on the dependency
// walker will ignore all the classes except for the includes.
if (tempOEMConfiguration.configuration.getIncludeInheritanceDependenciesOnly())
{
tempOEMConfiguration.configuration.addIncludes(qNameClasses);
}
int count = CompilerAPI.validateCompilationUnits(data.fileSpec, data.sourceList, data.sourcePath,
data.bundlePath, data.resources, swcContext,
data.classes, data.perCompileData,
tempOEMConfiguration.configuration);
Map<String, Source> classes = new TreeMap<String, Source>();
Set<SwcComponent> nsComponents = null;
if ((nsComponents = processInputs(swcContext, copy, classes)) == null)
{
clean(false /* cleanData */, false /* cleanCache */, false /* cleanOutput */);
return FAIL;
}
// If the other --include-* are different, build incrementally.
boolean isDifferent = isDifferent(data.classes.keySet(), classes.keySet());
if (count > 0 || isDifferent || isResourceBundleListDifferent() ||
data.swcChecksum != swcContext.checksum())
{
// create a symbol table
SymbolTable symbolTable = new SymbolTable(tempOEMConfiguration.configuration, data.perCompileData);
data.configuration = tempOEMConfiguration.configuration;
data.nsComponents = nsComponents;
data.classes = classes;
data.fileSet = fileSet;
data.linkChecksum = tempOEMConfiguration.cfgbuf.link_checksum_ts();
data.swcChecksum = swcContext.checksum();
// compile
data.sources = new ArrayList<Source>();
data.units = compile(compilers, swcContext, symbolTable, mappings, licenseMap, classes, data.sources);
boolean forcedToStop = CompilerAPI.forcedToStop();
if (data.units == null || forcedToStop)
{
clean(true, false, false);
return FAIL;
}
else
{
if (benchmark != null)
{
benchmark.benchmark2("Ending active compile for " + getOutput(), true);
}
clean(false /* cleanData */, false /* cleanCache */, false /* cleanOutput */);
return OK;
}
}
else
{
if (benchmark != null)
{
benchmark.stopTime(Benchmark.PRECOMPILE, false);
benchmark.startTime(Benchmark.POSTCOMPILE);
}
int retVal = SKIP;
if (data != null)
{
CompilerAPI.displayWarnings(data.units);
if (data.linkChecksum != tempOEMConfiguration.cfgbuf.link_checksum_ts())
{
retVal = LINK;
}
}
else
{
retVal = LINK;
}
data.linkChecksum = tempOEMConfiguration.cfgbuf.link_checksum_ts();
data.swcChecksum = swcContext.checksum();
if (CompilerAPI.forcedToStop()) retVal = FAIL;
if (benchmark != null)
{