}
}
private static void compile_compc(SwcTarget s)
{
LocalizationManager l10n = ThreadLocalToolkit.getLocalizationManager();
Benchmark benchmark = null;
try
{
// setup the path resolver
CompilerAPI.usePathResolver();
// process configuration
ConfigurationBuffer cfgbuf = new ConfigurationBuffer(CompcConfiguration.class, CompcConfiguration.getAliases());
cfgbuf.setDefaultVar("include-classes");
DefaultsConfigurator.loadCompcDefaults( cfgbuf );
CompcConfiguration configuration = (CompcConfiguration) Mxmlc.processConfiguration(
ThreadLocalToolkit.getLocalizationManager(), "compc", s.args, cfgbuf, CompcConfiguration.class, "include-classes");
CompilerAPI.setupHeadless(configuration);
if (configuration.benchmark())
{
benchmark = CompilerAPI.runBenchmark();
benchmark.startTime(Benchmark.PRECOMPILE);
}
else
{
CompilerAPI.disableBenchmark();
}
s.sourcePath.clearCache();
s.bundlePath.clearCache();
s.resources.refresh();
// C: We don't really need to parse the manifest files again.
CompilerConfiguration compilerConfig = configuration.getCompilerConfiguration();
// note: if Configuration is ever shared with other parts of the system, then this part will need
// to change, since we're setting a compc-specific setting below
compilerConfig.setMetadataExport(true);
NameMappings mappings = CompilerAPI.getNameMappings(configuration);
Transcoder[] transcoders = WebTierAPI.getTranscoders( configuration );
SubCompiler[] compilers = WebTierAPI.getCompilers(compilerConfig, mappings, transcoders);
if (benchmark != null)
{
benchmark.benchmark(l10n.getLocalizedTextString(new InitialSetup()));
}
// load SWCs
CompilerSwcContext swcContext = new CompilerSwcContext(true);
// for compc the theme and include-libraries values have been purposely not passed in below.
// This is done because the theme attribute doesn't make sense and the include-libraries value
// actually causes issues when the default value is used with external libraries.
// FIXME: why don't we just get rid of these values from the configurator for compc? That's a problem
// for include-libraries at least, since this value appears in flex-config.xml
swcContext.load( compilerConfig.getLibraryPath(),
compilerConfig.getExternalLibraryPath(),
null,
null,
mappings,
I18nUtils.getTranslationFormat(compilerConfig),
s.swcCache );
configuration.addExterns( swcContext.getExterns() );
// recompile or incrementally compile...
boolean recompile = false;
int newChecksum = cfgbuf.checksum_ts() + swcContext.checksum();
if (newChecksum != s.checksum)
{
ThreadLocalToolkit.logInfo(l10n.getLocalizedTextString(new DetectConfigurationChange()));
s.checksum = newChecksum;
s.resources = new ResourceContainer();
recompile = true;
}
// validate CompilationUnits in FileSpec and SourcePath
if (recompile || CompilerAPI.validateCompilationUnits(s.fileSpec, s.sourceList, s.sourcePath, s.bundlePath, s.resources,
swcContext, s.classes, s.perCompileData, configuration) > 0)
{
Map licenseMap = configuration.getLicensesConfiguration().getLicenseMap();
// create a symbol table
SymbolTable symbolTable = new SymbolTable(configuration, s.perCompileData);
s.configuration = configuration;
Map<String, Source> classes = new HashMap<String, Source>();
s.nsComponents = SwcAPI.setupNamespaceComponents(configuration, mappings, s.sourcePath, s.sourceList, classes);
SwcAPI.setupClasses(configuration, s.sourcePath, s.sourceList, classes);
// Only updated the SwcTarget's classes if
// setupNamespaceComponents() and setupClasses() are
// successful.
s.classes = classes;
Map<String, VirtualFile> rbFiles = new HashMap<String, VirtualFile>();
if (benchmark != null)
{
benchmark.stopTime(Benchmark.PRECOMPILE, false);
}
List<CompilationUnit> units = CompilerAPI.compile(s.fileSpec, s.sourceList, s.classes.values(),
s.sourcePath, s.resources, s.bundlePath, swcContext,
symbolTable, mappings, configuration, compilers,
new CompcPreLink(rbFiles, configuration.getIncludeResourceBundles(),
false),
licenseMap, new ArrayList<Source>());
if (benchmark != null)
{
benchmark.startTime(Benchmark.POSTCOMPILE);
}
s.units = units;
s.rbFiles = rbFiles;
s.sourcePath.clearCache();
s.bundlePath.clearCache();
s.resources.refresh();
}
else
{
ThreadLocalToolkit.logInfo(l10n.getLocalizedTextString(new NoChange()));
}
}
catch (ConfigurationException ex)
{
Compc.displayStartMessage();