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

Unified Diff: mojo/dart/mojom/bin/generate.dart

Issue 1136503002: Create wrapper script around mojom's generate.dart in the Sky package. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rebase Created 5 years, 7 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/README.md ('k') | mojo/dart/mojom/lib/README.md » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/dart/mojom/bin/generate.dart
diff --git a/mojo/dart/mojom/bin/generate.dart b/mojo/dart/mojom/bin/generate.dart
deleted file mode 100644
index e579655c8fe349ab6655155c84e01aff64c25e74..0000000000000000000000000000000000000000
--- a/mojo/dart/mojom/bin/generate.dart
+++ /dev/null
@@ -1,135 +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.
-
-/*
-* This script should be invoked via 'pub run' for an application that consumes
-* pub packages containing generated Mojo bindings (.mojom.dart files).
-*
-* It should be invoked as follows after 'pub get':
-* $ pub run mojom:generate
-*/
-
-import 'dart:async';
-import 'dart:io';
-
-import 'package:args/args.dart' as args;
-import 'package:path/path.dart' as path;
-
-bool verbose;
-bool dryRun;
-
-bool isMojomDart(String path) => path.endsWith('.mojom.dart');
-
-// Copies .mojom.dart files from a particular package's mojom directory to
-// the mojom package directory.
-//
-// mojomDirectory: A pub packages mojom directory, i.e. $PACKAGE/mojom.
-// mojomPackage: The mojom package directory.
-copyMojomDirContents(Directory mojomDirectory, Directory mojomPackage) async {
- assert(await mojomDirectory.exists());
- await for (var mojoms in mojomDirectory.list(recursive: true)) {
- if (mojoms is! File) continue;
- if (!isMojomDart(mojoms.path)) continue;
- if (verbose) print("Found $mojoms");
-
- final relative = path.relative(mojoms.path, from: mojomDirectory.path);
- final dest = path.join(mojomPackage.path, relative);
- final destDirectory = new Directory(path.dirname(dest));
-
- if (verbose || dryRun) {
- print('Copying $mojoms to $dest');
- }
-
- if (!dryRun) {
- final File source = new File(mojoms.path);
- if (verbose) print("Ensuring $destDirectory exists");
- await destDirectory.create(recursive: true);
- source.copy(dest);
- }
- }
-}
-
-// If a package has a mojom directory, uses copyMojomDirContents to install them
-// in the mojom package.
-//
-// package: The directory of a pub package in an application's packages
-// directory.
-// mojoPackage: The mojom package directory in an application's packages
-// directory
-installPackageMojoms(Directory package, Directory mojomPackage) async {
- if (package.path == mojomPackage.path) return;
- if (verbose) print("package = $package");
- final mojomDirectory = new Directory(path.join(package.path, 'mojom'));
- if (verbose) print("looking for = $mojomDirectory");
- if (await mojomDirectory.exists()) {
- copyMojomDirContents(mojomDirectory, mojomPackage);
- } else if (verbose) {
- print("$mojomDirectory not found");
- }
-}
-
-main(List<String> arguments) async {
- final parser = new args.ArgParser()
- ..addOption('package-root',
- abbr: 'p',
- defaultsTo: path.join(Directory.current.path, 'packages'),
- help: 'An absolute path to an application\'s package root')
- ..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('dry-run',
- abbr: 'd',
- defaultsTo: false,
- help: 'Print the copy operations that would have been run, but'
- 'do not copy anything.')
- ..addFlag('verbose', abbr: 'v', defaultsTo: false);
- final result = parser.parse(arguments);
- verbose = result['verbose'];
- dryRun = result['dry-run'];
-
- final packages = new Directory(result['package-root']);
- if (!packages.isAbsolute) {
- print("The --package-root parameter should be an absolute path.");
- exit(1);
- }
- if (verbose) print("packages = $packages");
- if (!(await packages.exists())) {
- print("The packages directory $packages does not exist");
- exit(1);
- }
-
- var additional_mojom_dirs = [];
- for (var mojom_dir_path in result['additional-mojom-dir']) {
- final mojom_dir = new Directory(mojom_dir_path);
- if (!mojom_dir.isAbsolute) {
- print("All --additional-mojom-dir parameters should be absolute paths.");
- exit(1);
- }
- if (!(await mojom_dir.exists())) {
- print("The additional mojom directory $mojom_dir does not exist");
- exit(1);
- }
- additional_mojom_dirs.add(mojom_dir);
- }
- if (verbose) print("additional_mojom_dirs = $additional_mojom_dirs");
-
- final mojomPackage = new Directory(path.join(packages.path, 'mojom'));
- if (verbose) print("mojom package = $mojomPackage");
- if (!(await mojomPackage.exists())) {
- print("The mojom package directory $mojomPackage does not exist");
- exit(1);
- }
-
- await for (var package in packages.list()) {
- if (package is Directory) {
- installPackageMojoms(package, mojomPackage);
- }
- }
-
- for (var mojom_dir in additional_mojom_dirs) {
- copyMojomDirContents(mojom_dir, mojomPackage);
- }
-}
« no previous file with comments | « mojo/dart/mojom/README.md ('k') | mojo/dart/mojom/lib/README.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698