public void processCommandOption( final CmdOption cmdOption, final CommandLine cmdLine, final Map<Object, Object> context) throws InvalidCommandLineException { final CmdFlag opt = Assert.assertInstanceof(cmdOption, CmdFlag.class); if (FORCE_ID.equals(opt.getId())) { ForceRegenContextHelper.setForceRegen(context, opt.isPresent(cmdLine)); } else if (KEEP_ID.equals(opt.getId())) { ForceRegenContextHelper.setKeepTemp(context, opt.isPresent(cmdLine)); } else if (NO_BIN_ID.equals(opt.getId())) { ForceRegenContextHelper.setNoBinaryAST(context, opt.isPresent(cmdLine)); } else { Assert.fail("Unknown id '" + opt.getId() + "'"); } }
protected boolean regenerate( final File outputFile, final Definition definition, final Map<Object, Object> context) { if (ForceRegenContextHelper.getForceRegen(context)) return true; if (!outputFile.exists()) { if (depLogger.isLoggable(Level.FINE)) { depLogger.fine("Generated source file '" + outputFile + "' does not exist, generate."); } return true; } if (!inputResourceLocatorItf.isUpToDate( outputFile, InputResourcesHelper.getInputResources(definition), context)) { if (depLogger.isLoggable(Level.FINE)) { depLogger.fine("Generated source file '" + outputFile + "' is out-of-date, regenerate."); } return true; } else { if (depLogger.isLoggable(Level.FINE)) { depLogger.fine( "Generated source file '" + outputFile + "' is up-to-date, do not regenerate."); } return false; } }
public Definition load(final String name, final Map<Object, Object> context) throws ADLException { if (ForceRegenContextHelper.getForceRegen(context)) { if (logger.isLoggable(Level.FINE)) logger.log(Level.FINE, "Load ADL \"" + name + "\". Forced mode, load source"); return loadSourceADL(name, context); } final URL binADL = adlLocatorItf.findBinaryADL(name, context); if (binADL == null) { if (logger.isLoggable(Level.FINE)) logger.log(Level.FINE, "Load ADL \"" + name + "\". binary ADL not found, load source"); return loadSourceADL(name, context); } final URL srcADL = adlLocatorItf.findSourceADL(name, context); if (srcADL == null) { // only binary file is available, load from binary file. if (logger.isLoggable(Level.FINE)) logger.log(Level.FINE, "Load ADL \"" + name + "\". source unavailable, load binary"); try { return loadBinaryADL(name, binADL, context); } catch (final IOException e) { errorManagerItf.logFatal( GenericErrors.INTERNAL_ERROR, e, "Can't read binary ADL " + binADL + "."); return null; } } // both binary and source file are available, check timestamps: boolean outOfDate; long binTimestamp = 0; try { binTimestamp = getTimestamp(binADL); outOfDate = getTimestamp(srcADL) >= binTimestamp; } catch (final MalformedURLException e) { if (logger.isLoggable(Level.WARNING)) logger.log(Level.WARNING, "Load ADL \"" + name + "\". can't determine file timestamps"); outOfDate = true; } if (outOfDate) { logger.log( Level.FINE, "Load ADL \"" + name + "\". Binary ADL older from source, load source"); } else { // if binary file is more recent than source file, check dependencies. // load binary ADL to retrieve list of input resources. Definition binDef; try { binDef = loadBinaryADL(name, binADL, context); } catch (final IOException e) { errorManagerItf.logWarning( GenericErrors.INTERNAL_ERROR, e, "Can't read binary ADL " + binADL + ". Use source ADL."); return null; } if (binDef != null) { final Set<InputResource> dependencies = InputResourcesHelper.getInputResources(binDef); if (logger.isLoggable(Level.FINEST)) logger.log(Level.FINEST, "Load ADL \"" + name + "\". check dependencies=" + dependencies); if (dependencies != null && inputResourceLocatorItf.isUpToDate(binTimestamp, dependencies, context)) { if (logger.isLoggable(Level.FINEST)) logger.log(Level.FINEST, "Load ADL \"" + name + "\". Binary version is up-to-date"); // binary version is up to date, return it return binDef; } } } if (logger.isLoggable(Level.FINE)) logger.log(Level.FINE, "Load ADL \"" + name + "\". Binary ADL out of date, load source"); // binary version is older than source file, load from source return loadSourceADL(name, context); }