Skip to content

Commit

Permalink
Merge pull request #555 from TheBosZ/master
Browse files Browse the repository at this point in the history
Fix file separators on Windows
  • Loading branch information
vsmenon committed May 9, 2016
2 parents c2e170f + c3b43ac commit 35f35ff
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/dev_compiler/lib/src/compiler/code_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import 'package:analyzer/src/summary/summarize_elements.dart'
show PackageBundleAssembler;
import 'package:analyzer/src/task/strong/info.dart' show DynamicInvoke;
import 'package:source_maps/source_maps.dart';
import 'package:path/path.dart' show separator;

import '../closure/closure_annotator.dart' show ClosureAnnotator;
import '../js_ast/js_ast.dart' as JS;
Expand Down Expand Up @@ -145,8 +146,8 @@ class CodeGenerator extends GeneralizingAstVisitor
List<String> errors) {
_buildUnit = unit;
_buildRoot = _buildUnit.buildRoot;
if (!_buildRoot.endsWith('/')) {
_buildRoot = '$_buildRoot/';
if (!_buildRoot.endsWith(separator)) {
_buildRoot = '$_buildRoot${separator}';
}

var jsTree = _emitModule(compilationUnits);
Expand Down Expand Up @@ -4359,12 +4360,12 @@ String jsLibraryName(String buildRoot, LibraryElement library) {
// TODO(vsm): This is not unique if an escaped '/'appears in a filename.
// E.g., "foo/bar.dart" and "foo$47bar.dart" would collide.
qualifiedPath = uri.pathSegments.skip(1).join(separator);
} else if (uri.path.startsWith(buildRoot)) {
} else if (uri.toFilePath().startsWith(buildRoot)) {
qualifiedPath =
uri.path.substring(buildRoot.length).replaceAll('/', separator);
} else {
// We don't have a unique name.
throw 'Invalid build root. $buildRoot does not contain ${uri.path}';
throw 'Invalid build root. $buildRoot does not contain ${uri.toFilePath()}';
}
return pathToJSIdentifier(qualifiedPath);
}
Expand Down

0 comments on commit 35f35ff

Please sign in to comment.