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

Unified Diff: mojo/public/tools/bindings/generators/mojom_dart_generator.py

Issue 1210253006: Dart: Allows the mojom package's generate script to download .mojoms. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Address comments Created 5 years, 5 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/test/generate_test.dart ('k') | mojo/tools/get_test_list.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/tools/bindings/generators/mojom_dart_generator.py
diff --git a/mojo/public/tools/bindings/generators/mojom_dart_generator.py b/mojo/public/tools/bindings/generators/mojom_dart_generator.py
index 87c16ef8819e3f7c3ccce2122f5d944e7872f73b..c324c9c35d269976d3e860b218f00773231f0de4 100644
--- a/mojo/public/tools/bindings/generators/mojom_dart_generator.py
+++ b/mojo/public/tools/bindings/generators/mojom_dart_generator.py
@@ -9,6 +9,7 @@ import re
import shutil
import sys
+import mojom.fileutil as fileutil
import mojom.generate.constant_resolver as resolver
import mojom.generate.generator as generator
import mojom.generate.module as mojom
@@ -421,20 +422,25 @@ class Generator(generator.Generator):
def GenerateFiles(self, args):
elements = self.module.namespace.split('.')
elements.append("%s.dart" % self.module.name)
- path = os.path.join("dart-pkg", "mojom/lib", *elements)
- self.Write(self.GenerateLibModule(args), path)
- path = os.path.join("dart-gen", "mojom/lib", *elements)
- self.Write(self.GenerateLibModule(args), path)
+
+ lib_module = self.GenerateLibModule(args)
+ pkg_path = os.path.join("dart-pkg", "mojom/lib", *elements)
+ self.Write(lib_module, pkg_path)
+
+ gen_path = os.path.join("dart-gen", "mojom/lib", *elements)
+ full_gen_path = os.path.join(self.output_dir, gen_path)
+ self.Write(lib_module, gen_path)
+
link = self.MatchMojomFilePath("%s.dart" % self.module.name)
- if os.path.exists(os.path.join(self.output_dir, link)):
- os.unlink(os.path.join(self.output_dir, link))
+ full_link_path = os.path.join(self.output_dir, link)
+ if os.path.exists(full_link_path):
+ os.unlink(full_link_path)
+ fileutil.EnsureDirectoryExists(os.path.dirname(full_link_path))
try:
if sys.platform == "win32":
- shutil.copy(os.path.join(self.output_dir, path),
- os.path.join(self.output_dir, link))
+ shutil.copy(full_gen_path, full_link_path)
else:
- os.symlink(os.path.join(self.output_dir, path),
- os.path.join(self.output_dir, link))
+ os.symlink(full_gen_path, full_link_path)
except OSError as e:
# Errno 17 is file already exists. If the link fails because file already
# exists assume another instance of this script tried to create the same
« no previous file with comments | « mojo/dart/mojom/test/generate_test.dart ('k') | mojo/tools/get_test_list.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698