| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library old_servicec.compiler; | |
| 6 | |
| 7 import 'dart:io'; | |
| 8 | |
| 9 import 'src/emitter.dart'; | |
| 10 import 'src/parser.dart'; | |
| 11 import 'src/pretty_printer.dart'; | |
| 12 import 'src/resolver.dart'; | |
| 13 | |
| 14 import 'src/plugins/cc.dart' as cc; | |
| 15 import 'src/plugins/dart.dart' as dart; | |
| 16 import 'src/plugins/java.dart' as java; | |
| 17 | |
| 18 import 'package:path/path.dart' show join, dirname; | |
| 19 | |
| 20 const List<String> RESOURCES = const [ | |
| 21 "Service.podspec", | |
| 22 ]; | |
| 23 | |
| 24 void compile(String path, | |
| 25 Unit unit, | |
| 26 String resourcesDirectory, | |
| 27 String outputDirectory) { | |
| 28 resolve(unit); | |
| 29 dump(path, unit); | |
| 30 | |
| 31 cc.generate(path, unit, resourcesDirectory, outputDirectory); | |
| 32 dart.generate(path, unit, resourcesDirectory, outputDirectory); | |
| 33 java.generate(path, unit, resourcesDirectory, outputDirectory); | |
| 34 | |
| 35 for (String resource in RESOURCES) { | |
| 36 String resourcePath = join(resourcesDirectory, resource); | |
| 37 File file = new File(resourcePath); | |
| 38 String contents = file.readAsStringSync(); | |
| 39 writeToFile(outputDirectory, resource, contents); | |
| 40 } | |
| 41 } | |
| 42 | |
| 43 void dump(String path, Unit unit) { | |
| 44 String banner = "Parsed IDL for $path"; | |
| 45 print(banner); | |
| 46 print('-' * banner.length); | |
| 47 var printer = new PrettyPrinter(); | |
| 48 printer.visit(unit); | |
| 49 String printed = printer.buffer.toString().replaceAll('\n', '\n '); | |
| 50 print(' $printed'); | |
| 51 } | |
| OLD | NEW |