| Index: third_party/mojo/src/mojo/public/tools/bindings/generators/mojom_dart_generator.py
|
| diff --git a/third_party/mojo/src/mojo/public/tools/bindings/generators/mojom_dart_generator.py b/third_party/mojo/src/mojo/public/tools/bindings/generators/mojom_dart_generator.py
|
| index 87c16ef8819e3f7c3ccce2122f5d944e7872f73b..c324c9c35d269976d3e860b218f00773231f0de4 100644
|
| --- a/third_party/mojo/src/mojo/public/tools/bindings/generators/mojom_dart_generator.py
|
| +++ b/third_party/mojo/src/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
|
|
|