| OLD | NEW |
| 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 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 | 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 library fletchc.verbs.servicec_verb; | 5 library dartino_compiler.verbs.servicec_verb; |
| 6 | 6 |
| 7 import 'dart:io' show | 7 import 'dart:io' show |
| 8 File, | 8 File, |
| 9 Directory, | 9 Directory, |
| 10 Platform; | 10 Platform; |
| 11 | 11 |
| 12 import 'package:path/path.dart' show join, dirname; | 12 import 'package:path/path.dart' show join, dirname; |
| 13 | 13 |
| 14 import 'infrastructure.dart'; | 14 import 'infrastructure.dart'; |
| 15 | 15 |
| 16 import '../hub/exit_codes.dart' show | 16 import '../hub/exit_codes.dart' show |
| 17 DART_VM_EXITCODE_COMPILE_TIME_ERROR; | 17 DART_VM_EXITCODE_COMPILE_TIME_ERROR; |
| 18 | 18 |
| 19 import 'package:servicec/compiler.dart' as servicec; | 19 import 'package:servicec/compiler.dart' as servicec; |
| 20 | 20 |
| 21 import 'package:servicec/errors.dart' show | 21 import 'package:servicec/errors.dart' show |
| 22 CompilationError, | 22 CompilationError, |
| 23 ErrorReporter; | 23 ErrorReporter; |
| 24 | 24 |
| 25 import 'documentation.dart' show | 25 import 'documentation.dart' show |
| 26 servicecDocumentation; | 26 servicecDocumentation; |
| 27 | 27 |
| 28 import "package:compiler/src/util/uri_extras.dart" show | 28 import "package:compiler/src/util/uri_extras.dart" show |
| 29 relativize; | 29 relativize; |
| 30 | 30 |
| 31 import "package:fletchc/src/guess_configuration.dart" show | 31 import "package:dartino_compiler/src/guess_configuration.dart" show |
| 32 executable; | 32 executable; |
| 33 | 33 |
| 34 const Action servicecAction = const Action( | 34 const Action servicecAction = const Action( |
| 35 // A session is required for a worker. | 35 // A session is required for a worker. |
| 36 servicecAct, | 36 servicecAct, |
| 37 servicecDocumentation, | 37 servicecDocumentation, |
| 38 requiresSession: true, | 38 requiresSession: true, |
| 39 requiredTarget: TargetKind.FILE, | 39 requiredTarget: TargetKind.FILE, |
| 40 allowsTrailing: true); | 40 allowsTrailing: true); |
| 41 | 41 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 66 bool _looksLikeServicecDir(Uri uri) { | 66 bool _looksLikeServicecDir(Uri uri) { |
| 67 if (!new Directory.fromUri(uri).existsSync()) return false; | 67 if (!new Directory.fromUri(uri).existsSync()) return false; |
| 68 String expectedDirectory = join(uri.path, 'lib', 'src', 'resources'); | 68 String expectedDirectory = join(uri.path, 'lib', 'src', 'resources'); |
| 69 return new Directory(expectedDirectory).existsSync(); | 69 return new Directory(expectedDirectory).existsSync(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 Uri guessServicecDir(Uri base) { | 72 Uri guessServicecDir(Uri base) { |
| 73 Uri servicecDirectory; | 73 Uri servicecDirectory; |
| 74 if (_SERVICEC_DIR != null) { | 74 if (_SERVICEC_DIR != null) { |
| 75 // Use Uri.base here because _SERVICEC_DIR is a constant relative to the | 75 // Use Uri.base here because _SERVICEC_DIR is a constant relative to the |
| 76 // location of where fletch was called from, not relative to the C++ | 76 // location of where dartino was called from, not relative to the C++ |
| 77 // client. | 77 // client. |
| 78 servicecDirectory = base.resolve(_SERVICEC_DIR); | 78 servicecDirectory = base.resolve(_SERVICEC_DIR); |
| 79 } else { | 79 } else { |
| 80 Uri uri = executable.resolve(join('..', '..', 'tools', 'servicec')); | 80 Uri uri = executable.resolve(join('..', '..', 'tools', 'servicec')); |
| 81 if (new Directory.fromUri(uri).existsSync()) { | 81 if (new Directory.fromUri(uri).existsSync()) { |
| 82 servicecDirectory = uri; | 82 servicecDirectory = uri; |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 if (servicecDirectory == null) { | 85 if (servicecDirectory == null) { |
| 86 throw new StateError(""" | 86 throw new StateError(""" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 109 print("Compiling $relativeName..."); | 109 print("Compiling $relativeName..."); |
| 110 | 110 |
| 111 String fileName = targetUri.toFilePath(); | 111 String fileName = targetUri.toFilePath(); |
| 112 bool success = await servicec.compileAndReportErrors( | 112 bool success = await servicec.compileAndReportErrors( |
| 113 fileName, relativeName, resourcesDirectory, outputDirectory); | 113 fileName, relativeName, resourcesDirectory, outputDirectory); |
| 114 | 114 |
| 115 print("Compiled $relativeName to $outputDirectory"); | 115 print("Compiled $relativeName to $outputDirectory"); |
| 116 | 116 |
| 117 return success ? 0 : DART_VM_EXITCODE_COMPILE_TIME_ERROR; | 117 return success ? 0 : DART_VM_EXITCODE_COMPILE_TIME_ERROR; |
| 118 } | 118 } |
| OLD | NEW |