Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Unified Diff: mojo/dart/mojom/lib/src/options.dart

Issue 1318903005: Move mojom to public/dart (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/dart/mojom/lib/generate.dart ('k') | mojo/dart/mojom/lib/src/utils.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/dart/mojom/lib/src/options.dart
diff --git a/mojo/dart/mojom/lib/src/options.dart b/mojo/dart/mojom/lib/src/options.dart
deleted file mode 100644
index 63ff6834170ad28753438b30febcf1fa43e6a135..0000000000000000000000000000000000000000
--- a/mojo/dart/mojom/lib/src/options.dart
+++ /dev/null
@@ -1,123 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-part of generate;
-
-class GenerateOptions {
- final Directory packages;
- final Directory mojoSdk;
- final Directory mojomPackage;
- final List<Directory> additionalDirs;
- final bool download;
- final bool generate;
- final bool errorOnDuplicate;
- final bool verbose;
- final bool dryRun;
- GenerateOptions(this.packages, this.mojomPackage, this.mojoSdk,
- this.additionalDirs, this.download, this.generate, this.errorOnDuplicate,
- this.verbose, this.dryRun);
-}
-
-/// Ensures that the directories in [additionalPaths] are absolute and exist,
-/// and creates Directories for them, which are returned.
-Future<List<Directory>> validateAdditionalDirs(Iterable additionalPaths) async {
- var additionalDirs = [];
- for (var mojomPath in additionalPaths) {
- final mojomDir = new Directory(mojomPath);
- if (!mojomDir.isAbsolute) {
- throw new CommandLineError(
- "All --additional-mojom-dir parameters must be absolute paths.");
- }
- if (!(await mojomDir.exists())) {
- throw new CommandLineError(
- "The additional mojom directory $mojomDir must exist");
- }
- additionalDirs.add(mojomDir);
- }
- return additionalDirs;
-}
-
-Future<GenerateOptions> parseArguments(List<String> arguments) async {
- final parser = new args.ArgParser()
- ..addOption('additional-mojom-dir',
- abbr: 'a',
- allowMultiple: true,
- help: 'Absolute path to an additional directory containing mojom.dart'
- 'files to put in the mojom package. May be specified multiple times.')
- ..addFlag('download',
- abbr: 'd',
- defaultsTo: false,
- help: 'Searches packages for a .mojoms file, and downloads .mojom files'
- 'as speficied in that file. Implies -g.')
- ..addFlag('fake',
- abbr: 'f',
- defaultsTo: false,
- help: 'Print the operations that would have been run, but'
- 'do not run anything.')
- ..addFlag('generate',
- abbr: 'g',
- defaultsTo: false,
- help: 'Generate Dart bindings for .mojom files.')
- ..addFlag('ignore-duplicates',
- abbr: 'i',
- defaultsTo: false,
- help: 'Ignore generation of a .mojom.dart file into the same location '
- 'as an existing file. By default this is an error')
- ..addOption('mojo-sdk',
- abbr: 'm',
- defaultsTo: Platform.environment['MOJO_SDK'],
- help: 'Absolute path to the Mojo SDK, which can also be specified '
- 'with the environment variable MOJO_SDK.')
- ..addOption('package-root',
- abbr: 'p',
- defaultsTo: path.join(Directory.current.path, 'packages'),
- help: 'An absolute path to an application\'s package root')
- ..addFlag('verbose', abbr: 'v', defaultsTo: false);
- final result = parser.parse(arguments);
- bool verbose = result['verbose'];
- bool dryRun = result['fake'];
- bool errorOnDuplicate = !result['ignore-duplicates'];
-
- final packages = new Directory(result['package-root']);
- if (!packages.isAbsolute) {
- throw new CommandLineError(
- "The --package-root parameter must be an absolute path.");
- }
- if (verbose) print("packages = $packages");
- if (!(await packages.exists())) {
- throw new CommandLineError("The packages directory $packages must exist");
- }
-
- final mojomPackage = new Directory(path.join(packages.path, 'mojom'));
- if (verbose) print("mojom package = $mojomPackage");
- if (!(await mojomPackage.exists())) {
- throw new CommandLineError(
- "The mojom package directory $mojomPackage must exist");
- }
-
- final download = result['download'];
- final generate = result['generate'] || download;
- var mojoSdk = null;
- if (generate) {
- final mojoSdkPath = result['mojo-sdk'];
- if (mojoSdkPath == null) {
- throw new CommandLineError(
- "The Mojo SDK directory must be specified with the --mojo-sdk flag or"
- "the MOJO_SDK environment variable.");
- }
- mojoSdk = new Directory(mojoSdkPath);
- if (verbose) print("Mojo SDK = $mojoSdk");
- if (!(await mojoSdk.exists())) {
- throw new CommandLineError(
- "The specified Mojo SDK directory $mojoSdk must exist.");
- }
- }
-
- final additionalDirs =
- await validateAdditionalDirs(result['additional-mojom-dir']);
- if (verbose) print("additional_mojom_dirs = $additionalDirs");
-
- return new GenerateOptions(packages, mojomPackage, mojoSdk, additionalDirs,
- download, generate, errorOnDuplicate, verbose, dryRun);
-}
« no previous file with comments | « mojo/dart/mojom/lib/generate.dart ('k') | mojo/dart/mojom/lib/src/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698