/** * Starts the code server. Shuts down the JVM if startup fails. * @param args Command-line options that can be parsed by {@link Options}. */ public static void main(String[] args) throws Exception { Options options = new Options(); if (!options.parseArgs(args)) { System.exit(1); } main(options); }
if (isIncrementalCompileEnabled()) { addTags("incremental_on"); } else { addTags("incremental_off"); if (getNoPrecompile()) { addTags("precompile_off"); } else { addTags("precompile_on");
/** * @see #maybeCreate */ private LauncherDir(Options options) { this.launcherDir = Preconditions.checkNotNull(options.getLauncherDir()); this.options = options; }
CompilerOptionsImpl(CompileDir compileDir, String moduleName, Options options) { this.compileDir = compileDir; this.incremental = options.isIncrementalCompileEnabled(); this.moduleNames = Lists.newArrayList(moduleName); this.sourceLevel = options.getSourceLevel(); this.failOnError = options.isFailOnError(); this.strictSourceResources = options.enforceStrictResources(); this.strictPublicResources = options.enforceStrictResources(); this.logLevel = options.getLogLevel(); this.jsInteropMode = options.getJsInteropMode(); this.methodNameDisplayMode = options.getMethodNameDisplayMode(); this.properties = LinkedListMultimap.create(options.getProperties()); this.closureFormattedOutput = options.isClosureFormattedOutput(); }
CompilerOptionsImpl(CompileDir compileDir, String moduleName, Options options) { this.compileDir = compileDir; this.incremental = options.isIncrementalCompileEnabled(); this.moduleNames = Lists.newArrayList(moduleName); this.sourceLevel = options.getSourceLevel(); this.failOnError = options.isFailOnError(); this.logLevel = options.getLogLevel(); this.generateJsInteropExports = options.shouldGenerateJsInteropExports(); this.jsInteropExportFilter = new WhitelistRegexFilter(); this.jsInteropExportFilter.addAll(options.getJsInteropExportFilter()); this.methodNameDisplayMode = options.getMethodNameDisplayMode(); this.properties = LinkedListMultimap.create(options.getProperties()); this.closureFormattedOutput = options.isClosureFormattedOutput(); this.output = options.getOutput(); }
if (options.isCompileTest()) { PrintWriterTreeLogger logger = new PrintWriterTreeLogger(); logger.setMaxDetail(options.getLogLevel()); DiskCachingUtil.computePreferredCacheDir(options.getModuleNames(), logger); UnitCache unitCache = UnitCacheSingleton.get(logger, null, baseCacheDir); MinimalRebuildCacheManager minimalRebuildCacheManager = int retries = options.getCompileTestRecompiles(); for (int i = 0; i < retries; i++) { System.out.println("\n### Recompile " + (i + 1) + "\n"); start(options); String url = "http://" + options.getPreferredHost() + ":" + options.getPort() + "/";
/** * Creates a job to update an outbox. * @param bindingProperties Properties that uniquely identify a permutation. * (Otherwise, more than one permutation will be compiled.) * @param parentLogger The parent of the logger that will be used for this job. */ Job(Outbox box, Map<String, String> bindingProperties, TreeLogger parentLogger, Options options) { this.id = chooseNextId(box); this.outbox = box; this.inputModuleName = box.getInputModuleName(); // TODO: we will use the binding properties to find or create the outbox, // then take binding properties from the outbox here. this.bindingProperties = ImmutableSortedMap.copyOf(bindingProperties); this.recompileListener = Preconditions.checkNotNull(options.getRecompileListener()); this.jobChangeListener = Preconditions.checkNotNull(options.getJobChangeListener()); this.args = Preconditions.checkNotNull(options.getArgs()); this.tags = Preconditions.checkNotNull(options.getTags()); this.logSupplier = new LogSupplier(parentLogger, id); }
/** * Starts the code server with the given command line options. To shut it down, see * {@link WebServer#stop}. * * <p>Only one code server should be started at a time because the GWT compiler uses * a lot of static variables.</p> */ public static WebServer start(Options options) throws IOException, UnableToCompleteException { PrintWriterTreeLogger topLogger = new PrintWriterTreeLogger(); topLogger.setMaxDetail(options.getLogLevel()); TreeLogger startupLogger = topLogger.branch(Type.INFO, "Super Dev Mode starting up"); File baseCacheDir = DiskCachingUtil.computePreferredCacheDir(options.getModuleNames(), startupLogger); UnitCache unitCache = UnitCacheSingleton.get(startupLogger, null, baseCacheDir); MinimalRebuildCacheManager minimalRebuildCacheManager = new MinimalRebuildCacheManager(topLogger, baseCacheDir); OutboxTable outboxes = makeOutboxes(options, startupLogger, unitCache, minimalRebuildCacheManager); JobEventTable eventTable = new JobEventTable(); JobRunner runner = new JobRunner(eventTable, minimalRebuildCacheManager); JsonExporter exporter = new JsonExporter(options, outboxes); SourceHandler sourceHandler = new SourceHandler(outboxes, exporter); WebServer webServer = new WebServer(sourceHandler, exporter, outboxes, runner, eventTable, options.getBindAddress(), options.getPort()); webServer.start(topLogger); return webServer; }
private static MinimalRebuildCacheManager createMinimalRebuildCacheManager( PrintWriterTreeLogger logger, Options options,File baseCacheDir) { return new MinimalRebuildCacheManager( logger, baseCacheDir, ImmutableMap.of( "style", options.getOutput().name(), "closureFormattedOutput", String.valueOf(options.isClosureFormattedOutput()), "generateJsInteropExports", String.valueOf(options.shouldGenerateJsInteropExports()), "exportFilters", options.getJsInteropExportFilter().toString(), "methodDisplayMode", options.getMethodNameDisplayMode().name())); }
private TreeLogger makeCompileLogger(CompileDir compileDir, TreeLogger parent) throws UnableToCompleteException { try { PrintWriterTreeLogger fileLogger = new PrintWriterTreeLogger(compileDir.getLogFile()); fileLogger.setMaxDetail(options.getLogLevel()); return new CompositeTreeLogger(parent, fileLogger); } catch (IOException e) { parent.log(TreeLogger.ERROR, "unable to open log file: " + compileDir.getLogFile(), e); throw new UnableToCompleteException(); } }
/** * Configures and compiles all the modules (unless {@link Options#getNoPrecompile} is false). */ private static OutboxTable makeOutboxTable(Options options, TreeLogger logger, UnitCache unitCache, MinimalRebuildCacheManager minimalRebuildCacheManager) throws IOException, UnableToCompleteException { File workDir = ensureWorkDir(options); logger.log(Type.INFO, "workDir: " + workDir); LauncherDir launcherDir = LauncherDir.maybeCreate(options); int nextOutboxId = 1; OutboxTable outboxTable = new OutboxTable(); for (String moduleName : options.getModuleNames()) { OutboxDir outboxDir = OutboxDir.create(new File(workDir, moduleName), logger); Recompiler recompiler = new Recompiler(outboxDir, launcherDir, moduleName, options, unitCache, minimalRebuildCacheManager); // The id should be treated as an opaque string since we will change it again. // TODO: change outbox id to include binding properties. String outboxId = moduleName + "_" + nextOutboxId; nextOutboxId++; outboxTable.addOutbox(new Outbox(outboxId, recompiler, options, logger)); } return outboxTable; }
if (options.isCompileTest()) { PrintWriterTreeLogger logger = new PrintWriterTreeLogger(); logger.setMaxDetail(options.getLogLevel()); DiskCachingUtil.computePreferredCacheDir(options.getModuleNames(), logger); UnitCache unitCache = UnitCacheSingleton.get(logger, null, baseCacheDir, new CompilerOptionsImpl(options)); int retries = options.getCompileTestRecompiles(); for (int i = 0; i < retries; i++) { System.out.println("\n### Recompile " + (i + 1) + "\n"); start(options); String url = "http://" + options.getPreferredHost() + ":" + options.getPort() + "/";
/** * Creates a job to update an outbox. * @param bindingProperties Properties that uniquely identify a permutation. * (Otherwise, more than one permutation will be compiled.) * @param parentLogger The parent of the logger that will be used for this job. */ Job(Outbox box, Map<String, String> bindingProperties, TreeLogger parentLogger, Options options) { this.id = chooseNextId(box); this.outbox = box; this.inputModuleName = box.getInputModuleName(); // TODO: we will use the binding properties to find or create the outbox, // then take binding properties from the outbox here. this.bindingProperties = ImmutableSortedMap.copyOf(bindingProperties); this.recompileListener = Preconditions.checkNotNull(options.getRecompileListener()); this.jobChangeListener = Preconditions.checkNotNull(options.getJobChangeListener()); this.args = Preconditions.checkNotNull(options.getArgs()); this.tags = Preconditions.checkNotNull(options.getTags()); this.logSupplier = new LogSupplier(parentLogger, id); }
/** * Starts the code server with the given command line options. To shut it down, see * {@link WebServer#stop}. * * <p>Only one code server should be started at a time because the GWT compiler uses * a lot of static variables.</p> */ public static WebServer start(Options options) throws IOException, UnableToCompleteException { PrintWriterTreeLogger topLogger = new PrintWriterTreeLogger(); topLogger.setMaxDetail(options.getLogLevel()); TreeLogger startupLogger = topLogger.branch(Type.INFO, "Super Dev Mode starting up"); File baseCacheDir = DiskCachingUtil.computePreferredCacheDir(options.getModuleNames(), startupLogger); UnitCache unitCache = UnitCacheSingleton.get( startupLogger, null, baseCacheDir, new CompilerOptionsImpl(options)); MinimalRebuildCacheManager minimalRebuildCacheManager = createMinimalRebuildCacheManager(topLogger, options, baseCacheDir); OutboxTable outboxTable = makeOutboxTable(options, startupLogger, unitCache, minimalRebuildCacheManager); JobEventTable eventTable = new JobEventTable(); JobRunner runner = new JobRunner(eventTable, minimalRebuildCacheManager); JsonExporter exporter = new JsonExporter(options, outboxTable); SourceHandler sourceHandler = new SourceHandler(outboxTable, exporter); SymbolMapHandler symbolMapHandler = new SymbolMapHandler(outboxTable); WebServer webServer = new WebServer(sourceHandler, symbolMapHandler, exporter, outboxTable, runner, eventTable, options.getBindAddress(), options.getPort()); webServer.start(topLogger); return webServer; }
private TreeLogger makeCompileLogger(CompileDir compileDir, TreeLogger parent) throws UnableToCompleteException { try { PrintWriterTreeLogger fileLogger = new PrintWriterTreeLogger(compileDir.getLogFile()); fileLogger.setMaxDetail(options.getLogLevel()); return new CompositeTreeLogger(parent, fileLogger); } catch (IOException e) { parent.log(TreeLogger.ERROR, "unable to open log file: " + compileDir.getLogFile(), e); throw new UnableToCompleteException(); } }
/** * Configures and compiles all the modules (unless {@link Options#getNoPrecompile} is false). */ private static OutboxTable makeOutboxes(Options options, TreeLogger logger, UnitCache unitCache, MinimalRebuildCacheManager minimalRebuildCacheManager) throws IOException, UnableToCompleteException { File workDir = ensureWorkDir(options); logger.log(Type.INFO, "workDir: " + workDir); LauncherDir launcherDir = LauncherDir.maybeCreate(options); int nextOutboxId = 1; OutboxTable outboxes = new OutboxTable(); for (String moduleName : options.getModuleNames()) { OutboxDir outboxDir = OutboxDir.create(new File(workDir, moduleName), logger); Recompiler recompiler = new Recompiler(outboxDir, launcherDir, moduleName, options, unitCache, minimalRebuildCacheManager); // The id should be treated as an opaque string since we will change it again. // TODO: change outbox id to include binding properties. String outboxId = moduleName + "_" + nextOutboxId; nextOutboxId++; outboxes.addOutbox(new Outbox(outboxId, recompiler, options, logger)); } return outboxes; }
if (isIncrementalCompileEnabled()) { addTags("incremental_on"); } else { addTags("incremental_off"); if (getNoPrecompile()) { addTags("precompile_off"); } else { addTags("precompile_on");
/** * Starts the code server. Shuts down the JVM if startup fails. * @param args Command-line options that can be parsed by {@link Options}. */ public static void main(String[] args) throws Exception { Options options = new Options(); if (!options.parseArgs(args)) { System.exit(1); } main(options); }
/** * @see #maybeCreate */ private LauncherDir(Options options) { this.launcherDir = Preconditions.checkNotNull(options.getLauncherDir()); this.options = options; }
/** * Returns a new LauncherDir or null if not enabled. */ static LauncherDir maybeCreate(Options options) { if (options.getLauncherDir() == null) { return null; } return new LauncherDir(options); }