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

Side by Side Diff: mojo/public/tools/bindings/generators/mojom_dart_generator.py

Issue 1449203002: Check in generated Dart bindings and add presubmit script (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 1 month 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 unified diff | Download patch
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Generates dart source files from a mojom.Module.""" 5 """Generates dart source files from a mojom.Module."""
6 6
7 import os 7 import os
8 import re 8 import re
9 import shutil 9 import shutil
10 import sys 10 import sys
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 439
440 @UseJinja("dart_templates/module.lib.tmpl", filters=dart_filters) 440 @UseJinja("dart_templates/module.lib.tmpl", filters=dart_filters)
441 def GenerateLibModule(self, args): 441 def GenerateLibModule(self, args):
442 return self.GetParameters(args) 442 return self.GetParameters(args)
443 443
444 444
445 def GenerateFiles(self, args): 445 def GenerateFiles(self, args):
446 elements = self.module.namespace.split('.') 446 elements = self.module.namespace.split('.')
447 elements.append("%s.dart" % self.module.name) 447 elements.append("%s.dart" % self.module.name)
448 448
449 lib_module = self.GenerateLibModule(args)
450
451 # List of packages with checked in bindings.
452 # TODO(johnmccutchan): Stop generating bindings as part of build system
453 # and then remove this.
454 packages_with_checked_in_bindings = [
455 'mojo',
456 'mojo_apptest',
457 'mojo_services',
458 'mojo_sdk'
459 'mojom'
460 ]
449 package_name = GetPackage(self.module) 461 package_name = GetPackage(self.module)
450 lib_module = self.GenerateLibModule(args) 462 if not (package_name in packages_with_checked_in_bindings):
451 pkg_path = os.path.join("dart-pkg", package_name, "lib", *elements) 463 pkg_path = os.path.join("dart-pkg", package_name, "lib", *elements)
452 self.Write(lib_module, pkg_path) 464 self.Write(lib_module, pkg_path)
453 465
454 gen_path = os.path.join("dart-gen", package_name, "lib", *elements) 466 gen_path = os.path.join("dart-gen", package_name, "lib", *elements)
455 full_gen_path = os.path.join(self.output_dir, gen_path) 467 full_gen_path = os.path.join(self.output_dir, gen_path)
456 self.Write(lib_module, gen_path) 468 self.Write(lib_module, gen_path)
457 469
458 link = self.MatchMojomFilePath("%s.dart" % self.module.name) 470 link = self.MatchMojomFilePath("%s.dart" % self.module.name)
459 full_link_path = os.path.join(self.output_dir, link) 471 full_link_path = os.path.join(self.output_dir, link)
460 if os.path.exists(full_link_path): 472 if os.path.exists(full_link_path):
461 os.unlink(full_link_path) 473 os.unlink(full_link_path)
462 fileutil.EnsureDirectoryExists(os.path.dirname(full_link_path)) 474 fileutil.EnsureDirectoryExists(os.path.dirname(full_link_path))
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 interface_to_import[name] = each_import["unique_name"] + "." + name 512 interface_to_import[name] = each_import["unique_name"] + "." + name
501 return interface_to_import 513 return interface_to_import
502 514
503 def ImportedFrom(self): 515 def ImportedFrom(self):
504 interface_to_import = {} 516 interface_to_import = {}
505 for each_import in self.module.imports: 517 for each_import in self.module.imports:
506 for each_interface in each_import["module"].interfaces: 518 for each_interface in each_import["module"].interfaces:
507 name = each_interface.name 519 name = each_interface.name
508 interface_to_import[name] = each_import["unique_name"] + "." 520 interface_to_import[name] = each_import["unique_name"] + "."
509 return interface_to_import 521 return interface_to_import
OLDNEW
« no previous file with comments | « mojo/dart/tools/presubmit/check_mojom_dart.py ('k') | mojo/public/tools/bindings/mojom_list_dart_outputs.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698