Chromium Code Reviews| Index: mojo/dart/packages/mojom/lib/src/generate.dart |
| diff --git a/mojo/dart/packages/mojom/lib/src/generate.dart b/mojo/dart/packages/mojom/lib/src/generate.dart |
| index 5657bd9fe5f8372245c20bfef7165620bb5313e8..6b91b9f240caed6e0ce38a45107a8770b303484f 100644 |
| --- a/mojo/dart/packages/mojom/lib/src/generate.dart |
| +++ b/mojo/dart/packages/mojom/lib/src/generate.dart |
| @@ -95,7 +95,9 @@ class MojomGenerator { |
| // Delete .mojom.dart files under [package] that are [olderThanThis]. |
| _deleteOldMojomDart(Directory package, DateTime olderThanThis) async { |
| Directory libDir = new Directory(path.join(package.path, 'lib')); |
| - assert(await libDir.exists()); |
| + if (!await libDir.exists()) { |
| + return; |
| + } |
| await for (var file in libDir.list(recursive: true, followLinks: false)) { |
| if (file is! File) continue; |
| if (!isMojomDart(file.path)) continue; |
| @@ -124,6 +126,23 @@ class MojomGenerator { |
| return result; |
| } |
| + // This is a hack until we can express import paths in .mojom files. |
| + // This checks the mojom path for '/mojo/services/' and if found assumes |
| + // that is an import path. |
|
jamesr
2015/11/17 01:35:07
i think you accidentally a word or few. maybe "..a
Cutch
2015/11/17 18:17:15
Done.
|
| + String _sniffForMojoServicesInclude(String mojomPath) { |
| + List<String> pathComponents = path.split(mojomPath); |
| + while (pathComponents.length > 2) { |
| + int last = pathComponents.length; |
| + if ((pathComponents[last - 1] == 'services') && |
| + (pathComponents[last - 2] == 'mojo')) { |
| + return path.joinAll(pathComponents); |
| + } |
| + // Remove the last element and try again. |
| + pathComponents.removeLast(); |
| + } |
| + return null; |
| + } |
| + |
| _generateForMojom(File mojom, Directory importDir, Directory destination, |
| String packageName) async { |
| if (!isMojom(mojom.path)) return; |
| @@ -134,19 +153,26 @@ class MojomGenerator { |
| final sdkInc = path.normalize(path.join(_mojoSdk.path, '..', '..')); |
| final outputDir = await destination.createTemp(); |
| final output = outputDir.path; |
| + |
| + final servicesPath = _sniffForMojoServicesInclude(mojom.path); |
| + |
| final arguments = [ |
| '--use_bundled_pylibs', |
| '-g', |
| 'dart', |
| '-o', |
| output, |
| - // TODO(zra): Are other include paths needed? |
| '-I', |
| sdkInc, |
| '-I', |
| - importDir.path, |
| - mojom.path |
| + importDir.path |
| ]; |
| + // TODO(zra): Are other include paths needed? |
|
jamesr
2015/11/17 01:35:07
i think we can nuke this for now
Cutch
2015/11/17 18:17:15
Done.
|
| + if (servicesPath != null) { |
| + arguments.add('-I'); |
| + arguments.add(servicesPath); |
| + } |
| + arguments.add(mojom.path); |
| log.info('Generating $mojom'); |
| log.info('$script ${arguments.join(" ")}'); |